/*
 * Over/Under Dashboard — Design System
 * Production stylesheet derived from mockup/revised-dashboard.html
 * See DESIGN.md for full design documentation.
 */

/* ============================================================
 * DESIGN TOKENS
 * ============================================================ */
:root {
    /* Semantic — data status */
    --positive: #059212;
    --negative: #e01b24;
    --neutral: #4b5563;
    --accent: #1d4ed8;

    /* Surface */
    --surface: #ffffff;
    --surface-secondary: #f8fafc;
    --border: #d1d5db;
    --border-light: #e5e7eb;

    /* Text */
    --text-primary: #111827;
    --text-secondary: #374151;
    --text-muted: #6b7280;

    --radius: 10px;
}

/* ============================================================
 * RESET / BASE
 * ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--surface-secondary);
    color: var(--text-primary);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============================================================
 * NAVIGATION (top fixed bar)
 * ============================================================ */
.nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 60px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 32px;
    gap: 32px;
}

.nav-brand {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--text-primary);
    text-decoration: none;
    letter-spacing: -0.02em;
}
.nav-brand:hover { text-decoration: none; color: var(--text-primary); }

.nav-links {
    display: flex;
    gap: 4px;
    list-style: none;
}

.nav-links a {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 14px;
    border-radius: 6px;
    transition: color 0.15s, background 0.15s;
    display: inline-block;
}

.nav-links a:hover { color: var(--text-primary); text-decoration: none; }
.nav-links a.active { color: var(--text-primary); background: var(--surface-secondary); }

.nav-right {
    margin-left: auto;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.nav-right a {
    color: var(--text-secondary);
    text-decoration: none;
}
.nav-right a:hover { color: var(--text-primary); text-decoration: none; }

.nav-signout {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.nav-signout:hover { border-color: var(--negative); color: var(--negative); }

/* Hamburger toggle, hidden on desktop */
.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 1.15rem;
    line-height: 1;
    color: var(--text-secondary);
    cursor: pointer;
    font-family: inherit;
    margin-left: auto;
}
.nav-toggle:hover { color: var(--text-primary); border-color: var(--accent); }

/* ============================================================
 * LAYOUT
 * ============================================================ */
.dashboard {
    max-width: 1440px;
    margin: 0 auto;
    padding: 88px 32px 60px;
}

.page-header {
    margin-bottom: 28px;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
}

.page-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.timestamp {
    font-size: 0.95rem;
    color: var(--text-muted);
}

/* ============================================================
 * SEARCH (dual input + select)
 * ============================================================ */
.search {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    margin-bottom: 24px;
}

.search input,
.search select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
    min-height: 48px;
}

.search input {
    flex: 1 1 320px;
    max-width: 420px;
}

.search select {
    flex: 0 1 280px;
    cursor: pointer;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%236b7280' d='M6 8L0 0h12z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
    appearance: none;
    -webkit-appearance: none;
}

.search input:focus,
.search select:focus { border-color: var(--accent); }
.search input::placeholder { color: var(--text-muted); }

.search-or {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Suggestions dropdown attached to the symbol search input.
 * Every property is !important to defeat Bootstrap's .btn cascade and
 * browser default <button> user-agent styling (which adds grey background,
 * border, padding, inline-block display, etc.). */
.symbol-suggestions {
    position: absolute !important;
    top: calc(100% + 4px) !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1000 !important;
    width: 100% !important;
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12) !important;
    max-height: 360px !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 4px 0 !important;
    list-style: none !important;
}
.symbol-suggestions[hidden] { display: none !important; }

