/* style.css */

/* --- Ultra-Modern Terminal Design System --- */
:root {
    /* Clinical Terminal Theme - Absolute Contrast */
    --bg-base: #0a0a0a;
    --bg-panel: #0f0f11;
    --bg-elevated: #161618;

    /* High-Vis Accents */
    --accent: #818cf8;
    --accent-dim: rgba(129, 140, 248, 0.15);
    --up-green: #10b981;
    --down-red: #ef4444;

    /* Typography - Mono focus */
    --text-primary: #e4e4e7;
    --text-muted: #71717a;
    --border: #27272a;
}

body.light-mode {
    --bg-base: #f8fafc;
    --bg-panel: #ffffff;
    --bg-elevated: #f1f5f9;
    --accent: #4f46e5;
    --accent-dim: rgba(79, 70, 229, 0.1);
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --border: #e2e8f0;
}

/* --- Resets & Global --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: var(--bg-base);
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

body.page-index {
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

/* Custom Sleek Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* --- Helper Classes --- */
.h-100 {
    height: 100%;
}

.flex-col {
    display: flex;
    flex-direction: column;
}

.flex-1 {
    flex: 1;
}

.scroll-y {
    overflow-y: auto;
}

/* Empty States & Overlays */
.empty-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(10, 10, 10, 0.85);
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1px;
    text-transform: uppercase;
    z-index: 10;
    pointer-events: none;
}

.hide-mobile {
    display: flex;
}

/* Keep Strategy chain advanced fields as real table columns on desktop. */
.chain-table-scroll-wrapper th.hide-mobile,
.chain-table-scroll-wrapper td.hide-mobile,
.options-chain-table th.hide-mobile,
.options-chain-table td.hide-mobile {
    display: table-cell !important;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    .chain-table-scroll-wrapper th.hide-mobile,
    .chain-table-scroll-wrapper td.hide-mobile,
    .options-chain-table th.hide-mobile,
    .options-chain-table td.hide-mobile {
        display: none !important;
    }
}

/* =========================================
   SINGLE-LINE RIBBON HEADER ARCHITECTURE
   ========================================= */
.master-header {
    display: flex;
    align-items: center;
    padding: 0 16px;
    height: 52px;
    background: var(--bg-panel);
    border-bottom: 2px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    white-space: nowrap;
    transition: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.header-center-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex: 1;
    min-width: 280px;
}

/* Full Screen Overlay */
.nav-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 10, 12, 0.98);
    backdrop-filter: blur(20px);
    z-index: 9000;
    display: none;
    flex-direction: column;
    padding: 24px;
    animation: slideDown 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.module-stage-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 8, 10, 0.98);
    backdrop-filter: blur(16px);
    z-index: 10001;
    display: none;
    flex-direction: column;
    overflow: hidden;
    pointer-events: auto;
}

.module-stage-overlay.active {
    display: flex;
}

.module-stage-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 10, 12, 0.9);
    position: sticky;
    top: 0;
    z-index: 20050;
    pointer-events: auto;
}

.module-stage-brand {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.module-stage-title {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1.2px;
    text-transform: uppercase;
    font-weight: 700;
}

.module-stage-mount {
    flex: 1;
    overflow: auto;
    padding: 16px;
    min-height: 0;
    position: relative;
    z-index: 1;
}

.module-stage-mount #dashboard-layout {
    max-width: none;
    margin: 0;
    padding: 0;
}

.module-stage-mount .dashboard-top-row {
    display: none !important;
}

.nav-overlay.active {
    display: flex;
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.overlay-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 48px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.overlay-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    overflow-y: auto;
}

.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-bottom: 64px;
}

.nav-item {
    padding: 24px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    text-decoration: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
}

.nav-item:hover {
    background: var(--accent-dim);
    border-color: var(--accent);
    transform: translateY(-2px);
}

.nav-item.active {
    border-left: 4px solid var(--accent);
    background: var(--accent-dim);
}

.nav-item.locked {
    opacity: 0.5;
    cursor: pointer;
}

