:root {
    --bg-primary: #0a0e1a;
    --bg-secondary: #111827;
    --bg-card: rgba(26, 31, 53, 0.8);
    --bg-card-hover: rgba(34, 40, 69, 0.9);
    --border: rgba(255, 255, 255, 0.08);
    --bg-topbar: linear-gradient(180deg, rgba(17, 24, 39, 0.95), rgba(10, 14, 26, 0.95));
    --text-primary: #e8eaf0;
    --text-secondary: #8b92a8;
    --text-muted: #5a6178;
    --accent-blue: #3b82f6;
    --accent-purple: #8b5cf6;
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #f43f5e;
    --gradient-1: linear-gradient(135deg, #3b82f6, #8b5cf6);
    --gradient-2: linear-gradient(135deg, #06b6d4, #10b981);
    --gradient-3: linear-gradient(135deg, #f59e0b, #f43f5e);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.4);
    --radius: 12px;
    --radius-sm: 8px;
    --glass: blur(12px) saturate(180%);
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #f1f5f9;
    --bg-card: #ffffff;
    --bg-card-hover: #f1f5f9;
    --border: #e2e8f0;
    --bg-topbar: rgba(255, 255, 255, 0.9);
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --shadow-lg: 0 4px 20px rgba(0, 0, 0, 0.05);
}

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

#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease;
}

#loading-overlay.fade-out {
    opacity: 0;
}

#loading-overlay.hidden {
    display: none;
}

.loader-dots {
    display: flex;
    gap: 8px;
}

.dot {
    width: 12px;
    height: 12px;
    background: var(--accent-blue);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1.0);
    }
}

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

.topbar {
    background: var(--bg-topbar);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 32px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: sticky;
    top: 0;
    z-index: 100;
}


.topbar .timestamp {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Refresh Progress Bar (Phase 2) ── */
.refresh-progress-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 500;
}

#refresh-progress-msg {
    color: var(--text-primary);
}

#refresh-progress-pct {
    color: var(--accent-blue);
    font-family: tabular-nums;
}

.progress-track {
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-blue), var(--accent-emerald));
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
    transition: width 0.4s cubic-bezier(0.1, 0.7, 1.0, 0.1);
}

