/* Study dashboard. Allora palette + Giga Sans; the chart series colours live in study.js (validated set). */
:root {
  --ink: #0A2536; --ink-2: #33566C; --muted: #5d7584; --bg: #F3FAFF; --card: #ffffff;
  --line: rgba(10, 37, 54, 0.12); --grid: #e6edf2;
  --teal: #5EA8A8; --teal-deep: #4F9595; --mint: #DAF6EF;
  --hot: #b4541a; --hot-bg: #fdeee2; --warn-bg: #fff6d6;
  --font: 'Giga Sans', 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --gutter: clamp(16px, 4vw, 56px);
  --radius: 14px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 110px; }
body.study { margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font); font-size: 16px; line-height: 1.6; -webkit-font-smoothing: antialiased; }
img { max-width: 100%; display: block; }
a { color: var(--teal-deep); }
.wrap { max-width: 1360px; margin: 0 auto; padding-left: var(--gutter); padding-right: var(--gutter); }
.muted { color: var(--muted); }
.preview-bar { background: var(--warn-bg); color: #5b4500; font-size: 14px; padding: 8px var(--gutter); text-align: center; }
.preview-bar a { margin-left: 10px; color: inherit; font-weight: 600; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; font: 600 15px var(--font); text-decoration: none; cursor: pointer; border: 1px solid transparent; white-space: nowrap; }
.btn--sm { min-height: 38px; padding: 0 16px; font-size: 14px; }
.btn--primary { background: var(--teal); color: #fff; }
.btn--primary:hover { background: var(--teal-deep); }
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--teal); }
.link { border: 0; background: none; color: var(--teal-deep); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }

/* hero */
.hero { padding: clamp(36px, 6vw, 80px) 0 clamp(28px, 4vw, 44px); }
.hero--img { position: relative; color: #fff; background: linear-gradient(180deg, rgba(10,37,54,.35), rgba(10,37,54,.82)), var(--hero) center / cover no-repeat; padding-top: clamp(80px, 12vw, 160px); }
.hero__in { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 40px; align-items: end; }
.eyebrow { margin: 0 0 8px; font-size: 13px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase; color: var(--teal-deep); }
.hero--img .eyebrow { color: var(--mint); }
.hero h1 { margin: 0; font-size: clamp(32px, 5.4vw, 60px); line-height: 1.05; letter-spacing: -0.03em; font-weight: 600; max-width: 18ch; }
.hero__sub { margin: 12px 0 0; font-size: clamp(17px, 2vw, 21px); color: var(--ink-2); max-width: 60ch; }
.hero--img .hero__sub { color: rgba(255,255,255,.86); }
.hero__meta { display: flex; flex-wrap: wrap; gap: 6px 20px; margin: 16px 0 0; font-size: 14px; color: var(--muted); }
.hero--img .hero__meta { color: rgba(255,255,255,.75); }
.hero__note { margin-top: 22px; max-width: 680px; padding: 16px 20px; border-left: 3px solid var(--teal); background: var(--card); color: var(--ink); border-radius: 0 var(--radius) var(--radius) 0; font-size: 16px; }
.agent { min-width: 260px; padding: 20px 22px; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: var(--radius); }
.agent__label { margin: 0; font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.agent__name { margin: 4px 0 0; font-size: 20px; font-weight: 600; }
.agent__title { margin: 0; color: var(--muted); font-size: 14px; }
.agent__links { display: grid; gap: 2px; margin-top: 10px; font-size: 15px; }
.agent__links a { text-decoration: none; overflow-wrap: anywhere; }

/* layout: sticky contents rail + content */
.layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: clamp(24px, 3vw, 48px); align-items: start; padding-top: 28px; padding-bottom: 24px; }
.layout:not(:has(.toc)) { grid-template-columns: minmax(0, 1fr); }
.toc { position: sticky; top: 112px; padding-top: 8px; }
.toc__h { margin: 0 0 8px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: t; border-left: 1px solid var(--line); }
.toc li { counter-increment: t; }
.toc a { display: flex; gap: 10px; padding: 6px 0 6px 14px; margin-left: -1px; border-left: 2px solid transparent; color: var(--ink-2); text-decoration: none; font-size: 14px; line-height: 1.35; }
.toc a::before { content: counter(t, decimal-leading-zero); color: var(--muted); font-size: 12px; font-weight: 600; padding-top: 1px; }
.toc a:hover { color: var(--ink); }
.toc a[aria-current="true"] { border-left-color: var(--teal); color: var(--ink); font-weight: 600; }
.content { min-width: 0; }

.summary { padding: clamp(20px, 3vw, 32px); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); font-size: 17px; margin-bottom: 8px; }
.summary > :first-child { margin-top: 0; }
.summary > :last-child { margin-bottom: 0; }