.nav-label {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.nav-separator {
    grid-column: 1 / -1;
    font-size: 11px;
    color: var(--accent);
    font-weight: 800;
    margin-top: 32px;
    margin-bottom: 8px;
    letter-spacing: 3px;
    text-transform: uppercase;
}

.overlay-footer {
    margin-top: auto;
    padding: 32px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    background: rgba(0, 0, 0, 0.2);
}

.user-info-large {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-avatar-large {
    width: 48px;
    height: 48px;
    background: var(--accent);
    color: #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 900;
}

.username-large {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
}

.user-role-large {
    font-size: 10px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.footer-actions {
    display: flex;
    gap: 12px;
}

.footer-actions .btn-ghost {
    padding: 12px 24px;
    font-size: 12px;
}

.logout-link {
    color: var(--down-red) !important;
}

@media (max-width: 768px) {
    .nav-grid {
        grid-template-columns: 1fr;
    }

    .overlay-footer {
        flex-direction: column;
        text-align: center;
    }

    .user-info-large {
        flex-direction: column;
    }
}

.master-header::-webkit-scrollbar {
    display: none;
}

/* HACK: Flatten wrappers so JS content flows horizontally */
#quote-wrapper,
#quote-dynamic-area[style],
.quote-row {
    display: contents !important;
}

/* Header Ordering */
.logo-box {
    order: 1;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 2px;
    color: #fff;
}

.control-box {
    order: 3;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 16px;
}

.telemetry-group {
    order: 9;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: 16px;
}

/* Inputs & Buttons */
input.ticker-input,
select {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    color: var(--accent);
    padding: 6px 10px;
    border-radius: 0;
    font-size: 13px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    outline: none;
    text-transform: uppercase;
    transition: none;
}

input.ticker-input:focus,
select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent);
}

/* Optgroup Styling for the New Presets Dropdown */
optgroup {
    background: var(--bg-base);
    color: var(--text-muted);
    font-family: 'Inter', sans-serif;
    font-weight: 800;
    font-size: 11px;
    text-transform: uppercase;
}

option {
    background: var(--bg-panel);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    font-size: 13px;
    text-transform: none;
}

button {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 6px 14px;
    border-radius: 0;
    font-size: 11px;
    cursor: pointer;
    transition: none;
    border: none;
}

.btn-primary {
    background: #f4f4f5;
    color: #000;
}

.btn-primary:hover {
    background: var(--text-muted);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* Toggles */
.api-counter-widget {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--text-muted);
    margin-right: 10px;
}

.switch-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    position: relative;
    border: 1px solid var(--border);
    padding: 4px 8px;
}

.switch-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.slider {
    width: 28px;
    height: 14px;
    background-color: var(--bg-base);
    border-radius: 0;
    position: relative;
    transition: none;
    border: 1px solid var(--border);
}

.slider:before {
    position: absolute;
    content: "";
    height: 8px;
    width: 8px;
    left: 2px;
    bottom: 2px;
    background-color: var(--text-muted);
    border-radius: 0;
    transition: none;
}

.switch-toggle input:checked+.slider {
    background-color: var(--accent-dim);
    border-color: var(--accent);
}

.switch-toggle input:checked+.slider:before {
    transform: translateX(12px);
    background-color: var(--accent);
}

.toggle-lbl {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    letter-spacing: 0.5px;
}

/* Colors & Badges */
.text-green {
    color: var(--up-green) !important;
}

.text-red {
    color: var(--down-red) !important;
}

.text-accent {
    color: var(--accent) !important;
}

.market-badge {
    font-size: 10px;
    font-weight: 800;
    padding: 5px 8px;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-right: 4px;
}

.status-open {
    background: rgba(16, 185, 129, 0.1);
    color: var(--up-green);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.status-closed {
    background: rgba(239, 68, 68, 0.1);
    color: var(--down-red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.status-unknown {
    background: var(--bg-elevated);
    color: var(--text-muted);
}

/* =========================================
   DASHBOARD & GRID RESTRAINTS
   ========================================= */
#dashboard-layout {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 1900px;
    margin: 0 auto;
}

.page-index #dashboard-layout {
    flex: 1;
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    gap: 0;
    min-height: calc(100dvh - 60px);
    overflow: hidden;
}

.page-index .dashboard-top-row {
    display: block !important;
    width: 100% !important;
    height: calc(100dvh - 60px);
    min-height: calc(100dvh - 60px);
    margin: 0 !important;
    gap: 0 !important;
}

.page-index #history-container {
    display: block !important;
    max-width: none !important;
    height: 100%;
    min-height: calc(100dvh - 60px);
}

