/* ══════════════════════════════════════════════════════════════════
   report.css — beautiful branded research report
   Used by the live preview in index.html AND the public view at view.php.
   Modeled on the social tool's gold-standard report template.

   Design principles:
   - Each top-level section is its own "page" (min-height: 100vh on screen,
     page-break-after: always for print). This eliminates blank-gap pages.
   - All charts are PNG URLs from QuickChart.io — print perfectly with no
     JS dependency, render identically in browser and PDF.
   - Reveal animations via IntersectionObserver (added by report-renderer.js).
   - Brand color drives a 4-stop gradient used throughout.
   ══════════════════════════════════════════════════════════════════ */

:root {
    --r-brand:      #2563eb;
    --r-brand-rgb:  37, 99, 235;
    --r-brand-dark: #1e3a8a;
    --r-brand-deep: #0b1220;
    --r-text:       #0f172a;
    --r-text-soft:  #334155;
    --r-text-mute:  #64748b;
    --r-text-faint: #94a3b8;
    --r-bg:         #f4f6fb;
    --r-card:       #ffffff;
    --r-border:     #e2e8f0;
    --r-border-soft:#f1f5f9;
    --r-radius:     14px;
    --r-radius-lg:  20px;
    --r-shadow-sm:  0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.05);
    --r-shadow-md:  0 4px 14px rgba(15, 23, 42, 0.08), 0 2px 4px rgba(15, 23, 42, 0.04);
    --r-shadow-lg:  0 18px 48px rgba(15, 23, 42, 0.14), 0 4px 12px rgba(15, 23, 42, 0.06);
}

.report-preview,
.r-report {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji';
    color: var(--r-text);
    -webkit-font-smoothing: antialiased;
    line-height: 1.55;
}

/* ════════════════════════ PAGE / SECTION ════════════════════════ */
.r-page {
    background: var(--r-card);
    border-radius: var(--r-radius);
    box-shadow: var(--r-shadow-md);
    margin: 0 auto 28px;
    overflow: hidden;
    position: relative;
    max-width: 820px;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
}
.r-page:last-child {
    page-break-after: auto;
    margin-bottom: 0;
}
.r-page-pad {
    padding: 56px 64px;
}
@media (max-width: 720px) {
    .r-page-pad { padding: 32px 24px; }
}

/* ════════════════════════ COVER PAGE ════════════════════════ */
.r-cover {
    background:
        radial-gradient(900px 600px at 50% 20%, rgba(255, 255, 255, 0.18), transparent 60%),
        radial-gradient(600px 400px at 80% 100%, rgba(255, 255, 255, 0.10), transparent 60%),
        linear-gradient(165deg, var(--r-brand) 0%, var(--r-brand-dark) 55%, var(--r-brand-deep) 100%);
    color: #ffffff;
    padding: 8% 9% 6%;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    min-height: 760px;
}
.r-cover::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 40%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse 70% 60% at 50% 30%, #000 40%, transparent 85%);
    pointer-events: none;
}
.r-cover-particles {
    position: absolute; inset: 0;
    overflow: hidden;
    pointer-events: none;
}
.r-cover-particle {
    position: absolute;
    bottom: -20px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.5);
    animation: rCoverFloat linear infinite;
}
@keyframes rCoverFloat {
    0%   { transform: translateY(0)    translateX(0); opacity: 0; }
    10%  { opacity: var(--p-opacity, 0.7); }
    90%  { opacity: var(--p-opacity, 0.7); }
    100% { transform: translateY(-110%) translateX(var(--p-drift, 0px)); opacity: 0; }
}
.r-cover > * { position: relative; z-index: 2; }

.r-cover-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: auto;
    gap: 16px;
}
.r-cover-logo {
    min-width: 60px; min-height: 60px;
    max-width: 240px; max-height: 80px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.24);
    display: grid; place-items: center;
    padding: 12px 16px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
.r-cover-logo svg { width: 32px; height: 32px; color: #fff; }
.r-cover-brand-img {
    max-width: 200px;
    max-height: 56px;
    width: auto;
    height: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.25));
}

