:root {
  --bg: #f6f7f9; --panel: #ffffff; --line: #e3e6eb; --text: #14171c; --muted: #5b6577; --faint: #8a94a6;
  --birth: #0f9d6a; --death: #d6303f; --accent: #0f9d6a; --warn: #b7791f;
  --serif: "Instrument Serif", Georgia, serif; --sans: "Inter Tight", system-ui, -apple-system, "Segoe UI", sans-serif;
  --gutter: 16px; --max: 1080px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #05070b; --panel: #0c111a; --line: rgba(255,255,255,0.09); --text: #e9edf3; --muted: #8a94a6; --faint: #5b6577;
    --birth: #34e89e; --death: #ff4d5e; --accent: #34e89e; --warn: #ffd166; }
}
* { box-sizing: border-box; }
html { background: var(--bg); color: var(--text); font: 15px/1.5 var(--sans); -webkit-text-size-adjust: 100%; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; }
a { color: inherit; }
main { flex: 1; width: 100%; max-width: var(--max); margin: 0 auto; padding: 24px var(--gutter) 48px; overflow-x: hidden; }
h1, h2, h3, p, li { overflow-wrap: anywhere; }
td { overflow-wrap: break-word; }
td time, td .badge, td button, td .small-link, .filing time, .alert-list time, td .btn { white-space: nowrap; }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; letter-spacing: -0.01em; line-height: 1.1; margin: 0 0 8px; }
h1 { font-size: clamp(30px, 5vw, 44px); }
h2 { font-size: 26px; margin-top: 36px; }
h3 { font-size: 20px; }
h1 em, .brand em { font-style: normal; color: var(--accent); }
p.lede { font-size: 17px; color: var(--muted); max-width: 64ch; margin: 0 0 20px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
small { color: var(--muted); }
button, input, select { font: inherit; color: inherit; }

/* header */
.site-head { display: flex; align-items: center; gap: 20px; padding: 12px var(--gutter); border-bottom: 1px solid var(--line); background: var(--panel); position: sticky; top: 0; z-index: 10; }
.brand { font: 400 26px/1 var(--serif); text-decoration: none; }
.site-head nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.site-head nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.site-head nav a[aria-current], .site-head nav a:hover { color: var(--text); background: color-mix(in srgb, var(--text) 6%, transparent); }
.head-search { margin-left: auto; display: flex; }
.head-search input { width: 220px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px 0 0 8px; background: var(--bg); }
.head-search button { border: 1px solid var(--line); border-left: 0; background: var(--bg); border-radius: 0 8px 8px 0; padding: 0 10px; cursor: pointer; }
@media (max-width: 720px) { .site-head { flex-wrap: wrap; gap: 8px 14px; } .head-search { margin-left: 0; width: 100%; } .head-search input { flex: 1; width: auto; } }

/* footer */
.site-foot { border-top: 1px solid var(--line); padding: 18px var(--gutter) 28px; color: var(--faint); font-size: 12.5px; max-width: var(--max); margin: 0 auto; width: 100%; }
.site-foot p { margin: 0 0 6px; }

/* cards & lists */
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.card h3 { margin-bottom: 6px; }
.stat { display: block; font: 400 34px/1 var(--serif); font-variant-numeric: tabular-nums; }
.stat.birth { color: var(--birth); } .stat.death { color: var(--death); }
.stat + small { display: block; margin-top: 4px; }
.co-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); counter-reset: co; }
.co-list.ranked li::before { counter-increment: co; content: counter(co); color: var(--faint); font-variant-numeric: tabular-nums; width: 2.2em; flex: none; font-size: 13px; }
.co { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); flex-wrap: wrap; min-width: 0; }
.co:first-child { border-top: 0; }
.co a { text-decoration: none; flex: 1 1 200px; min-width: 0; max-width: 100%; }
.co a b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.co a:hover b { text-decoration: underline; }
.co-meta { color: var(--muted); font-size: 13px; flex: 2 1 200px; min-width: 0; overflow-wrap: anywhere; }
.co-dead a b { color: var(--muted); }
.sec { white-space: nowrap; }
dl.facts .sec { white-space: normal; }
.sec i { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--c); margin-right: 6px; vertical-align: 1px; }
.badge { font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.badge-ok { color: var(--birth); border-color: color-mix(in srgb, var(--birth) 40%, transparent); }
.badge-dead { color: var(--death); border-color: color-mix(in srgb, var(--death) 40%, transparent); }
.badge-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
dl.facts { display: grid; grid-template-columns: minmax(84px, max-content) minmax(0, 1fr); gap: 8px 18px; margin: 0; }
dl.facts dt { color: var(--muted); } dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar-a { fill: var(--birth); } .chart .bar-b { fill: var(--death); }
.chart .axis { fill: var(--faint); font: 11px var(--sans); }
.legend { display: flex; gap: 16px; font-size: 13px; color: var(--muted); margin: 6px 0 0; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; vertical-align: -1px; }
table { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 9px 12px; border-top: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 13px; border-top: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.up { color: var(--birth); } .down { color: var(--death); }
.two { display: grid; gap: 24px; grid-template-columns: 1fr 1fr; }
@media (max-width: 760px) { .two { grid-template-columns: 1fr; } }
.prose { max-width: 68ch; } .prose p, .prose li { color: var(--text); }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 18px; }
.pill { border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; text-decoration: none; color: var(--muted); background: var(--panel); font-size: 13.5px; }
.pill[aria-current], .pill:hover { color: var(--text); border-color: var(--text); }
.share { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.share a, .share button { border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; text-decoration: none; font-size: 13.5px; cursor: pointer; color: var(--text); }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 18px; align-items: center; }
.filters select, .filters input[type=search] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.filters input[type=search] { flex: 1 1 260px; }
.filters button { padding: 8px 14px; border-radius: 8px; border: 0; background: var(--accent); color: #03110b; font-weight: 500; cursor: pointer; }
.callout { border-left: 3px solid var(--warn); padding: 10px 14px; background: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: 0 10px 10px 0; margin: 14px 0; }
.callout.live { border-color: var(--birth); background: color-mix(in srgb, var(--birth) 8%, transparent); }
.mini-map { width: 100%; aspect-ratio: 16/9; border-radius: 12px; border: 1px solid var(--line); background: #05070b; overflow: hidden; }
.mini-map canvas { border-radius: 12px; }
.obit { border-left: 3px solid var(--death); padding: 6px 14px; margin: 0 0 14px; }
.obit b { font-weight: 500; }
.obit .dates { color: var(--muted); font-variant-numeric: tabular-nums; }
.kpi-row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 16px 0 24px; }
.trend-word { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); }
.trend-word:first-child { border-top: 0; }
.trend-word b { font-weight: 500; text-transform: capitalize; }
.pagination { display: flex; gap: 8px; margin: 18px 0; }
.pagination a { border: 1px solid var(--line); padding: 6px 12px; border-radius: 8px; text-decoration: none; }
.region-group h2 { font-size: 22px; margin-top: 28px; }
.town-grid { display: grid; gap: 6px 18px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); list-style: none; padding: 0; margin: 0; }
.town-grid a { text-decoration: none; display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.town-grid small { font-variant-numeric: tabular-nums; }
.officer { padding: 10px 0; border-top: 1px solid var(--line); }
.officer:first-child { border-top: 0; }
.officer b { font-weight: 500; }
.officer .role { color: var(--muted); font-size: 13px; }
.filing { display: grid; grid-template-columns: 96px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.filing:first-child { border-top: 0; }
.filing time { color: var(--muted); font-variant-numeric: tabular-nums; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 10px; background: var(--accent); color: #03110b; text-decoration: none; font-weight: 500; border: 0; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn[aria-disabled="true"] { opacity: 0.55; cursor: default; }

.mini-pin { width: 14px; height: 14px; border-radius: 50%; background: #34e89e; box-shadow: 0 0 0 4px rgba(52,232,158,0.25), 0 0 18px #34e89e; }

.mini-map .maplibregl-ctrl-attrib { font-size: 10px; background: rgba(5,7,11,0.6); color: #8a94a6; }
.mini-map .maplibregl-ctrl-attrib a { color: #8a94a6; }
.card, .kpi-row > * { min-width: 0; }
.head-search input { min-width: 0; }

/* ---------- signed-in app ---------- */
.app-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.app-team select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
.app-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 0 0 20px; overflow-x: auto; scrollbar-width: none; }
.app-tabs a { padding: 9px 12px; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.app-tabs a[aria-current] { color: var(--text); border-bottom-color: var(--accent); }
.flash { padding: 10px 14px; border-radius: 10px; margin: 0 0 16px; }
.flash-ok { background: color-mix(in srgb, var(--birth) 12%, transparent); }
.flash-err { background: color-mix(in srgb, var(--death) 12%, transparent); }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack input, .stack select, .stack textarea, .filters input:not([type=search]) { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); width: 100%; }
.stack label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 14px; }
.stack label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.stack label.check input { width: auto; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px; display: flex; flex-direction: column; gap: 6px; }
legend { color: var(--muted); padding: 0 6px; }
form.inline { display: inline-flex; gap: 6px; align-items: center; margin: 2px 0; }
form.inline button, form.inline select, form.inline input { padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); cursor: pointer; font-size: 13px; }
.table-wrap { overflow-x: auto; }
table.watch td { vertical-align: middle; }
.tag { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: color-mix(in srgb, var(--text) 7%, transparent); color: var(--muted); }
.small-link { font-size: 13px; color: var(--muted); cursor: pointer; }
.alert-list { list-style: none; padding: 0; margin: 0; }
.alert-list li { padding: 8px 0; border-top: 1px solid var(--line); }
.alert-list li:first-child { border-top: 0; }
.alert-list time { color: var(--muted); font-variant-numeric: tabular-nums; margin-right: 6px; font-size: 13px; }
.copy-field { width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); font: 13px ui-monospace, monospace; }
tr.current td { background: color-mix(in srgb, var(--accent) 8%, transparent); }
code { font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }
.btn[disabled] { opacity: .5; cursor: default; }

/* tables scroll sideways on small screens instead of crushing words */
.table-wrap, main > table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
main table { min-width: 520px; }
.app-tabs { mask-image: linear-gradient(to right, #000 85%, transparent); -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); }
@media (min-width: 900px) { .app-tabs { mask-image: none; -webkit-mask-image: none; } }
.site-head nav { flex: 1 1 auto; min-width: 0; mask-image: linear-gradient(to right, #000 88%, transparent); -webkit-mask-image: linear-gradient(to right, #000 88%, transparent); }
@media (min-width: 1180px) { .site-head nav { mask-image: none; -webkit-mask-image: none; } }
/* officer network */
.network { width: 100%; height: auto; display: block; }
.net-edge { stroke: var(--line); stroke-width: 1.2; }
.network text { fill: var(--muted); font: 11px var(--sans); }
.net-focus circle { fill: var(--accent); }
.net-focus text { fill: var(--text); font-weight: 600; font-size: 12px; }
.net-officer rect { fill: #82aaff; }
.net-company circle { fill: color-mix(in srgb, var(--accent) 55%, var(--panel)); }
.net-dead circle { fill: var(--death); opacity: .6; }
.network a:hover text { fill: var(--text); text-decoration: underline; }