.symbol-suggestions .symbol-suggestion-item,
.symbol-suggestions button.symbol-suggestion-item {
    display: flex !important;
    align-items: center !important;
    gap: 12px !important;
    width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    padding: 10px 16px !important;
    margin: 0 !important;
    background: var(--surface) !important;
    background-color: var(--surface) !important;
    background-image: none !important;
    border: none !important;
    border-top: none !important;
    border-left: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border-light) !important;
    border-radius: 0 !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif !important;
    font-size: 0.95rem !important;
    font-weight: 400 !important;
    line-height: 1.3 !important;
    color: var(--text-primary) !important;
    cursor: pointer !important;
    text-align: left !important;
    text-decoration: none !important;
    transition: background-color 0.1s !important;
    box-shadow: none !important;
    outline: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    text-transform: none !important;
    letter-spacing: normal !important;
}
.symbol-suggestions .symbol-suggestion-item:last-child {
    border-bottom: none !important;
}
.symbol-suggestions .symbol-suggestion-item:hover,
.symbol-suggestions .symbol-suggestion-item.active,
.symbol-suggestions .symbol-suggestion-item:focus,
.symbol-suggestions .symbol-suggestion-item:focus-visible {
    background: var(--surface-secondary) !important;
    background-color: var(--surface-secondary) !important;
    color: var(--text-primary) !important;
    text-decoration: none !important;
    outline: none !important;
    box-shadow: none !important;
}

.symbol-suggestions .symbol-suggestion-item .sym {
    font-family: 'JetBrains Mono', monospace !important;
    font-weight: 700 !important;
    color: var(--text-primary) !important;
    flex: 0 0 72px !important;
    width: 72px !important;
    min-width: 72px !important;
    text-align: left !important;
}

.symbol-suggestions .symbol-suggestion-item .co {
    color: var(--text-secondary) !important;
    font-size: 0.92rem !important;
    flex: 1 1 auto !important;
    min-width: 0 !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    white-space: nowrap !important;
}

.symbol-suggestions .symbol-suggestion-empty {
    padding: 14px !important;
    color: var(--text-muted) !important;
    font-size: 0.95rem !important;
    text-align: center !important;
}

.symbol-suggestions mark {
    background: #fef3c7 !important;
    color: inherit !important;
    padding: 0 !important;
    font-weight: inherit !important;
}

/* Make sure the search wrap is the positioning context for the absolute dropdown,
 * AND that the dropdown does not affect parent flex sizing (overlay only). */
.search-input-wrap {
    position: relative !important;
}

/* ============================================================
 * RECENTS (ticker chips)
 * ============================================================ */
.recents {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 28px;
    font-size: 0.95rem;
    color: var(--text-muted);
    flex-wrap: wrap;
}

.recents a {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    transition: all 0.15s;
}

.recents a:hover { border-color: var(--accent); color: var(--accent); text-decoration: none; }

/* ============================================================
 * SEMANTIC UP/DOWN
 * ============================================================ */
.up, .table td.up { color: var(--positive); }
.down, .table td.down { color: var(--negative); }

/* ============================================================
 * KPI ROW
 * ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
}

.kpi-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 6px;
}

.kpi-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
}

.kpi-delta {
    font-size: 0.95rem;
    font-weight: 600;
    margin-top: 6px;
}

/* ============================================================
 * GRIDS
 * ============================================================ */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

/* ============================================================
 * CARD / MODULE
 * ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: none;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
}

.card-header-left {
    display: flex;
    align-items: center;
    min-width: 0;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-action {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.15s;
}

.card-action:hover { color: var(--accent); background: var(--surface-secondary); text-decoration: none; }

.card-body { padding: 16px 20px; }
.card-body.flush { padding: 0; }

.card-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border-light);
    font-size: 0.9rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Collapsible cards */
.card-toggle {
    background: none;
    border: none;
    padding: 0;
    margin-right: 12px;
    color: var(--text-secondary);
    font-size: 1.1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    transition: transform 0.2s ease, color 0.15s, background 0.15s;
    font-family: inherit;
    line-height: 1;
    flex-shrink: 0;
}
.card-toggle:hover { color: var(--text-primary); background: var(--surface-secondary); }
.card.collapsed .card-toggle { transform: rotate(-90deg); }
.card.collapsed .card-header { border-bottom: none; }
.card.collapsed > *:not(.card-header) { display: none; }

