/* ============================================================
   ZeroAnalyzer — STYLE.md Design System Implementation
   Theme: Warm parchment · IBM Plex · Forest green/Blue accents
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;500;600&family=IBM+Plex+Sans:wght@300;400;500;600;700&display=swap");

/* ── CSS Variables (from STYLE.md §1.1) ──────────────────── */
:root {
    --bg: #f4f1eb;
    --surface: #ffffff;
    --surface2: #ede9e0;
    --border: #d4cfc4;
    --text: #1a1a18;
    --text2: #6b6760;

    --amber: #ba7517;
    --amber-light: #faeeda;
    --blue: #185fa5;
    --blue-hover: #134b82;
    --blue-light: #e6f1fb;
    --green: #3b6d11;
    --green-light: #eaf3de;
    --red: #a32d2d;
    --red-light: #fcebeb;

    /* Shadow tokens (STYLE.md §4) */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);

    /* Radius */
    --radius: 16px;

    /* Transitions */
    --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-std: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset & Base ───────────────────────────────────────────── */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    background: var(--bg);
    color: var(--text);
    font-family: "IBM Plex Sans", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}
::-webkit-scrollbar-track {
    background: var(--surface2);
}
::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--blue);
}

/* ── Typography utilities (STYLE.md §2.2) ───────────────────── */
.mono {
    font-family: "IBM Plex Mono", monospace;
}
.text-primary {
    color: var(--text);
}
.text-secondary {
    color: var(--text2);
}
.text-muted {
    color: var(--text2);
    opacity: 0.6;
}
.text-green {
    color: var(--green);
}
.text-red {
    color: var(--red);
}
.text-amber {
    color: var(--amber);
}
.text-blue {
    color: var(--blue);
}
.text-sm {
    font-size: 12px;
}
.text-xs {
    font-size: 11px;
}
.text-lg {
    font-size: 16px;
}
.font-bold {
    font-weight: 700;
}
.font-semibold {
    font-weight: 600;
}
.font-medium {
    font-weight: 500;
}
.val-red {
    color: var(--red);
}
.val-green {
    color: var(--green);
}
.val-blue {
    color: var(--blue);
}

/* ── App Layout ─────────────────────────────────────────────── */
#app {
    display: grid;
    grid-template-rows: 58px 1fr;
    grid-template-columns: 300px 1fr 320px;
    grid-template-areas:
        "header header header"
        "sidebar main signals";
    height: 100vh;
    overflow: hidden;
}

/* ── Header (STYLE.md §5.12) ────────────────────────────────── */
#header {
    grid-area: header;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 28px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}

.logo-icon {
    width: 34px;
    height: 34px;
    background: var(--blue);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.logo-text {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.logo-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    background: var(--blue-light);
    color: var(--blue);
    border: 1px solid rgba(24, 95, 165, 0.2);
    border-radius: 99px;
    letter-spacing: 0.5px;
}

.header-spacer {
    flex: 1;
}

/* Market status pill */
.market-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 99px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text2);
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse 2s infinite;
}
.status-dot.closed {
    background: var(--red);
}
.status-dot.mock {
    background: var(--amber);
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.85);
    }
}

/* Auth button */
#auth-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(24, 95, 165, 0.3);
    transition: all 0.2s;
}
#auth-btn:hover {
    background: var(--blue-hover);
    transform: translateY(-1px);
}
#auth-btn:active {
    transform: scale(0.98);
}
#auth-btn.connected {
    background: var(--green-light);
    color: var(--green);
    border: 1px solid rgba(59, 109, 17, 0.25);
    box-shadow: none;
}

/* ── Sidebar / Watchlist ─────────────────────────────────────── */
#sidebar {
    grid-area: sidebar;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface2);
}

.sidebar-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text2);
    margin-bottom: 12px;
}

/* Search (filter-card style from STYLE.md §5.5) */
.search-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 9px 12px 9px 34px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    outline: none;
    transition: border-color 0.2s;
}
.search-input:focus {
    border-color: var(--blue);
}
.search-input::placeholder {
    color: var(--text2);
    font-weight: 400;
}

