/* ═══════════════════════════════════════════════════════════════
   DETAILED VIEW — Long-form reading layout
   Matches the app-wide design system (Inter / white / blue)
   ═══════════════════════════════════════════════════════════════ */

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f4;
    --bg-card: #ffffff;
    --border-primary: #e1e4e8;
    --border-secondary: #d0d7de;
    --text-primary: #1f2328;
    --text-secondary: #57606a;
    --text-muted: #8b949e;
    --accent-blue: #0066FF;
    --accent-green: #1a7f37;
    --accent-yellow: #9a6700;
    --accent-red: #cf222e;
    --accent-purple: #6f42c1;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;
    --dv-col-width: 820px;
    --dv-sidebar-width: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { overflow-x: hidden; max-width: 100vw; }

body.detailed-view {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

/* ── Reading Progress ── */
.reading-progress {
    position: fixed; top: 0; left: 0; height: 3px; width: 0%;
    background: var(--accent-blue);
    z-index: 1100; transition: width 0.15s ease;
}

/* ── Top Navigation — matches full_report.html ── */
.top-nav {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: 64px;
    background: rgba(255, 255, 255, 0.97);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-primary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    z-index: 1000;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 600;
    font-size: 16px;
    text-decoration: none;
    color: var(--text-primary);
}
.nav-brand i { color: var(--accent-blue); }

.nav-meta {
    display: flex;
    align-items: center;
    gap: 24px;
    font-size: 13px;
    color: var(--text-muted);
}
.nav-meta span { display: flex; align-items: center; gap: 6px; }

/* ── Layout ── */
.main-container {
    margin-top: 64px;
    display: flex;
    overflow-x: hidden;
}

/* ── Sidebar — matches full_report.html & analysis_progressive.html ── */
.sidebar {
    width: var(--dv-sidebar-width);
    height: calc(100vh - 64px);
    position: fixed;
    left: 0; top: 64px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    padding: 20px 12px;
    overflow-y: auto;
}
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-primary); border-radius: 2px; }

.sidebar-section { margin-bottom: 20px; }

.sidebar-title {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 10px;
    padding-left: 12px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.15s;
    font-size: 13px;
    margin-bottom: 2px;
    text-decoration: none;
}
.sidebar-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}
.sidebar-item.active {
    background: rgba(0, 102, 255, 0.08);
    color: var(--accent-blue);
}
.sidebar-item i { width: 16px; text-align: center; font-size: 12px; }

.sidebar-views {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-primary);
}
.sidebar-views .sidebar-item {
    font-size: 12px;
    color: var(--text-muted);
    padding: 8px 12px;
}
.sidebar-views .sidebar-item:hover { color: var(--accent-blue); }

/* ── Content Area ── */
.content {
    margin-left: var(--dv-sidebar-width);
    padding: 32px 48px;
    max-width: calc(var(--dv-col-width) + 96px);
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
    overflow-wrap: break-word;
    word-wrap: break-word;
}

/* ── Stock Header — matches full_report.html ── */
.stock-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-primary);
}
.stock-info { display: flex; gap: 16px; align-items: center; }
.stock-logo {
    width: 64px; height: 64px;
    background: linear-gradient(135deg, #0066FF 0%, #218bff 100%);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 800; color: white;
}
.stock-details h1 {
    font-size: 24px; font-weight: 700; margin-bottom: 2px;
}
.stock-details .subtitle {
    color: var(--text-secondary); font-size: 14px;
}

/* ── Key Facts Strip ── */
.dv-keyfacts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1px;
    background: var(--border-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    margin-bottom: 32px;
    overflow: hidden;
}
.dv-keyfact {
    background: var(--bg-primary);
    padding: 14px 16px;
    text-align: center;
}
.dv-keyfact-label {
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-muted); margin-bottom: 4px;
}
.dv-keyfact-value {
    font-size: 18px; font-weight: 700; color: var(--text-primary);
}

/* ── Section Dividers ── */
.dv-section-divider {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 44px 0 20px;
    margin-bottom: 0;
}

/* ── Section Hook — key insight callout ── */
.dv-section-hook {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    margin: 8px 0 24px;
    padding: 14px 18px;
    background: linear-gradient(135deg, rgba(0,102,255,0.04) 0%, rgba(0,102,255,0.02) 100%);
    border-left: 3px solid var(--accent-blue);
    border-radius: 0 10px 10px 0;
    font-size: 14px;
    line-height: 1.65;
    color: var(--text-secondary);
}
.dv-section-hook-icon {
    flex-shrink: 0;
    margin-top: 1px;
    font-size: 13px;
    color: var(--accent-blue);
    opacity: 0.8;
}
.dv-section-hook-text {
    font-style: italic;
}
.dv-section-num {
    font-size: 11px; font-weight: 700;
    color: var(--accent-blue); letter-spacing: 1px;
    min-width: 20px;
}
.dv-section-label {
    font-size: 22px; font-weight: 700;
    color: var(--text-primary); line-height: 1.2;
    letter-spacing: -0.2px;
}
.dv-section-line {
    flex: 1; height: 1px; background: var(--border-primary);
}