/* ============================================================
 * TABLE
 * ============================================================ */
.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 12px 14px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    background: var(--surface);
    white-space: nowrap;
}

.table td {
    padding: 14px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-secondary);
    vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--surface-secondary); }

/* Sticky header — opt-in via .table-scroll wrapper. Adds vertical scroll +
 * pins the thead row to the top of the wrapper's scroll area.
 *
 * CRITICAL: tables inside .table-scroll must use border-collapse: separate.
 * Chrome and Safari have a long-standing bug where `position: sticky` on
 * `thead th` is silently ignored when the table uses `border-collapse: collapse`.
 * Switching to `separate` + manual cell borders restores sticky behavior. */
.table-scroll {
    max-height: 540px;
    overflow-y: auto;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
}

.table-scroll .table {
    border-collapse: separate !important;
    border-spacing: 0;
}

.table-scroll .table thead th {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--surface);
    /* border-collapse: separate doesn't share borders between cells, so the
     * thead's bottom border has to live on the th itself. The inset shadow
     * keeps it pinned above scrolling rows that scroll up behind it. */
    border-bottom: 2px solid var(--border);
    box-shadow: 0 2px 0 var(--border);
}

/* td borders need explicit re-styling under border-collapse: separate */
.table-scroll .table td {
    border-bottom: 1px solid var(--border-light);
}
.table-scroll .table tr:last-child td {
    border-bottom: none;
}

/* Load-more row inside paginated tables */
.table .load-more-row td {
    text-align: center;
    padding: 16px;
    background: var(--surface);
    border-top: 1px solid var(--border-light);
}
.load-more-btn {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 18px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.load-more-btn:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--surface-secondary);
}

.mono {
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
}

.bold { font-weight: 700; color: var(--text-primary); }