.search-icon {
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text2);
    font-size: 13px;
    pointer-events: none;
}

/* Search results dropdown */
#search-results {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    z-index: 200;
    max-height: 280px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow-lg);
}
#search-results.visible {
    display: block;
}

.search-result-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-item:hover {
    background: var(--surface2);
}

.sri-symbol {
    font-weight: 600;
    font-size: 13px;
}
.sri-name {
    font-size: 11px;
    color: var(--text2);
    margin-top: 1px;
}
.sri-exchange {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    background: var(--blue-light);
    color: var(--blue);
    border: 1px solid rgba(24, 95, 165, 0.2);
    border-radius: 4px;
}

/* Watchlist items */
#watchlist-items {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.watchlist-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 180px;
    color: var(--text2);
    gap: 10px;
}
.watchlist-empty .empty-icon {
    font-size: 32px;
    opacity: 0.4;
}
.watchlist-empty p {
    font-size: 12px;
    text-align: center;
}

.watchlist-item {
    display: flex;
    align-items: center;
    padding: 11px 12px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.15s;
    position: relative;
    margin-bottom: 2px;
    border: 1px solid transparent;
}
.watchlist-item:hover {
    background: var(--surface2);
    border-color: var(--border);
}
.watchlist-item.active {
    background: var(--blue-light);
    border-color: rgba(24, 95, 165, 0.3);
}

.wi-left {
    flex: 1;
    min-width: 0;
}
.wi-symbol {
    font-weight: 700;
    font-size: 13px;
}
.wi-name {
    font-size: 11px;
    color: var(--text2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.wi-right {
    text-align: right;
    flex-shrink: 0;
}
.wi-price {
    font-family: "IBM Plex Mono", monospace;
    font-weight: 600;
    font-size: 13px;
}
.wi-change {
    font-size: 11px;
    font-weight: 500;
}
.wi-change.up {
    color: var(--green);
}
.wi-change.down {
    color: var(--red);
}

.wi-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    opacity: 0;
    background: none;
    border: none;
    color: var(--text2);
    font-size: 13px;
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: all 0.15s;
    line-height: 1;
}
.watchlist-item:hover .wi-remove {
    opacity: 1;
}
.wi-remove:hover {
    color: var(--red);
    background: var(--red-light);
}

/* Signal badge on watchlist item */
.wi-signal {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 99px;
    letter-spacing: 0.3px;
    margin-top: 3px;
    display: inline-block;
}
.wi-signal.buy,
.wi-signal.strong-buy {
    background: var(--green-light);
    color: var(--green);
}
.wi-signal.sell,
.wi-signal.strong-sell {
    background: var(--red-light);
    color: var(--red);
}
.wi-signal.hold {
    background: var(--amber-light);
    color: var(--amber);
}

/* ── Main Panel ──────────────────────────────────────────────── */
#main {
    grid-area: main;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
}

/* ── Main Area Tabs ─────────────────────────────────────────── */
.main-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    background: var(--surface);
    flex-shrink: 0;
}

.main-tab {
    padding: 12px 20px;
    border: none;
    background: none;
    color: var(--text2);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}

.main-tab:hover {
    color: var(--text);
}

.main-tab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

/* Main tab content areas */
#main-chart,
#main-scanner,
#main-performance,
#main-paper-trading {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Full-width scanner containers */
.scanner-full-container,
.performance-full-container,
.paper-trading-full-container {
    padding: 24px;
    overflow-y: auto;
    height: 100%;
}

/* Instrument header (STYLE.md §5.12 header style) */
#instrument-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.ih-symbol {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--text);
}
.ih-name {
    font-size: 12px;
    color: var(--text2);
    margin-top: 2px;
}

.ih-price {
    font-family: "IBM Plex Mono", monospace;
    font-size: 22px;
    font-weight: 600;
    color: var(--text);
}

