/* ================================================================
   stock-report.css — Stock layout, sidebar, header, report sections,
   metric cards, factor lists, score gauges, overview, returns table
   ================================================================ */

    .stock-layout {
        display: flex;
        min-height: 100vh;
        padding-top: var(--nav-h);
    }

    /* ── Sidebar ───────────────────────────────────────────────── */
    .stock-sidebar {
        width: 280px;
        min-width: 280px;
        position: sticky;
        top: var(--nav-h);
        height: calc(100vh - var(--nav-h));
        overflow-y: auto;
        border-right: 1px solid var(--border-subtle);
        padding: 28px 20px;
        display: flex;
        flex-direction: column;
        gap: 24px;
        background: var(--bg);
        z-index: 10;
    }

    .snowflake-wrap {
        display: flex;
        justify-content: center;
    }
    .snowflake-wrap svg {
        width: 240px;
        height: 240px;
        overflow: visible;
    }
    .snowflake-label {
        font-family: var(--font-ui);
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.08em;
        text-transform: uppercase;
        fill: var(--text-secondary);
    }
    .snowflake-grid { stroke: rgba(255,255,255,0.06); fill: none; stroke-width: 1; }
    .snowflake-axis { stroke: rgba(255,255,255,0.06); stroke-width: 1; }
    .snowflake-shape {
        fill: rgba(251,191,36,0.12);
        stroke: rgba(251,191,36,0.55);
        stroke-width: 2;
        stroke-linejoin: round;
        transition: all 0.8s cubic-bezier(0.22, 1, 0.36, 1);
    }
    .snowflake-dot {
        fill: #fbbf24;
        r: 4;
        transition: all 0.8s cubic-bezier(0.22, 1, 0.36, 1);
        cursor: pointer;
    }
    .snowflake-dot:hover { r: 6; fill: #fde68a; }
    .snowflake-center-score {
        font-family: var(--font-mono);
        font-size: 22px;
        font-weight: 600;
        fill: var(--text);
        text-anchor: middle;
        dominant-baseline: central;
    }
    .snowflake-center-label {
        font-family: var(--font-ui);
        font-size: 9px;
        fill: var(--text-secondary);
        text-anchor: middle;
        text-transform: uppercase;
        letter-spacing: 0.1em;
    }

    .sidebar-info { text-align: center; }
    .sidebar-company {
        font-family: 'Instrument Serif', serif;
        font-size: 20px;
        color: var(--text);
        margin-bottom: 4px;
    }
    .sidebar-ticker {
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--text-secondary);
        margin-bottom: 4px;
    }
    .sidebar-mcap {
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--muted);
    }

    .sidebar-actions {
        display: flex;
        gap: 8px;
        justify-content: center;
    }
    .sidebar-actions a {
        font-size: 12px;
        padding: 6px 14px;
        border-radius: var(--radius-pill);
        border: 1px solid var(--border);
        color: var(--text-secondary);
        text-decoration: none;
        transition: all 0.15s;
    }
    .sidebar-actions a:hover {
        background: var(--surface);
        color: var(--text);
        border-color: var(--text-secondary);
    }

    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 2px;
        border-top: 1px solid var(--border-subtle);
        padding-top: 16px;
    }
    .sidebar-nav a {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 12px;
        border-radius: var(--radius-xs);
        color: var(--text-secondary);
        text-decoration: none;
        font-size: 13px;
        font-weight: 400;
        transition: all 0.15s;
        border-left: 3px solid transparent;
        margin-left: -3px;
    }
    .sidebar-nav a:hover {
        color: var(--text);
        background: var(--surface);
    }
    .sidebar-nav a.active {
        color: var(--text);
        border-left-color: var(--blue);
        background: var(--surface);
        font-weight: 500;
    }
    .sidebar-nav .nav-num {
        font-family: var(--font-mono);
        font-size: 11px;
        color: var(--muted);
        width: 16px;
        text-align: right;
    }

    /* ── Main Content ──────────────────────────────────────────── */
    .stock-main {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
    }

    /* ── Hero Header Card (SWS-style) ────────────────────────── */
    .stock-header-bar {
        background: var(--surface);
        border-bottom: 1px solid var(--border-subtle);
        padding: 0;
        display: grid;
        grid-template-columns: 1fr 400px;
        align-items: stretch;
    }
    .header-left {
        display: flex;
        flex-direction: column;
        gap: 6px;
        min-width: 0;
        padding: 24px 28px;
    }
    .header-breadcrumb {
        font-size: 12px;
        color: var(--muted);
    }
    .header-top-row {
        display: flex;
        align-items: center;
        gap: 12px;
        flex-wrap: wrap;
    }
    .header-name {
        font-family: 'Instrument Serif', serif;
        font-size: 26px;
        color: var(--text);
    }
    .header-ticker {
        font-family: var(--font-mono);
        font-size: 12px;
        font-weight: 600;
        color: var(--blue);
        background: var(--blue-dim);
        padding: 2px 8px;
        border-radius: var(--radius-xs);
    }
    .header-meta {
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--muted);
    }
    .header-verdict-row {
        display: flex;
        align-items: center;
        gap: 14px;
        margin-top: 4px;
    }
    .header-price {
        font-family: var(--font-mono);
        font-size: 24px;
        font-weight: 700;
        color: var(--text);
    }
    .header-decision {
        font-family: var(--font-mono);
        font-size: 13px;
        font-weight: 700;
        padding: 5px 16px;
        border-radius: var(--radius-pill);
        text-transform: uppercase;
        letter-spacing: 0.08em;
        white-space: nowrap;
    }
    .header-decision.buy { background: var(--green-dim); color: var(--green); border: 1px solid var(--green-border); }
    .header-decision.sell { background: var(--red-dim); color: var(--red); border: 1px solid var(--red-border); }
    .header-decision.hold { background: var(--amber-dim); color: var(--amber); border: 1px solid var(--amber-border); }

    /* Score Ring */
    .header-score-ring {
        display: inline-flex;
        align-items: center;
        flex-shrink: 0;
    }
    .score-ring-svg {
        width: 48px;
        height: 48px;
        filter: drop-shadow(0 0 10px var(--score-glow));
    }
    .score-ring-bg { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 5; }
    .score-ring-fill { fill: none; stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(0.22, 1, 0.36, 1); }
    .score-ring-text { font-family: var(--font-mono); font-weight: 700; fill: var(--text); text-anchor: middle; dominant-baseline: central; }
    .score-ring-label { font-family: var(--font-mono); fill: var(--muted); text-anchor: middle; letter-spacing: 0.08em; }

    .stock-content {
        padding: 32px 40px;
        max-width: 960px;
    }

    /* ── Sections ──────────────────────────────────────────────── */
    .report-section {
        margin-bottom: 48px;
        scroll-margin-top: calc(var(--nav-h) + 60px);
    }
    .section-head {
        display: flex;
        align-items: center;
        gap: 12px;
        margin-bottom: 20px;
        padding-bottom: 12px;
        border-bottom: 1px solid var(--border-subtle);
    }
    .section-num {
        font-family: var(--font-mono);
        font-size: 12px;
        color: var(--muted);
        width: 22px;
        height: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 50%;
        border: 1px solid var(--border);
        flex-shrink: 0;
    }
    .section-title {
        font-family: 'Instrument Serif', serif;
        font-size: 22px;
        color: var(--text);
        flex: 1;
    }
    .section-score-badge {
        font-family: var(--font-mono);
        font-size: 13px;
        font-weight: 500;
        padding: 4px 12px;
        border-radius: var(--radius-pill);
        white-space: nowrap;
    }
    .score-high { background: var(--green-dim); color: var(--green); }
    .score-mid { background: var(--amber-dim); color: var(--amber); }
    .score-low { background: var(--red-dim); color: var(--red); }

    .section-body { line-height: 1.7; color: var(--text-secondary); font-size: 14px; }
    .section-body p { margin-bottom: 12px; }

    /* ── Overview ──────────────────────────────────────────────── */
    .overview-with-chart { display: grid; grid-template-columns: 1fr 340px; gap: 28px; margin-bottom: 20px; }
    .overview-text-col { min-width: 0; }
    .overview-chart-col { display: flex; flex-direction: column; gap: 8px; }
    .overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
    .rewards-list, .risks-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
    .rewards-list li, .risks-list li { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; line-height: 1.5; }
    .rewards-list li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--green); flex-shrink: 0; margin-top: 5px; }
    .risks-list li::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--red); flex-shrink: 0; margin-top: 5px; }
    .overview-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 10px; }

    /* ── Metric Cards ─────────────────────────────────────────── */
    .metric-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 12px; margin-bottom: 20px; }
    .metric-card { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
    .metric-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
    .metric-value { font-family: var(--font-mono); font-size: 18px; font-weight: 600; color: var(--text); }
    .metric-value.positive { color: var(--green); }
    .metric-value.negative { color: var(--red); }

    /* ── Score Gauge (per section) ────────────────────────────── */
    .section-gauge { margin-bottom: 20px; display: flex; align-items: center; gap: 16px; }
    .section-gauge-bar { flex: 1; height: 8px; background: var(--surface-elevated); border-radius: 4px; overflow: hidden; position: relative; }
    .section-gauge-fill { height: 100%; border-radius: 4px; transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1); }
    .section-gauge-fill.green { background: linear-gradient(90deg, #16a34a, #22c55e); }
    .section-gauge-fill.amber { background: linear-gradient(90deg, #d97706, #f59e0b); }
    .section-gauge-fill.red { background: linear-gradient(90deg, #dc2626, #ef4444); }
    .section-gauge-pct { font-family: var(--font-mono); font-size: 13px; font-weight: 600; min-width: 40px; text-align: right; }

    /* ── Factor List (visual bars) ────────────────────────────── */
    .factor-list { display: flex; flex-direction: column; gap: 6px; }
    .factor-row { display: grid; grid-template-columns: 1fr 120px 55px; align-items: center; gap: 12px; font-size: 13px; padding: 10px 14px; border-radius: var(--radius-xs); background: var(--surface); border: 1px solid var(--border-subtle); }
    .factor-name { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .factor-value { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--text); text-align: right; }
    .factor-bar-wrap { height: 6px; background: var(--surface-elevated); border-radius: 3px; overflow: hidden; }
    .factor-bar { height: 100%; border-radius: 3px; transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
    .factor-bar.green { background: linear-gradient(90deg, #16a34a, #22c55e); }
    .factor-bar.amber { background: linear-gradient(90deg, #d97706, #f59e0b); }
    .factor-bar.red { background: linear-gradient(90deg, #dc2626, #ef4444); }

    /* ── Overview Truncation ──────────────────────────────────── */
    .overview-text { max-height: 120px; overflow: hidden; position: relative; transition: max-height 0.3s ease; }
    .overview-text.expanded { max-height: 2000px; }
    .overview-text::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 40px; background: linear-gradient(transparent, var(--bg)); pointer-events: none; transition: opacity 0.3s; }
    .overview-text.expanded::after { opacity: 0; }
    .expand-btn { font-size: 12px; color: var(--blue); background: none; border: none; cursor: pointer; padding: 8px 0; font-family: var(--font-ui); }
    .expand-btn:hover { text-decoration: underline; }

    /* ── Valuation Gauge ──────────────────────────────────────── */
    .gauge-container { margin: 20px 0; }
    .gauge-track { position: relative; height: 40px; border-radius: 8px; background: linear-gradient(to right, rgba(239,68,68,0.25) 0%, rgba(245,158,11,0.15) 35%, rgba(34,197,94,0.25) 50%, rgba(245,158,11,0.15) 65%, rgba(239,68,68,0.25) 100%); border: 1px solid var(--border-subtle); display: flex; align-items: center; }
    .gauge-marker { position: absolute; width: 3px; height: 52px; background: var(--text); border-radius: 2px; top: -6px; transition: left 0.8s cubic-bezier(0.22, 1, 0.36, 1); }
    .gauge-marker::after { content: attr(data-label); position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-family: var(--font-mono); font-size: 11px; font-weight: 600; color: var(--text); white-space: nowrap; }
    .gauge-label { position: absolute; top: -20px; font-family: var(--font-mono); font-size: 10px; color: var(--muted); }
    .gauge-label.bear { left: 0; }
    .gauge-label.base { left: 50%; transform: translateX(-50%); color: var(--green); }
    .gauge-label.bull { right: 0; }
    .gauge-verdict { margin-top: 28px; font-family: var(--font-mono); font-size: 14px; font-weight: 500; }
    .gauge-verdict.undervalued { color: var(--green); }
    .gauge-verdict.overvalued { color: var(--red); }
    .gauge-verdict.fair { color: var(--amber); }

    /* ── Returns Table ────────────────────────────────────────── */
    .returns-table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 16px 0; }
    .returns-table th { font-family: var(--font-mono); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 8px 12px; text-align: right; border-bottom: 1px solid var(--border-subtle); }
    .returns-table th:first-child { text-align: left; }
    .returns-table td { font-family: var(--font-mono); padding: 10px 12px; text-align: right; border-bottom: 1px solid var(--border-subtle); }
    .returns-table td:first-child { text-align: left; color: var(--text-secondary); font-family: var(--font-ui); }
    .returns-table td.positive { color: var(--green); }
    .returns-table td.negative { color: var(--red); }

    /* ── Section Subtitle ────────────────────────────────────── */
    .section-subtitle { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 16px; }

    /* ── Side-by-side valuation comparison ────────────────── */
    .val-split { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-subtle); }
    @media (max-width: 800px) { .val-split { grid-template-columns: 1fr; } }
    .val-panel { padding: 20px; background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius); }
    .val-panel-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 12px; }
    .val-panel-verdict { font-family: var(--font-mono); font-size: 22px; font-weight: 700; margin-bottom: 6px; }
    .val-panel-verdict.undervalued { color: var(--green); }
    .val-panel-verdict.overvalued { color: var(--red); }
    .val-panel-verdict.fair { color: var(--amber); }
    .val-panel-detail { font-size: 12px; color: var(--text-secondary); line-height: 1.5; margin-bottom: 14px; }
    .val-panel .returns-table { font-size: 12px; }
    .val-panel .returns-table td, .val-panel .returns-table th { padding: 6px 8px; }
    .val-score-ring { display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 56px; border-radius: 50%; border: 3px solid; font-family: var(--font-mono); font-size: 18px; font-weight: 700; margin-bottom: 10px; }
    .val-score-ring.high { border-color: var(--green); color: var(--green); }
    .val-score-ring.mid { border-color: var(--amber); color: var(--amber); }
    .val-score-ring.low { border-color: var(--red); color: var(--red); }
    .val-factor-row { display: flex; flex-direction: column; gap: 4px; padding: 8px 0; border-bottom: 1px solid var(--border-subtle); font-size: 12px; }
    .val-factor-row:last-child { border-bottom: none; }
    .val-factor-top { display: flex; justify-content: space-between; align-items: center; }
    .val-factor-name { color: var(--text-secondary); }
    .val-factor-score { font-family: var(--font-mono); font-size: 11px; font-weight: 500; color: var(--muted); }
    .val-factor-bar { height: 6px; border-radius: 3px; background: var(--border-subtle); overflow: hidden; }
    .val-factor-bar-fill { height: 100%; border-radius: 3px; transition: width 0.5s ease; }
    .val-factor-bar-fill.green { background: var(--green); }
    .val-factor-bar-fill.amber { background: var(--amber); }
    .val-factor-bar-fill.red { background: var(--red); }

    /* ── Price vs Value bars ──────────────────────────────────── */
    .pvv-container { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-subtle); }
    .pvv-title { font-family: var(--font-ui); font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
    .pvv-subtitle { font-size: 13px; color: var(--text-secondary); margin-bottom: 16px; line-height: 1.5; }
    .pvv-annotation { font-family: var(--font-mono); font-size: 20px; font-weight: 700; margin-bottom: 14px; }
    .pvv-annotation.undervalued { color: var(--green); }
    .pvv-annotation.overvalued { color: var(--red); }
    .pvv-annotation.fair { color: var(--amber); }
    .pvv-bars { display: flex; flex-direction: column; gap: 10px; }
    .pvv-bar { display: flex; align-items: center; gap: 12px; }
    .pvv-bar-label { font-size: 12px; color: var(--text-secondary); width: 100px; text-align: right; flex-shrink: 0; }
    .pvv-bar-track { flex: 1; height: 38px; background: var(--surface); border-radius: var(--radius-sm); overflow: hidden; }
    .pvv-bar.current .pvv-bar-fill { height: 100%; border-radius: var(--radius-sm); background: linear-gradient(90deg, rgba(251,191,36,0.15), rgba(251,191,36,0.35)); border-right: 3px solid var(--amber); }
    .pvv-bar.fair .pvv-bar-fill { height: 100%; border-radius: var(--radius-sm); background: linear-gradient(90deg, rgba(34,197,94,0.12), rgba(34,197,94,0.3)); border-right: 3px solid var(--green); }
    .pvv-bar-value { font-family: var(--font-mono); font-size: 14px; font-weight: 600; color: var(--text); width: 80px; flex-shrink: 0; }

        /* ── Quant-only banner ──────────────────────────────────── */
    .quant-only-banner {
        display: flex;
        align-items: flex-start;
        gap: 14px;
        padding: 16px 20px;
        margin-bottom: 24px;
        background: rgba(59,130,246,0.06);
        border: 1px solid rgba(59,130,246,0.15);
        border-radius: var(--radius-sm);
        font-size: 13px;
        color: var(--text-secondary);
        line-height: 1.6;
    }
    .quant-only-banner strong { color: var(--text); }
    .quant-only-icon { color: var(--blue); flex-shrink: 0; margin-top: 1px; }

    /* ── TradingView Widget ──────────────────────────────────── */
    .tv-widget-container {
        width: 100%;
        margin: 16px 0;
        border-radius: var(--radius-sm);
        overflow: hidden;
        border: 1px solid var(--border-subtle);
    }

    @media (max-width: 900px) {
        .stock-header-bar { grid-template-columns: 1fr; }
        .overview-with-chart { grid-template-columns: 1fr; }
    }
