:root {
    --bg: #f5f5f8;
    --bg-gradient: linear-gradient(135deg, #f5f5f8 0%, #eeeef2 100%);
    --surface: #ffffff;
    --surface-2: #f8f8fb;
    --surface-hover: #f0f0f5;
    --border: #e0e0e8;
    --border-light: #d0d0da;
    --text: #1d1d44;
    --text-secondary: #4a4a6a;
    --text-muted: #8e8ea0;
    --primary: #0ea5e9;
    --primary-light: #38bdf8;
    --primary-glow: rgba(14, 165, 233, 0.1);
    --primary-gradient: linear-gradient(135deg, #0ea5e9, #38bdf8);
    --positive: #00ab44;
    --positive-bg: rgba(0, 171, 68, 0.08);
    --negative: #d0021b;
    --negative-bg: rgba(208, 2, 27, 0.08);
    --overbought: #e67e00;
    --overbought-bg: rgba(230, 126, 0, 0.08);
    --oversold: #0066cc;
    --oversold-bg: rgba(0, 102, 204, 0.08);
    --buy: #00ab44;
    --hold: #e67e00;
    --sell: #d0021b;
    --danger: #d0021b;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 1px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.12);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* ── Navbar ── */
.navbar {
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-inner {
    max-width: 1440px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
}

.brand-logo {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    object-fit: contain;
}

.brand-text {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.nav-links { display: flex; gap: 0.25rem; }

.nav-link {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s;
}

.nav-link:hover { color: var(--text); background: var(--surface-hover); }
.nav-link.active { color: var(--primary-light); background: var(--primary-glow); }

.nav-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-username {
    font-size: 0.825rem;
    font-weight: 500;
    color: var(--text-secondary);
}

/* ── More Dropdown ── */
.nav-more {
    position: relative;
}

.nav-more-btn {
    cursor: pointer;
    background: none;
    border: none;
}

.nav-more-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 200;
    padding: 0.35rem 0;
    margin-top: 0.25rem;
}

.nav-more.open .nav-more-dropdown { display: block; }

.nav-more-item {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.1s;
}

.nav-more-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-more-item.active { color: var(--primary); }

/* ── Theme Toggle ── */
.theme-toggle {
    font-size: 1.1rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
}

/* ── Search ── */
.nav-search {
    flex: 0 1 320px;
}

.search-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.875rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.825rem;
    transition: all 0.2s;
}

.search-input::placeholder { color: var(--text-muted); }

.search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
    background: var(--surface);
}

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 200;
}

.search-results.visible { display: block; }

.search-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.search-item:last-child { border-bottom: none; }
.search-item:hover { background: var(--surface-hover); }

.search-ticker {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--primary-light);
    min-width: 55px;
}

.search-name {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-price {
    font-size: 0.825rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.search-fetch {
    background: var(--primary-glow);
    border-bottom: none !important;
}

.search-fetch:hover { background: rgba(14, 165, 233, 0.15); }

.search-action {
    font-size: 0.8rem;
    color: var(--primary-light);
    font-weight: 500;
}

.mobile-topbar { display: none; }
.mobile-bottomnav { display: none; }

/* ── Layout ── */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 2rem;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    box-shadow: 0 2px 12px rgba(14, 165, 233, 0.3);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 4px 20px rgba(14, 165, 233, 0.4); }

.btn-secondary {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-light); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }

.btn-small { padding: 0.375rem 0.75rem; font-size: 0.8rem; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 0.375rem 0.75rem;
}
.btn-ghost:hover { color: var(--text); background: var(--surface-hover); }