.ih-change {
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 6px;
}
.ih-change.up {
    color: var(--green);
    background: var(--green-light);
}
.ih-change.down {
    color: var(--red);
    background: var(--red-light);
}

/* Interval selector */
.interval-selector {
    display: flex;
    gap: 4px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 3px;
}

.interval-btn {
    padding: 4px 12px;
    border: none;
    background: none;
    color: var(--text2);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}
.interval-btn:hover {
    color: var(--text);
    background: var(--surface);
}
.interval-btn.active {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 2px 8px rgba(24, 95, 165, 0.25);
}

/* Chart area */
#chart-container {
    flex: 1;
    min-height: 0;
    position: relative;
    overflow: hidden;
}

#chart {
    width: 100%;
    height: 100%;
}

.chart-loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    gap: 14px;
    z-index: 10;
}
.chart-loading.hidden {
    display: none;
}

.hidden {
    display: none !important;
}

/* Spinner (STYLE.md §6.1 slick-spinner) */
.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid rgba(24, 95, 165, 0.12);
    border-top: 3px solid var(--blue);
    border-radius: 50%;
    animation: spin 0.8s var(--ease-std) infinite;
}
@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Empty state */
#chart-empty {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: var(--text2);
}
#chart-empty.hidden {
    display: none;
}
.empty-icon-lg {
    font-size: 56px;
    opacity: 0.15;
}
.empty-text {
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}
.empty-hint {
    font-size: 12px;
    color: var(--text2);
    opacity: 0.6;
}

/* Indicator tabs */
#indicator-tabs {
    display: flex;
    gap: 4px;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
    background: var(--surface2);
    flex-shrink: 0;
    overflow-x: auto;
}

.ind-tab {
    padding: 5px 14px;
    border: 1px solid var(--border);
    border-radius: 99px;
    background: var(--surface);
    color: var(--text2);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s;
}
.ind-tab:hover {
    color: var(--text);
    border-color: #b0a99a;
}
.ind-tab.active {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue);
}

/* Sub chart */
#sub-chart-container {
    height: 150px;
    flex-shrink: 0;
    border-top: 1px solid var(--border);
    background: var(--bg);
}
#sub-chart {
    width: 100%;
    height: 100%;
}

/* ── Right Signals Panel ─────────────────────────────────────── */
#signals-panel {
    grid-area: signals;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-left: 1px solid var(--border);
    overflow: hidden;
}

.panel-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface2);
}

.panel-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text2);
}

/* Panel tabs (STYLE.md style) */
.panel-tabs {
    display: flex;
    padding: 0 12px;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    background: var(--surface);
}
.ptab {
    padding: 10px 12px;
    border: none;
    background: none;
    color: var(--text2);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.15s;
}
.ptab:hover {
    color: var(--text);
}
.ptab.active {
    color: var(--blue);
    border-bottom-color: var(--blue);
}

/* Panel content areas with scrolling */
#panel-signal,
#signal-history {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 12px;
}

/* ── Signal Card ─────────────────────────────────────────────── */
#current-signal-card {
    margin-bottom: 12px;
    border-radius: 10px;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    flex-shrink: 0;
    transition:
        border-color 0.3s,
        background 0.3s;
}
#current-signal-card.buy,
#current-signal-card.strong-buy {
    border-color: rgba(59, 109, 17, 0.35);
    background: rgba(59, 109, 17, 0.03);
}
#current-signal-card.sell,
#current-signal-card.strong-sell {
    border-color: rgba(163, 45, 45, 0.3);
    background: rgba(163, 45, 45, 0.03);
}
#current-signal-card.hold {
    border-color: rgba(186, 117, 23, 0.3);
    background: rgba(186, 117, 23, 0.03);
}

.signal-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.signal-action-badge {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: -0.3px;
    padding: 5px 14px;
    border-radius: 6px;
}
.signal-action-badge.buy,
.signal-action-badge.strong-buy {
    color: var(--green);
    background: var(--green-light);
}
.signal-action-badge.sell,
.signal-action-badge.strong-sell {
    color: var(--red);
    background: var(--red-light);
}
.signal-action-badge.hold {
    color: var(--amber);
    background: var(--amber-light);
}

