:root {
    --bg: #0f1115;
    --panel: #171a21;
    --panel-2: #1f2430;
    --border: #2a3040;
    --text: #e7ebf3;
    --muted: #8b94a7;
    --accent: #4f8cff;
    --up: #2ecc71;
    --down: #ff5d6c;
    --radius: 12px;
    --font-display: "Bricolage Grotesque", "Segoe UI", sans-serif;
    --font-body: "Hanken Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    /* Subtle depth so it isn't a flat slab — radial glows behind the dark base. */
    background-image:
        radial-gradient(900px 500px at 100% -10%, rgba(79, 140, 255, .10), transparent 60%),
        radial-gradient(700px 500px at -10% 0%, rgba(122, 92, 255, .08), transparent 55%);
    background-attachment: fixed;
    color: var(--text);
    font-family: var(--font-body);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Figures read as data: distinctive display face + lining tabular numerals. */
.stat-value, .brand, .card h2, .analysis h3, .analysis h4, .tab, .btn {
    font-family: var(--font-display);
    letter-spacing: -.01em;
}
.stat-value, .table .num, .alloc-pct, .section-totals strong, .tab-count {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* Gentle staggered reveal on load. */
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: no-preference) {
    .stats, .fx-note, .card { animation: rise .5s cubic-bezier(.2, .7, .2, 1) both; }
    .fx-note { animation-delay: .04s; }
    main.wrap > .card:nth-of-type(1) { animation-delay: .08s; }
    main.wrap > .card:nth-of-type(2) { animation-delay: .14s; }
    main.wrap > .card:nth-of-type(3) { animation-delay: .20s; }
}

.wrap {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
}

.topbar {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 14px 0;
}
.topbar .wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text);
    text-decoration: none;
}
.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent), #7a5cff);
    font-weight: 800;
}
nav { display: flex; align-items: center; gap: 18px; }
nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
nav a:hover { color: var(--text); }

main.wrap { padding-top: 28px; padding-bottom: 28px; }

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}
.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-label { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 24px; font-weight: 700; }
.stat-value small { font-size: 14px; font-weight: 500; }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 24px;
}
.card h2 { margin: 0 0 16px; font-size: 16px; }

.section-totals { display: flex; flex-wrap: wrap; gap: 18px; font-size: 13px; color: var(--muted); margin-bottom: 16px; }
.section-totals strong { color: var(--text); font-weight: 600; }
.section-totals .up strong { color: var(--up); }
.section-totals .down strong { color: var(--down); }

