* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Courier New', monospace;
    background: linear-gradient(135deg, #0a0e27 0%, #1a1f3a 50%, #0f1629 100%);
    height: 100vh;
    padding: 10px;
    color: #e0e0ff;
    overflow: hidden;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    background: rgba(15, 22, 41, 0.8);
    border-radius: 8px;
    border: 2px solid #00d9ff;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 20px);
    overflow: hidden;
}

/* Header */
.header {
    padding: 8px 15px;
    border-bottom: 2px solid #00d9ff;
    background: linear-gradient(135deg, #1a0033 0%, #0d001a 50%, #1a003f 100%);
    color: #00d9ff;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 50px;
}

.header h1 {
    font-size: 30px;
    margin: 0;
    font-weight: 600;
    letter-spacing: 2px;
    color: #22c55e; /* Green matching status text */
    text-align: center;
    text-transform: uppercase; /* All caps */
}

.title-initial {
    font-size: 36px; /* 6px larger than base 30px */
}

.title-w {
    margin-left: 2px; /* Extra spacing between N and W */
}

/* Status bar removed */

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 8px;
    gap: 6px;
}

/* Control Panel */
.control-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 6px;
    padding: 8px;
    background: rgba(26, 31, 58, 0.6);
    border-radius: 4px;
    border: 1px solid #00d9ff;
}

.control-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.control-section > label {
    display: none; /* Hide labels for ticker, metric, view */
}

.control-section label {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.control-section input,
.control-section select {
    padding: 6px 8px;
    border: 1px solid #ffffff;
    border-radius: 3px;
    font-size: 14px;
    font-weight: 700;
    height: 36px;
    transition: all 0.25s;
    background: rgba(15, 25, 41, 0.9);
    color: #ffffff;
    font-family: 'Courier New', monospace;
}

/* Custom dropdown arrow for all dropdowns */
.control-section select,
#tickerInput {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    padding-right: 28px; /* Space for custom arrow */
    background-image: url('data:image/svg+xml;charset=UTF-8,<svg width="10" height="6" viewBox="0 0 10 6" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1 1L5 5L9 1" stroke="%23ffffff" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 10px 6px;
}

/* Style ticker input to match select dropdowns */
#tickerInput {
    text-transform: uppercase;
    cursor: pointer;
}

/* Custom ticker dropdown */
.ticker-dropdown-wrapper {
    position: relative;
}

.ticker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(15, 25, 41, 0.98);
    border: 1px solid #00d9ff;
    border-top: none;
    border-radius: 0 0 3px 3px;
    max-height: 250px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.ticker-dropdown.show {
    display: block;
}

.ticker-dropdown-item {
    padding: 8px 12px;
    cursor: pointer;
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Courier New', monospace;
    transition: background 0.15s;
}

.ticker-dropdown-item:hover {
    background: rgba(0, 217, 255, 0.1);
}

.ticker-dropdown-item:active {
    background: rgba(0, 217, 255, 0.2);
}

.control-section input::placeholder {
    color: rgba(224, 224, 255, 0.4);
}

.control-section input:focus,
.control-section select:focus {
    outline: none;
    border-color: #ffffff;
    color: #ffffff;
}

.control-section.log-buttons {
    display: flex;
    flex-direction: row;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.log-btn {
    padding: 6px 8px;
    border: 1px solid #ffffff;
    border-radius: 3px;
    background: rgba(15, 25, 41, 0.9);
    color: #ffffff;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    font-weight: 700;
    height: 36px;
    flex: 1;
    min-width: 50px;
    cursor: pointer;
    transition: all 0.25s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .control-section select,
    #tickerInput {
        min-width: 80px;
        padding: 6px 4px;
    }

    .log-btn {
        min-width: 45px;
        padding: 6px 4px;
        font-size: 12px;
    }
}

.log-btn:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #ffffff;
}

.log-btn.active {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border-color: #22c55e;
}

.log-btn.active:hover {
    background: rgba(34, 197, 94, 0.25);
}