/* Confidence bar */
.confidence-section {
    margin-bottom: 12px;
}
.confidence-label {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text2);
    margin-bottom: 5px;
}
.confidence-bar {
    height: 5px;
    background: var(--surface2);
    border-radius: 99px;
    overflow: hidden;
}
.confidence-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--blue);
    transition: width 0.8s var(--ease-spring);
}
.confidence-fill.sell-fill {
    background: var(--red);
}
.confidence-fill.hold-fill {
    background: var(--amber);
}

/* Scores */
.score-bars {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}
.score-label {
    font-size: 10px;
    color: var(--text2);
    margin-bottom: 2px;
}
.score-val {
    font-size: 20px;
    font-weight: 700;
    font-family: "IBM Plex Mono", monospace;
}
.score-val.bull {
    color: var(--green);
}
.score-val.bear {
    color: var(--red);
}

/* Reasons */
.reasons-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text2);
    margin-bottom: 8px;
}
.reason-item {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 6px 0;
    border-bottom: 1px solid var(--border);
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--text);
}
.reason-item:last-child {
    border-bottom: none;
}
.reason-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    margin-top: 5px;
    flex-shrink: 0;
}
.reason-dot.bullish {
    background: var(--green);
}
.reason-dot.bearish {
    background: var(--red);
}
.reason-dot.neutral {
    background: var(--amber);
}

/* ── Risk Params (STYLE.md metric-card style) ────────────────── */
#risk-params {
    margin-bottom: 12px;
    padding: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 10px;
    flex-shrink: 0;
}
.rp-title {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text2);
    margin-bottom: 10px;
}
.rp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}
.rp-label {
    font-size: 10px;
    color: var(--text2);
}
.rp-value {
    font-family: "IBM Plex Mono", monospace;
    font-size: 13px;
    font-weight: 600;
    margin-top: 1px;
}
.rp-value.stop {
    color: var(--red);
}
.rp-value.target {
    color: var(--green);
}

/* ── Indicator Cards Grid (STYLE.md §5.7 metric-card) ────────── */
#indicators-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding-bottom: 12px;
}

.ind-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
.ind-card:hover {
    border-color: #b0a99a;
    box-shadow: var(--shadow-sm);
}

.ind-card-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text2);
    margin-bottom: 5px;
}
.ind-card-value {
    font-family: "IBM Plex Mono", monospace;
    font-size: 15px;
    font-weight: 700;
}
.ind-card-sub {
    font-size: 10px;
    color: var(--text2);
    margin-top: 3px;
}

/* RSI gradient bar */
.rsi-bar {
    height: 4px;
    background: linear-gradient(
        90deg,
        var(--green) 0%,
        var(--amber) 50%,
        var(--red) 100%
    );
    border-radius: 99px;
    margin-top: 7px;
    position: relative;
}
.rsi-pointer {
    position: absolute;
    top: -3px;
    width: 10px;
    height: 10px;
    background: var(--text);
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
    transition: left 0.5s;
}

/* ── Signal History ──────────────────────────────────────────── */
#signal-history {
    padding: 0 12px 12px;
    overflow-y: auto;
    flex: 1;
    display: none;
}
#signal-history.visible {
    display: block;
}

.sh-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
}
.sh-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 4px;
    flex-shrink: 0;
}
.sh-badge.buy {
    background: var(--green-light);
    color: var(--green);
}
.sh-badge.sell {
    background: var(--red-light);
    color: var(--red);
}
.sh-badge.hold {
    background: var(--amber-light);
    color: var(--amber);
}
.sh-symbol {
    font-weight: 600;
    flex-shrink: 0;
}
.sh-time {
    color: var(--text2);
    font-size: 10px;
    margin-left: auto;
}

/* ── Auth Overlay (STYLE.md §7.1 login card style) ───────────── */
#auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(26, 26, 24, 0.5);
    backdrop-filter: blur(4px);
    z-index: 500;
    display: none;
    align-items: center;
    justify-content: center;
}
#auth-overlay.visible {
    display: flex;
}

