:root {
    --bg-dark: #07090e;
    --bg-panel: #0e131d;
    --bg-card: #131a27;
    --bg-card-hover: #1a2334;
    --border: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(56, 189, 248, 0.35);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --text-dim: #64748b;
    --accent: #38bdf8;
    --accent-blue: #3b82f6;
    --long: #10b981;
    --long-bg: rgba(16, 185, 129, 0.14);
    --short: #f43f5e;
    --short-bg: rgba(244, 63, 94, 0.14);
    --warn: #f59e0b;
    --warn-bg: rgba(245, 158, 11, 0.14);
    --gold: #facc15;
    --purple: #a855f7;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100vh;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 13px;
    display: flex;
    flex-direction: column;
}

/* TOP HEADER */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 14px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    gap: 10px;
    flex-wrap: nowrap;
}

.topbar-header-row {
    display: contents;
}

@media (max-width: 1550px) {
    .brand-subtitle {
        display: none;
    }
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.brand-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, #0284c7, #2563eb);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 14px;
    letter-spacing: 0.5px;
    box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

.brand-title {
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.4px;
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tag-version {
    font-size: 9.5px;
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.35);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 700;
}

.brand-subtitle {
    font-size: 10.5px;
    color: var(--text-muted);
    margin-top: 1px;
    white-space: nowrap;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 9px;
    border: 1px solid var(--border);
    flex-shrink: 0;
}

.nav-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.nav-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.nav-btn.active {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
}

.top-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.control-group {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 10.5px;
    color: var(--text-muted);
    white-space: nowrap;
}

select, input[type="number"], input[type="text"] {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 12px;
    font-family: var(--font-sans);
}

input[type="number"] {
    width: 60px;
    font-family: var(--font-mono);
    font-weight: 700;
}

.status-pill {
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 9.5px;
    font-weight: 800;
    letter-spacing: 0.5px;
    background: var(--long-bg);
    color: var(--long);
    border: 1px solid rgba(16, 185, 129, 0.35);
    white-space: nowrap;
    flex-shrink: 0;
}

/* VIEWS */
.view-section {
    display: none;
    padding: 8px 14px;
    flex: 1;
    min-height: 0;
}

.view-section.active {
    display: flex;
    flex-direction: column;
}

/* TERMINAL GRID - PRODUCTIVE FULL-VIEWPORT LAYOUT */
.terminal-grid {
    display: grid;
    grid-template-columns: 1fr 345px;
    gap: 10px;
    align-items: stretch;
    flex: 1;
    min-height: 0;
    height: 100%;
}

.chart-column {
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
    min-height: 0;
    height: 100%;
}

.chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 6px 10px;
    border-radius: 9px;
    gap: 8px;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.symbol-picker {
    display: flex;
    align-items: center;
    gap: 8px;
}

.symbol-picker label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
}

#custom-symbol-input {
    width: 110px;
}

.tf-buttons {
    display: flex;
    gap: 4px;
    background: rgba(0, 0, 0, 0.3);
    padding: 3px;
    border-radius: 7px;
}

.tf-btn {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 5px 12px;
    border-radius: 5px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
}

.tf-btn.active {
    background: var(--accent);
    color: #05080f;
}

.price-ticker {
    display: flex;
    flex-direction: column;
}

.ticker-label {
    font-size: 10px;
    color: var(--text-dim);
    text-transform: uppercase;
}

.ticker-val {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 13px;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-primary {
    background: linear-gradient(135deg, #0284c7, #2563eb);
    color: #fff;
    border: none;
    padding: 8px 14px;
    border-radius: 7px;
    font-weight: 700;
    font-size: 12px;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-primary:hover {
    opacity: 0.92;
}

.replay-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--warn-bg);
    color: var(--warn);
    border: 1px solid rgba(245, 158, 11, 0.4);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
}

.replay-badge button {
    background: rgba(0, 0, 0, 0.35);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    cursor: pointer;
}

.hidden {
    display: none !important;
}

/* CHART CANVAS CARD */
.canvas-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 380px;
}