/* Top-right column: client logo (if any) + Research Report pill */
.r-cover-top-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    flex-shrink: 0;
}
.r-cover-client-logo {
    background: rgba(255, 255, 255, 0.96);
    border-radius: 14px;
    padding: 10px 16px 12px;
    text-align: center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.4);
    max-width: 240px;
}
.r-cover-client-label {
    font-size: 8px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--r-text-mute, #64748b);
    margin-bottom: 6px;
}
.r-cover-client-img {
    max-width: 200px;
    max-height: 56px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
.r-cover-pill {
    padding: 7px 16px;
    background: rgba(0, 0, 0, 0.32);
    border: 1px solid rgba(255, 255, 255, 0.24);
    border-radius: 100px;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.92);
}

.r-cover-middle {
    margin: 60px 0 auto;
}
.r-cover-eyebrow {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.24em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.55);
    margin-bottom: 18px;
}
.r-cover-title {
    font-size: clamp(34px, 5.5vw, 64px);
    font-weight: 900;
    line-height: 1.04;
    letter-spacing: -0.025em;
    margin: 0 0 16px;
    max-width: 92%;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}
.r-cover-subtitle {
    font-size: clamp(14px, 1.8vw, 19px);
    font-weight: 400;
    color: rgba(255, 255, 255, 0.78);
    line-height: 1.55;
    max-width: 78%;
}

.r-cover-divider {
    height: 3px;
    width: 80px;
    background: linear-gradient(90deg, #fff, rgba(255, 255, 255, 0));
    margin: 40px 0 22px;
    border-radius: 2px;
}

.r-cover-meta {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 28px;
    padding-top: 4px;
}
.r-cover-meta-label {
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.5);
    margin-bottom: 8px;
}
.r-cover-meta-value {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.005em;
}

.r-cover-footer-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--r-brand), #ffffff, var(--r-brand));
    opacity: 0.85;
}

/* ════════════════════════ TABLE OF CONTENTS ════════════════════════ */
.r-toc-eyebrow {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 28px;
}
.r-toc-eyebrow-bar {
    width: 4px; height: 26px;
    background: var(--r-brand);
    border-radius: 2px;
}
.r-toc-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--r-text-mute);
}
.r-toc-h1 {
    font-size: 34px;
    font-weight: 900;
    letter-spacing: -0.02em;
    margin: 0;
    color: var(--r-text);
}

.r-toc-list { list-style: none; margin: 0; padding: 0; }
.r-toc-item {
    display: flex; align-items: baseline;
    padding: 16px 0;
    border-bottom: 1px dashed var(--r-border);
    font-size: 14px;
}
.r-toc-num {
    font-size: 11px;
    font-weight: 900;
    color: var(--r-brand);
    letter-spacing: 0.04em;
    margin-right: 18px;
    min-width: 26px;
}
.r-toc-text { flex: 1; font-weight: 700; color: var(--r-text); }
.r-toc-page {
    font-size: 12px;
    font-weight: 800;
    color: var(--r-brand);
    min-width: 24px;
    text-align: right;
}

/* ════════════════════════ SECTION HEADER ════════════════════════ */
.r-section-eyebrow-row {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 8px;
}
.r-section-eyebrow {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--r-brand);
    background: rgba(var(--r-brand-rgb), 0.08);
    border: 1px solid rgba(var(--r-brand-rgb), 0.2);
    padding: 5px 12px;
    border-radius: 100px;
}
.r-section-num {
    font-size: 11px;
    font-weight: 900;
    color: var(--r-text-faint);
    letter-spacing: 0.06em;
}
.r-section-title {
    font-size: 30px;
    font-weight: 900;
    letter-spacing: -0.02em;
    color: var(--r-text);
    margin: 0 0 14px;
    line-height: 1.1;
}
.r-section-subtitle {
    font-size: 14px;
    color: var(--r-text-mute);
    margin: 0 0 28px;
    max-width: 92%;
    line-height: 1.55;
}