.auth-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 40px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: var(--shadow-lg);
    animation: popIn 0.3s var(--ease-spring);
}
@keyframes popIn {
    from {
        transform: scale(0.92);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.auth-modal-icon {
    font-size: 48px;
    margin-bottom: 16px;
}
.auth-modal h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}
.auth-modal p {
    color: var(--text2);
    font-size: 14px;
    margin-bottom: 24px;
    line-height: 1.6;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(24, 95, 165, 0.3);
    transition: all 0.2s;
    text-decoration: none;
}
.btn-primary:hover {
    background: var(--blue-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: transparent;
    color: var(--text2);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    margin-left: 8px;
    transition: all 0.2s;
}
.btn-secondary:hover {
    color: var(--text);
    border-color: #b0a99a;
    background: var(--surface2);
}

/* ── Toast notifications (STYLE.md §5.11 error-box style) ───── */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 11px 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    box-shadow: var(--shadow-md);
    animation:
        slideIn 0.3s var(--ease-spring),
        fadeOut 0.3s ease 2.7s forwards;
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 10px;
}
.toast.success {
    border-color: rgba(59, 109, 17, 0.35);
}
.toast.error {
    border-color: rgba(163, 45, 45, 0.35);
}
.toast.info {
    border-color: rgba(24, 95, 165, 0.3);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}
@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
        transform: translateX(20px);
    }
}

/* ── slideUpFade entrance (STYLE.md §6.1) ────────────────────── */
@keyframes slideUpFade {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Price tick animations ───────────────────────────────────── */
@keyframes priceUp {
    0%,
    100% {
        color: var(--text);
    }
    40% {
        color: var(--green);
    }
}
@keyframes priceDown {
    0%,
    100% {
        color: var(--text);
    }
    40% {
        color: var(--red);
    }
}
.price-up {
    animation: priceUp 0.5s ease;
}
.price-down {
    animation: priceDown 0.5s ease;
}

/* ── Scanner & Paper Trading Styles ─────────────────────────── */
.scanner-controls {
    display: flex;
    align-items: center;
    gap: 24px;
    margin-bottom: 16px;
}

.scanner-profile-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.scanner-options {
    display: flex;
    gap: 16px;
    flex: 1;
}

.scanner-option {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 120px;
}

.scan-info-bar {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 12px 16px;
    background: var(--surface2);
    border-radius: 8px;
    margin-bottom: 16px;
}

.scan-stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.range-slider {
    width: 100%;
    cursor: pointer;
}

.select-input,
.input-number {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.select-input:focus,
.input-number:focus {
    border-color: var(--blue);
}

.scan-result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.scan-result-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--blue);
}