.page-index #history-container>.card {
    height: 100%;
    margin: 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
}

.page-index #history-container #tv-wrapper {
    min-height: 0 !important;
    height: 100%;
}

.page-index .dashboard-top-row,
.page-index #history-container,
.page-index #history-container>.card,
.page-index #history-container #tv-wrapper,
.page-index #history-container #tv-chart {
    width: 100%;
}

.page-index .footer-bottom {
    display: none !important;
}

.dashboard-top-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* SPA Fade In */
.app-section {
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Layouts */
#strategy-lab-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.panel-wrapper {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.panel-wrapper>.card {
    flex: 1;
    min-height: 0;
}

/* Cards */
.card {
    background: var(--bg-panel);
    border-radius: 0;
    padding: 16px;
    border: 1px solid var(--border);
    transition: none;
}

.card:hover {
    border-color: var(--text-muted);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.card-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0;
}

/* -----------------------------------------
   STRATEGY LAB & TABLE STYLES
   ----------------------------------------- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    text-align: center;
    color: var(--text-muted);
    font-size: 10px;
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    text-transform: uppercase;
}

td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    font-family: 'JetBrains Mono', monospace;
    text-align: center;
    color: #d4d4d8;
}

#options-chain-table thead {
    background: rgba(9, 9, 11, 0.95);
    backdrop-filter: blur(8px);
    position: relative;
    z-index: 20;
    will-change: transform;
}

#options-chain-table th {
    background: transparent;
}

#options-chain-table tbody tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.itm-cell {
    background: rgba(255, 255, 255, 0.03);
}

/* Option Chain Specifics */
th.strike-col {
    background: var(--bg-elevated) !important;
    color: var(--text-primary);
    font-size: 11px;
}

td.strike-col {
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-weight: 800;
}

.calls-header {
    color: var(--up-green) !important;
    font-size: 12px !important;
}

.puts-header {
    color: var(--down-red) !important;
    font-size: 12px !important;
}

.calls-header-line {
    border-bottom: 2px solid var(--up-green) !important;
}

.puts-header-line {
    border-bottom: 2px solid var(--down-red) !important;
}

.atm-row td {
    background: var(--accent-dim) !important;
    border-top: 1px solid var(--accent);
    border-bottom: 1px solid var(--accent);
}

/* Metrics */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    align-content: start;
}

.metric-card {
    background: var(--bg-panel);
    padding: 14px;
    border-radius: 4px;
    border: 1px solid var(--border);
    text-align: center;
}

.metric-label {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: 0.5px;
}

.metric-value {
    font-size: 1.1rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
}

.chart-box {
    height: 280px;
    position: relative;
    width: 100%;
}

.table-container {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    position: relative;
}

.profit-table th,
.profit-table td {
    white-space: nowrap;
}

/* Interactive Cells */
.clickable-cell {
    cursor: pointer;
    transition: color 0.2s;
}

.clickable-cell:hover {
    color: var(--accent);
}

.cell-buy-active {
    background: rgba(16, 185, 129, 0.15) !important;
    color: var(--up-green) !important;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px var(--up-green);
}

.cell-sell-active {
    background: rgba(239, 68, 68, 0.15) !important;
    color: var(--down-red) !important;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px var(--down-red);
}

#tv-wrapper {
    border: 1px solid var(--border);
    border-radius: 4px;
}

/* Active Legs Cart */
.legs-cart-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 140px;
    overflow-y: auto;
}

.leg-cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
}

.leg-badge-action {
    padding: 2px 6px;
    border-radius: 3px;
    font-weight: 800;
    font-family: 'Inter', sans-serif;
    font-size: 9px;
    text-transform: uppercase;
}