.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--muted);
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 14px;
    margin-bottom: -1px;
    cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-count {
    display: inline-block;
    min-width: 18px;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--panel-2);
    color: var(--muted);
    font-size: 11px;
    text-align: center;
}
.tab.active .tab-count { background: var(--accent); color: #fff; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.analysis {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 20px;
}
.analysis h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
details.analysis > summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    user-select: none;
}
details.analysis > summary::-webkit-details-marker { display: none; }
details.analysis > summary::after {
    content: "›";
    font-size: 18px;
    line-height: 1;
    transform: rotate(90deg);
    transition: transform .2s ease;
    color: var(--muted);
}
details.analysis:not([open]) > summary { margin-bottom: 0; }
details.analysis:not([open]) > summary::after { transform: rotate(0deg); }
details.analysis > summary:hover { color: var(--text); }
.analysis h4 { margin: 16px 0 8px; font-size: 13px; }
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}
.analysis .metric { display: flex; flex-direction: column; gap: 3px; }
.analysis .metric span { font-size: 12px; }
.analysis .metric strong { font-size: 14px; font-weight: 600; }
.alloc-fill.alt { background: linear-gradient(90deg, #2ecc71, #1e9e8a); }

.warn { color: #e8c34a; }

/* Portfolio overview + donut */
.overview-grid { display: grid; grid-template-columns: minmax(220px, 280px) 1fr; gap: 26px; align-items: center; }
.overview-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 14px 18px; }
.overview-metrics .metric { display: flex; flex-direction: column; gap: 3px; }
.overview-metrics .metric > span { font-size: 12px; }
.overview-metrics .metric strong { font-size: 15px; font-weight: 600; }
.overview-metrics .metric small { font-size: 11px; }

.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-svg { width: 150px; height: 150px; flex: none; }
.donut-center-val { fill: var(--text); font-family: var(--font-display); font-size: 17px; font-weight: 700; }
.donut-center-lbl { fill: var(--muted); font-size: 8.5px; text-transform: uppercase; letter-spacing: .05em; }
.donut-legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 5px; font-size: 13px; min-width: 0; }
.donut-legend li { display: flex; align-items: center; gap: 8px; border-radius: 6px; padding: 2px 5px; transition: background .15s; }
.donut-legend li.on { background: var(--panel-2); }
.donut-legend .sw { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.donut-legend .lg-pct { margin-left: auto; color: var(--muted); font-variant-numeric: tabular-nums; }

.split-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: var(--panel-2); margin: 2px 0; }
.split-bar span { display: block; height: 100%; }
.top-holding .alloc-label { font-size: 13px; }

/* Per-tab analysis: composition donut beside the metrics, then mix donuts. */
.analysis-top { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
.analysis-top .analysis-grid { margin: 0; }
.mix-donuts { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 20px; margin-top: 10px; }
.mix-block h4 { margin: 0 0 8px; }
.analysis .donut-svg { width: 120px; height: 120px; }
.analysis .donut-legend { font-size: 12px; }

.tab-extra { margin-top: 4px; }
.callout {
    margin-top: 6px;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    font-size: 14px;
}
.callout strong { color: var(--text); }
.callout-warn { border-color: #e8c34a; background: rgba(232, 195, 74, .08); }

.alloc { display: flex; flex-direction: column; gap: 10px; }
.alloc-row { display: grid; grid-template-columns: 160px 1fr 60px; align-items: center; gap: 12px; font-size: 14px; }
.alloc-bar { background: var(--panel-2); border-radius: 6px; height: 10px; overflow: hidden; }
.alloc-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #7a5cff); }
.alloc-pct { text-align: right; color: var(--muted); }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.table .num { text-align: right; }
.table tbody tr:hover { background: var(--panel-2); }
.muted { color: var(--muted); font-size: 12px; }
.fx-note { margin: -10px 0 20px; }
.logout-form { display: inline-flex; align-items: center; gap: 10px; }
.logout-form .muted { font-size: 13px; }
.login-card { max-width: 380px; margin: 40px auto; }
.up { color: var(--up); }
.down { color: var(--down); }
.actions a { color: var(--accent); text-decoration: none; margin-left: 10px; }
.actions a.danger { color: var(--down); }

.empty { color: var(--muted); }
.empty a { color: var(--accent); }

.form-card { max-width: 560px; }
.field { margin-bottom: 16px; display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 14px; font-weight: 600; }
.field input, .field select, .field textarea {
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 10px 12px;
    font-size: 14px;
    font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none;
    border-color: var(--accent);
}
.field .error { color: var(--down); font-size: 13px; }

.radio {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-weight: 400;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-2);
    cursor: pointer;
}
.radio input[type="radio"] {
    width: auto;
    margin-top: 3px;
    padding: 0;
}
.radio span { display: flex; flex-direction: column; gap: 2px; }
.radio strong { font-size: 14px; }
.radio small { font-size: 12px; line-height: 1.4; }
.radio:has(input:checked) { border-color: var(--accent); }

.form-actions { display: flex; gap: 12px; margin-top: 8px; }

.btn {
    display: inline-block;
    padding: 9px 16px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #3d7bf0; }
.btn-danger { background: var(--down); border-color: var(--down); color: #fff; }

.messages { list-style: none; padding: 0; margin: 0 0 20px; display: flex; flex-direction: column; gap: 8px; }
.msg { padding: 10px 14px; border-radius: 8px; font-size: 14px; border: 1px solid var(--border); }
.msg.success { background: rgba(46, 204, 113, .12); border-color: var(--up); }
.msg.error { background: rgba(255, 93, 108, .12); border-color: var(--down); }

.footer { color: var(--muted); font-size: 13px; padding-top: 12px; padding-bottom: 32px; }

@media (max-width: 760px) {
    .wrap { padding: 0 14px; }

    /* Top bar: let the brand sit on its own line and the nav wrap below it. */
    .topbar .wrap { flex-wrap: wrap; gap: 10px; }
    nav { flex-wrap: wrap; gap: 10px 14px; width: 100%; }
    .logout-form { margin-left: auto; }

    .stats { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat { padding: 14px; }
    .stat-value { font-size: 20px; }

    .card { padding: 16px; }
    .analysis { padding: 14px; }

    /* Tabs swipe horizontally instead of stacking into many rows. */
    .tabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tab { white-space: nowrap; padding: 10px 12px; }

    /* Tables → one card per row, each cell a label/value line (no overflow). */
    .table, .table tbody { display: block; }
    .table thead { display: none; }
    .table tr {
        display: block;
        background: var(--panel-2);
        border: 1px solid var(--border);
        border-radius: 10px;
        padding: 4px 14px;
        margin-bottom: 10px;
    }
    .table tbody tr:hover { background: var(--panel-2); }
    .table td {
        display: flex;
        justify-content: space-between;
        align-items: baseline;
        gap: 16px;
        padding: 7px 0;
        border: none;
        text-align: right;
        white-space: nowrap;
        font-size: 14px;
    }
    .table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 12px;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: .03em;
        text-align: left;
    }
    .table td small { margin-left: 6px; color: var(--muted); }
    .table td.cell-name {
        display: block;
        text-align: left;
        white-space: normal;
        padding: 10px 0 8px;
        margin-bottom: 4px;
        border-bottom: 1px solid var(--border);
        font-size: 15px;
    }
    .table td.cell-name::before { content: none; }
    .table td.cell-name .muted { margin-left: 8px; }
    .table td.actions { justify-content: flex-end; gap: 20px; padding-top: 10px; }
    .table td.actions::before { content: none; }
    .table td.actions a { margin-left: 0; }

    .alloc-row { grid-template-columns: 96px 1fr 46px; gap: 8px; font-size: 13px; }
    .section-totals { gap: 10px 16px; }

    .overview-grid { grid-template-columns: 1fr; gap: 18px; }
    .donut-wrap { justify-content: center; }
    .analysis-top { grid-template-columns: 1fr; gap: 16px; }
    .mix-donuts { grid-template-columns: 1fr; gap: 16px; }
}

@media (max-width: 420px) {
    .brand { font-size: 16px; }
    .stat-value { font-size: 18px; }
    .form-actions { flex-wrap: wrap; }
}

/* ============================ Analysis page ============================ */
.page-title { margin: 0 0 6px; font-family: var(--font-display); font-size: 22px; }
.disclaimer-top { margin: 0 0 18px; font-size: 13px; }

/* Sub-tabs reuse the dashboard tab look. */
.subtabs {
    display: flex; flex-wrap: wrap; gap: 4px;
    border-bottom: 1px solid var(--border); margin-bottom: 20px;
}
.subtab {
    background: none; border: none; border-bottom: 2px solid transparent;
    color: var(--muted); font: inherit; font-size: 14px; font-weight: 600;
    padding: 10px 14px; margin-bottom: -1px; cursor: pointer;
}
.subtab:hover { color: var(--text); }
.subtab.active { color: var(--text); border-bottom-color: var(--accent); }
.subtab-panel { display: none; }
.subtab-panel.active { display: block; }

.analysis-cards {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px;
}
.analysis-card {
    background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; cursor: pointer; transition: border-color .15s, transform .15s;
}
.analysis-card:hover { border-color: var(--muted); }
.analysis-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.analysis-card.open { border-color: var(--accent); }
.ac-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.ac-title strong { font-size: 15px; }
.ac-sym { display: block; font-size: 12px; margin-top: 2px; }
.ac-badge { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.ac-verdict, .ac-cta { font-size: 12px; }
.ac-sub { font-size: 13px; margin-top: 8px; }
.score-pill {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 30px; height: 30px; padding: 0 8px; border-radius: 8px;
    font-weight: 700; font-size: 14px; color: #0f1115;
    font-variant-numeric: tabular-nums;
}
.score-pill.up { background: var(--up); }
.score-pill.warn { background: #e8c34a; }
.score-pill.down { background: var(--down); }

.ac-detail { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Confidence gauge */
.ac-score { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.score-gauge { position: relative; width: 140px; flex: 0 0 auto; text-align: center; }
.gauge-svg { width: 140px; height: 82px; display: block; }
.gauge-track { stroke: rgba(255,255,255,.08); stroke-width: 9; }
.gauge-fill { stroke-width: 9; }
.score-gauge.up .gauge-fill { stroke: var(--up); }
.score-gauge.warn .gauge-fill { stroke: #e8c34a; }
.score-gauge.down .gauge-fill { stroke: var(--down); }
.gauge-label { margin-top: -34px; }
.gauge-score { font-family: var(--font-display); font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.gauge-of { font-size: 12px; color: var(--muted); }
.gauge-verdict { display: block; font-weight: 700; font-size: 13px; margin-top: 2px; }
.score-gauge.up .gauge-verdict { color: var(--up); }
.score-gauge.warn .gauge-verdict { color: #e8c34a; }
.score-gauge.down .gauge-verdict { color: var(--down); }
.rationale { margin: 0; padding-left: 18px; flex: 1 1 200px; min-width: 180px; }
.rationale li { font-size: 13px; margin: 3px 0; color: var(--text); }

.ac-brief { font-size: 13.5px; line-height: 1.5; color: var(--text); margin: 14px 0 8px; }
.ac-meta { font-size: 12.5px; margin-bottom: 10px; }
.ac-section-h { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 14px 0 8px; }
.ac-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px 14px; }
.ac-stat { display: flex; flex-direction: column; gap: 2px; }
.ac-stat span { font-size: 11.5px; }
.ac-stat strong { font-size: 14px; font-variant-numeric: tabular-nums; }

.reco-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; margin: 6px 0; background: var(--panel); }
.reco-bar span { display: block; height: 100%; }
.ac-target { font-size: 13px; margin-top: 8px; }
.peer-list, .news-list { margin: 0; padding-left: 18px; }
.peer-list li, .news-list li { font-size: 13px; margin: 4px 0; }
.news-list a { color: var(--accent); text-decoration: none; }
.news-list a:hover { text-decoration: underline; }
.tiny { font-size: 11px; }
.ac-foot { margin-top: 16px; }
.ac-disc { margin-top: 4px; font-style: italic; }
.ac-err { color: var(--down); font-size: 13.5px; }
.retry { margin-top: 8px; }

/* Skeleton loaders */
.skeleton { background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 37%, var(--panel) 63%);
    background-size: 400% 100%; border-radius: 8px; animation: sk 1.3s ease infinite; }
.sk-gauge { width: 140px; height: 70px; margin-bottom: 14px; }
.sk-line { height: 12px; margin: 8px 0; }
.sk-line:nth-of-type(3) { width: 70%; }
.sk-grid { height: 60px; margin-top: 12px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: -100% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

@media (max-width: 760px) {
    .analysis-cards { grid-template-columns: 1fr; }
    .subtabs { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .subtab { white-space: nowrap; padding: 10px 12px; }
    .ac-score { gap: 12px; }
}

/* ===================================================== Recommendation page == */
.rec-stats { margin: 16px 0; }
.rec-stats .stat { min-width: 120px; }

.rec-filters {
    display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
    margin: 14px 0 18px;
}
.rec-filters input, .rec-filters select {
    background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
    border-radius: 8px; padding: 8px 10px; font: inherit; min-width: 110px;
}
.rec-filters input[type="search"] { min-width: 200px; flex: 1 1 200px; }
.rec-filters input[type="number"] { width: 110px; }

.table-wrap { overflow-x: auto; }
.rec-table { width: 100%; border-collapse: collapse; }
.rec-table th, .rec-table td { padding: 9px 10px; border-bottom: 1px solid var(--border); text-align: left; }
.rec-table th { font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; }
.rec-table th a { color: var(--muted); text-decoration: none; }
.rec-table th a:hover { color: var(--text); }
.rec-table td.num, .rec-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.rec-table tbody tr:hover { background: var(--panel-2); }
.rec-table .cell-name a { color: var(--text); text-decoration: none; font-weight: 600; }
.rec-table .cell-name a:hover { color: var(--accent); }
.rec-table .ac-sym { display: block; font-size: 11px; }
.rec-table .tiny { font-size: 12px; }

.pager { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 16px; }

/* score pill + verdict colour bands */
.score-pill {
    display: inline-block; min-width: 30px; text-align: center; padding: 2px 8px;
    border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums;
    background: var(--panel-2); border: 1px solid var(--border);
}
.score-pill.big { font-size: 26px; min-width: 56px; padding: 8px 14px; }
.verdict-tag { font-size: 12px; font-weight: 600; white-space: nowrap; }
.vbuy   { color: #2ecc71; border-color: rgba(46,204,113,.5); }
.vacc   { color: #6fd99a; border-color: rgba(111,217,154,.5); }
.vhold  { color: #e8c34a; border-color: rgba(232,195,74,.5); }
.vred   { color: #ff9e5b; border-color: rgba(255,158,91,.5); }
.vavoid { color: #ff5d6c; border-color: rgba(255,93,108,.5); }
.score-pill.vbuy { background: rgba(46,204,113,.14); }
.score-pill.vacc { background: rgba(111,217,154,.12); }
.score-pill.vhold { background: rgba(232,195,74,.12); }
.score-pill.vred { background: rgba(255,158,91,.12); }
.score-pill.vavoid { background: rgba(255,93,108,.12); }

/* ---- detail page ---- */
.back-link { display: inline-block; margin-bottom: 10px; text-decoration: none; }
.rd-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.rd-head .page-title { margin-bottom: 2px; }
.rd-meta { font-size: 13px; }
.rd-sym { font-weight: 600; color: var(--text); }
.rd-score { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.rd-verdict { font-weight: 700; font-family: var(--font-display); }
.rd-keyline { display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0; font-size: 15px; }
.rd-desc { color: var(--text); opacity: .9; max-width: 70ch; }
.rd-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; margin: 18px 0; }
.rd-h { font-family: var(--font-display); font-size: 15px; margin: 0 0 10px; }

.signal-bars { display: flex; flex-direction: column; gap: 9px; }
.signal-row { display: grid; grid-template-columns: 110px 1fr 34px; gap: 10px; align-items: center; }
.signal-label { font-size: 13px; color: var(--muted); }
.signal-track { height: 8px; background: var(--panel-2); border-radius: 999px; overflow: hidden; }
.signal-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7a5cff); }
.signal-val { text-align: right; font-variant-numeric: tabular-nums; font-size: 13px; }

.q-chart { width: 100%; overflow-x: auto; }
.q-svg { width: 100%; min-width: 320px; height: 200px; }
.q-svg .bar-sales { fill: var(--accent); }
.q-svg .bar-profit { fill: #2ecc71; }
.q-svg .q-lbl { fill: var(--muted); font-size: 9px; text-anchor: middle; }
.q-legend { margin-top: 4px; display: flex; gap: 14px; }
.q-key.q-sales { color: var(--accent); }
.q-key.q-profit { color: #2ecc71; }

.rd-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; margin-top: 8px; }
.table.mini { width: 100%; border-collapse: collapse; }
.table.mini td { padding: 5px 6px; border-bottom: 1px solid var(--border); font-size: 13px; }
.table.mini td.num { text-align: right; font-variant-numeric: tabular-nums; }
.rd-refresh { margin-top: 18px; }

@media (max-width: 760px) {
    .rd-grid { grid-template-columns: 1fr; }
    .rec-filters input, .rec-filters select { flex: 1 1 calc(50% - 8px); min-width: 0; }
    .signal-row { grid-template-columns: 92px 1fr 30px; }
}

/* ---- screener sort headers + pager (many rows) ---- */
.rec-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.rec-toggle input { accent-color: var(--accent); }
.rec-count { margin: 4px 0 10px; font-size: 13px; }

.rec-table th .sort-link { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 3px; cursor: pointer; }
.rec-table th .sort-link:hover { color: var(--text); }
.rec-table th .sort-link.sorted { color: var(--accent); font-weight: 700; }
.rec-table th.num .sort-link { flex-direction: row-reverse; }
.sort-arrow { font-size: 9px; }

.pager { flex-wrap: wrap; }
.pager .page-nums { display: inline-flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.pager .page-nums a { color: var(--muted); text-decoration: none; min-width: 18px; text-align: center; }
.pager .page-nums a:hover { color: var(--text); }
.pager .page-cur { color: var(--accent); font-weight: 700; }
.pager .jump input {
    width: 64px; background: var(--panel-2); border: 1px solid var(--border);
    color: var(--text); border-radius: 6px; padding: 4px 6px; font: inherit;
}

/* analysis section separators on the detail page */
.rd-h.section-h { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border);
    display: flex; align-items: center; gap: 10px; font-size: 17px; flex-wrap: wrap; }

/* ============================================================ mobile fixes ==
   The global ".table → stacked cards" rule above is for the dashboard tables
   (which carry data-label). The screener table and the detail key/value tables
   don't, so we opt them BACK OUT to real tables on small screens. */
@media (max-width: 760px) {
    /* --- Recommendation screener: stay a compact table, key columns only --- */
    .rec-table, .rec-table tbody { display: table; width: 100%; }
    .rec-table thead { display: table-header-group; }
    .rec-table tr { display: table-row; background: none; border: 0; padding: 0; margin: 0; }
    .rec-table th, .rec-table td, .rec-table td.cell-name {
        display: table-cell; padding: 9px 8px; text-align: left;
        white-space: nowrap; font-size: 13px; border-bottom: 1px solid var(--border);
    }
    .rec-table td.num, .rec-table th.num { text-align: right; }
    .rec-table td::before, .rec-table th::before { content: none; }
    .rec-table .ac-sym { display: block; font-size: 10px; }
    /* Show only Company / P-E / Score / Verdict — hide #, Sector, Cap, Mkt cap, ROE, Rev g. */
    .rec-table th:nth-child(1), .rec-table td:nth-child(1),
    .rec-table th:nth-child(3), .rec-table td:nth-child(3),
    .rec-table th:nth-child(4), .rec-table td:nth-child(4),
    .rec-table th:nth-child(5), .rec-table td:nth-child(5),
    .rec-table th:nth-child(7), .rec-table td:nth-child(7),
    .rec-table th:nth-child(8), .rec-table td:nth-child(8) { display: none; }

    /* --- Detail page key/value tables: real 2-col tables, not per-row cards --- */
    .table.mini, .table.mini tbody { display: table; width: 100%; }
    .table.mini tr { display: table-row; background: none; border: 0; padding: 0; margin: 0; }
    .table.mini td {
        display: table-cell; text-align: left; padding: 6px 4px; font-size: 13px;
        white-space: normal; border-bottom: 1px solid var(--border);
    }
    .table.mini td.num { text-align: right; white-space: nowrap; }
    .table.mini td::before { content: none; }

    .rd-stats { grid-template-columns: 1fr; }
    .rd-head { flex-direction: column; }
    .rd-score { align-items: flex-start; }
    .rd-keyline { gap: 10px 16px; font-size: 14px; }
    .pager { gap: 8px; font-size: 13px; }
    .pager .btn { padding: 6px 10px; }
}

/* multi-source confidence badges */
.conf { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); }
.conf-high { color: #2ecc71; border-color: rgba(46,204,113,.5); background: rgba(46,204,113,.12); }
.conf-mixed { color: #e8c34a; border-color: rgba(232,195,74,.5); background: rgba(232,195,74,.12); }
.conf-single { color: var(--muted); }

/* trade-setup grid */
.trade-setup { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px; margin: 6px 0 4px; }
.ts-item { background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px;
    padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.ts-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.ts-val { font-family: var(--font-display); font-size: 17px; font-variant-numeric: tabular-nums; }

/* ── data freshness (Phase D) ─────────────────────────────────────────── */
.asof-badge {
  display: inline-block; font-size: .68rem; padding: .1rem .45rem;
  border-radius: 999px; border: 1px solid rgba(140, 160, 200, .25);
  color: var(--muted, #9aa6c0); vertical-align: middle; white-space: nowrap;
}
.asof-badge.stale { color: #f5a623; border-color: rgba(245, 166, 35, .45); }
.asof-badge.very-stale { color: #ff5d6c; border-color: rgba(255, 93, 108, .45); }
.stale-banner {
  margin: .4rem 0 .8rem; padding: .55rem .8rem; font-size: .82rem;
  border-left: 3px solid #f5a623; background: rgba(245, 166, 35, .08);
  border-radius: 0 8px 8px 0; color: #e8d5b0;
}

/* ── /health/ data-health page ────────────────────────────────────────── */
.health-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.health-card {
  background: var(--card, #171a21); border: 1px solid rgba(140,160,200,.12);
  border-radius: 12px; padding: 1rem 1.2rem;
}
.health-card h2 { margin: 0 0 .6rem; font-size: 1.05rem; }
.health-table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.health-table th, .health-table td { text-align: left; padding: .3rem .5rem; border-bottom: 1px solid rgba(140,160,200,.08); }
.health-table td.num, .health-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.hb-bar { height: 6px; border-radius: 3px; background: rgba(140,160,200,.15); overflow: hidden; min-width: 90px; }
.hb-fill { height: 100%; background: #4f8cff; }
.hb-fill.warn { background: #f5a623; }
.hb-fill.crit { background: #ff5d6c; }
.ok-dot { color: #2ecc71; } .fail-dot { color: #ff5d6c; } .na-dot { color: #9aa6c0; }
.breaker-open { color: #ff5d6c; font-weight: 600; }
@media (max-width: 760px) {
  .health-table { font-size: .72rem; }
  .health-card { padding: .7rem .8rem; }
}

/* ── Ideas facet rail (replaced Categories/Market Cap pages) ─────────── */
.eyebrow {
  font-size: .68rem; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--accent, #4f8cff); margin: 0 0 .2rem;
}
.facet-rail { margin: .8rem 0 .4rem; }
.facet-label {
  display: block; font-size: .66rem; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted, #9aa6c0); margin: .5rem 0 .3rem;
}
.facet-chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.facet-chip {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .74rem; padding: .18rem .6rem; border-radius: 999px;
  border: 1px solid rgba(140,160,200,.22); color: inherit; text-decoration: none;
  transition: border-color .15s, background .15s;
}
.facet-chip:hover { border-color: rgba(140,160,200,.5); }
.facet-chip.active {
  background: rgba(79,140,255,.16); border-color: rgba(79,140,255,.6);
  color: #cfe0ff;
}
.facet-chip .fc-n { font-size: .64rem; color: var(--muted, #9aa6c0); }
@media (max-width: 760px) {
  .facet-chips { overflow-x: auto; flex-wrap: nowrap; padding-bottom: .3rem; }
  .facet-chip { white-space: nowrap; }
}

/* ── dashboard v2: value timeline, collapsed board, viz band, activity ── */
.pf-history .ph-head { display: flex; align-items: baseline; justify-content: space-between; }
.pf-history h2 { margin: 0 0 .4rem; }
.ph-legend { display: flex; gap: .8rem; font-size: .72rem; color: var(--muted, #9aa6c0); }
.ph-key::before { content: ""; display: inline-block; width: 14px; height: 3px; margin-right: .3rem; vertical-align: middle; border-radius: 2px; }
.ph-key.val::before { background: #4f8cff; }
.ph-key.inv::before { background: rgba(154,166,192,.8); }
.ph-chart { position: relative; height: 220px; }
.ph-val { stroke: #4f8cff; stroke-width: 2; }
.ph-val-area { fill: rgba(79,140,255,.12); }
.ph-inv { stroke: rgba(154,166,192,.7); stroke-width: 1.4; stroke-dasharray: 5 4; }
.ph-dot { fill: #4f8cff; }
.ph-tick { font-size: 10px; fill: var(--muted, #9aa6c0); }
.ph-guide { stroke: rgba(154,166,192,.5); stroke-width: 1; stroke-dasharray: 3 3; }
.ph-tip { position: absolute; top: 6px; background: rgba(15,17,21,.92); border: 1px solid rgba(140,160,200,.25);
  padding: .25rem .55rem; border-radius: 6px; font-size: .72rem; pointer-events: none; white-space: nowrap; }

.ab-collapse > summary { list-style: none; cursor: pointer; }
.ab-collapse > summary::-webkit-details-marker { display: none; }
.ab-summary { display: flex; align-items: baseline; gap: .8rem; flex-wrap: wrap; }
.ab-sum-title { font-weight: 700; font-size: 1.02rem; }
.ab-sum-hint { margin-left: auto; }
.ab-collapse[open] .ab-sum-hint { display: none; }
.ab-collapse[open] > summary { margin-bottom: .8rem; }

.viz-band { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
.viz-card h2 { margin: 0 0 .7rem; font-size: 1.02rem; }
.mv-row { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: .5rem; align-items: center;
  font-size: .78rem; padding: .18rem 0; }
.mv-bar { height: 8px; border-radius: 4px; background: rgba(140,160,200,.12); overflow: hidden; }
.mv-fill { display: block; height: 100%; border-radius: 4px; }
.mv-fill.up { background: #2ecc71; } .mv-fill.down { background: #ff5d6c; }
.mv-amt { font-variant-numeric: tabular-nums; white-space: nowrap; }
.dr-row { display: grid; grid-template-columns: minmax(90px, 1fr) 2fr auto; gap: .5rem; align-items: center;
  font-size: .78rem; padding: .22rem 0; }
.dr-track { position: relative; height: 8px; border-radius: 4px; background: rgba(140,160,200,.12); }
.dr-cur { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: #7a5cff; opacity: .85; }
.dr-tgt { position: absolute; top: -3px; bottom: -3px; width: 2px; background: #f5a623; }
.dr-nums { font-variant-numeric: tabular-nums; white-space: nowrap; }

.activity-feed h2 { margin: 0 0 .6rem; font-size: 1.02rem; }
.af-list { list-style: none; margin: 0; padding: 0; }
.af-item { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; padding: .3rem 0;
  border-bottom: 1px solid rgba(140,160,200,.08); font-size: .8rem; }
.af-item:last-child { border-bottom: 0; }
.af-event { font-size: .66rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: .08rem .45rem; border-radius: 999px; border: 1px solid rgba(140,160,200,.3); }
.af-create, .af-reactivate { color: #2ecc71; border-color: rgba(46,204,113,.4); }
.af-delete, .af-deactivate { color: #ff5d6c; border-color: rgba(255,93,108,.4); }
.af-src { font-size: .66rem; color: var(--muted, #9aa6c0); border: 1px dashed rgba(140,160,200,.3);
  padding: .05rem .4rem; border-radius: 999px; }
.af-reco { font-size: .68rem; color: #2ecc71; }
.af-when { margin-left: auto; }

@media (max-width: 760px) {
  .viz-band { grid-template-columns: 1fr; }
  .ph-chart { height: 160px; }
  .mv-row, .dr-row { grid-template-columns: minmax(70px, 1fr) 1.5fr auto; font-size: .7rem; }
}

/* ── agent decision loop (Phase 1) ────────────────────────────────────── */
.nav-badge { display: inline-block; min-width: 1.15rem; text-align: center; font-size: .66rem;
  font-weight: 700; background: #ff5d6c; color: #fff; border-radius: 999px; padding: .05rem .3rem; }
.dec-banner { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap;
  padding: .6rem .9rem; margin-bottom: 1rem; border-radius: 10px; text-decoration: none; color: inherit;
  border: 1px solid rgba(245,166,35,.4); background: rgba(245,166,35,.07); }
.dec-banner:hover { border-color: rgba(245,166,35,.7); }
.dec-banner-dot { width: 8px; height: 8px; border-radius: 50%; background: #f5a623;
  animation: dec-pulse 1.6s ease-in-out infinite; align-self: center; }
@keyframes dec-pulse { 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .dec-banner-dot { animation: none; } }

.dec-list { display: grid; gap: .7rem; }
.dec-card { border: 1px solid rgba(140,160,200,.16); border-radius: 10px; padding: .7rem .9rem; }
.dec-card.slim { padding: .5rem .9rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; justify-content: space-between; }
.dec-head { display: flex; align-items: baseline; gap: .55rem; flex-wrap: wrap; }
.dec-side { font-size: .66rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
  padding: .12rem .5rem; border-radius: 999px; }
.dec-buy { background: rgba(46,204,113,.15); color: #2ecc71; }
.dec-sell, .dec-trim { background: rgba(255,93,108,.15); color: #ff5d6c; }
.dec-switch { background: rgba(122,92,255,.15); color: #a68cff; }
.dec-review { background: rgba(245,166,35,.15); color: #f5a623; }
.dec-band { font-variant-numeric: tabular-nums; color: #cfe0ff; }
.dec-src { border: 1px dashed rgba(140,160,200,.3); border-radius: 999px; padding: .03rem .4rem; }
.dec-why { margin: .35rem 0; font-size: .85rem; line-height: 1.45; }
.dec-meta { margin-bottom: .5rem; }
.dec-actions { display: flex; gap: .5rem; }
.dec-exec { display: flex; gap: .4rem; align-items: center; }
.dec-exec input { width: 130px; }
.dec-st-executed, .dec-st-evaluated { color: #2ecc71; }
.dec-st-rejected { color: #ff5d6c; }
.dec-st-expired { color: var(--muted, #9aa6c0); }
.btn.tiny { font-size: .68rem; padding: .15rem .5rem; }
@media (max-width: 760px) { .dec-card.slim { flex-direction: column; align-items: flex-start; } }

/* benchmark overlay on the value timeline */
.ph-bench { stroke: #f5a623; stroke-width: 1.4; stroke-dasharray: 2 3; opacity: .9; }
.ph-key.bench::before { background: #f5a623; }

/* paper autopilot sleeves */
.sleeve { border: 1px solid rgba(140,160,200,.14); border-radius: 10px; padding: .7rem .9rem; margin-bottom: .8rem; }
.sleeve .dec-head { margin-bottom: .5rem; }
.sleeve .stats { margin: .3rem 0 .6rem; }
.stat-value.tiny { font-size: .72rem; font-weight: 500; }