.canvas-legend {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 7px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    color: var(--text-muted);
    flex-wrap: wrap;
    flex-shrink: 0;
}

.leg-item, .leg-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.leg-toggle {
    cursor: pointer;
    user-select: none;
    color: var(--text-main);
    font-weight: 600;
}

.leg-toggle input[type="checkbox"] {
    accent-color: var(--accent);
    cursor: pointer;
}

.btn-chart-mini {
    background: rgba(56, 189, 248, 0.12);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.3);
    padding: 2px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-chart-mini:hover {
    background: rgba(56, 189, 248, 0.25);
}

.leg-item i, .leg-toggle i {
    display: inline-block;
    width: 10px;
    height: 3px;
    border-radius: 2px;
}

.dot-ema50 { background: #38bdf8; }
.dot-ema200 { background: #a855f7; }
.dot-wave { background: #facc15; height: 4px !important; }
.dot-entry { background: #f59e0b; }
.dot-sl { background: #f43f5e; }
.dot-tp1 { background: #10b981; }
.dot-tp2 { background: #22d3ee; }

.hover-readout {
    margin-left: auto;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--accent);
}

.canvas-wrapper {
    width: 100%;
    flex: 1;
    min-height: 220px;
    position: relative;
}

#main-chart-canvas {
    width: 100%;
    height: 100%;
    display: block;
    cursor: crosshair;
}

/* VALIDATION CHECKLIST PANEL */
.validation-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 9px;
    padding: 8px 10px;
    flex-shrink: 0;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.panel-header h3 {
    font-size: 12px;
    font-weight: 700;
}

.validation-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.val-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 9px;
    border-radius: 6px;
    gap: 5px;
    min-width: 0;
}

.val-item.pass {
    border-left: 3px solid var(--long);
}

.val-item.fail {
    border-left: 3px solid var(--short);
    opacity: 0.78;
}

.val-label {
    font-size: 10px;
    color: var(--text-muted);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.val-value {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 700;
    flex-shrink: 0;
}
    font-weight: 700;
    white-space: nowrap;
}

/* RIGHT RAIL */
.right-rail {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
    overflow-y: auto;
}

.signal-hero {
    background: linear-gradient(135deg, rgba(19, 26, 39, 0.95), rgba(14, 19, 29, 0.98));
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 13px;
    text-align: center;
}

.hero-small {
    font-size: 10px;
    letter-spacing: 1px;
    color: var(--text-dim);
    font-weight: 700;
}

.hero-big {
    font-size: 22px;
    font-weight: 900;
    margin: 4px 0;
    letter-spacing: 0.5px;
}

.hero-sub {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
}

.rail-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 13px;
}

.highlight-card {
    border-color: rgba(16, 185, 129, 0.4);
    background: linear-gradient(180deg, rgba(16, 185, 129, 0.06), var(--bg-panel));
}

.rail-card-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--accent);
    margin-bottom: 8px;
}

.kv-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    font-size: 12px;
}

.kv-row:last-child {
    border-bottom: none;
}

.kv-key {
    color: var(--text-muted);
}

.kv-val {
    font-family: var(--font-mono);
    font-weight: 700;
}

/* BACKTEST VIEW */
.bt-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.bt-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    padding: 14px 18px;
    border-radius: 10px;
    gap: 16px;
    flex-wrap: wrap;
}

.bt-header-row h2 {
    font-size: 16px;
    margin-bottom: 4px;
}

.bt-header-row p {
    font-size: 12px;
    color: var(--text-muted);
}

.bt-suite-switcher {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.suite-btn {
    background: var(--bg-card);
    color: var(--text-muted);
    border: 1px solid var(--border);
    padding: 9px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.suite-btn.active {
    background: rgba(56, 189, 248, 0.15);
    color: var(--accent);
    border-color: var(--accent);
}

.kpi-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.kpi-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
}

.kpi-title {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.kpi-val,
.kpi-value {
    font-family: var(--font-mono);
    font-size: 24px;
    font-weight: 900;
    margin: 6px 0 3px;
}

.kpi-sub {
    font-size: 11px;
    color: var(--text-dim);
}

.bt-mid-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 14px;
    min-width: 0;
}

.bt-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px 16px;
    min-width: 0;
    max-width: 100%;
}