.leg-badge-action.buy {
    background: rgba(16, 185, 129, 0.15);
    color: var(--up-green);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.leg-badge-action.sell {
    background: rgba(239, 68, 68, 0.15);
    color: var(--down-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-remove-leg {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
}

.btn-remove-leg:hover {
    color: var(--down-red);
    background: rgba(239, 68, 68, 0.1);
}

/* Context Menu */
.context-menu {
    position: absolute;
    background: var(--bg-elevated);
    border: 1px solid var(--text-muted);
    border-radius: 0;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 1);
    padding: 4px 0;
    min-width: 180px;
    z-index: 10050;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    font-weight: 600;
    user-select: none;
}

.context-menu .menu-item {
    padding: 8px 14px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background 0.2s, padding-left 0.2s;
}

.context-menu .menu-item:hover {
    background: var(--bg-elevated);
    color: var(--accent);
    padding-left: 18px;
}

.context-menu .menu-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

.active-neon {
    border-color: var(--accent) !important;
    color: var(--accent) !important;
    background: var(--accent-dim) !important;
    box-shadow: 0 0 10px var(--accent-dim);
}

/* --- NO THEME PRESETS IN CLINICAL TERMINAL --- */

/* =========================================
   GLOBAL TOOLTIP ENGINE
   ========================================= */
#gnx-global-tooltip {
    position: absolute;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border);
    padding: 8px 12px;
    border-radius: 0;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    pointer-events: none;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: none;
    box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
    max-width: 250px;
    white-space: pre-wrap;
    line-height: 1.4;
}

#gnx-global-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

body.light-mode #gnx-global-tooltip {
    background: rgba(255, 255, 255, 0.95);
    color: var(--text-primary);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

/* --- Restored Chart Sentiment Buttons --- */
.sentiment-mini-card {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-left: 2px solid;
    padding: 4px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    margin-right: 8px;
    /* Spacing between buttons */
}

.sentiment-mini-card:hover {
    background: var(--bg-elevated);
}

.sentiment-mini-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.sentiment-mini-info span {
    font-size: 9px;
    color: var(--text-muted);
    text-transform: uppercase;
    font-weight: 600;
}

.sentiment-mini-info strong {
    font-size: 13px;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

/* =========================================
   collapsible modules Layout Transitions
   ========================================= */

/* Collapsible Details/Summary Chevron */
details>summary {
    list-style: none;
}

details>summary::-webkit-details-marker {
    display: none;
}

details[open]>summary .collapsible-chevron {
    transform: rotate(90deg);
}

details>summary .collapsible-chevron {
    display: inline-block;
    transition: transform 0.2s ease;
}

.dashboard-top-row {
    display: flex;
    transition: all 0.3s ease;
    gap: 12px;
}

#history-container {
    flex: 1;
    transition: flex 0.3s ease;
    min-width: 0;
    /* Prevents flex items from overflowing */
}

#right-panel {
    width: 400px;
    transition: width 0.3s ease;
}

/* =========================================
   MOBILE TERMINAL OPTIMIZATIONS
   ========================================= */
@media (max-width: 1024px) {
    #dashboard-layout {
        padding: 8px;
        gap: 8px;
    }

    .dashboard-top-row {
        flex-direction: column;
    }

    #right-panel {
        width: 100%;
    }

    #strategy-lab-layout {
        grid-template-columns: 1fr;
    }
}

/* "Ghost Strike" - Sticky Strike Column for horizontal scrolls */
@media (max-width: 768px) {
    .chain-table-scroll-wrapper {
        position: relative;
    }

    .strike-col {
        position: sticky;
        left: 0;
        /* Default stick to left for small screens */
        right: 0;
        z-index: 25 !important;
        background: var(--bg-elevated) !important;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.5);
    }

    /* If we want it centered sticky, it requires a specific JS or complex CSS.
       Sticking it to a fixed position when scrolling is the goal. */
    #options-chain-table th.strike-col,
    #options-chain-table td.strike-col {
        left: 50%;
        transform: translateX(-50%);
        width: 80px;
        min-width: 80px;
    }
}


/* Collapsed States Removed */

/* =========================================
   MOBILE RESPONSIVENESS & MEDIA QUERIES
   ========================================= */