/* ════════════════════════ BODY TYPOGRAPHY ════════════════════════ */
.r-body {
    font-size: 14px;
    line-height: 1.72;
    color: var(--r-text-soft);
    orphans: 3;
    widows: 3;
}
.r-body p { margin: 0 0 14px; }
.r-body p:last-child { margin-bottom: 0; }
.r-body strong { color: var(--r-text); font-weight: 700; }
.r-body em { font-style: italic; color: var(--r-text-mute); }
.r-body a { color: var(--r-brand); text-decoration: underline; text-underline-offset: 3px; }
.r-body code {
    font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace;
    font-size: 12px;
    background: var(--r-border-soft);
    padding: 1px 6px;
    border-radius: 4px;
}

/* ════════════════════════ STAT TILES ════════════════════════ */
.r-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin: 24px 0 28px;
    page-break-inside: avoid;
    break-inside: avoid;
}
.r-stat {
    padding: 26px 22px;
    background: var(--r-card);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    box-shadow: var(--r-shadow-sm);
    position: relative;
    overflow: hidden;
}
.r-stat::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--r-brand), var(--r-brand-dark));
}
.r-stat-value {
    font-size: 38px;
    font-weight: 900;
    color: var(--r-text);
    letter-spacing: -0.025em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.r-stat-suffix { font-size: 22px; color: var(--r-brand); margin-left: 2px; }
.r-stat-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--r-text-mute);
    margin-top: 8px;
}
.r-stat-delta {
    font-size: 11px;
    font-weight: 700;
    color: #059669;
    margin-top: 6px;
}
.r-stat-delta.down { color: #dc2626; }

/* Highlight stat (filled) */
.r-stat.highlight {
    background: linear-gradient(165deg, var(--r-brand) 0%, var(--r-brand-dark) 100%);
    border-color: transparent;
    color: #fff;
}
.r-stat.highlight::before { display: none; }
.r-stat.highlight .r-stat-value { color: #fff; }
.r-stat.highlight .r-stat-suffix { color: rgba(255, 255, 255, 0.7); }
.r-stat.highlight .r-stat-label { color: rgba(255, 255, 255, 0.75); }

/* ════════════════════════ BULLETS ════════════════════════ */
.r-bullets {
    list-style: none;
    margin: 16px 0 24px;
    padding: 0;
}
.r-bullets li {
    position: relative;
    padding: 14px 16px 14px 44px;
    margin-bottom: 8px;
    background: var(--r-card);
    border: 1px solid var(--r-border);
    border-left: 3px solid var(--r-brand);
    border-radius: 0 10px 10px 0;
    font-size: 13.5px;
    color: var(--r-text-soft);
    line-height: 1.6;
    page-break-inside: avoid;
    break-inside: avoid;
}
.r-bullets li::before {
    content: '';
    position: absolute;
    left: 16px; top: 19px;
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--r-brand);
    box-shadow: 0 0 0 3px rgba(var(--r-brand-rgb), 0.18);
}

/* ════════════════════════ CALLOUT ════════════════════════ */
.r-callout {
    padding: 22px 26px;
    background: linear-gradient(135deg, rgba(var(--r-brand-rgb), 0.05), rgba(var(--r-brand-rgb), 0.02));
    border: 1px solid rgba(var(--r-brand-rgb), 0.15);
    border-left: 4px solid var(--r-brand);
    border-radius: 0 12px 12px 0;
    margin: 24px 0;
    page-break-inside: avoid;
    break-inside: avoid;
}
.r-callout-label {
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.16em;
    color: var(--r-brand);
    margin-bottom: 8px;
}
.r-callout-text {
    font-size: 15px;
    color: var(--r-text);
    line-height: 1.6;
    font-weight: 500;
}

/* ════════════════════════ QUOTE ════════════════════════ */
.r-quote {
    padding: 32px 36px 28px;
    background: linear-gradient(165deg, var(--r-brand-dark), var(--r-brand-deep));
    color: #fff;
    border-radius: var(--r-radius);
    margin: 28px 0;
    font-size: 17px;
    font-style: italic;
    line-height: 1.55;
    position: relative;
    page-break-inside: avoid;
    break-inside: avoid;
    box-shadow: 0 18px 40px rgba(11, 18, 32, 0.25);
}
.r-quote::before {
    content: '\201C';
    position: absolute;
    top: 8px; left: 18px;
    font-size: 80px;
    color: rgba(255, 255, 255, 0.15);
    font-family: Georgia, serif;
    line-height: 1;
}
.r-quote-text { position: relative; padding-left: 14px; }
.r-quote-cite {
    display: block;
    margin-top: 14px;
    font-size: 11px;
    font-style: normal;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.06em;
    text-transform: uppercase;
    font-weight: 700;
}

/* ════════════════════════ CHART ════════════════════════ */
.r-chart {
    margin: 24px 0;
    padding: 24px 28px;
    background: var(--r-card);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    box-shadow: var(--r-shadow-sm);
    page-break-inside: avoid;
    break-inside: avoid;
}
.r-chart-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--r-text-mute);
    margin-bottom: 6px;
}
.r-chart-title {
    font-size: 17px;
    font-weight: 800;
    color: var(--r-text);
    margin: 0 0 18px;
    letter-spacing: -0.01em;
}
.r-chart-img {
    display: block;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 8px;
}
.r-chart-caption {
    margin-top: 12px;
    font-size: 11px;
    color: var(--r-text-faint);
    font-style: italic;
}