.bt-card h3 {
    font-size: 13px;
    margin-bottom: 12px;
    color: var(--text-main);
}

.eq-canvas-wrap {
    width: 100%;
    height: 270px;
}

#equity-curve-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.table-wrap {
    overflow-x: auto;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    -webkit-overflow-scrolling: touch;
}

.ledger-scroll {
    max-height: 460px;
    overflow-y: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.data-table th, .data-table td {
    padding: 9px 10px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: rgba(0, 0, 0, 0.25);
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    position: sticky;
    top: 0;
}

.data-table tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 5px;
    font-size: 10px;
    font-weight: 800;
    font-family: var(--font-mono);
}

.badge-long { background: var(--long-bg); color: var(--long); border: 1px solid rgba(16, 185, 129, 0.35); }
.badge-short { background: var(--short-bg); color: var(--short); border: 1px solid rgba(244, 63, 94, 0.35); }
.badge-warn { background: var(--warn-bg); color: var(--warn); border: 1px solid rgba(245, 158, 11, 0.35); }
.badge-info { background: rgba(56, 189, 248, 0.15); color: var(--accent); border: 1px solid rgba(56, 189, 248, 0.35); }

.btn-Action {
    color: var(--text-main);
    border: none;
    border-radius: 6px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s, transform 0.1s;
}

.btn-Action:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-replay {
    background: rgba(56, 189, 248, 0.14);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.35);
    padding: 4px 9px;
    border-radius: 5px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.btn-replay:hover {
    background: var(--accent);
    color: #05080f;
}

.ledger-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    flex-wrap: wrap;
    gap: 10px;
}

/* SCANNER GRID */
.scanner-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.scanner-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 12px;
}

.scan-card {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s;
}

.scan-card:hover {
    transform: translateY(-2px);
    border-color: var(--accent);
}

.scan-card.sniper {
    border-left: 4px solid var(--long);
}

.scan-card.candidate {
    border-left: 4px solid var(--warn);
}

/* ==================== RESPONSIVE & MOBILE DESIGN SYSTEM ==================== */