@media (max-width: 1200px) {

    /* Tablet/Mid-size screens */
    #strategy-lab-layout {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 768px) {
    /* Mobile/Small screens */

    /* 1. Unhide the missing utility class that strategy.js relies on! */
    .hide-mobile {
        display: none !important;
    }

    /* 2. Adjust Master Header to wrap cleanly */
    .master-header {
        padding: 8px 12px;
        height: auto;
        flex-wrap: wrap;
        gap: 8px;
    }

    .header-center-stack {
        width: 100%;
        order: 2;
        min-width: 0;
    }

    .header-right-tools {
        order: 3;
        margin-left: 0 !important;
    }

    .header-left-tools {
        order: 1;
    }

    .logo-box {
        width: 100%;
        text-align: center;
        margin-bottom: 4px;
    }

    .control-box {
        flex-wrap: wrap;
        width: 100%;
        justify-content: center;
        margin-left: 0;
    }

    .telemetry-group {
        margin-left: 0;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
        flex-wrap: wrap;
    }

    /* 3. Module Navigation Bar */
    .module-nav-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding: 12px;
    }

    .module-nav-bar>div {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .module-nav-bar select {
        width: 100%;
        max-width: 100% !important;
    }

    /* 4. Overall Layout Wrappers */
    #dashboard-layout {
        padding: 8px;
    }

    /* 5. Metrics Grids (Scanner, Strategy, etc.) */
    .metrics-grid {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }

    /* 6. Specific App Fixes */
    #strategy-bottom-panel .card {
        margin-bottom: 0;
    }

    @media (max-width: 768px) {
        #strategy-bottom-panel>div {
            grid-template-columns: 1fr !important;
        }
    }

    .scroll-x-hide::-webkit-scrollbar {
        display: none;
    }

    .scroll-x-hide {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
}

/* ─── Expiry Selector ─────────────────────────────────────────── */
#expiry-tiered-selector {
    display: inline-flex;
    gap: 12px;
    align-items: flex-end;
    min-width: max-content;
    flex-wrap: nowrap;
}

.expiry-month-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

.expiry-month-label {
    background: #1e293b;
    color: #94a3b8;
    font-size: 10px;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 6px;
    width: 100%;
    text-align: center;
    border: 1px solid #334155;
}

.expiry-days-group {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.expiry-day-item {
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    min-width: 28px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
}

.expiry-day-item:hover {
    background: rgba(14, 165, 233, 0.1);
}

.expiry-day-item.active {
    background: #0ea5e9;
    color: #000;
    box-shadow: 0 0 10px rgba(14, 165, 233, 0.4);
}

#expiry-selector-wrapper {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    scroll-snap-type: x proximity;
}

@media (max-width: 768px) {
    #expiry-selector-wrapper {
        padding-bottom: 8px;
    }

    #expiry-tiered-selector {
        gap: 8px;
    }

    .expiry-month-group {
        gap: 6px;
        scroll-snap-align: start;
    }

    .expiry-month-label {
        font-size: 9px;
        padding: 4px 8px;
    }

    .expiry-days-group {
        gap: 6px;
    }

    .expiry-day-item {
        font-size: 11px;
        padding: 4px 7px;
        min-width: 26px;
    }
}

/* ─── Strike Slider – global ──────────────────────────────────── */

.ss-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: grab;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 900;
    color: #fff;
    user-select: none;
    touch-action: none;
    transition: box-shadow 0.15s, transform 0.1s;
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.5);
}

.ss-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.15);
}

.ss-handle.buy {
    background: var(--up-green);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.5);
}

.ss-handle.sell {
    background: var(--down-red);
    box-shadow: 0 0 16px rgba(239, 68, 68, 0.5);
}

.ss-strike-lbl {
    position: absolute;
    top: calc(50% + 24px);
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
    font-family: 'JetBrains Mono', monospace;
    white-space: nowrap;
    pointer-events: none;
}

/* BUY / SELL action buttons on each handle */
.ss-action-btn {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 94px;
    height: 26px;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: 0.5px;
    border-radius: 4px;
    border: 1px solid transparent;
    cursor: pointer;
    color: #fff;
    white-space: nowrap;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.28;
    filter: grayscale(0.5);
    transition: opacity 0.18s, filter 0.18s, transform 0.15s;
}

.ss-action-btn.buy {
    top: calc(50% - 62px);
    /* above the handle circle */
    background: var(--up-green);
}

.ss-action-btn.sell {
    top: calc(50% + 46px);
    /* below the strike label */
    background: var(--down-red);
}

.ss-action-btn.active {
    opacity: 1;
    filter: none;
    border-color: rgba(255, 255, 255, 0.45);
    transform: translateX(-50%) scale(1.06);
}

.ss-action-btn:hover {
    opacity: 0.82;
    filter: brightness(1.15);
}