/* ── Cards ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.card:hover { border-color: var(--border-light); }

.card-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

/* ── Page Headers ── */
.page-header {
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: linear-gradient(135deg, var(--text) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.page-header p {
    color: var(--text-muted);
    margin-top: 0.25rem;
    font-size: 0.9rem;
}

/* ── Dashboard ── */
.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
    align-items: start;
}

.dashboard-main { min-width: 0; }

.dashboard-sidebar {
    position: sticky;
    top: 80px;
}

.sidebar-news {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.sidebar-news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.875rem 1rem;
    border-bottom: 1px solid var(--border);
    background: var(--surface-2);
}

.sidebar-news-header h3 {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0;
}

.sidebar-news-header span {
    font-size: 0.65rem;
    color: var(--text-muted);
}

.sidebar-news-list {
    max-height: 600px;
    overflow-y: auto;
}

.sidebar-news-item {
    display: block;
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    transition: background 0.15s;
}

.sidebar-news-item:last-child { border-bottom: none; }
.sidebar-news-item:hover { background: var(--surface-hover); }

.sidebar-news-title {
    display: block;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sidebar-news-meta {
    display: block;
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
}

/* ── Index Performance Cards ── */
.index-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
    margin-bottom: 2rem;
}

.index-card {
    background: #111827;
    border: 1px solid #1e2a3a;
    border-radius: 10px;
    overflow: hidden;
    min-width: 0;
}

.index-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 0.4rem 0.55rem 0.25rem;
}

.index-card-left {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: 0;
}

.index-card-name {
    font-size: 0.65rem;
    font-weight: 800;
    color: #e2e8f0;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.index-card-meta {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    flex-wrap: nowrap;
}

.index-card-date {
    font-size: 0.58rem;
    color: #475569;
    white-space: nowrap;
}

.index-card-chg {
    font-size: 0.62rem;
    font-weight: 700;
    white-space: nowrap;
}

.index-card-price {
    font-size: 0.75rem;
    font-weight: 700;
    color: #e2e8f0;
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
    flex-shrink: 0;
    padding-left: 0.3rem;
}

.index-card-chart {
    height: 88px;
    padding: 0 0 2px;
}

.idx-live-badge {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: #22c55e;
    margin-bottom: 0.4rem;
    animation: live-pulse 2s ease-in-out infinite;
}

@keyframes live-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--primary-gradient);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.stat-card h3 {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.stat-number {
    font-size: 2rem;
    font-weight: 800;
    margin-top: 0.5rem;
    letter-spacing: -0.02em;
}

.stat-date { font-size: 0.95rem; font-weight: 600; }

/* ── Sector Performance ── */
.sector-perf-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 2rem;
}