/* ── Prose Content: readable long-form text ── */
.dv-prose {
    font-family: var(--font-sans);
    font-size: 15px;
    line-height: 1.75;
    color: var(--text-secondary);
}
.dv-prose p { margin-bottom: 16px; }
.dv-prose h1 {
    font-size: 22px; font-weight: 700; color: var(--text-primary);
    margin: 32px 0 12px; line-height: 1.3;
}
.dv-prose h2 {
    font-size: 18px; font-weight: 700; color: var(--text-primary);
    margin: 28px 0 10px; line-height: 1.3;
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-primary);
}
.dv-prose h3 {
    font-size: 15px; font-weight: 700;
    color: var(--text-primary); margin: 24px 0 8px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.dv-prose h4 {
    font-size: 13px; font-weight: 700;
    color: var(--text-secondary); margin: 20px 0 8px;
}
.dv-prose ul, .dv-prose ol { margin: 0 0 16px; padding-left: 24px; }
.dv-prose li { margin-bottom: 6px; }
.dv-prose strong { color: var(--text-primary); font-weight: 700; }
.dv-prose em { font-style: italic; }
.dv-prose blockquote {
    border-left: 3px solid var(--accent-blue);
    padding: 12px 0 12px 20px;
    margin: 20px 0;
    font-style: italic;
    color: var(--text-secondary);
    background: rgba(0, 102, 255, 0.04);
    border-radius: 0 8px 8px 0;
}
.dv-prose hr {
    border: none; height: 1px; background: var(--border-primary);
    margin: 28px 0;
}
.dv-prose table {
    width: 100%; border-collapse: collapse; margin: 18px 0;
    font-size: 13px;
}
.dv-prose table th {
    text-align: left; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.5px;
    color: var(--text-muted); padding: 10px 12px;
    border-bottom: 2px solid var(--text-primary);
    background: transparent;
}
.dv-prose table td {
    padding: 10px 12px; border-bottom: 1px solid var(--border-primary);
    color: var(--text-secondary); vertical-align: top;
}
.dv-prose table tr:hover { background: var(--bg-tertiary); }
.dv-prose pre {
    font-family: var(--font-mono); font-size: 13px; line-height: 1.6;
    background: var(--bg-secondary); border: 1px solid var(--border-primary);
    border-radius: 8px; padding: 16px 20px;
    overflow-x: auto; margin: 16px 0;
    white-space: pre-wrap; word-wrap: break-word;
}
.dv-prose code {
    font-family: var(--font-mono); font-size: 13px;
    background: var(--bg-secondary); padding: 2px 6px; border-radius: 4px;
}

/* ── Callout Boxes ── */
.dv-callout {
    padding: 18px 22px;
    border-radius: 12px;
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.65;
}
.dv-callout-verdict {
    background: rgba(0, 102, 255, 0.05);
    border: 1px solid rgba(0, 102, 255, 0.15);
}
.dv-callout-green {
    background: rgba(26, 127, 55, 0.05);
    border: 1px solid rgba(26, 127, 55, 0.15);
}
.dv-callout-red {
    background: rgba(207, 34, 46, 0.05);
    border: 1px solid rgba(207, 34, 46, 0.15);
}
.dv-callout-amber {
    background: rgba(154, 103, 0, 0.05);
    border: 1px solid rgba(154, 103, 0, 0.15);
}
.dv-callout-title {
    font-weight: 700; font-size: 11px; text-transform: uppercase;
    letter-spacing: 0.8px; margin-bottom: 6px;
}
.dv-callout-verdict .dv-callout-title { color: var(--accent-blue); }
.dv-callout-green .dv-callout-title { color: var(--accent-green); }
.dv-callout-red .dv-callout-title { color: var(--accent-red); }
.dv-callout-amber .dv-callout-title { color: var(--accent-yellow); }

/* ── Investor Opinions ── */
.dv-investor-opinion {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-primary);
}
.dv-investor-opinion:last-child { border-bottom: none; }
.dv-investor-name-line {
    font-size: 14px; font-weight: 700;
    color: var(--text-primary); margin-bottom: 3px;
    display: flex; align-items: center; gap: 10px;
}
.dv-investor-stance {
    font-size: 11px; font-weight: 600;
    padding: 2px 8px; border-radius: 4px;
}
.dv-investor-stance-buy { background: rgba(26,127,55,0.08); color: var(--accent-green); }
.dv-investor-stance-sell { background: rgba(207,34,46,0.08); color: var(--accent-red); }
.dv-investor-stance-hold { background: rgba(154,103,0,0.08); color: var(--accent-yellow); }
.dv-investor-meta {
    font-size: 12px; color: var(--text-muted); margin-bottom: 10px;
}
.dv-investor-thesis {
    font-size: 14px; line-height: 1.7; color: var(--text-secondary);
}
.dv-investor-thesis p { margin-bottom: 10px; }
.dv-investor-details {
    margin-top: 12px; padding-top: 12px;
    border-top: 1px solid var(--border-primary);
}
.dv-investor-detail-section { margin-bottom: 12px; }
.dv-investor-detail-section h4 {
    font-size: 11px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-muted); margin-bottom: 6px;
}
.dv-investor-detail-section ul {
    padding-left: 18px; font-size: 14px;
    line-height: 1.65; color: var(--text-secondary);
}
.dv-investor-detail-section li { margin-bottom: 4px; }