/* ── Layout ──────────────── */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ──────────────── */
.sidebar {
    width: 260px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: sticky;
    top: 0;
    z-index: 101;
    transition: width 0.3s ease;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar .logo {
    font-size: 18px;
    font-weight: 800;
    background: var(--gradient-1);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.3px;
    display: flex;
    flex-direction: column;
}

.sidebar .logo span {
    font-size: 11px;
    font-weight: 400;
    -webkit-text-fill-color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-group {
    margin-bottom: 24px;
}

.nav-group-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin: 0 12px 10px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    background: none;
    border: none;
    width: 100%;
    text-align: left;
    margin-bottom: 2px;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    opacity: 0.7;
}

.nav-item.active svg {
    opacity: 1;
    color: var(--accent-blue);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* ── Content Area ────────── */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.topbar-content {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 20px;
    width: 100%;
}

.main {
    padding: 24px 32px 48px;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

.section {
    display: none;
}

.section.active {
    display: block;
    animation: fadeUp 0.35s ease;
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title .badge {
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border-radius: 20px;
    animation: pulseBadge 2s infinite;
}

@keyframes pulseBadge {
    0% { transform: scale(1); opacity: 0.9; }
    50% { transform: scale(1.05); opacity: 1; box-shadow: 0 0 8px rgba(59, 130, 246, 0.3); }
    100% { transform: scale(1); opacity: 0.9; }
}

/* ── KPI Grid ────────────── */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.kpi {
    background: var(--bg-card);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    overflow: hidden;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.kpi:hover {
    transform: translateY(-4px);
    border-color: rgba(59, 130, 246, 0.4);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.3);
}

.kpi::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
}

.kpi:nth-child(1)::before {
    background: var(--gradient-1);
}

.kpi:nth-child(2)::before {
    background: var(--gradient-2);
}

.kpi:nth-child(3)::before {
    background: var(--gradient-3);
}

.kpi:nth-child(4)::before {
    background: linear-gradient(135deg, #8b5cf6, #ec4899);
}

.kpi:nth-child(5)::before {
    background: var(--gradient-2);
}

.kpi:nth-child(6)::before {
    background: var(--gradient-1);
}

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.kpi-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.kpi-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.kpi-value.positive {
    color: var(--accent-emerald);
}

.kpi-value.negative {
    color: var(--accent-rose);
}

/* ── Cards & Charts ───────── */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

.grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    margin-bottom: 28px;
}

@media (max-width: 1100px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

.card {
    background: var(--bg-card);
    backdrop-filter: var(--glass);
    -webkit-backdrop-filter: var(--glass);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-lg);
    transition: border-color 0.2s;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.15);
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulseDot 3s infinite alternate;
}

@keyframes pulseDot {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 6px currentColor; }
}

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

/* ── Filter bar ──────────── */
.filter-bar {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 24px;
    align-items: center;
    padding: 4px 0;
}

.search-box {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    padding: 6px 14px;
    border-radius: 20px;
    min-width: 240px;
    transition: all 0.2s;
}

.search-box:focus-within {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.search-box svg {
    color: var(--text-muted);
}

.search-box input {
    background: none;
    border: none;
    outline: none;
    color: var(--text-primary);
    font-size: 13px;
    width: 100%;
}

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

.filter-bar label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-right: 4px;
}

.filter-btn {
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.filter-btn:hover {
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

.filter-btn.active {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

select.filter-select {
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

/* ── Table ────────────────── */
.table-wrap {
    overflow-x: auto;
    overflow-y: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    position: relative;
    background: var(--bg-card);
}

.table-wrap table {
    width: 100%;
    border-collapse: collapse;
}

.table-wrap thead {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(59, 130, 246, 0.06);
    border-bottom: 2px solid var(--border);
}

.table-wrap tbody {
    overflow-y: auto;
}

.table-wrap th,
.table-wrap td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: normal;
    box-sizing: border-box;
}

.table-wrap th {
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.table-wrap th:hover {
    color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.08);
}

.table-wrap tbody tr:hover td {
    background: rgba(59, 130, 246, 0.04);
}

.table-wrap tbody tr {
    transition: background 0.15s ease;
}

.table-wrap.screener-table {
    height: 60vh;
    min-height: 400px;
}

.table-wrap.backtest-table {
    height: 60vh;
    min-height: 400px;
}

.table-wrap.dividends-table {
    height: 60vh;
    min-height: 400px;
}

.ticker-cell {
    font-weight: 700;
    color: var(--accent-blue);
    cursor: pointer;
}

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

.rec-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.rec-Buy,
.rec-Outperform {
    background: rgba(16, 185, 129, 0.15);
    color: var(--accent-emerald);
}

.rec-Hold,
.rec-Neutral {
    background: rgba(245, 158, 11, 0.15);
    color: var(--accent-amber);
}

.rec-Sell,
.rec-Reduce {
    background: rgba(244, 63, 94, 0.15);
    color: var(--accent-rose);
}

.return-pos {
    color: var(--accent-emerald);
    font-weight: 600;
}

.return-neg {
    color: var(--accent-rose);
    font-weight: 600;
}

.verdict-correct {
    color: var(--accent-emerald);
}

.verdict-wrong {
    color: var(--accent-rose);
}

.verdict-missed {
    color: var(--accent-amber);
}

.num-cell {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
}

/* ── Portfolio Specifics ─── */
.input-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
}

.summary-card-item {
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid var(--border);
}

.summary-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

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

/* ── SQL Console ─────────── */
.sql-area {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
}

.sql-input {
    width: 100%;
    min-height: 100px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: #a5f3fc;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
    padding: 14px;
    resize: vertical;
    outline: none;
}

.sql-input:focus {
    border-color: var(--accent-cyan);
}

.sql-btns {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    align-items: center;
}

.btn {
    padding: 8px 20px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--gradient-1);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-ghost {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-ghost:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.sql-result-info {
    font-size: 12px;
    color: var(--text-muted);
    margin-left: auto;
}

.sql-templates {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.sql-templates button {
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-muted);
    font-size: 11px;
    cursor: pointer;
    font-family: inherit;
}

.sql-templates button:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

/* ── Detail Panel ────────── */
.detail-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 200;
    backdrop-filter: blur(4px);
}

.detail-overlay.active {
    display: flex;
    justify-content: flex-end;
}

.detail-panel {
    width: 560px;
    max-width: 90vw;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border);
    padding: 28px;
    overflow-y: auto;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

.detail-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    float: right;
    line-height: 1;
}

.detail-close:hover {
    color: var(--text-primary);
}

.detail-name {
    font-size: 24px;
    font-weight: 800;
    margin-bottom: 4px;
}

.detail-ticker {
    font-size: 14px;
    color: var(--accent-blue);
    font-weight: 600;
    margin-bottom: 20px;
}

.detail-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.detail-stat {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    padding: 14px;
    border: 1px solid var(--border);
}

.detail-stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.detail-stat-value {
    font-size: 20px;
    font-weight: 700;
}

.rsi-high {
    color: var(--accent-rose);
}

.rsi-low {
    color: var(--accent-emerald);
}

.rsi-mid {
    color: var(--text-muted);
}

.detail-chart {
    height: 200px;
    margin: 20px 0;
}

.detail-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin: 16px 0 8px;
    text-transform: uppercase;
}

/* ── Scrollbar ───────────── */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ── Loading ─────────────── */
.loading {
    text-align: center;
    padding: 60px;
    color: var(--text-muted);
}

.spinner {
    display: inline-block;
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent-blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.line-skel {
    height: 16px;
    margin: 8px 0;
    width: 80%;
}

.line-skel.short {
    width: 40%;
}

/* ── Toasts ───────────────── */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in 0.3s ease forwards;
    min-width: 200px;
}

@keyframes toast-in {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* ── Responsive ──────────── */
@media (max-width: 1200px) {
    .main {
        padding: 20px;
    }
}

@media (max-width: 1024px) {
    .sidebar {
        width: 70px;
    }

    .sidebar .logo,
    .sidebar .logo span,
    .sidebar .nav-group-title,
    .sidebar .nav-item span,
    .sidebar .sidebar-footer span {
        display: none;
    }

    .sidebar .nav-item {
        justify-content: center;
        padding: 12px;
    }

    .sidebar .nav-item svg {
        margin: 0;
        width: 20px;
        height: 20px;
    }

    .sidebar-header {
        padding: 16px;
        display: flex;
        justify-content: center;
    }

    .sidebar-nav {
        padding: 16px 8px;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: fixed;
        bottom: 0;
        top: auto;
        flex-direction: row;
        border-right: none;
        border-top: 1px solid var(--border);
        overflow-x: auto;
        background: var(--bg-secondary);
        z-index: 1000;
    }

    .sidebar-header,
    .sidebar-footer,
    .nav-group-title {
        display: none;
    }

    .sidebar-nav {
        display: flex;
        flex-direction: row;
        padding: 4px;
        width: 100%;
        justify-content: space-around;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .nav-group {
        margin: 0;
        display: flex;
    }

    .nav-item {
        flex-direction: column;
        gap: 4px;
        padding: 8px 12px;
        margin: 0;
        width: auto;
        font-size: 10px;
    }

    .nav-item span {
        display: block;
    }

    .nav-item.active span {
        display: block;
    }

    .content-area {
        padding-bottom: 140px;
        /* Increased offset for bottom nav */
    }

    .topbar {
        padding: 0 16px;
    }

    .main {
        padding: 16px 16px 160px !important;
        /* Extra bottom padding for fixed nav */
    }

    .section-title {
        font-size: 18px;
        flex-wrap: wrap;
    }

    .filter-bar {
        gap: 8px;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 12px;
        margin-bottom: 16px;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .filter-bar::-webkit-scrollbar {
        display: none;
    }

    .filter-bar .search-box {
        min-width: 180px;
        flex-shrink: 0;
    }

    .filter-btn {
        flex-shrink: 0;
        white-space: nowrap;
    }

    .filter-bar label {
        display: none;
    }

    /* Bottom mobile nav indicator */
    .sidebar::after {
        content: '';
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        width: 40px;
        background: linear-gradient(90deg, transparent, var(--bg-secondary));
        pointer-events: none;
        opacity: 0.8;
        z-index: 1001;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .input-grid {
        grid-template-columns: 1fr !important;
        display: grid !important;
    }

    .summary-grid {
        grid-template-columns: 1fr 1fr;
    }

    .kpi-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* AI Performance Tracking */
.rec-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.rec-Buy {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.rec-Sell {
    background: rgba(244, 63, 94, 0.2);
    color: #f43f5e;
    border: 1px solid rgba(244, 63, 94, 0.3);
}

.rec-Hold {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.verdict-correct {
    color: #10b981;
    font-weight: 700;
}

.verdict-wrong {
    color: #f43f5e;
    font-weight: 700;
}

.return-pos {
    color: #10b981;
}

.return-neg {
    color: #f43f5e;
}

.kpi-skel {
    height: 80px;
    background: var(--bg-card);
    border-radius: 12px;
}

@media (max-width: 480px) {
    .kpi-grid {
        grid-template-columns: 1fr;
    }

    .topbar .timestamp {
        display: none;
    }
}

/* ── Landing Page ──────────────── */
.landing-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at top right, rgba(59, 130, 246, 0.05), transparent),
        radial-gradient(circle at bottom left, rgba(16, 185, 129, 0.05), transparent);
    padding: 40px 20px;
}

.landing-content {
    max-width: 1000px;
    width: 100%;
    margin: 0 auto;
}

.landing-hero {
    text-align: center;
    margin-bottom: 60px;
    animation: fadeInDown 0.8s ease-out;
}

.hero-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    filter: drop-shadow(0 0 20px rgba(16, 185, 129, 0.3));
}

.landing-hero h1 {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 12px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -1px;
}

.hero-tagline {
    font-size: 18px;
    color: var(--accent-emerald);
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.landing-grid {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 32px;
    animation: fadeInUp 0.8s ease-out 0.2s both;
}

@media (max-width: 900px) {
    .landing-grid {
        grid-template-columns: 1fr;
    }

    .landing-hero h1 {
        font-size: 36px;
    }
}

.glass-card {
    background: rgba(26, 31, 53, 0.6);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    padding: 32px;
}

.landing-description h3 {
    font-size: 24px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.landing-description p {
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 24px;
    font-size: 15px;
}

.feature-list {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.feature-list li {
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 10px;
}

.feature-list li::before {
    content: '✓';
    color: var(--accent-emerald);
    font-weight: 800;
}

.landing-auth-card {
    display: flex;
    flex-direction: column;
    gap: 24px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.auth-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 12px;
}

.auth-tab-btn {
    flex: 1;
    padding: 10px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.auth-tab-btn.active {
    background: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.form-group input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
}

.form-group input:focus {
    border-color: var(--accent-blue);
    background: rgba(0, 0, 0, 0.3);
}

.logo-img {
    width: 24px;
    height: 24px;
    margin-bottom: 8px;
}

.hero-logo {
    width: 100px;
    height: 100px;
    background: white;
    border-radius: 20px;
    padding: 10px;
    display: inline-block;
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Tabs & Governance Premium Styling ──────────── */
.tabs {
    display: flex;
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px;
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
    overflow-x: auto;
    backdrop-filter: blur(10px);
}

.tab-btn {
    padding: 10px 20px;
    border-radius: 12px;
    background: transparent;
    color: var(--text-secondary);
    border: none;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
    background: var(--accent-blue);
    background: var(--gradient-1);
    color: white;
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
    transform: translateY(-1px);
}

/* ── Governance Layout Additions ──────────── */
.gov-zone-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
}

.gov-zone-card {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s;
}

.gov-zone-card:hover {
    border-color: rgba(59, 130, 246, 0.4);
    transform: translateY(-4px);
    background: rgba(26, 31, 53, 0.9);
    box-shadow: 0 10px 20px rgba(0,0,0,0.2);
}

.gov-pipeline-flow {
    display: flex;
    align-items: center;
    overflow-x: auto;
    padding: 30px 10px;
    gap: 15px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 13px;
}

.gov-pipeline-node {
    padding: 12px 20px;
    border-radius: 12px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
    transition: all 0.3s;
    white-space: nowrap;
}

.gov-pipeline-node:hover {
    transform: scale(1.05);
}

.gov-pipeline-arrow {
    color: var(--text-muted);
    font-weight: bold;
    font-size: 18px;
    animation: pulseArrow 2s infinite;
}

@keyframes pulseArrow {
    0%, 100% { opacity: 0.5; transform: translateX(0); }
    50% { opacity: 1; transform: translateX(3px); }
}

.risk-matrix-wrapper {
    display: grid;
    grid-template-columns: 35px repeat(5, 1fr);
    gap: 8px;
    background: rgba(0, 0, 0, 0.2);
    padding: 24px;
    border-radius: 16px;
    border: 1px solid var(--border);
}

.risk-cell {
    height: 50px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 16px;
    color: rgba(255,255,255,0.9);
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.risk-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    z-index: 10;
}

.expandable-item {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.expandable-item:hover {
    border-color: rgba(59, 130, 246, 0.3);
    background: rgba(26, 31, 53, 0.7);
    transform: translateY(-2px);
}

.expand-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.expandable-content {
    display: none;
    margin-top: 16px;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-secondary);
    border-top: 1px dashed var(--border);
    padding-top: 16px;
    animation: fadeInDown 0.3s ease;
}