.strike-tick {
    position: absolute;
    bottom: 0;
    width: 1px;
    height: 6px;
    background: rgba(255, 255, 255, 0.12);
    transform: translateX(-50%);
}

.strike-tick-label {
    position: absolute;
    top: 7px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--text-muted);
    white-space: nowrap;
    font-family: 'JetBrains Mono', monospace;
}

@media (max-width: 768px) {
    .ss-handle {
        width: 42px;
        height: 42px;
        font-size: 12px;
    }

    .ss-strike-lbl {
        font-size: 13px;
        top: calc(50% + 28px);
    }

    .ss-action-btn {
        width: 104px;
        height: 30px;
        font-size: 11px;
    }

    .ss-action-btn.buy {
        top: calc(50% - 70px);
    }

    .ss-action-btn.sell {
        top: calc(50% + 54px);
    }

    .strike-tick-label {
        font-size: 11px;
    }
}

/* =========================================
   INTERACTIVE TOUR ENGINE (ONBOARDING)
   ========================================= */
#gnx-tour-overlay {
    position: fixed;
    inset: 0;
    z-index: 999990;
    pointer-events: none;
    transition: opacity 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

#gnx-tour-overlay.visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* The SVG Mask that dims everything except the target */
#gnx-tour-mask {
    width: 100vw;
    height: 100vh;
    fill: rgba(0, 0, 0, 0.85);
    pointer-events: none;
}

#gnx-tour-hole {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    fill: black;
}

/* The Glowing Highlight Box */
#gnx-tour-highlight {
    position: fixed;
    pointer-events: none;
    z-index: 999991;
    border: 2px solid var(--accent);
    border-radius: 6px;
    box-shadow: 0 0 20px var(--accent-dim), inset 0 0 10px rgba(129, 140, 248, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    visibility: hidden;
}

#gnx-tour-highlight.visible {
    opacity: 1;
    visibility: visible;
}

/* The Floating Popover Card */
#gnx-tour-popover {
    position: fixed;
    z-index: 999992;
    pointer-events: auto;
    background: rgba(9, 9, 11, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 16px;
    width: 320px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.8);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    gap: 12px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(10px);
}

#gnx-tour-popover.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

body.light-mode #gnx-tour-popover {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
}

.tour-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.tour-title {
    font-size: 13px;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.tour-progress {
    font-family: 'JetBrains Mono', monospace;
    font-size: 10px;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid var(--border);
}

.tour-body {
    font-size: 13px;
    color: var(--text-primary);
    line-height: 1.5;
}

.tour-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 4px;
}

.btn-tour-skip {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    text-transform: uppercase;
    font-weight: 700;
    transition: color 0.2s;
}

.btn-tour-skip:hover {
    color: var(--text-primary);
}

/* =========================================
   GLOBAL FONT SCALING (USER PREFERENCES)
   ========================================= */

/* --- MEDIUM FONT SCALING --- */
body.font-md {
    font-size: 15px;
}

body.font-md input.ticker-input,
body.font-md select {
    font-size: 15px;
}

body.font-md th {
    font-size: 12px;
}

body.font-md td {
    font-size: 14px;
}

body.font-md .metric-label {
    font-size: 11px;
}

body.font-md .metric-value {
    font-size: 1.25rem;
}

body.font-md .card-title {
    font-size: 13px;
}

body.font-md button {
    font-size: 13px;
}

body.font-md th.strike-col {
    font-size: 13px;
}

body.font-md .calls-header,
body.font-md .puts-header {
    font-size: 14px !important;
}

body.font-md .leg-cart-item {
    font-size: 13px;
}

body.font-md #gnx-global-tooltip {
    font-size: 13px;
}

body.font-md .sentiment-mini-info span {
    font-size: 11px;
}

body.font-md .sentiment-mini-info strong {
    font-size: 15px;
}

body.font-md .market-badge {
    font-size: 11px;
}

/* --- LARGE FONT SCALING --- */
body.font-lg {
    font-size: 17px;
}

body.font-lg input.ticker-input,
body.font-lg select {
    font-size: 17px;
}

body.font-lg th {
    font-size: 14px;
}

body.font-lg td {
    font-size: 16px;
}

body.font-lg .metric-label {
    font-size: 13px;
}

