* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 95vw;
    margin: 0 auto;
    padding: 10px;
}

.banner {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    margin-bottom: 30px;
	display: flex;
}

.header {
    padding: 30px;
}

.header h1 {
    font-size: 2rem;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.header p {
    color: #666;
    font-size: 1.1rem;
}

.hero-left {
    flex: 2;
	display: flex;
	flex-direction: column;
    justify-content: center;
    max-width: 500px;
    min-width: 500px;	
}

.hero-right {
	flex: 1;
	display: flex;
}

.upload-section {
    background: transparent;
    backdrop-filter: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    text-align: left;
	flex: 2;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.session-input-wrapper {
    position: relative;
    display: inline-block;
    margin-bottom: 20px;
}

.session-input {
    padding: 15px 20px;
    border: 2px solid #667eea;
    border-radius: 50px;
    font-size: 1.1rem;
    width: 300px;
    text-align: center;
    outline: none;
    transition: all 0.3s ease;
}

.session-input:focus {
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.fetch-button {
    display: inline-block;
    padding: 15px 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    font-weight: 600;
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3);
    margin-left: 15px;
}

.fetch-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px rgba(102, 126, 234, 0.4);
}

.fetch-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.loading {
    display: none;
    margin-top: 15px;
    color: #667eea;
    font-style: italic;
}

.segment-info {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
	padding-left: 30px;
    padding-right: 30px;	
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: none;
}

.session-summary {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
	padding-left: 30px;
    padding-right: 30px;	
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
    gap: 10px;
}

.info-card {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    padding: 8px 10px;
    border-radius: 8px;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: center;
}

.info-card h3 {
    font-size: 13px;
    margin: 0;
    margin-right: 5px;
    opacity: 0.95;
    font-weight: 600;
    display: inline;
}

.info-card .value {
    font-size: 13px;
    font-weight: bold;
    display: inline;
}

.timeline-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: none;
    width: 100%;
}

.timeline-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 15px;
}

.zoom-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.zoom-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.zoom-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.zoom-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.zoom-level {
    font-weight: bold;
    color: #333;
    min-width: 80px;
    text-align: center;
}

.pan-control {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pan-button {
    background: linear-gradient(135deg, #4ecdc4 0%, #44a08d 100%);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
}

.pan-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(78, 205, 196, 0.3);
}

.reset-button {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: all 0.3s ease;
}

.reset-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(240, 147, 251, 0.3);
}

.timeline {
    position: relative;
    margin: 40px 0;
    min-height: 400px;
}

.timeline-axis {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
}

.timeline-labels {
    position: absolute;
    bottom: -30px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: #666;
}

.event-track {
    position: absolute;
    left: 0;
    right: 0;
    height: 60px;
    margin-bottom: 10px;
}

.event-marker {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    top: 50%;
    transform: translateY(-50%);
}

.event-marker:hover {
    transform: translateY(-50%) scale(1.5);
    z-index: 10;
}

/* OFF Events - Red/Orange spectrum (disconnections, stops) */
.event-marker.psd-off {
    background: #FF7F50;  /* Coral - Search Stop */
    border: 2px solid #FF6347;
}

.event-marker.ble-peri-disconnected {
    background: #8B4513;  /* Saddle Brown - Mat Disconnected */
    border: 2px solid #A0522D;
}

.event-marker.therapy-end {
    background: #000000;  /* Black - Therapy End */
    border: 2px solid #1a1a1a;
}

.event-marker.ble-disconnected {
    background: #654321;  /* Dark Brown - Implant Disconnected */
    border: 2px solid #8B4513;
}

/* ON Events - Green spectrum (connections, starts) */
.event-marker.search-resume {
    background: #3CB371;  /* Medium Sea Green - Search Resume */
    border: 2px solid #2E8B57;
}

.event-marker.ble-peri-connected {
    background: #00FF00;  /* Bright Green - Mat Connected */
    border: 2px solid #00CC00;
}

.event-marker.therapy-start {
    background: #FFFF00;  /* Yellow - Therapy Start */
    border: 2px solid #FFD700;
}

.event-marker.ble-connected-light {
    background: #90ee90;  /* Light Green - Implant Connected (0x2) */
    border: 2px solid #7ed87e;
}

.event-marker.ble-connected-dark {
    background: #2ecc71;  /* Dark Green - Implant Connected (0x3) */
    border: 2px solid #27ae60;
}

.event-marker.stim-start {
    background: #800080;  /* Purple - Stim Start */
    border: 2px solid #9370DB;
}

.event-marker.stim-stop {
    background: #FF00FF;  /* Magenta - Stim Stop */
    border: 2px solid #DA70D6;
}

/* Stim Current Events - Blue spectrum */
.event-marker.stim-current-e0 {
    background: #87CEEB;  /* Sky Blue - Stim Current E0 */
    border: 2px solid #87CEEB;
}

.event-marker.stim-current-e1 {
    background: #4169E1;  /* Royal Blue - Stim Current E1 */
    border: 2px solid #4169E1;
}

.event-marker.stim-current-e2 {
    background: #0000CD;  /* Medium Blue - Stim Current E2 */
    border: 2px solid #0000CD;
}

.event-marker.stim-current-e3 {
    background: #00008B;  /* Dark Blue - Stim Current E3 */
    border: 2px solid #00008B;
}

