:root {
  --paper: #f3f1ec;
  --card: #ffffff;
  --ink: #221f1b;
  --ink-soft: #625c53;
  --ink-faint: #9a9388;
  --line: #ddd8ce;
  --accent: #3d7ea6;
  --warm: #c8452c;
  --focus: #e0a526;
  --track: #ebe6dc;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 150px; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font: 16px/1.55 var(--sans); font-variant-numeric: tabular-nums;
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.top {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .6rem clamp(1rem, 4vw, 3rem);
  background: rgba(243, 241, 236, .95); backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.brand { font: 1.35rem var(--serif); color: var(--ink); text-decoration: none; white-space: nowrap; }
.top nav { display: flex; gap: 1.1rem; overflow-x: auto; }
.top nav a { color: var(--ink-soft); text-decoration: none; font-size: .9rem; white-space: nowrap; }
.top nav a:hover { color: var(--ink); }

.filters {
  position: sticky; top: 49px; z-index: 15;
  background: rgba(243, 241, 236, .97); border-bottom: 1px solid var(--line);
  padding: .5rem clamp(1rem, 4vw, 3rem) .45rem;
}
.filters-in { max-width: 1180px; margin: 0 auto; display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: flex-end; }
.filters label { display: flex; flex-direction: column; font-size: .72rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; gap: .15rem; }
.filters label.grow { flex: 1 1 180px; }
.filters select, .filters input, .controls select {
  font: 400 .88rem var(--sans); color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 6px; padding: .35rem .5rem; max-width: 220px;
}
.filters input { max-width: none; width: 100%; }
.filters select.on { border-color: var(--ink); background: #fffbe9; }
.ghost { font: 500 .85rem var(--sans); background: transparent; border: 1px solid var(--ink); border-radius: 999px; padding: .35rem .9rem; cursor: pointer; color: var(--ink); }
.ghost:hover { background: var(--ink); color: #fff; }
.filters-count { max-width: 1180px; margin: .3rem auto 0; font-size: .8rem; color: var(--ink-soft); }
.filters-count b { color: var(--ink); }

main { max-width: 1180px; margin: 0 auto; padding: 0 clamp(1rem, 4vw, 3rem) 4rem; }

.hero { padding: clamp(2rem, 6vw, 4.5rem) 0 1.5rem; }
.hero h1 { font: 400 clamp(2.1rem, 5vw, 3.9rem)/1.04 var(--serif); letter-spacing: -.01em; max-width: 19ch; margin: 0 0 1.3rem; }
.lede { max-width: 66ch; font-size: 1.06rem; color: var(--ink-soft); margin: 0 0 2rem; }
.lede em { font-style: normal; color: var(--ink); font-weight: 600; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; }
@media (max-width: 700px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .8rem 1rem; }
.kpi b { display: block; font: 400 2rem/1.1 var(--serif); }
.kpi span { font-size: .82rem; color: var(--ink-soft); }

.chapter { padding-top: 3rem; border-top: 1px solid var(--line); margin-top: 2.5rem; }
.chapter-head h2, .sources h2 { font: 400 clamp(1.8rem, 3.4vw, 2.5rem)/1.1 var(--serif); margin: 0 0 .5rem; }
.chapter-head p { max-width: 72ch; color: var(--ink-soft); margin: 0 0 1.3rem; }

.controls { display: flex; flex-wrap: wrap; gap: .8rem 1.4rem; align-items: center; margin-bottom: 1rem; }
.controls label.inline { font-size: .88rem; color: var(--ink-soft); display: flex; align-items: center; gap: .5rem; }
.seg { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--ink); border-radius: 999px; overflow: hidden; }
.seg button { font: 500 .86rem var(--sans); color: var(--ink); background: transparent; border: 0; padding: .42rem .95rem; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--ink); }
.seg button[aria-selected="true"] { background: var(--ink); color: #fff; }
.seg.small button { font-size: .8rem; padding: .32rem .75rem; }

.legend { display: flex; flex-wrap: wrap; gap: .35rem 1rem; font-size: .82rem; color: var(--ink-soft); margin: 0 0 .8rem; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.legend .line i { height: 3px; vertical-align: 3px; width: 16px; }

/* profile table */
.ptable { background: var(--card); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.prow { display: grid; grid-template-columns: minmax(150px, 1.3fr) 76px 66px 66px minmax(220px, 3fr); gap: .8rem; align-items: center; padding: .45rem .9rem; border-top: 1px solid var(--line); font-size: .88rem; }
.prow:first-child { border-top: 0; }
.prow.head { font-size: .74rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .03em; background: #faf8f4; }
.prow.head span { cursor: pointer; user-select: none; }
.prow.head span.sorted::after { content: " ▾"; }
.prow.head span.sorted.asc::after { content: " ▴"; }
.prow.total { font-weight: 600; background: #faf8f4; }
.prow .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prow .name.click { cursor: pointer; text-decoration: underline dotted var(--ink-faint); text-underline-offset: 3px; }
.prow .num { text-align: right; }
.sbar { position: relative; display: flex; height: 20px; border-radius: 3px; overflow: hidden; background: var(--track); }
.sbar div { height: 100%; display: flex; align-items: center; justify-content: center; color: #fff; font-size: .7rem; overflow: hidden; white-space: nowrap; }
.sbar .ref { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); opacity: .65; }
.bval { font-size: .78rem; color: var(--ink-soft); margin-left: .4rem; }

/* dots */
.dots { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .4rem .9rem .8rem; }
.drow { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 1rem; align-items: center; padding: .35rem 0; border-top: 1px solid var(--line); font-size: .88rem; }
.drow:first-child { border-top: 0; }
.dtrack { position: relative; height: 24px; }
.dtrack .axis { position: absolute; left: 0; right: 0; top: 11px; height: 2px; background: var(--track); }
.dtrack .span { position: absolute; top: 10px; height: 4px; background: #cfc8bb; border-radius: 2px; }
.dtrack .dot { position: absolute; top: 5px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.12); }
.dtrack .dot.sq { border-radius: 2px; transform: rotate(45deg); }
.daxis { display: grid; grid-template-columns: minmax(140px, 220px) 1fr; gap: 1rem; font-size: .72rem; color: var(--ink-faint); }
.daxis .ticks { position: relative; height: 16px; }
.daxis .ticks span { position: absolute; transform: translateX(-50%); }

/* map */
.geo-wrap { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); gap: 1.4rem; align-items: start; }
.map-box { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .8rem; }
#map { width: 100%; height: auto; display: block; }
#map path { stroke: #fff; stroke-width: .6; cursor: pointer; transition: opacity .15s; }
#map path:hover { stroke: var(--ink); stroke-width: 1.4; }
#map path.sel { stroke: var(--ink); stroke-width: 2; }
#map .acad-border { fill: none; stroke: var(--ink); stroke-width: .9; pointer-events: none; opacity: .55; }
.map-scale { display: flex; align-items: center; gap: .5rem; font-size: .76rem; color: var(--ink-soft); margin-top: .4rem; }
.map-scale .grad { flex: 1; height: 10px; border-radius: 2px; }
.drom { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .6rem; }
.drom button { font: 500 .76rem var(--sans); border: 1px solid var(--line); border-radius: 4px; padding: .25rem .5rem; cursor: pointer; color: var(--ink); }
.drom button.sel { outline: 2px solid var(--ink); }
.rank { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .9rem; max-height: 640px; overflow-y: auto; }
.rank h3 { font: 600 .78rem var(--sans); text-transform: uppercase; letter-spacing: .04em; color: var(--ink-soft); margin: .3rem 0 .5rem; }
.rrow { display: grid; grid-template-columns: 1fr 120px 52px; gap: .5rem; align-items: center; font-size: .84rem; padding: .18rem 0; cursor: pointer; }
.rrow:hover { background: #faf8f4; }
.rrow.sel { font-weight: 700; }
.rrow .rb { height: 8px; border-radius: 2px; background: var(--accent); }
.rrow .num { text-align: right; }

/* scatter & lines */
.scatter, .lines { position: relative; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: .5rem; }
.scatter canvas { position: absolute; left: 0; top: 0; }
.scatter svg, .lines svg { display: block; width: 100%; }
.axis text { font: 11px var(--sans); fill: var(--ink-soft); }
.axis path, .axis line { stroke: var(--line); }
.grid line { stroke: var(--track); }
.grid path { display: none; }
.alabel { font: 12px var(--sans); fill: var(--ink-soft); }

/* explorer */
.xtable-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.xtable { width: 100%; border-collapse: collapse; font-size: .84rem; }
.xtable th { text-align: right; font-weight: 600; font-size: .68rem; text-transform: uppercase; letter-spacing: .03em; color: var(--ink-soft); padding: .55rem .6rem; background: #faf8f4; border-bottom: 1px solid var(--line); cursor: pointer; white-space: nowrap; position: sticky; top: 0; }
.xtable th:first-child, .xtable td:first-child, .xtable th:nth-child(2), .xtable td:nth-child(2) { text-align: left; }
.xtable th.sorted::after { content: " ▾"; }
.xtable th.sorted.asc::after { content: " ▴"; }
.xtable td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: right; vertical-align: top; }
.xtable td:first-child { min-width: 230px; }
.xtable td .sub { display: block; color: var(--ink-soft); font-size: .78rem; }
.xtable tr:hover td { background: #faf8f4; }
.pager { display: flex; gap: .5rem; align-items: center; justify-content: flex-end; margin-top: .6rem; font-size: .85rem; color: var(--ink-soft); }

.sources ul { padding-left: 1.1rem; max-width: 80ch; color: var(--ink-soft); }
.sources li { margin-bottom: .5rem; }
.sources b { color: var(--ink); }

.tip { position: fixed; z-index: 50; pointer-events: none; background: var(--ink); color: #fff; font-size: .8rem; line-height: 1.4; padding: .5rem .65rem; border-radius: 6px; max-width: 300px; box-shadow: 0 4px 14px rgba(0,0,0,.18); }
.tip b { font-weight: 600; }
.tip .m { color: #d9d3c8; }
.empty { padding: 1.2rem; color: var(--ink-soft); font-size: .9rem; }

@media (max-width: 860px) {
  .geo-wrap { grid-template-columns: 1fr; }
  .prow { grid-template-columns: minmax(0, 1fr) 56px minmax(0, 1.5fr); gap: .5rem; padding: .45rem .6rem; }
  .drow { grid-template-columns: 1fr; gap: .1rem; }
  .daxis { grid-template-columns: 1fr; }
  .daxis > span { display: none; }
  .prow .h-voe, .prow .h-taux { display: none; }
  .filters { position: static; }
  html { scroll-padding-top: 60px; }
  .top nav { display: none; }
}

.sub-h { font: 600 1.05rem var(--sans); margin: 2rem 0 .3rem; }
.note { max-width: 72ch; color: var(--ink-soft); font-size: .9rem; margin: 0 0 .8rem; }
.src { font-size: .78rem; color: var(--ink-faint); margin: .5rem 0 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .9rem; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 1rem 1.1rem; }
.card h4 { font: 400 1.35rem/1.15 var(--serif); margin: 0 0 .5rem; }
.card p { font-size: .9rem; margin: 0 0 .5rem; color: var(--ink); }
.prow.host { grid-template-columns: minmax(150px, 1.2fr) repeat(6, minmax(60px, .6fr)); }
@media (max-width: 860px) { .prow.host { grid-template-columns: minmax(0, 1fr) repeat(3, 52px); } .prow.host .h-x { display: none; } }

.caveat { background: #fbf3df; border-left: 4px solid var(--focus); padding: .8rem 1rem; border-radius: 4px; font-size: .9rem; max-width: 90ch; margin: 0 0 1rem; }
@media (max-width: 860px) { #soc-table .prow { grid-template-columns: minmax(0,1fr) minmax(0,1.6fr) 44px 44px !important; gap: .4rem; } }