/* Toggle Switch Container */
.toggle-container {
    display: flex;
    flex-direction: row;
    gap: 6px;
    align-items: center;
}

.toggle-label {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 32px;
    height: 16px;
    cursor: pointer;
}

.toggle-switch input[type="checkbox"] {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(75, 85, 99, 0.3);
    border: 1px solid rgba(107, 114, 128, 0.5);
    border-radius: 22px;
    transition: all 0.3s ease;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 2px;
    bottom: 1px;
    background-color: #6b7280;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Checked state - Cyberpunk cyan glow */
.toggle-switch input:checked+.toggle-slider {
    background-color: rgba(0, 217, 255, 0.2);
    border-color: #00d9ff;
    box-shadow: 0 0 8px rgba(0, 217, 255, 0.3);
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(16px);
    background-color: #00d9ff;
    box-shadow: 0 0 8px rgba(0, 217, 255, 0.6);
}

/* Hover effects */
.toggle-switch:hover .toggle-slider {
    border-color: rgba(0, 217, 255, 0.3);
}

.toggle-switch input:checked:hover+.toggle-slider {
    box-shadow: 0 0 12px rgba(0, 217, 255, 0.4);
}

/* Expiration Navigation */
.expiration-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: rgba(26, 31, 58, 0.6);
    border-radius: 4px;
    border: 1px solid #00d9ff;
}

.nav-btn {
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    height: 36px;
    transition: all 0.25s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1; /* Grow equally to fill space on either side of DTE box */
    display: flex;
    align-items: center;
}

/* Prev Button - Orange (left side, content centered) */
#prevExpBtn {
    background: rgba(249, 115, 22, 0.05);
    color: #f97316;
    border: 1px solid #f97316;
    justify-content: center; /* Center content in button */
    gap: 4px; /* Space between arrow and text */
}

#prevExpBtn:hover {
    background: rgba(249, 115, 22, 0.15);
    transform: translateY(-2px);
    color: #fb923c;
    border-color: #fb923c;
}

/* Next Button - Green (right side, content centered) */
#nextExpBtn {
    background: rgba(34, 197, 94, 0.05);
    color: #22c55e;
    border: 1px solid #22c55e;
    justify-content: center; /* Center content in button */
    gap: 4px; /* Space between arrow and text */
}

#nextExpBtn:hover {
    background: rgba(34, 197, 94, 0.15);
    transform: translateY(-2px);
    color: #4ade80;
    border-color: #4ade80;
}

.nav-btn:active {
    transform: translateY(0);
}

.nav-btn:disabled {
    background: transparent;
    border-color: #4b5563;
    color: #6b7280;
    cursor: not-allowed;
    transform: none;
}

.expiration-display {
    flex: 0 0 auto; /* Don't grow or shrink - stay fixed width */
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
}

#expirationText {
    font-size: 14px;
    font-weight: 700;
    color: #ffffff;
    padding: 6px 10px;
    height: 36px;
    background: rgba(15, 25, 41, 0.8);
    border-radius: 3px;
    border: 1px solid #ffffff;
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

/* Info Bar */
.info-bar {
    padding: 8px;
    background: rgba(26, 31, 58, 0.6);
    border-radius: 4px;
    border: 1px solid #00d9ff;
    font-size: 14px;
    font-weight: 600;
    color: #22c55e;
    height: 36px;
    display: flex;
    align-items: center;
}

/* Fetch stats visibility controlled by JavaScript based on overflow */
.fetch-stats.hidden {
    display: none;
}

#infoText {
    white-space: pre-wrap;
    word-break: break-word;
    color: #22c55e;
}

/* Chart Container */
.chart-container {
    flex: 1;
    position: relative;
    background: rgba(15, 22, 41, 0.9);
    border: 2px solid #00d9ff;
    border-radius: 4px;
    padding: 4px;
    overflow: hidden;
    min-height: 0;
    /* Important for flex children to shrink properly */
    display: flex;
    flex-direction: column;
}

#optionsChart {
    width: 100%;
    flex: 1;
    min-height: 0;
    /* Crucial for flex child to shrink */
    background: rgba(15, 22, 41, 0.95);
}