@media (max-width: 1180px) {
    .terminal-grid {
        display: flex;
        flex-direction: column;
        height: auto;
    }
    .bt-mid-grid {
        grid-template-columns: 1fr;
        height: auto;
    }
    .canvas-wrapper {
        height: 460px;
    }
    .validation-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    html, body {
        height: auto;
        min-height: 100vh;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .topbar {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 8px 10px;
        gap: 8px;
        height: auto;
    }

    .topbar-header-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        gap: 6px;
    }

    .brand {
        gap: 6px;
        min-width: 0;
        flex-shrink: 1;
    }

    .brand-title {
        font-size: 13px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .tag-version {
        display: none;
    }

    .user-profile-widget {
        display: flex;
        align-items: center;
        gap: 4px;
        flex-shrink: 0;
    }

    .user-badge {
        padding: 3px 6px;
        font-size: 10px;
    }

    .btn-logout {
        padding: 3px 7px;
        font-size: 10px;
        white-space: nowrap;
    }

    .nav-tabs {
        width: 100%;
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding: 3px;
        gap: 4px;
        background: rgba(0, 0, 0, 0.4);
        border-radius: 8px;
    }

    .nav-tabs::-webkit-scrollbar {
        display: none;
    }

    .nav-btn {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 6px 11px;
        font-size: 11px;
    }

    .top-controls {
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        flex-wrap: wrap;
        gap: 6px;
    }

    .control-group {
        font-size: 10px;
    }

    .control-group select,
    .control-group input {
        font-size: 11px;
        padding: 4px 6px;
    }

    .view-section {
        flex: none;
        height: auto;
        min-height: auto;
        padding: 8px 10px 30px;
        overflow-y: visible;
    }

    .terminal-grid {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: auto;
        gap: 12px;
    }

    .chart-column {
        height: auto;
        min-height: auto;
        flex: none;
        gap: 8px;
    }

    .chart-toolbar {
        flex-wrap: wrap;
        gap: 6px;
        padding: 8px;
        height: auto;
    }

    .symbol-picker {
        width: 100%;
        display: flex;
        gap: 6px;
    }

    .symbol-picker label {
        display: none;
    }

    .symbol-picker select {
        flex: 1;
        min-width: 0;
    }

    #custom-symbol-input {
        flex: 1;
        min-width: 0;
        width: auto;
    }

    .tf-buttons {
        display: flex;
        gap: 3px;
        flex: 1;
    }

    .tf-btn {
        flex: 1;
        padding: 6px 0;
        text-align: center;
        font-size: 11px;
    }

    .toolbar-actions {
        display: flex;
        align-items: center;
        gap: 6px;
    }

    .toolbar-actions .btn-primary {
        padding: 6px 10px;
        font-size: 11px;
        white-space: nowrap;
    }

    .price-ticker {
        flex: 1;
        min-width: 80px;
        background: rgba(255, 255, 255, 0.03);
        border: 1px solid var(--border);
        padding: 4px 6px;
        border-radius: 6px;
        text-align: center;
    }

    .ticker-label {
        font-size: 9px;
    }

    .ticker-val {
        font-size: 11.5px;
    }

    .canvas-legend {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
        padding: 6px 8px;
        font-size: 10px;
    }

    .hover-readout {
        display: none;
    }

    .canvas-card {
        flex: none;
        min-height: auto;
        height: auto;
        display: flex;
        flex-direction: column;
    }

    .canvas-wrapper {
        height: 280px;
        min-height: 280px;
        flex: none;
        position: relative;
    }

    .validation-checklist {
        padding: 10px;
    }

    .validation-grid {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .val-item {
        padding: 7px 10px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .val-label {
        white-space: normal;
        font-size: 11px;
        word-break: break-word;
        padding-right: 8px;
    }

    .val-value {
        font-size: 11px;
        flex-shrink: 0;
    }

    .right-rail {
        height: auto;
        overflow-y: visible;
        flex: none;
        gap: 12px;
    }

    .setup-card {
        padding: 12px;
    }

    .setup-plan-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
    }

    .action-buttons {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .btn-approve, .btn-simulate, .btn-reject {
        width: 100%;
        min-height: 40px;
        font-size: 12.5px;
    }

    /* Live Trades Monitor Responsive */
    .bt-header-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .scanner-controls {
        display: flex;
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
    }

    .lt-kpi-grid, .bt-kpi-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .table-wrap {
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        border: 1px solid var(--border);
        border-radius: 8px;
    }

    #live-trades-table,
    #closed-trades-table,
    #opt-counterfactual-table,
    #opt-fib-cvd-table,
    #opt-tf-sl-table,
    #opt-session-table,
    #bt-tiers-table,
    #bt-ledger-table {
        min-width: 820px;
    }

    /* Scanner View */
    .scanner-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    /* Backtest View */
    .bt-mid-grid {
        grid-template-columns: 1fr;
        gap: 12px;
        min-width: 0;
        width: 100%;
    }

    .bt-card {
        min-width: 0;
        max-width: 100%;
        overflow-x: hidden;
    }

    .bt-suite-switcher {
        display: flex;
        flex-direction: column;
        gap: 6px;
        width: 100%;
    }

    .suite-btn {
        width: 100%;
        text-align: center;
        padding: 8px;
        font-size: 11px;
    }

    /* Telemetry Modal */
    #telemetry-inspector-modal {
        padding: 8px;
    }

    #telemetry-inspector-modal .bt-card {
        width: 96% !important;
        max-width: 96% !important;
        max-height: 90vh !important;
        padding: 12px !important;
    }

    #tel-modal-body {
        grid-template-columns: 1fr !important;
        gap: 10px !important;
    }

    /* Auth Card */
    .auth-card {
        width: 94%;
        max-width: 370px;
        padding: 24px 18px;
    }

    .input-with-icon input {
        font-size: 13.5px;
        padding: 12px 38px 12px 36px;
    }

    .btn-login {
        min-height: 44px;
    }
}