.section { padding-top: clamp(36px, 5vw, 64px); }
.section__head { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 14px; border-bottom: 1px solid var(--line); margin-bottom: 22px; }
.section__num { font-size: 14px; font-weight: 600; color: var(--teal-deep); padding-top: 8px; }
.section__head h2 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.15; letter-spacing: -0.02em; font-weight: 600; }
.section__intro { margin: 6px 0 0; color: var(--muted); max-width: 70ch; }
.blocks { display: grid; gap: 20px; }
.blocks > *, .col > * { margin: 0; min-width: 0; }

/* columns */
.cols { display: grid; grid-template-columns: var(--cols); gap: 20px; align-items: start; }
.col { display: grid; gap: 20px; min-width: 0; }

/* text */
.prose { max-width: 76ch; font-size: 16.5px; }
.cols .prose { max-width: none; }
.prose--lead { font-size: 18.5px; color: var(--ink-2); }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose h3 { font-size: 20px; margin: 1.5em 0 .4em; letter-spacing: -0.01em; }
.prose h4 { font-size: 17px; margin: 1.3em 0 .3em; }
.prose ul, .prose ol { padding-left: 1.2em; }
.prose li { margin: .25em 0; }
.prose blockquote, .prose .callout { margin: 1em 0; padding: 12px 16px; background: var(--card); border-left: 3px solid var(--teal); border-radius: 0 8px 8px 0; }
.prose hr { border: 0; border-top: 1px solid var(--line); margin: 1.6em 0; }
.prose img { border-radius: 10px; margin: 1em 0; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14.5px; background: var(--card); border-radius: 10px; overflow: hidden; }
.prose th, .prose td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.prose .ncols { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 24px; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.card__title { font-size: 15px; font-weight: 600; margin: 0; }
.card__sub { margin: 2px 0 0; font-size: 13.5px; color: var(--muted); }
.card__caption { margin-top: 10px; font-size: 13px; color: var(--muted); }
.card__caption p { margin: 0; }

/* KPI tiles */
.kpis { display: grid; grid-template-columns: repeat(var(--n, 4), minmax(0, 1fr)); gap: 12px; }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 16px 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.kpi__label { font-size: 13px; color: var(--muted); }
.kpi__value { font-size: clamp(22px, 2.4vw, 30px); font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; font-variant-numeric: lining-nums; }
.kpi__note { font-size: 12.5px; color: var(--muted); }
.kpi--accent { background: var(--ink); border-color: var(--ink); color: #fff; }
.kpi--accent .kpi__label, .kpi--accent .kpi__note { color: rgba(255,255,255,.72); }
.kpi--good .kpi__value::before { content: "▲ "; font-size: .55em; vertical-align: middle; color: #0ca30c; }
.kpi--bad .kpi__value::before { content: "▼ "; font-size: .55em; vertical-align: middle; color: #d03b3b; }

/* charts */
.chart__plot { width: 100%; margin-top: 8px; }

/* tables */
.table__head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }
.table__search { font: 14px var(--font); padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; min-width: 200px; }
.table__scroll { overflow-x: auto; margin: 0 -20px; padding: 0 20px; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.data th { position: sticky; top: 0; background: var(--card); font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; border-bottom: 1px solid var(--ink); cursor: pointer; user-select: none; white-space: nowrap; }
.data th[aria-sort="ascending"]::after { content: " ↑"; }
.data th[aria-sort="descending"]::after { content: " ↓"; }
.data td { padding: 9px 10px; border-bottom: 1px solid var(--grid); }
.data--compact td { padding: 6px 10px; }
.data tbody tr:hover td { background: #f6fafc; }
.data tr.hl td { background: var(--mint); font-weight: 600; }
.data td[data-heat] { background: color-mix(in oklab, #0f9d8c calc(var(--heat) * 38%), #ffffff); }
.data tfoot td { font-weight: 600; border-top: 1px solid var(--ink); border-bottom: 0; }
.a-right { text-align: right; }
.a-left { text-align: left; }
.a-center { text-align: center; }
.table__more { margin-top: 10px; font-size: 14px; }

/* maps */
.map__plot { margin-top: 8px; border-radius: 10px; z-index: 0; }
.mpin { width: 14px; height: 14px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); }
.mpin--subject { width: 22px; height: 22px; background: var(--ink); border-width: 3px; }
.map-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-legend i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.leaflet-container { font-family: var(--font); }
.leaflet-popup-content { font-size: 13px; line-height: 1.45; }
.leaflet-popup-content dl { margin: 6px 0 0; display: grid; grid-template-columns: auto auto; gap: 2px 12px; }
.leaflet-popup-content dt { color: var(--muted); }
.leaflet-popup-content dd { margin: 0; text-align: right; font-weight: 600; }

/* callouts, facts, figures */
.callout { padding: 16px 20px; border-radius: var(--radius); background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--teal); }
.callout > :last-child { margin-bottom: 0; }
.callout > p:first-of-type { margin-top: 0; }
.callout__title { font-weight: 600; margin: 0 0 4px; }
.callout--key { background: var(--ink); color: #fff; border-color: var(--ink); }
.callout--key a { color: var(--mint); }
.callout--risk { background: var(--hot-bg); border-left-color: var(--hot); }
.callout--good { background: var(--mint); border-left-color: var(--teal-deep); }
.facts dl { margin: 10px 0 0; display: grid; gap: 0; }
.facts dl div { display: flex; justify-content: space-between; gap: 16px; padding: 8px 0; border-bottom: 1px solid var(--grid); font-size: 14.5px; }
.facts dl div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.figure img { border-radius: var(--radius); width: 100%; }
.figure figcaption { margin-top: 8px; font-size: 13px; color: var(--muted); }
.divider { border: 0; border-top: 1px solid var(--line); margin: 8px 0; }

.sources { margin-top: 56px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13.5px; color: var(--ink-2); }
.sources__h { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.sources ul { margin: 0; padding-left: 1.1em; }
.disclaimer { margin: 28px 0 64px; font-size: 12.5px; color: var(--muted); max-width: 90ch; }

/* ask dialog */
dialog { border: 0; padding: 0; }
dialog::backdrop { background: rgba(10, 37, 54, 0.6); }
.ask { width: min(540px, calc(100vw - 32px)); padding: 28px; border-radius: var(--radius); color: var(--ink); font-family: var(--font); }
.ask h3 { margin: 0 0 4px; font-size: 22px; }
.ask textarea { width: 100%; margin-top: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font: 16px var(--font); resize: vertical; }
.ask__actions { margin-top: 12px; display: flex; justify-content: flex-end; }
.ask__close { position: absolute; top: 8px; right: 10px; }
.ask__close button { border: 0; background: none; font-size: 28px; line-height: 1; cursor: pointer; color: var(--muted); }
.ask__done { text-align: center; padding: 12px 0; }
.ask__done svg { margin: 0 auto; }
.ask__done p { font-size: 18px; }

.closed { min-height: 100vh; display: grid; place-content: center; justify-items: center; text-align: center; padding: 24px; }
.closed h1 { font-size: 30px; margin: 28px 0 6px; }
.closed p { color: var(--muted); max-width: 420px; }

@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .toc { position: static; }
  .toc ol { display: flex; flex-wrap: wrap; gap: 6px; border: 0; }
  .toc a { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: var(--card); margin: 0; }
  .toc a[aria-current="true"] { border-color: var(--teal); }
}
@media (max-width: 860px) {
  .hero__in { grid-template-columns: 1fr; }
  .agent { min-width: 0; }
  .cols { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ac-header__right .btn--ghost { display: none; }
}
@media (max-width: 420px) {
  .kpis { grid-template-columns: 1fr; }
}
@media print {
  @page { margin: 14mm; }
  body.study { background: #fff; font-size: 12.5px; }
  .ac-header, .preview-bar, .toc, .ac-footer, .table__search, .table__more, .ask { display: none !important; }
  .layout { display: block; }
  .hero--img { color: var(--ink); background: none; padding-top: 0; }
  .hero--img .hero__sub, .hero--img .hero__meta, .hero--img .eyebrow { color: var(--ink-2); }
  .section { break-before: page; padding-top: 0; }
  .card, .kpi, .callout, .figure { break-inside: avoid; }
  .data tr[hidden] { display: table-row !important; }
  .table__scroll { overflow: visible; }
}