/* ════════════════════════ GLOSSARY ════════════════════════ */
.r-glossary {
    margin: 24px 0;
    background: var(--r-card);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    box-shadow: var(--r-shadow-sm);
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
}
.r-glossary-header {
    padding: 18px 24px;
    background: linear-gradient(180deg, var(--r-border-soft), var(--r-card));
    border-bottom: 1px solid var(--r-border);
}
.r-glossary-label {
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--r-brand);
}
.r-glossary-title {
    font-size: 18px;
    font-weight: 800;
    color: var(--r-text);
    margin: 4px 0 0;
    letter-spacing: -0.01em;
}
.r-glossary-scroll {
    max-height: 360px;
    overflow-y: auto;
    padding: 10px 0;
}
.r-glossary-item {
    padding: 14px 24px;
    border-bottom: 1px solid var(--r-border-soft);
}
.r-glossary-item:last-child { border-bottom: none; }
.r-glossary-term {
    font-size: 13px;
    font-weight: 800;
    color: var(--r-brand);
    margin-bottom: 4px;
}
.r-glossary-def {
    font-size: 12.5px;
    color: var(--r-text-soft);
    line-height: 1.6;
}
@media print {
    .r-glossary-scroll { max-height: none; overflow: visible; }
}

/* ════════════════════════ SOURCES ════════════════════════ */
.r-sources { list-style: none; margin: 16px 0 0; padding: 0; counter-reset: r-src; }
.r-source {
    padding: 16px 18px 16px 56px;
    margin-bottom: 12px;
    background: var(--r-card);
    border: 1px solid var(--r-border);
    border-radius: var(--r-radius);
    position: relative;
    page-break-inside: avoid;
    break-inside: avoid;
    box-shadow: var(--r-shadow-sm);
}
.r-source::before {
    counter-increment: r-src;
    content: counter(r-src);
    position: absolute;
    left: 16px; top: 16px;
    width: 28px; height: 28px;
    background: linear-gradient(135deg, var(--r-brand), var(--r-brand-dark));
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 900;
    display: grid;
    place-items: center;
}
.r-source-title { font-weight: 800; color: var(--r-text); font-size: 14px; margin-bottom: 4px; }
.r-source-url {
    font-size: 11px;
    color: var(--r-brand);
    text-decoration: none;
    word-break: break-all;
    display: block;
    margin-bottom: 6px;
}
.r-source-snippet { font-size: 12px; color: var(--r-text-mute); line-height: 1.55; }