body.font-lg .metric-value {
    font-size: 1.4rem;
}

body.font-lg .card-title {
    font-size: 15px;
}

body.font-lg button {
    font-size: 15px;
}

body.font-lg th.strike-col {
    font-size: 15px;
}

body.font-lg .calls-header,
body.font-lg .puts-header {
    font-size: 16px !important;
}

body.font-lg .leg-cart-item {
    font-size: 15px;
}

body.font-lg #gnx-global-tooltip {
    font-size: 15px;
}

body.font-lg .sentiment-mini-info span {
    font-size: 13px;
}

body.font-lg .sentiment-mini-info strong {
    font-size: 17px;
}

body.font-lg .market-badge {
    font-size: 12px;
}

/* =========================================
   DCA CALCULATOR UX + MOBILE
   ========================================= */
#app-dca #dca-metrics-grid {
    display: flex;
    gap: 24px;
    padding: 12px;
    flex-wrap: wrap;
}

#app-dca .metric-group {
    min-width: 130px;
}

#app-dca .dca-prob-group {
    border-left: 1px solid var(--border);
    padding-left: 24px;
}

#app-dca .dca-metric-subtext {
    font-size: 9px;
    color: var(--text-muted);
}

#dca-dynamic-tutorial {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 14px 16px;
    margin-bottom: 12px;
}

.dca-tutorial-title {
    color: var(--accent);
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 12px;
    letter-spacing: 0.4px;
}

.dca-workflow-list {
    margin: 0;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: var(--text-primary);
    font-size: 11px;
}

.dca-workflow-note {
    margin-top: 10px;
    font-size: 10px;
    color: var(--text-muted);
}

#app-dca .dca-widget {
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: 100%;
    padding: 4px;
}

#app-dca .dca-card {
    padding: 12px;
    border: 1px solid var(--border);
    background: var(--bg-panel);
    margin-bottom: 12px;
}

#app-dca .dca-guidance-card {
    background: linear-gradient(140deg, rgba(129, 140, 248, 0.11) 0%, rgba(129, 140, 248, 0.03) 45%, transparent 100%);
    border-color: var(--accent-dim);
    margin-bottom: 10px;
}

#app-dca .dca-guidance-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 10px;
}

#app-dca .dca-guidance-header strong {
    color: var(--accent);
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

#app-dca .dca-guidance-header span {
    color: var(--text-primary);
}

#app-dca .dca-card-header {
    padding: 0;
    margin-bottom: 10px;
    border: none;
}

#app-dca .dca-step-title {
    color: var(--accent);
    margin: 0;
}

#app-dca .dca-actions-inline,
#app-dca .dca-preset-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

#app-dca .dca-small-btn,
#app-dca .dca-preset-btn {
    font-size: 10px;
    padding: 4px 10px;
}

#app-dca .dca-fields-row {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

#app-dca .dca-input {
    width: 100%;
    background: transparent;
    text-transform: none;
}

#app-dca .dca-summary-line {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid var(--border);
    padding-top: 8px;
    font-size: 10px;
    color: var(--text-muted);
}

#app-dca .dca-summary-tight {
    border-top: none;
    padding-top: 4px;
}

#app-dca #dca-current-basis,
#app-dca #dca-current-drawdown,
#app-dca #dca-total-cap,
#app-dca #dca-new-avg,
#app-dca #dca-smart-cap {
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
    font-weight: 800;
}

#app-dca #dca-total-cap {
    color: var(--accent);
}

#app-dca .dca-hint-box {
    font-size: 9px;
    color: var(--accent);
    margin-bottom: 8px;
    border: 1px dashed var(--accent);
    padding: 6px 8px;
}

#app-dca .dca-entry-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    background: rgba(255, 255, 255, 0.03);
    padding: 8px;
    border: 1px solid var(--border);
    margin-bottom: 8px;
}

#app-dca .dca-market-row {
    background: rgba(0, 0, 0, 0.2);
    padding: 10px;
}

#app-dca .dca-remove-row-btn {
    color: var(--down-red);
    font-size: 12px;
    padding: 5px 9px;
    height: 30px;
}

#app-dca .dca-capital-line {
    padding-top: 10px;
    margin-top: 8px;
}