/* Warning Events - Yellow/Amber spectrum (caution) */
.event-marker.return-loss {
    background: #FFA500;  /* Orange - Return Loss High */
    border: 2px solid #FF8C00;
}

.event-marker.hb-current {
    background: #FFD70070;  /* Gold with 70% opacity - High HB Curr */
    border: 2px solid #FFD700;
}

/* Out-of-Range Events - Brown spectrum (parameter violations) */
.event-marker.ec-3v3-voltage {
    background: #FF4500;  /* Orange Red - High EC 3.3V */
    border: 2px solid #FF6347;
}

.event-marker.ec-5v-voltage {
    background: #A0522D;  /* Sienna - High EC 5V */
    border: 2px solid #8B4513;
}

.event-marker.temp-out-range {
    background: #FF6347;  /* Tomato Red - Temperature Error */
    border: 2px solid #FF4500;
}

/* Error/Critical Events - Red/Magenta spectrum (failures) */
.event-marker.comm-lost {
    background: #8B0000;  /* Dark Red - BLE Cent Unresponsive */
    border: 2px solid #A52A2A;
}

.event-marker.mat-reset {
    background: #DC143C;  /* Crimson - Mat Reset */
    border: 2px solid #B22222;
}

.event-marker.mat-off {
    background: #FF0000;  /* Red - Safety Off */
    border: 2px solid #DC143C;
}

.event-marker.pb-test-error {
    background: #FF00FF;  /* Magenta - POST/BIST Fail */
    border: 2px solid #DA70D6;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-top: 30px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.legend-color {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid;
}

.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 10px 15px;
    border-radius: 10px;
    font-size: 0.9rem;
    pointer-events: none;
    z-index: 100;
    display: none;
    max-width: 300px;
}

.stats-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    display: none;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 10px;
}

.stat-card {
    background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%);
    padding: 5px;
    border-radius: 8px;
    text-align: center;
}

.error-message {
    background: #ff6b6b;
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin: 20px 0;
    display: none;
}

/* Packet section styles */
.packet-section {
    margin-top: 30px;
    padding: 20px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.packet-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.packet-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #ddd;
    padding: 10px;
    background-color: #f9f9f9;
    border-radius: 5px;
}

.packet-item {
    margin-bottom: 15px;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.packet-item.error {
    border-color: #dc3545;
    background-color: #f8d7da;
}

.packet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.packet-header h4 {
    margin: 0;
    color: #333;
    font-size: 1.1em;
}

.packet-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 15px;
    font-size: 0.9em;
    background-color: #f8f9fa;
    padding: 10px;
    border-radius: 3px;
}

.packet-data, .packet-parsed {
    margin-bottom: 10px;
}

.packet-data > div:first-child,
.packet-parsed > div:first-child {
    margin-bottom: 5px;
    font-weight: bold;
    color: #495057;
}

.packet-raw {
    background-color: #f5f5f5;
    padding: 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    word-break: break-all;
    border: 1px solid #e9ecef;
}

.packet-parsed-data {
    background-color: #f0f8ff;
    padding: 8px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 0.8em;
    white-space: pre-wrap;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #b3d9ff;
}

.packet-error {
    color: #dc3545;
    margin-top: 8px;
    font-size: 0.8em;
    padding: 5px;
    background-color: #f8d7da;
    border-radius: 3px;
    border: 1px solid #f5c6cb;
}

/* Responsive design for packet info */
@media (max-width: 768px) {
    .packet-info {
        grid-template-columns: 1fr;
    }
    
    .packet-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Segment Tabs Styles (V3) */
.segment-tabs-section {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
}

.segment-tab {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
    font-weight: 500;
    min-width: 80px;
    justify-content: center;
}

.segment-tab:hover:not(.disabled) {
    background: #e9ecef;
    border-color: #dee2e6;
    transform: translateY(-2px);
}

.segment-tab.active {
    background: #007bff;
    border-color: #007bff;
    color: white;
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.segment-tab.disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: #f8f9fa;
    border-color: #e9ecef;
}

.segment-tab .tab-number {
    font-weight: 600;
    font-size: 1rem;
}

.segment-tab .tab-status {
    font-size: 1.2rem;
}

.segment-tab .tab-time {
    font-size: 0.8rem;
    opacity: 0.8;
}

.segment-tab.processing {
    background: #fff3cd;
    border-color: #ffeaa7;
    color: #856404;
}

.segment-tab.error {
    background: #f8d7da;
    border-color: #f5c6cb;
    color: #721c24;
}

.segment-tab.completed {
    background: #d4edda;
    border-color: #c3e6cb;
    color: #155724;
}

/* Responsive tabs */
@media (max-width: 768px) {
    .segment-tabs {
        flex-direction: column;
        align-items: stretch;
    }
    
    .segment-tab {
        justify-content: flex-start;
        min-width: auto;
    }
}

/* Segment Navigation Buttons */
.segment-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid rgba(102, 126, 234, 0.5);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    color: #667eea;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.segment-nav-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(102, 126, 234, 0.8);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-50%) scale(1.1);
}

.segment-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.segment-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

.segment-nav-prev {
    left: 10px;
}

.segment-nav-next {
    right: 10px;
}

.segment-nav-btn span {
    line-height: 1;
}