/* ── Compare ── */
.compare-controls {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.compare-inputs {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.75rem;
}

.compare-inputs .ticker-autocomplete { flex: 0 0 140px; }

.compare-inputs .ticker-input {
    width: 100%;
    padding: 0.5rem 0.7rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
}

.compare-inputs .ticker-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.compare-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.compare-legend {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.compare-legend-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.compare-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.compare-table-container { margin-top: 1.5rem; }

/* ── Top Movers ── */
.movers-section { margin-bottom: 2rem; }

.movers-group-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
    padding-left: 0.1rem;
}

.movers-group-label.gainers-label { color: var(--positive); }
.movers-group-label.losers-label { color: var(--negative); }

.movers-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    margin-bottom: 1.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.movers-scroll::-webkit-scrollbar { height: 4px; }
.movers-scroll::-webkit-scrollbar-track { background: transparent; }
.movers-scroll::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.mover-card {
    flex-shrink: 0;
    width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.875rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mover-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.mover-card-ticker {
    font-size: 0.95rem;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.mover-card-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

.mover-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-top: 0.25rem;
}

.mover-card-price {
    font-size: 0.85rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.mover-card-change {
    font-size: 0.78rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
}

.mover-card-change.positive { background: var(--positive-bg); color: var(--positive); }
.mover-card-change.negative { background: var(--negative-bg); color: var(--negative); }

/* ── Heatmap / Treemap ── */
.heatmap-page { max-width: 100%; }
.heatmap-page .container { max-width: 100%; }

.heatmap-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.heatmap-toolbar h1 {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.heatmap-controls { display: flex; align-items: center; gap: 0.5rem; }

.heatmap-select {
    padding: 0.45rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.85rem;
}

/* ── Legend ── */
.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.6rem;
}

.hm-leg-label {
    font-size: 0.68rem;
    color: var(--text-muted);
    font-weight: 600;
}

.hm-leg-bar {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    max-width: 200px;
    background: linear-gradient(to right, #cc2020, #4a1a1a, #3d3d4a, #1a4a30, #00b252);
}

/* ── Loading state ── */
.hm-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    height: 200px;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.hm-spinner {
    width: 22px; height: 22px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Treemap ── */
.treemap-container {
    overflow: hidden;
    background: #0d0d14;
    border: 1px solid #1e1e2e;
    border-radius: var(--radius-lg);
    min-height: 560px;
}

.tm-sector-label { display: none; }  /* legacy */

.tm-ind-label {
    position: relative;
    z-index: 2;
    height: 12px;
    line-height: 12px;
    padding: 0 3px;
    font-size: 0.42rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: rgba(255,255,255,0.6);
    background: rgba(0,0,0,0.3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tm-tile {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #fff;
    overflow: hidden;
    cursor: pointer;
    transition: filter 0.1s;
}

.tm-tile:hover {
    z-index: 10;
    outline: 2px solid rgba(255,255,255,0.9);
    outline-offset: -1px;
    filter: brightness(1.18);
}

.tm-ticker {
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.01em;
    text-shadow: 0 1px 4px rgba(0,0,0,0.7);
    line-height: 1;
}

.tm-ticker-sm { font-size: 0.56rem; }

.tm-price {
    font-size: 0.58rem;
    font-weight: 500;
    opacity: 0.85;
    margin-top: 1px;
    text-shadow: 0 1px 3px rgba(0,0,0,0.6);
}

.tm-change {
    font-size: 0.6rem;
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
    margin-top: 2px;
}

.empty-state {
    text-align: center;
    padding: 5rem 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.empty-state h2 { margin-bottom: 0.75rem; font-weight: 700; }
.empty-state p { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.95rem; }

.section-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    letter-spacing: -0.01em;
}

.action-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.action-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-decoration: none;
    color: var(--text);
    transition: all 0.25s;
    position: relative;
    overflow: hidden;
}

.action-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-gradient);
    transform: scaleX(0);
    transition: transform 0.25s;
}

.action-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(14, 165, 233, 0.15);
}

.action-card:hover::after { transform: scaleX(1); }
.action-card h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 0.35rem; }
.action-card p { color: var(--text-muted); font-size: 0.8rem; line-height: 1.5; }

.sector-tags { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 1rem; }

.sector-tag {
    padding: 0.4rem 1rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 100px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.2s;
}

.sector-tag:hover {
    border-color: var(--primary);
    color: var(--primary-light);
    background: var(--primary-glow);
}

.quick-actions, .sectors-overview { margin-bottom: 2.5rem; }

/* ── Screener ── */
.result-count {
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.toggle-filters { margin-bottom: 1.25rem; }

.filter-form {
    margin-bottom: 2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.filter-form.collapsed { display: none; }

.filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
}

fieldset {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    background: var(--surface-2);
    min-width: 0;
    overflow: hidden;
}

legend {
    color: var(--primary);
    font-weight: 700;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.2rem 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.filter-row label {
    min-width: 100px;
    flex-shrink: 0;
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.filter-row input[type="number"],
.filter-row select,
.filter-row textarea {
    flex: 1;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    transition: border-color 0.2s;
}

.filter-row input:focus,
.filter-row select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.filter-row input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

.filter-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border);
}

/* ── Tables ── */
.table-container {
    overflow-x: auto;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.stock-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.stock-table th {
    text-align: left;
    padding: 0.875rem 1rem;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    white-space: nowrap;
    position: sticky;
    top: 0;
}

.stock-table th:first-child { border-radius: var(--radius-lg) 0 0 0; }
.stock-table th:last-child { border-radius: 0 var(--radius-lg) 0 0; }

.stock-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.stock-table tbody tr { transition: background 0.15s; }
.stock-table tbody tr:hover { background: var(--surface-hover); }
.stock-table tbody tr:last-child td { border-bottom: none; }

.stock-table a {
    color: var(--primary-light);
    text-decoration: none;
    font-weight: 600;
}

.stock-table a:hover { color: var(--primary); text-decoration: underline; }

.name-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; color: var(--text-secondary); }
.sector-cell { max-width: 150px; overflow: hidden; text-overflow: ellipsis; color: var(--text-muted); }

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.overbought { color: var(--overbought); font-weight: 600; }
.oversold { color: var(--oversold); font-weight: 600; }

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 3rem 1rem !important;
}
.empty-row a { color: var(--primary-light); }

/* ── Recommendation Badges ── */
.rec-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rec-strong_buy, .rec-buy { background: var(--positive-bg); color: var(--buy); border: 1px solid rgba(0, 171, 68, 0.2); }
.rec-hold { background: var(--overbought-bg); color: var(--hold); border: 1px solid rgba(230, 126, 0, 0.2); }
.rec-sell, .rec-strong_sell { background: var(--negative-bg); color: var(--sell); border: 1px solid rgba(208, 2, 27, 0.2); }
.rec-underperform { background: var(--negative-bg); color: var(--sell); border: 1px solid rgba(208, 2, 27, 0.2); }

.rec-score {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    background: var(--surface-2);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-left: 0.35rem;
}

/* ── Pagination ── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding: 0.75rem 0;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.pagination-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-right {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.page-info { color: var(--text-muted); font-size: 0.8rem; font-weight: 500; }

/* ── Stock Detail ── */
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.detail-header h1 {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
}

.stock-name { color: var(--text-secondary); font-size: 1rem; margin-top: 0.15rem; }
.stock-sector { color: var(--text-muted); font-size: 0.85rem; margin-top: 0.25rem; }

/* ── Chart ── */
.chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-header h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.chart-periods { display: flex; gap: 0.25rem; }

.period-btn {
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--surface-2);
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.chart-controls-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chart-controls-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.chart-type-toggle, .chart-intervals { display: flex; gap: 0; }

.type-btn, .interval-btn {
    padding: 0.3rem 0.65rem;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}

.type-btn:first-child, .interval-btn:first-child { border-radius: 6px 0 0 6px; }
.type-btn:last-child, .interval-btn:last-child { border-radius: 0 6px 6px 0; }
.type-btn:not(:first-child), .interval-btn:not(:first-child) { border-left: none; }
.type-btn:hover, .interval-btn:hover { color: var(--text-secondary); }

.type-btn.active, .interval-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chart-sma-toggles {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.sma-toggle {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-muted);
}

.sma-toggle input { width: 14px; height: 14px; cursor: pointer; }

.sma20-color { color: #f59e0b; }
.sma50-color { color: #8b5cf6; }

.period-btn:hover { border-color: var(--primary); color: var(--primary); }

.period-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.chart-container {
    position: relative;
    height: 320px;
}

.chart-container.volume-chart {
    height: 80px;
    margin-top: -8px;
}

.price-display { text-align: right; }

.current-price {
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.price-change {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    margin-top: 0.25rem;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    display: inline-block;
}

.price-change.positive { background: var(--positive-bg); }
.price-change.negative { background: var(--negative-bg); }

.detail-grid-full {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.options-controls { margin-bottom: 0.75rem; }

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.detail-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.detail-card h3 {
    margin-bottom: 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-light);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.detail-table { width: 100%; }

.detail-table td {
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

.detail-table tr:last-child td { border-bottom: none; }
.detail-table td:first-child { color: var(--text-secondary); font-weight: 500; }
.detail-table td:last-child { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ── Analysis ── */
.analysis-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.analysis-header h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.outlook-badge {
    padding: 0.3rem 0.8rem;
    border-radius: 100px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.outlook-bullish { background: var(--positive-bg); color: var(--positive); border: 1px solid rgba(0, 171, 68, 0.2); }
.outlook-bearish { background: var(--negative-bg); color: var(--negative); border: 1px solid rgba(208, 2, 27, 0.2); }
.outlook-neutral { background: var(--overbought-bg); color: var(--hold); border: 1px solid rgba(230, 126, 0, 0.2); }

.analysis-summary {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.analysis-points { display: flex; flex-direction: column; gap: 0.5rem; }

.analysis-point {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.point-indicator {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 0.75rem;
    margin-top: 1px;
}

.point-bullish { background: var(--positive-bg); color: var(--positive); }
.point-bearish { background: var(--negative-bg); color: var(--negative); }
.point-neutral { background: var(--overbought-bg); color: var(--hold); }

/* ── News ── */
.news-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.news-card h3 {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 1rem;
}

.market-news-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.market-news-header h3 {
    margin-bottom: 0;
}

.news-loading {
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 1rem 0;
}

.news-empty { color: var(--text-muted); font-size: 0.85rem; }

.news-list { display: flex; flex-direction: column; }

.news-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
    color: var(--text);
    transition: background 0.15s;
}

.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--surface-hover); margin: 0 -1.5rem; padding-left: 1.5rem; padding-right: 1.5rem; }

.news-content {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.news-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.news-meta {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.news-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
}

/* ── Upgrade Banner ── */
.upgrade-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, var(--primary-glow), rgba(14,165,233,0.05));
    border: 1px solid rgba(14,165,233,0.25);
    border-radius: var(--radius);
    padding: 0.875rem 1.25rem;
    margin-bottom: 1rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.upgrade-banner div {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.upgrade-banner strong {
    font-size: 0.875rem;
    color: var(--text);
}

.upgrade-banner span {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.updated-at { color: var(--text-muted); font-size: 0.8rem; margin-bottom: 1rem; }

/* ── Portfolio ── */
.portfolio-summary {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.port-stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow-sm);
}

.port-stat-label {
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.port-stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    font-variant-numeric: tabular-nums;
}

.port-add-form, .alert-add-form {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.port-add-form input, .port-add-form select,
.alert-add-form input, .alert-add-form select {
    padding: 0.5rem 0.7rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    font-size: 0.825rem;
}

.port-add-form input:focus, .alert-add-form input:focus,
.port-add-form select:focus, .alert-add-form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.port-add-form input[name="ticker"], .alert-add-form input[name="ticker"] { width: 90px; }
.port-add-form input[name="shares"] { width: 90px; }
.port-add-form input[name="buy_price"] { width: 110px; }
.port-add-form input[name="buy_date"] { width: 150px; }
.port-add-form input[name="notes"] { width: 140px; }

.port-summary-row { cursor: pointer; }
.port-summary-row:hover { background: var(--surface-hover); }
.port-summary-row td { font-weight: 600; }

.port-expand {
    width: 20px;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: center;
}

.port-lot-row { background: var(--surface-2); }
.port-lot-row td { font-size: 0.8rem; color: var(--text-secondary); font-weight: 400; }
.port-lot-label { font-style: italic; color: var(--text-muted) !important; font-size: 0.72rem !important; }
.port-lot-date { color: var(--text-muted) !important; font-size: 0.75rem !important; }
.alert-add-form input[name="threshold"] { width: 120px; }

/* ── Ticker Autocomplete ── */
.ticker-autocomplete {
    position: relative;
    display: inline-block;
}

.ticker-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    min-width: 250px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 250px;
    overflow-y: auto;
    margin-top: 2px;
}

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

.ticker-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
    transition: background 0.1s;
}

.ticker-option:last-child { border-bottom: none; }
.ticker-option:hover { background: var(--surface-hover); }

.ticker-option-sym {
    font-weight: 700;
    color: var(--primary);
    min-width: 50px;
}

.ticker-option-name {
    flex: 1;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ticker-option-price {
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

/* ── Alerts ── */
.alert-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 100px;
    background: var(--negative);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 800;
    margin-left: 4px;
    vertical-align: middle;
}

.alerts-section { margin-bottom: 2rem; }

.alerts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.75rem;
    margin-top: 0.75rem;
}

.alert-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
}

.alert-triggered {
    border-color: var(--negative);
    background: var(--negative-bg);
}

.alert-inactive { opacity: 0.5; }

.alert-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.alert-ticker {
    font-weight: 800;
    font-size: 1rem;
    color: var(--primary);
    text-decoration: none;
}

.alert-ticker:hover { text-decoration: underline; }

.alert-type-badge {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: var(--surface-2);
    color: var(--text-muted);
}

.alert-card-mid {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.alert-card-bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.alert-time {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.alert-actions { display: flex; gap: 0.35rem; }

/* ── Fetch Page ── */
.fetch-page { max-width: 640px; }

.form-group { margin-bottom: 1.5rem; }

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    resize: vertical;
    transition: border-color 0.2s;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.progress-section { margin-top: 2rem; }

.progress-bar-container {
    width: 100%;
    height: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 100px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.progress-bar {
    height: 100%;
    background: var(--primary-gradient);
    border-radius: 100px;
    transition: width 0.3s ease;
}

.progress-stats {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    font-size: 0.85rem;
    font-weight: 500;
}

#progress-ticker { color: var(--text-muted); font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }

.progress-details {
    display: flex;
    gap: 2rem;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.progress-detail strong { font-weight: 700; }

.fetch-done {
    margin-top: 2rem;
    padding: 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.fetch-done p { margin-bottom: 1rem; }

.hidden { display: none; }

.loading { margin-top: 1.5rem; }

.spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-bottom: 0.75rem;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Watchlists ── */
.create-watchlist {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 2rem;
}

.create-watchlist input {
    flex: 1;
    max-width: 320px;
    padding: 0.625rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s;
}

.create-watchlist input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.watchlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.watchlist-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s;
}

.watchlist-card:hover { border-color: var(--border-light); }
.watchlist-card h3 { margin-bottom: 0.25rem; }

.watchlist-card h3 a {
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
}

.watchlist-card h3 a:hover { color: var(--primary-light); }
.watchlist-card p { color: var(--text-muted); font-size: 0.85rem; }
.watchlist-date { font-size: 0.75rem !important; color: var(--text-muted) !important; }
.delete-form { margin-top: 1rem; }

.add-stock-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.add-stock-form input[type="text"] {
    padding: 0.625rem 0.875rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: inherit;
    max-width: 220px;
    transition: border-color 0.2s;
}

.add-stock-form input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

/* ── Target Price Indicator ── */
.target-indicator {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.target-upside { color: var(--positive); font-weight: 600; }
.target-downside { color: var(--negative); font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 1100px) {
    .filter-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 960px) {
    .dashboard-layout { grid-template-columns: 1fr; }
    .dashboard-sidebar { position: static; }
    .sidebar-news-list { max-height: 350px; }
}

@media (max-width: 768px) {
    /* ── Mobile Nav ── */
    .navbar { display: none !important; }

    body { padding-bottom: 56px; }

    .mobile-bottomnav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -4px 16px rgba(0,0,0,0.08);
        z-index: 200;
        justify-content: space-around;
        align-items: stretch;
        padding: 0.4rem 0.3rem;
        padding-bottom: env(safe-area-inset-bottom, 0.4rem);
        gap: 0.25rem;
    }

    .mobile-tab {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 0.2rem;
        flex: 1;
        font-size: 0.7rem;
        font-weight: 700;
        color: var(--text-secondary);
        text-decoration: none;
        padding: 0.5rem 0.2rem;
        border-radius: 10px;
        transition: all 0.15s;
    }

    .mobile-tab::before {
        content: '';
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: transparent;
        transition: background 0.15s;
    }

    .mobile-tab:active { background: var(--surface-hover); }

    .mobile-tab.active {
        color: var(--primary);
        background: var(--primary-glow);
    }

    .mobile-tab.active::before { background: var(--primary); }

    .mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.5rem 1rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        position: sticky;
        top: 0;
        z-index: 150;
    }

    .mobile-topbar .brand-logo { width: 28px; height: 28px; }
    .mobile-topbar .brand-text { display: inline !important; font-size: 1rem; }

    /* ── General Mobile ── */
    .container { padding: 0.75rem; }
    .page-header h1 { font-size: 1.3rem; }
    .page-header p { font-size: 0.8rem; }

    /* ── Tables ── */
    .table-container { margin: 0 -0.75rem; border-radius: 0; border-left: none; border-right: none; }
    .stock-table { font-size: 0.75rem; }
    .stock-table th { padding: 0.5rem 0.4rem; font-size: 0.6rem; }
    .stock-table td { padding: 0.5rem 0.4rem; }
    .name-cell { display: none; }
    .sector-cell { display: none; }

    /* ── Cards ── */
    .stat-card { padding: 1rem; }
    .stat-number { font-size: 1.5rem; }
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 0.5rem; }
    .index-grid { grid-template-columns: repeat(2, 1fr); gap: 0.4rem; }
    .index-card-chart { height: 78px; }

    /* ── Detail Page ── */
    .detail-header { flex-direction: column; gap: 0.75rem; }
    .price-display { text-align: left; }
    .current-price { font-size: 2rem; }
    .detail-grid { grid-template-columns: 1fr; }
    .detail-grid-full { grid-template-columns: 1fr; }
    .detail-card { padding: 1rem; }

    /* ── Chart ── */
    .chart-card { padding: 0.75rem; }
    .chart-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .chart-controls-right { flex-wrap: wrap; gap: 0.4rem; }
    .chart-container { height: 250px; }
    .chart-sma-toggles { gap: 0.4rem; }
    .sma-toggle { font-size: 0.6rem; }
    .period-btn { padding: 0.3rem 0.5rem; font-size: 0.65rem; }
    .interval-btn, .type-btn { padding: 0.3rem 0.5rem; font-size: 0.65rem; }

    /* ── Filters ── */
    .filter-form { padding: 0.75rem; }
    .filter-grid { grid-template-columns: 1fr; }
    .filter-row { flex-wrap: wrap; }
    .filter-row label { min-width: 80px; font-size: 0.75rem; }

    /* ── Dashboard ── */
    .action-grid { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .action-card { padding: 0.875rem; }
    .action-card h3 { font-size: 0.85rem; }
    .action-card p { font-size: 0.7rem; }
    .mover-card { width: 130px; padding: 0.65rem; }
    .mover-card-ticker { font-size: 0.85rem; }

    /* ── Heatmap ── */
    .treemap-container { min-height: 400px; }

    /* ── Compare ── */
    .compare-inputs { gap: 0.4rem; }
    .compare-inputs .ticker-autocomplete { flex: 0 0 100px; }

    /* ── Portfolio ── */
    .portfolio-summary { gap: 0.5rem; }
    .port-stat { padding: 0.75rem; }
    .port-stat-value { font-size: 1.1rem; }
    .port-add-form, .alert-add-form { gap: 0.4rem; }
    .port-add-form input, .alert-add-form input,
    .port-add-form select, .alert-add-form select { font-size: 0.78rem; padding: 0.4rem 0.5rem; }

    /* ── Alerts ── */
    .alerts-grid { grid-template-columns: 1fr; }

    /* ── Analysis ── */
    .analysis-card { padding: 1rem; }
    .analysis-point { font-size: 0.8rem; }

    /* ── News ── */
    .news-item { padding: 0.5rem 0; }
    .news-title { font-size: 0.78rem; }
    .sidebar-news-item { padding: 0.5rem 0.75rem; }
    .sidebar-news-title { font-size: 0.72rem; }
}

/* ── Dark Theme ── */
.dark-theme {
    --bg: #0f1117;
    --bg-gradient: linear-gradient(135deg, #0f1117, #1a1d27);
    --surface: #1a1d27;
    --surface-2: #22263a;
    --surface-hover: #282e42;
    --border: #2a2e3a;
    --border-light: #3a3f52;
    --text: #e4e6ed;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --primary-glow: rgba(14, 165, 233, 0.15);
    --positive-bg: rgba(0, 171, 68, 0.15);
    --negative-bg: rgba(208, 2, 27, 0.15);
    --overbought-bg: rgba(230, 126, 0, 0.15);
    --oversold-bg: rgba(0, 102, 204, 0.15);
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.dark-theme .navbar { background: rgba(26, 29, 39, 0.95); }
.dark-theme .mobile-topbar { background: var(--surface); border-color: var(--border); }
.dark-theme .mobile-bottomnav { background: var(--surface); box-shadow: 0 -4px 16px rgba(0,0,0,0.3); }
.dark-theme .login-card { background: var(--surface); }