/* ── Chart Figures ── */
.dv-figure {
    margin: 24px 0; padding: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.dv-figure-caption {
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--text-muted); margin-bottom: 14px;
    padding-bottom: 8px; border-bottom: 1px solid var(--border-primary);
}
.dv-figure-note {
    font-size: 12px; color: var(--text-muted);
    margin-top: 10px; font-style: italic; line-height: 1.5;
}

/* ── Debate Styling ── */
.dv-debate-transcript {
    font-size: 14px; line-height: 1.75;
}
.dv-debate-transcript p { margin-bottom: 14px; }
.dv-debate-transcript strong { color: var(--text-primary); }
.dv-debate-transcript blockquote {
    border-left: 3px solid var(--accent-blue);
    padding: 8px 0 8px 18px;
    margin: 14px 0; font-style: italic;
    background: rgba(0,102,255,0.04);
    border-radius: 0 8px 8px 0;
}

/* ── Preformatted Blocks ── */
.dv-preformatted {
    font-family: var(--font-mono); font-size: 12px; line-height: 1.65;
    background: var(--bg-secondary); border: 1px solid var(--border-primary);
    border-radius: 8px; padding: 18px 22px;
    overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;
    color: var(--text-secondary);
}

/* ── Investor Activity Table ── */
.dv-investor-activity-table {
    width: 100%; border-collapse: collapse; margin: 16px 0;
    font-size: 13px;
}
.dv-investor-activity-table th {
    text-align: left; font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.6px;
    color: var(--text-muted); padding: 10px 12px;
    border-bottom: 2px solid var(--text-primary); background: transparent;
}
.dv-investor-activity-table td {
    padding: 10px 12px; border-bottom: 1px solid var(--border-primary);
    color: var(--text-secondary);
}
.dv-investor-activity-table tr:hover { background: var(--bg-tertiary); }
.dv-badge-buy {
    display: inline-block; font-size: 10px; font-weight: 600;
    padding: 2px 8px; border-radius: 4px;
    background: rgba(26,127,55,0.08); color: var(--accent-green);
}
.dv-badge-sell {
    display: inline-block; font-size: 10px; font-weight: 600;
    padding: 2px 8px; border-radius: 4px;
    background: rgba(207,34,46,0.08); color: var(--accent-red);
}

/* ── Footer ── */
.dv-footer {
    padding: 24px 0; margin-top: 40px;
    border-top: 1px solid var(--border-primary);
    font-size: 12px;
    color: var(--text-muted); line-height: 1.6;
}

/* ── Back to Top ── */
.dv-back-to-top {
    position: fixed; bottom: 28px; right: 28px;
    width: 38px; height: 38px; border-radius: 50%;
    background: var(--accent-blue); color: white;
    border: none; cursor: pointer; font-size: 14px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none;
    transition: opacity 0.25s; z-index: 800;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.dv-back-to-top.visible { opacity: 1; pointer-events: auto; }

/* ── Print ── */
@media print {
    .top-nav, .sidebar, .dv-back-to-top, .reading-progress { display: none !important; }
    .main-container { display: block; }
    .content { margin-left: 0; max-width: 100%; }
    body.detailed-view { font-size: 11pt; background: white; }
    .dv-figure { break-inside: avoid; }
}

/* ── Responsive ── */
@media (max-width: 1024px) {
    .sidebar { display: none; }
    .content { margin-left: 0; padding: 24px 28px; max-width: 100%; }
}
@media (max-width: 600px) {
    .dv-keyfacts { grid-template-columns: repeat(2, 1fr); }
    .stock-header { flex-direction: column; gap: 16px; }
    .content { padding: 16px 20px; }
    .top-nav { padding: 0 16px; }
}