/* ════════════════════════ REVEAL ANIMATIONS ════════════════════════ */
.r-reveal { opacity: 0; will-change: opacity, transform; }
.r-reveal.r-revealed {
    animation-duration: 0.85s;
    animation-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
    animation-fill-mode: forwards;
}
.r-reveal-up.r-revealed    { animation-name: rRevealUp; }
.r-reveal-fade.r-revealed  { animation-name: rRevealFade; }
.r-reveal-scale.r-revealed { animation-name: rRevealScale; }
.r-reveal-left.r-revealed  { animation-name: rRevealLeft; }
.r-reveal-right.r-revealed { animation-name: rRevealRight; }

@keyframes rRevealUp    { from { opacity: 0; transform: translateY(28px); }   to { opacity: 1; transform: translateY(0); } }
@keyframes rRevealFade  { from { opacity: 0; }                                 to { opacity: 1; } }
@keyframes rRevealScale { from { opacity: 0; transform: scale(0.92); }         to { opacity: 1; transform: scale(1); } }
@keyframes rRevealLeft  { from { opacity: 0; transform: translateX(-30px); }   to { opacity: 1; transform: translateX(0); } }
@keyframes rRevealRight { from { opacity: 0; transform: translateX(30px); }    to { opacity: 1; transform: translateX(0); } }

/* Cover always animates on load (above the fold) */
.r-cover .r-reveal { animation-duration: 1.05s; animation-fill-mode: both; }
.r-cover .r-reveal-up    { animation-name: rRevealUp; }
.r-cover .r-reveal-fade  { animation-name: rRevealFade; }
.r-cover .r-reveal-scale { animation-name: rRevealScale; }

@media (prefers-reduced-motion: reduce) {
    .r-reveal { opacity: 1 !important; transform: none !important; animation: none !important; }
}

/* ════════════════════════════════════════════════════════════════════
   PRINT — bulletproof rules so window.print() produces a PDF that's
   pixel-for-pixel identical to the live preview.

   Strategy:
   - @page sets the sheet to A4 with zero margin (we control margins
     inside .r-page so backgrounds extend edge-to-edge)
   - Every .r-page is forced to exactly 210mm × 297mm
   - page-break-after: always on .r-page → each section = one PDF page
   - aspect-ratio: auto (override the screen-only 210/297 ratio)
   - All chrome (topbar, chat pane, modals, lightbox, etc.) hidden
   - print-color-adjust: exact on * → backgrounds and gradients print
   - All reveal elements forced to final state
   ════════════════════════════════════════════════════════════════════ */