/* Chart Header & Legend */
.chart-header {
    flex: 0 0 auto;
    /* Don't shrink or grow */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 10px;
    background: rgba(15, 22, 41, 0.95);
    border-bottom: 1px solid rgba(0, 217, 255, 0.2);
    min-height: 50px;
}

#chartTitle {
    font-size: 18px;
    color: #00d9ff;
    margin: 0 0 4px 0;
    text-align: center;
    font-weight: 700;
    letter-spacing: 1px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    min-height: 20px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.legend-color-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-label {
    color: #e0e0ff;
    font-weight: 600;
}

.legend-value {
    color: #ffffff;
    font-weight: 700;
}

/* Responsive Design - Tablets */
@media (max-width: 768px) {
    .control-panel {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    }

    /* Keep expiration bar in single row */
    .nav-btn {
        padding: 5px 8px;
        font-size: 14px;
    }

    .expiration-display {
        flex: 0 0 auto; /* Stay fixed width */
    }
}

/* Hide button text on very small screens, keep only arrows */
@media (max-width: 600px) {
    .nav-btn {
        padding: 5px 8px;
        font-size: 16px; /* Larger arrow */
    }

    /* Hide text, keep only arrow symbols */
    .nav-btn-text {
        display: none;
    }
}

/* Responsive Design - Phones */
@media (max-width: 480px) {
    body {
        padding: 3px;
        height: 100vh;
        overflow: hidden;
    }

    .container {
        height: calc(100vh - 6px);
        overflow: hidden;
        border-width: 1px;
    }

    .main-content {
        padding: 3px;
        gap: 3px;
    }

    .control-panel {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: auto auto;
        gap: 4px;
        padding: 5px;
    }

    .control-section:nth-child(1),
    .control-section:nth-child(2) {
        /* Ticker and Metric take first row */
    }

    .control-section.checkbox-group {
        grid-column: 1 / -1;
        /* Span full width */
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 20px;
        padding: 2px 0;
    }

    .control-section input,
    .control-section select {
        padding: 5px 6px;
        font-size: 14px;
    }

    .control-section label {
        font-size: 14px;
        margin-bottom: 2px;
    }

    .toggle-label {
        font-size: 14px;
    }

    .toggle-switch {
        width: 36px;
        height: 18px;
    }

    .toggle-slider:before {
        height: 14px;
        width: 14px;
    }

    .toggle-switch input:checked+.toggle-slider:before {
        transform: translateX(18px);
    }

    .header h1 {
        font-size: 30px;
        letter-spacing: 2px;
    }

    .title-initial {
        font-size: 36px;
    }

    .header {
        padding: 6px 8px;
        min-height: 36px;
        height: 36px;
    }

    .expiration-bar {
        gap: 4px;
        padding: 5px;
        min-height: 34px;
    }

    .nav-btn {
        padding: 5px 8px;
        font-size: 14px;
    }

    #expirationText {
        font-size: 14px;
        padding: 4px 6px;
    }

    .info-bar {
        padding: 5px 6px;
        min-height: 26px;
        font-size: 14px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chart-container {
        padding: 3px;
        flex: 1;
        min-height: 0;
        border-width: 1px;
    }

    .chart-header {
        padding: 3px 6px;
        min-height: 40px;
    }

    #chartTitle {
        font-size: 15px;
    }

    .chart-legend {
        font-size: 13px;
        gap: 10px;
    }
}

/* Loading Animation - Cyberpunk Pulse */
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes cyberpunk-pulse {

    0%,
    100% {
        text-shadow: 0 0 10px rgba(0, 217, 255, 0.8), 0 0 20px rgba(255, 0, 110, 0.4);
    }

    50% {
        text-shadow: 0 0 15px rgba(0, 217, 255, 1), 0 0 30px rgba(255, 0, 110, 0.6), 0 0 40px rgba(57, 255, 20, 0.3);
    }
}