/* Clickable rows */
.table tr.clickable { cursor: pointer; }
.table tr.clickable td { transition: background 0.1s; }
.table tr.selected td { background: #eff6ff; }
.table tr.selected:hover td { background: #dbeafe; }

/* ============================================================
 * BADGES
 * ============================================================ */
.badge {
    display: inline-block;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 5px;
    line-height: 1.3;
}

.badge-true { background: #d4edda; color: #046b0e; }
.badge-false { background: #f8d7da; color: #c41424; }
.badge-flip { background: #e8ddfc; color: #6d28d9; }
.badge-bull { background: #d4edda; color: #046b0e; }
.badge-bear { background: #f8d7da; color: #c41424; }
.badge-strong { background: #d0e4fc; color: #1a56db; }
.badge-moderate { background: #fde68a; color: #b45309; }
.badge-weak { background: #e5e7eb; color: #4b5563; }
.badge-doji { background: #fef3c7; color: #92400e; }
.badge-harami-bull { background: #fce7f3; color: #9d174d; }
.badge-harami-bear { background: #fce7f3; color: #9d174d; }

/* ============================================================
 * SIGNAL FEED (legacy, kept for any remaining usage)
 * ============================================================ */
.signal-list { list-style: none; }
.signal-item {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    gap: 14px;
    border-bottom: 1px solid var(--border-light);
}
.signal-item:last-child { border-bottom: none; }
.signal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.signal-dot.flip { background: #6d28d9; }
.signal-dot.bull { background: var(--positive); }
.signal-dot.bear { background: var(--negative); }
.signal-dot.pattern { background: #db2777; }
.signal-text { flex: 1; font-size: 1rem; color: var(--text-secondary); }
.signal-text strong { font-family: 'JetBrains Mono', monospace; font-weight: 700; color: var(--text-primary); }
.signal-price { font-family: 'JetBrains Mono', monospace; font-size: 1rem; font-weight: 600; color: var(--text-primary); }

/* ============================================================
 * CHART AREA + AXES + LOADER
 * ============================================================ */
.chart-area {
    position: relative;
    margin: 0;
    padding: 0;
}

.chart-area svg {
    width: 100%;
    height: auto;
    display: block;
}

.chart-area .axis-label {
    font-size: 11px;
    fill: var(--text-muted);
    font-family: 'Inter', sans-serif;
}

.chart-area .axis-tick {
    stroke: #e5e7eb;
    stroke-width: 0.5;
}

.chart-pane { display: none; }
.chart-pane.active { display: block; }

.chart-body {
    position: relative;
    min-height: 220px;
}

.chart-loader {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.9);
    z-index: 2;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    pointer-events: none;
}
.chart-loader.active { display: flex; }
.chart-loader::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: chart-spin 0.8s linear infinite;
}
@keyframes chart-spin { to { transform: rotate(360deg); } }

/* Generic Chart.js container support (existing dashboards) */
.chart-canvas-container {
    position: relative;
    height: 320px;
    width: 100%;
}

/* ============================================================
 * TABS (used by filter matches AND chart type)
 * ============================================================ */
.tab-strip {
    display: flex;
    gap: 4px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    scrollbar-width: thin;
}

.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    padding: 14px 16px;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

.tab-count {
    display: inline-block;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--surface-secondary);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    min-width: 22px;
    text-align: center;
}
.tab.active .tab-count { background: #dbeafe; color: var(--accent); }

/* Empty state for history/charts */
.history-empty {
    padding: 48px 20px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.history-empty strong {
    display: block;
    font-size: 1.05rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

/* ============================================================
 * PREDICTION CARD
 * ============================================================ */
.prediction {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
}

.prediction-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-muted);
}

.prediction-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 1.5rem;
    font-weight: 700;
}

.prediction-conf {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.prediction-divider {
    width: 1px;
    height: 48px;
    background: var(--border);
}

/* ============================================================
 * NAV CARDS
 * ============================================================ */
.nav-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 28px;
}

.nav-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    text-decoration: none;
    transition: border-color 0.15s;
    display: block;
}
.nav-card:hover { border-color: var(--accent); text-decoration: none; }

.nav-card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.nav-card-desc {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.nav-card-stat {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-light);
}

/* ============================================================
 * FILTER PILLS & BUTTONS
 * ============================================================ */
.filter-pills {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.pill {
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    padding: 10px 18px;
    border-radius: 24px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
}
.pill:hover { border-color: var(--accent); color: var(--accent); }
.pill.active { border-color: var(--accent); color: var(--accent); }

/* ============================================================
 * INLINE CONTROLS (option select, remove, watchlist add)
 * ============================================================ */
.option-select {
    font-family: inherit;
    font-size: 0.9rem;
    padding: 6px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    outline: none;
    cursor: pointer;
}
.option-select:focus { border-color: var(--accent); }

.remove-btn {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 1.1rem;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1;
}
.remove-btn:hover { border-color: var(--negative); color: var(--negative); }

.watchlist-add {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 1rem;
    font-weight: 600;
    width: 32px;
    height: 32px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    font-family: inherit;
    line-height: 1;
}
.watchlist-add:hover { border-color: var(--positive); color: var(--positive); background: #f0fdf4; }
.watchlist-add.in-list {
    border-color: var(--positive);
    color: var(--positive);
    background: #f0fdf4;
    cursor: default;
}

.watchlist-add-header {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.watchlist-add-header:hover { border-color: var(--positive); color: var(--positive); background: #f0fdf4; }
.watchlist-add-header:disabled { opacity: 1; cursor: default; }

/* ============================================================
 * FORM CONTROLS (login, register, profile)
 * ============================================================ */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 40px;
    max-width: 460px;
    width: 100%;
}

.form-card .form-header {
    text-align: center;
    margin-bottom: 28px;
}

.form-card .form-header h1 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: -0.02em;
}

.form-card .form-header p {
    font-size: 0.95rem;
    color: var(--text-muted);
}

.form-group {
    margin-bottom: 18px;
}

.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.15s;
    min-height: 48px;
}
.form-control:focus { border-color: var(--accent); }
.form-control::placeholder { color: var(--text-muted); }

.form-help {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

.btn-primary,
.btn-submit {
    width: 100%;
    background: var(--accent);
    color: var(--surface);
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--accent);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-primary:hover,
.btn-submit:hover { background: #1e40af; border-color: #1e40af; color: var(--surface); text-decoration: none; }

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
    background: var(--surface);
    color: var(--negative);
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.btn-danger:hover { border-color: var(--negative); background: #fef2f2; }

/* Auth page shell (centered card on light surface) */
.auth-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    background: var(--surface-secondary);
}

/* ============================================================
 * ALERTS
 * ============================================================ */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    border: 1px solid transparent;
    font-size: 0.95rem;
}
.alert-error,
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* Session-expired banner */
.session-expired-banner {
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    z-index: 99;
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
    color: #92400e;
    padding: 10px 32px;
    font-size: 0.95rem;
    display: none;
    align-items: center;
    gap: 12px;
}
.session-expired-banner.visible { display: flex; }
.session-expired-banner a { color: #92400e; font-weight: 600; text-decoration: underline; }
.session-expired-banner .close {
    margin-left: auto;
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #92400e;
}

/* ============================================================
 * RESPONSIVE
 * ============================================================ */
@media (max-width: 1024px) {
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
    .nav-cards { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    /* Layout */
    .dashboard { padding: 76px 16px 40px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .nav-cards { grid-template-columns: 1fr; }

    /* Nav — hamburger dropdown */
    .nav { padding: 0 16px; gap: 12px; }
    .nav-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .nav-right { font-size: 0.9rem; margin-left: 0; }
    .nav-links {
        display: none;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        flex-direction: column;
        align-items: stretch;
        padding: 8px 12px;
        gap: 2px;
        z-index: 99;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    }
    .nav-links.open { display: flex; }
    .nav-links li { width: 100%; }
    .nav-links a { display: block; padding: 14px 16px; font-size: 1rem; }

    /* Page header */
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
        margin-bottom: 20px;
    }
    .page-title { font-size: 1.4rem; }
    .timestamp { font-size: 0.88rem; }

    /* Search */
    .search { margin-bottom: 16px; }
    .search input { max-width: 100%; }

    /* Recents */
    .recents { flex-wrap: wrap; margin-bottom: 20px; }

    /* Cards */
    .card-header { padding: 14px 16px; }
    .card-body { padding: 14px 16px; }
    .card-footer {
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 4px 12px;
        font-size: 0.85rem;
    }
    .card-title { font-size: 1rem; }

    /* Tap targets ≥ 36px */
    .card-toggle { width: 36px; height: 36px; font-size: 1.2rem; margin-right: 8px; }
    .card-action { padding: 8px 12px; min-height: 36px; }
    .remove-btn { width: 36px; height: 36px; }
    .pill { padding: 10px 16px; }
    .option-select { padding: 8px 10px; font-size: 0.95rem; min-height: 36px; }

    /* Tables */
    .card-body.flush { -webkit-overflow-scrolling: touch; }
    .table { font-size: 0.9rem; }
    .table th { padding: 10px 12px; font-size: 0.75rem; }
    .table td { padding: 12px; }

    /* Tab strip */
    .tab-strip { padding: 0 12px; -webkit-overflow-scrolling: touch; }
    .tab { padding: 12px 14px; font-size: 0.9rem; gap: 6px; }
    .tab-count { font-size: 0.72rem; padding: 2px 7px; }

    /* KPI */
    .kpi { padding: 16px 18px; }
    .kpi-value { font-size: 1.8rem; }
    .kpi-label { font-size: 0.82rem; }

    /* Predictions */
    .prediction { padding: 18px 20px; }
    .prediction-value { font-size: 1.4rem; }

    /* Session-expired banner */
    .session-expired-banner { padding: 10px 16px; font-size: 0.88rem; }
}

@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .page-title { font-size: 1.25rem; }
    .kpi-value { font-size: 1.7rem; }
    .table { font-size: 0.88rem; }
    .table th { font-size: 0.7rem; padding: 8px 10px; }
    .table td { padding: 10px; }
    .nav-brand { font-size: 1.05rem; }
    .recents { font-size: 0.85rem; }
    .recents a { padding: 5px 10px; font-size: 0.85rem; }
}

/* ============================================================
 * BOOTSTRAP COMPATIBILITY OVERRIDES
 * Bootstrap 5 is loaded for legacy layout utilities (grid, spacing,
 * flexbox helpers). These overrides retune the visual classes to
 * match the Over/Under design language.
 * ============================================================ */

/* Buttons — make Bootstrap .btn-primary use the accent token */
.btn-primary,
.btn.btn-primary {
    background-color: var(--accent);
    border-color: var(--accent);
}
.btn-primary:hover,
.btn.btn-primary:hover {
    background-color: #1e40af;
    border-color: #1e40af;
}

.btn-success { background-color: var(--positive); border-color: var(--positive); }
.btn-success:hover { background-color: #047a0e; border-color: #047a0e; }

.btn-danger { background-color: var(--negative); border-color: var(--negative); color: #fff; }
.btn-danger:hover { background-color: #b91c1c; border-color: #b91c1c; color: #fff; }

.btn-outline-primary { color: var(--accent); border-color: var(--accent); }
.btn-outline-primary:hover { background-color: var(--accent); border-color: var(--accent); }

/* Bootstrap card-header dark variants — neutralise the purple/gradient look */
.card-header.bg-primary,
.card-header.bg-dark {
    background: var(--surface) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-light);
}
.card-header.bg-primary h1,
.card-header.bg-primary h2,
.card-header.bg-primary h3,
.card-header.bg-primary h4,
.card-header.bg-primary h5,
.card-header.bg-primary h6,
.card-header.bg-dark h1,
.card-header.bg-dark h2,
.card-header.bg-dark h3,
.card-header.bg-dark h4,
.card-header.bg-dark h5,
.card-header.bg-dark h6 {
    color: var(--text-primary);
}

/* Bootstrap table-dark thead — make it light/neutral */
.table-dark,
.table .table-dark,
.table > thead.table-dark {
    background-color: var(--surface) !important;
    color: var(--text-muted) !important;
}
.table-dark > tr > th,
.table > thead.table-dark > tr > th {
    background-color: var(--surface);
    color: var(--text-muted);
    border-bottom: 2px solid var(--border);
}

/* Bootstrap text-color utilities mapped to design tokens for consistency */
.text-success { color: var(--positive) !important; }
.text-danger { color: var(--negative) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-primary { color: var(--accent) !important; }

/* Bootstrap badge backgrounds → design tokens */
.badge.bg-success { background-color: #d4edda !important; color: #046b0e !important; }
.badge.bg-danger { background-color: #f8d7da !important; color: #c41424 !important; }
.badge.bg-warning { background-color: #fde68a !important; color: #b45309 !important; }
.badge.bg-info { background-color: #d0e4fc !important; color: #1a56db !important; }
.badge.bg-primary { background-color: #d0e4fc !important; color: #1a56db !important; }
.badge.bg-secondary { background-color: #e5e7eb !important; color: #4b5563 !important; }

/* Bootstrap alert colors → design tokens */
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* Bootstrap container width parity with our dashboard wrapper */
.dashboard .container,
.dashboard .container-fluid { padding-left: 0; padding-right: 0; }

/* Form controls inside legacy dashboards inherit our look-and-feel */
.dashboard .form-control { min-height: 44px; }
.dashboard .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(29, 78, 216, 0.1);
}

/* Spinner color */
.spinner-border.text-primary { color: var(--accent) !important; }