@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    /* Force backgrounds + gradients to actually print */
    *, *::before, *::after {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
        color-adjust: exact !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
        font-size: 12pt;
    }

    /* ─── Hide everything that isn't the report preview ─── */
    .topbar,
    .chat-pane,
    .preview-pane-header,
    .preview-zoom,
    .lightbox,
    .modal,
    .app-modal,
    .public-top,
    .r-chat-launcher,
    .r-chat-lightbox,
    .mobile-tabs,
    .mobile-drawer,
    .lock-alert,
    .no-print,
    #drop-overlay {
        display: none !important;
    }

    /* ─── Strip all positioning from the layout containers ─── */
    .split-layout {
        position: static !important;
        display: block !important;
        padding: 0 !important;
        margin: 0 !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        height: auto !important;
        width: auto !important;
        grid-template-columns: none !important;
        grid-template-rows: none !important;
        gap: 0 !important;
    }
    .preview-pane {
        position: static !important;
        display: block !important;
        background: #ffffff !important;
        border: none !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        max-width: none !important;
        width: auto !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }
    .preview-scroll {
        position: static !important;
        background: #ffffff !important;
        padding: 0 !important;
        margin: 0 !important;
        height: auto !important;
        max-height: none !important;
        overflow: visible !important;
    }
    .report-preview,
    .public-wrap,
    .public-report {
        max-width: none !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        transform: none !important;
    }

    /* ─── Each .r-page becomes exactly one A4 sheet ─── */
    .r-page {
        width: 210mm !important;
        max-width: 210mm !important;
        min-height: 297mm !important;
        height: 297mm !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        border: none !important;
        background: #ffffff !important;
        position: relative !important;
        display: block !important;
        overflow: hidden !important;
        aspect-ratio: auto !important;

        /* Force a page break after every report page */
        page-break-after: always !important;
        break-after: page !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }
    .r-page:last-child {
        page-break-after: auto !important;
        break-after: auto !important;
    }

    /* ─── Cover page fills the full A4 with the gradient ─── */
    .r-cover {
        width: 210mm !important;
        height: 297mm !important;
        min-height: 297mm !important;
        max-height: 297mm !important;
        padding: 18mm 20mm !important;
        margin: 0 !important;
        box-sizing: border-box !important;
        display: flex !important;
        flex-direction: column !important;
        background:
            radial-gradient(900px 600px at 50% 20%, rgba(255, 255, 255, 0.18), transparent 60%),
            radial-gradient(600px 400px at 80% 100%, rgba(255, 255, 255, 0.10), transparent 60%),
            linear-gradient(165deg, var(--r-brand) 0%, var(--r-brand-dark) 55%, var(--r-brand-deep) 100%) !important;
        color: #ffffff !important;
    }
    .r-cover-particles { display: none !important; }
    .r-cover::before   { display: none !important; }
    .r-cover-title     { font-size: 38pt !important; }
    .r-cover-subtitle  { font-size: 12pt !important; }
    .r-cover-meta-value { font-size: 11pt !important; }

    /* ─── Content pages — generous A4 margins ─── */
    .r-page-pad {
        padding: 18mm 20mm !important;
        box-sizing: border-box !important;
        max-width: 100% !important;
    }

    /* ─── Force every reveal element to its final state ─── */
    .r-reveal,
    .r-reveal-up,
    .r-reveal-fade,
    .r-reveal-scale,
    .r-reveal-left,
    .r-reveal-right {
        opacity: 1 !important;
        transform: none !important;
        animation: none !important;
        will-change: auto !important;
    }

    /* ─── Drop shadows hurt print quality, kill them ─── */
    .r-stat,
    .r-source,
    .r-chart,
    .r-glossary,
    .r-callout,
    .r-quote {
        box-shadow: none !important;
    }
    .r-glossary-scroll {
        max-height: none !important;
        overflow: visible !important;
    }

    /* ─── Cards and callouts shouldn't break across pages ─── */
    .r-stat,
    .r-callout,
    .r-quote,
    .r-bullets li,
    .r-source,
    .r-chart {
        page-break-inside: avoid !important;
        break-inside: avoid !important;
    }

    /* ─── Section title shouldn't be alone at the bottom of a page ─── */
    .r-section-title,
    .r-section-eyebrow-row {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    /* ─── Body text widow/orphan control ─── */
    .r-body p {
        orphans: 3;
        widows: 3;
    }

    /* ─── Charts render as static images, just make sure they fit ─── */
    .r-chart-img {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* ════════════════════════ EXPORTING TO PDF ════════════════════════ */
/* When chat.js sets body.exporting-pdf, freeze every animation and force
   reveal elements to their final state so html2canvas captures clean
   frames. Each .r-page becomes its own PDF page via the per-page render
   loop in chat.js downloadPdf(). */
.exporting-pdf .report-preview {
    max-width: 820px !important;
    margin: 0 !important;
    transform: none !important;
}
.exporting-pdf .r-page {
    box-shadow: none !important;
    border-radius: 8px !important;
    margin: 0 0 16px 0 !important;
}
.exporting-pdf .r-reveal {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}
.exporting-pdf .r-cover-particles { display: none !important; }
.exporting-pdf .r-cover::before    { display: none !important; }
.exporting-pdf .r-cover-logo {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
}
.exporting-pdf .r-quote::before { display: none !important; }
.exporting-pdf .r-glossary-scroll { max-height: none !important; overflow: visible !important; }

/* ════════════════════════ LEGACY-COMPAT HELPERS ════════════════════════ */
/* The previous renderer used .r-cover-* and .r-section-* class names that
   don't all match the new design above. These shims keep older renders
   from breaking while the renderer is updated. */
.r-page-content { padding: 56px 64px; }
.r-footer { display: none; }