.scan-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.scan-symbol {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.scan-name {
    margin-top: 2px;
}

.scan-signal {
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.signal-strong-buy {
    background: var(--green-light);
    color: var(--green);
    border: 1px solid rgba(59, 109, 17, 0.25);
}

.signal-buy {
    background: var(--green-light);
    color: var(--green);
    border: 1px solid rgba(59, 109, 17, 0.15);
}

.signal-strong-sell {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid rgba(163, 45, 45, 0.25);
}

.signal-sell {
    background: var(--red-light);
    color: var(--red);
    border: 1px solid rgba(163, 45, 45, 0.15);
}

.signal-hold {
    background: var(--surface2);
    color: var(--text2);
    border: 1px solid var(--border);
}

.scan-score {
    text-align: right;
}

.scan-score .mono {
    font-size: 20px;
    font-weight: 700;
}

.scan-timeframes {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.scan-tf-badge {
    display: flex;
    gap: 4px;
    padding: 4px 8px;
    background: var(--surface2);
    border-radius: 4px;
    font-size: 11px;
}

.scan-tf-interval {
    color: var(--text2);
    font-weight: 600;
}

.scan-tf-signal {
    font-weight: 700;
}

.scan-result-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--surface2);
    border-radius: 8px;
}

.scan-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.scan-detail-label {
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.scan-detail-value {
    font-size: 14px;
    font-weight: 600;
}

.scan-risk-params {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--amber-light);
    border-radius: 8px;
    border: 1px solid rgba(186, 117, 23, 0.2);
}

.scan-risk-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.scan-risk-label {
    font-size: 11px;
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.scan-risk-value {
    font-size: 13px;
    font-weight: 600;
}

.scan-actions {
    display: flex;
    gap: 8px;
}

/* Paper Trading Styles */
.pt-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 16px;
    padding: 16px;
    background: var(--surface2);
    border-radius: 12px;
}

.pt-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pt-label {
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pt-value {
    font-size: 18px;
    font-weight: 700;
}

.pt-summary-large {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
    padding: 24px;
    background: var(--surface2);
    border-radius: 16px;
}

.pt-summary-item-large {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pt-label-large {
    font-size: 12px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
}

.pt-value-large {
    font-size: 24px;
    font-weight: 700;
}

.pt-actions-large {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.pt-summary-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pt-label {
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pt-value {
    font-size: 18px;
    font-weight: 700;
}

.pt-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

.pt-position-card,
.pt-trade-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    margin-bottom: 10px;
}

.pt-position-header,
.pt-trade-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.pt-position-symbol,
.pt-trade-symbol {
    font-size: 14px;
    font-weight: 600;
}

.pt-position-pnl,
.pt-trade-pnl {
    text-align: right;
}

.pt-position-actions {
    display: flex;
    gap: 8px;
}

.pt-trade-details {
    display: flex;
    gap: 16px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

/* ── Button Styles for Scanner/Paper Trading ─────────────────── */
.btn-primary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(24, 95, 165, 0.3);
    transition: all 0.2s;
}

.btn-primary:hover {
    background: var(--blue-hover);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: scale(0.98);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--surface2);
    border-color: var(--blue);
}

/* Input styles for scanner */
.select-input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    background: var(--surface);
    color: var(--text);
    outline: none;
}

.select-input:focus {
    border-color: var(--blue);
}

.range-slider {
    width: 100%;
    cursor: pointer;
}

/* ── Performance Scanner Styles ───────────────────────────── */
.perf-result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    transition: all 0.2s;
}

.perf-result-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--blue);
}

.perf-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.perf-symbol {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.perf-name {
    margin-top: 2px;
}

.perf-gain {
    text-align: right;
}

.perf-gain .mono {
    font-size: 18px;
    font-weight: 700;
}

.perf-result-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    background: var(--surface2);
    border-radius: 8px;
}

.perf-detail-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.perf-detail-label {
    font-size: 11px;
    color: var(--text2);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.perf-detail-value {
    font-size: 13px;
    font-weight: 600;
}

.perf-ad-analysis {
    margin-bottom: 16px;
    padding: 12px;
    background: var(--blue-light);
    border-radius: 8px;
    border: 1px solid rgba(24, 95, 165, 0.2);
}

.perf-ad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.perf-ad-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--blue);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.perf-ad-trend {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 4px;
    background: var(--surface);
}

.perf-ad-details {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.perf-ad-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.perf-ad-label {
    font-size: 10px;
    color: var(--text2);
    text-transform: uppercase;
}

.perf-ad-value {
    font-size: 12px;
    font-weight: 600;
}

.perf-actions {
    display: flex;
    gap: 8px;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
    #app {
        grid-template-columns: 270px 1fr 290px;
    }
}

@media (max-width: 900px) {
    #app {
        grid-template-rows: 58px 56px 1fr 240px;
        grid-template-columns: 1fr;
        grid-template-areas:
            "header"
            "sidebar"
            "main"
            "signals";
    }
    #sidebar {
        border-right: none;
        border-bottom: 1px solid var(--border);
        flex-direction: row;
        overflow-x: auto;
        overflow-y: hidden;
    }
    #signals-panel {
        border-left: none;
        border-top: 1px solid var(--border);
    }
}