#app-dca .dca-smart-card {
    border: 1px solid var(--accent-dim);
    background: linear-gradient(145deg, rgba(129, 140, 248, 0.06) 0%, transparent 100%);
}

#app-dca .dca-smart-grid {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    margin-bottom: 12px;
}

#app-dca .dca-inline-input {
    display: flex;
    align-items: center;
    gap: 6px;
}

#app-dca .dca-inline-input span {
    color: var(--text-muted);
    font-size: 10px;
}

#app-dca .dca-smart-cap-col {
    text-align: right;
}

#app-dca .dca-smart-result {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    background: rgba(0, 0, 0, 0.25);
    padding: 8px;
    color: var(--text-muted);
    font-size: 10px;
}

#app-dca #dca-smart-shares {
    color: var(--accent);
    font-weight: 800;
}

#app-dca .dca-apply-btn {
    padding: 5px 10px;
    font-size: 10px;
}

#app-dca .dca-bottom-result {
    padding: 10px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border);
}

#app-dca #dca-new-avg {
    color: var(--up-green);
    font-size: 11px;
}

#app-dca #dca-lowered-by {
    font-size: 9px;
    color: var(--accent);
    text-align: right;
    display: none;
    margin-top: 4px;
}

@media (max-width: 768px) {
    #app-dca #dca-metrics-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 6px 2px;
    }

    #app-dca .card-title,
    #app-dca .dca-step-title {
        font-size: 14px;
        letter-spacing: 0.4px;
    }

    #app-dca .metric-label {
        font-size: 11px;
        font-weight: 700;
        letter-spacing: 0.6px;
    }

    #app-dca .metric-value {
        font-size: 1.35rem;
        font-weight: 800;
    }

    #app-dca .dca-metric-subtext,
    #app-dca .dca-workflow-note,
    #app-dca .dca-hint-box,
    #app-dca .dca-inline-input span {
        font-size: 11px;
    }

    #app-dca .dca-workflow-list,
    #app-dca .dca-guidance-header,
    #app-dca .dca-summary-line,
    #app-dca .dca-smart-result {
        font-size: 13px;
        line-height: 1.45;
    }

    #app-dca .dca-input {
        font-size: 16px;
        min-height: 42px;
        padding: 10px 12px;
    }

    #app-dca .metric-group {
        min-width: 0;
    }

    #app-dca .dca-prob-group {
        border-left: none;
        padding-left: 0;
        grid-column: 1 / -1;
    }

    #app-dca .dca-fields-row,
    #app-dca .dca-smart-grid,
    #app-dca .dca-entry-row,
    #app-dca .dca-smart-result {
        flex-direction: column;
        align-items: stretch;
    }

    #app-dca .dca-actions-inline,
    #app-dca .dca-preset-group {
        width: 100%;
        justify-content: flex-start;
    }

    #app-dca .dca-card-header {
        gap: 8px;
    }

    #app-dca .dca-remove-row-btn,
    #app-dca .dca-apply-btn {
        width: 100%;
        font-size: 13px;
        min-height: 40px;
    }

    #app-dca .dca-small-btn,
    #app-dca .dca-preset-btn {
        font-size: 12px;
        min-height: 38px;
        padding: 8px 12px;
    }

    #app-dca #dca-new-avg {
        font-size: 1.3rem;
    }

    #app-dca #dca-lowered-by {
        font-size: 11px;
    }

    #dca-dynamic-tutorial {
        padding: 12px;
    }
}
/* --- Autocomplete Dropdown --- */
.autocomplete-results-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-panel);
    border: 1px solid var(--accent);
    border-top: none;
    max-height: 250px;
    overflow-y: auto;
    z-index: 5000;
    display: none;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
}

.autocomplete-item {
    padding: 10px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}

.autocomplete-item:last-child {
    border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.active {
    background: var(--accent-dim);
}

.ac-symbol {
    font-weight: 800;
    color: var(--accent);
    font-size: 14px;
    min-width: 60px;
}

.ac-name {
    font-size: 11px;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ac-exchange {
    font-size: 9px;
    color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 4px;
    border-radius: 2px;
}

/* Specific adjustment for landing search bar to make it feel premium */
#main-landing-search-results {
    top: 100%;
    background: rgba(10, 10, 12, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 0 0 8px 8px;
    margin-top: -4px;
}