@media (max-width: 480px) {
    .price-ticker {
        min-width: 70px;
        padding: 3px 4px;
    }

    .ticker-label {
        font-size: 8.5px;
    }

    .ticker-val {
        font-size: 10.5px;
    }

    .canvas-wrapper {
        height: 350px;
        min-height: 300px;
    }

    .lt-kpi-grid, .bt-kpi-grid {
        grid-template-columns: 1fr;
    }
}

/* ==================== USER PROFILE & AUTH STYLES ==================== */
.user-profile-widget {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 6px;
    white-space: nowrap;
    flex-shrink: 0;
}

.user-badge {
    background: rgba(56, 189, 248, 0.12);
    border: 1px solid rgba(56, 189, 248, 0.35);
    color: var(--accent);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
}

.btn-logout {
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.35);
    color: var(--short);
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.btn-logout:hover {
    background: var(--short);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(244, 63, 94, 0.4);
}

.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(3, 7, 18, 0.90);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-panel);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.85), 0 0 40px rgba(56, 189, 248, 0.08);
    animation: authFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h2 {
    font-size: 19px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.3px;
    margin-bottom: 6px;
}

.auth-header p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.auth-field {
    margin-bottom: 16px;
}

.auth-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.field-icon {
    position: absolute;
    left: 12px;
    font-size: 14px;
    color: var(--text-dim);
    pointer-events: none;
}

.input-with-icon input {
    width: 100%;
    padding: 11px 40px 11px 36px;
    background: #060910;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 13px;
    font-family: var(--font-sans);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.input-with-icon input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.pwd-toggle {
    position: absolute;
    right: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-dim);
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.pwd-toggle:hover {
    opacity: 1;
}

.auth-error {
    background: rgba(244, 63, 94, 0.12);
    border: 1px solid rgba(244, 63, 94, 0.4);
    color: #fb7185;
    padding: 9px 13px;
    border-radius: 7px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
    text-align: center;
}

.btn-login {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    color: #ffffff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(37, 99, 235, 0.35);
    transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(37, 99, 235, 0.5);
    opacity: 0.95;
}

.btn-login:active {
    transform: translateY(0);
}

.auth-footer {
    text-align: center;
    margin-top: 18px;
    font-size: 11px;
    color: var(--text-dim);
}



/* =====================================================================
   APP LOADING SCREEN
   ===================================================================== */
.app-loader {
    position: fixed;
    inset: 0;
    z-index: 200000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 40%, rgba(56, 189, 248, 0.10), transparent 60%), var(--bg-dark);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.app-loader.app-loader-hide {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.app-loader-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    width: min(320px, 86vw);
    text-align: center;
}
.app-loader-ring {
    position: relative;
    width: 78px;
    height: 78px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.app-loader-ring::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(56, 189, 248, 0.15);
    border-top-color: var(--accent);
    border-right-color: var(--long);
    animation: qeSpin 0.9s linear infinite;
}
.app-loader-badge {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 18px;
    color: #fff;
    background: linear-gradient(135deg, var(--accent-blue), var(--purple));
    box-shadow: 0 0 22px rgba(56, 189, 248, 0.35);
}
.app-loader-title {
    font-size: 14px;
    font-weight: 900;
    letter-spacing: 2px;
    color: var(--text-main);
}
.app-loader-step {
    font-size: 12px;
    color: var(--text-muted);
    min-height: 16px;
}
.app-loader-bar {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    overflow: hidden;
}
.app-loader-bar-fill {
    width: 0%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--long));
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
    transition: width 0.35s ease;
}
.app-loader-pct {
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 800;
    color: var(--accent);
}
@keyframes qeSpin {
    to { transform: rotate(360deg); }
}

/* =====================================================================
   LIVE KPI CARDS - REAL-TIME UPDATES
   ===================================================================== */