@keyframes glitch {

    0%,
    100% {
        box-shadow: 0 0 10px rgba(0, 217, 255, 0.5);
    }

    25% {
        box-shadow: -2px 0 10px rgba(255, 0, 110, 0.5), 2px 0 10px rgba(0, 217, 255, 0.5);
    }

    50% {
        box-shadow: 0 0 15px rgba(57, 255, 20, 0.5);
    }

    75% {
        box-shadow: 2px 0 10px rgba(255, 0, 110, 0.5), -2px 0 10px rgba(0, 217, 255, 0.5);
    }
}

.loading {
    display: inline-block;
    animation: cyberpunk-pulse 1.5s ease-in-out infinite;
}

/* Scrollbar styling */
.chart-container::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.chart-container::-webkit-scrollbar-track {
    background: rgba(15, 25, 41, 0.8);
    border-radius: 4px;
    border: 1px solid rgba(0, 217, 255, 0.2);
}

.chart-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #00d9ff 0%, #39ff14 100%);
    border-radius: 4px;
    border: 1px solid #00d9ff;
}

.chart-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #39ff14 0%, #00d9ff 100%);
}

/* Surface Container (for 3D/WebGL canvas) */
.surface-container {
    flex: 1;
    position: relative;
    background: rgba(15, 22, 41, 0.9);
    border: 2px solid #00d9ff;
    border-radius: 4px;
    padding: 4px;
    overflow: hidden;
    min-height: 0;
    /* Important for flex children to shrink properly */
    display: flex;
    flex-direction: column;
}

#surfaceContainer {
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    /* Crucial for flex child to shrink */
    background: rgba(15, 22, 41, 0.95);
    display: block;
    /* Prevent inline spacing issues */
}

#surfaceCanvas {
    width: 100%;
    height: 100%;
    flex: 1;
    min-height: 0;
    /* Crucial for flex child to shrink */
    background: rgba(15, 22, 41, 0.95);
    display: block;
    /* Prevent inline spacing issues */
}

/* Surface Header & Legend */
#surfaceHeader {
    flex: 0 0 auto;
    /* Don't shrink or grow */
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 10px;
    background: rgba(15, 22, 41, 0.95);
    border-bottom: 1px solid rgba(0, 217, 255, 0.2);
    min-height: 50px;
}

#surfaceTitle {
    font-size: 18px;
    color: #00d9ff;
    margin: 0 0 4px 0;
    text-align: center;
    font-weight: 700;
    letter-spacing: 1px;
}

#surfaceInfo {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px;
    font-size: 16px;
    font-family: 'Courier New', monospace;
    min-height: 20px;
}

/* Back Button */
.back-btn {
    padding: 6px 12px;
    border-radius: 3px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.25s;
    min-width: 100px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(59, 130, 246, 0.05);
    color: #3b82f6;
    border: 1px solid #3b82f6;
}

.back-btn:hover {
    background: rgba(59, 130, 246, 0.15);
    transform: translateY(-2px);
    color: #60a5fa;
    border-color: #60a5fa;
}

.back-btn:active {
    transform: translateY(0);
}

.back-btn:disabled {
    background: transparent;
    border-color: #4b5563;
    color: #6b7280;
    cursor: not-allowed;
    transform: none;
}

/* Responsive Design - Tablets (surfaces) */
@media (max-width: 768px) {
    .surface-container {
        padding: 3px;
    }

    #surfaceHeader {
        padding: 4px 8px;
        min-height: 45px;
    }

    #surfaceTitle {
        font-size: 16px;
    }

    #surfaceInfo {
        font-size: 14px;
        gap: 10px;
    }
}

/* Responsive Design - Phones (surfaces) */
@media (max-width: 480px) {
    .surface-container {
        padding: 3px;
        flex: 1;
        min-height: 0;
        border-width: 1px;
    }

    #surfaceHeader {
        padding: 3px 6px;
        min-height: 40px;
    }

    #surfaceTitle {
        font-size: 15px;
    }

    #surfaceInfo {
        font-size: 13px;
        gap: 8px;
    }

    .back-btn {
        padding: 5px 10px;
        font-size: 13px;
        min-width: 85px;
    }
}