.live-kpi-status {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: -4px;
}
.live-kpi-status strong {
    color: var(--long);
    font-weight: 900;
    letter-spacing: 1px;
}
.live-kpi-status.stale strong {
    color: var(--warn);
}
.live-kpi-status #live-kpi-status-text {
    font-family: var(--font-mono);
}
.live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--long);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6);
    animation: qeLivePulse 1.6s infinite;
    flex-shrink: 0;
}
.live-kpi-status.stale .live-dot {
    background: var(--warn);
    animation: none;
}
@keyframes qeLivePulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
    70% { box-shadow: 0 0 0 7px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.kpi-live-val {
    display: inline-block;
    border-radius: 4px;
    transition: color 0.25s ease;
}
.kpi-live-val.flash-up {
    animation: qeFlashUp 0.9s ease;
}
.kpi-live-val.flash-down {
    animation: qeFlashDown 0.9s ease;
}
@keyframes qeFlashUp {
    0% { background: rgba(16, 185, 129, 0.45); }
    100% { background: transparent; }
}
@keyframes qeFlashDown {
    0% { background: rgba(244, 63, 94, 0.45); }
    100% { background: transparent; }
}

/* Skeleton shimmer while first server sync is loading */
.kpi-strip.kpi-loading .kpi-live-val {
    color: transparent !important;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.05) 25%, rgba(255, 255, 255, 0.14) 50%, rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: qeShimmer 1.2s infinite linear;
    min-width: 42px;
}
@keyframes qeShimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

.live-table-loading td {
    text-align: center;
    padding: 34px !important;
    color: var(--text-muted);
}
.live-table-loading .inline-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    vertical-align: middle;
    border-radius: 50%;
    border: 2px solid rgba(56, 189, 248, 0.2);
    border-top-color: var(--accent);
    animation: qeSpin 0.8s linear infinite;
}


/* =====================================================================
   DEDICATED LIVE TRADES VIEW LOADING SCREEN
   ===================================================================== */
.live-trades-loader {
    position: fixed;
    inset: 0;
    z-index: 150000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 40%, rgba(16, 185, 129, 0.12), transparent 60%), var(--bg-dark);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    transition: opacity 0.35s ease, visibility 0.35s ease;
}
.live-trades-loader.loader-hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.live-trades-loader-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    width: min(360px, 88vw);
    text-align: center;
    padding: 32px 24px;
    background: var(--bg-panel);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 35px rgba(16, 185, 129, 0.18);
}
.live-trades-loader-spinner {
    position: relative;
    width: 72px;
    height: 72px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.live-trades-loader-spinner::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid rgba(16, 185, 129, 0.18);
    border-top-color: var(--long);
    border-right-color: var(--accent);
    animation: qeSpin 0.85s linear infinite;
}
.live-loader-core {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(56, 189, 248, 0.3));
    border: 1px solid rgba(16, 185, 129, 0.5);
    box-shadow: 0 0 16px rgba(16, 185, 129, 0.4);
}
.live-trades-loader-title {
    font-size: 13.5px;
    font-weight: 900;
    letter-spacing: 1.8px;
    color: var(--text-main);
}
.live-trades-loader-status {
    font-size: 12px;
    color: var(--text-muted);
    min-height: 18px;
    line-height: 1.4;
}
.live-trades-loader-bar {
    width: 100%;
    height: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    overflow: hidden;
}
.live-trades-loader-bar-fill {
    width: 25%;
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--long), var(--accent));
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.6);
    transition: width 0.3s ease;
}
.live-trades-loader-badges {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 2px;
}

/* =====================================================================
   COOLDOWN RADAR & ANTI-CHOP STYLES
   ===================================================================== */
.cd-progress-wrap {
    width: 100%;
    min-width: 100px;
    height: 7px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-top: 4px;
}
.cd-progress-fill {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, #38bdf8, #10b981);
    box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
    transition: width 0.3s ease;
}
.cd-progress-fill.active {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}
.badge-cd-active {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.6);
    color: #f87171;
    font-weight: 800;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.badge-cd-ready {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.6);
    color: #34d399;
    font-weight: 800;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.cd-timer-live {
    font-family: var(--font-mono);
    font-weight: 800;
    letter-spacing: 0.5px;
}
