/* Tuklas Catbalogan — civic statistical report.
   One bold element: the barangay line map in the hero. Everything else stays quiet. */
:root {
  color-scheme: light;
  --page: #f2f4f6;
  --surface: #ffffff;
  --ink: #142033;
  --ink-2: #4a5566;
  --muted: #687384;
  --line: #dde2e8;
  --grid: #e6e9ee;
  --axis: #c5ccd6;
  --accent: #1f5fae;
  --accent-wash: #e8f0fa;
  --hero: #0f2a4a;
  --hero-ink: #eef3f9;
  --hero-muted: #a9bdd4;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --gray: #b9bec6;
  --seq-1: #cde2fb; --seq-2: #86b6ef; --seq-3: #3987e5; --seq-4: #1c5cab; --seq-5: #0d366b;
  --div-neg-2: #b8322f; --div-neg-1: #f0a09c; --div-mid: #e4e6ea; --div-pos-1: #9ec5f4; --div-pos-2: #1c5cab;
  --good: #11743a; --warn: #8a5a00; --bad: #b42828;
  --font: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0c1117; --surface: #141b23; --ink: #e7ecf2; --ink-2: #b4bfcc; --muted: #8794a5;
    --line: #243040; --grid: #222c38; --axis: #33404f; --accent: #6ea8ec; --accent-wash: #16263a;
    --hero: #0a1d33; --hero-ink: #eef3f9; --hero-muted: #93a9c2;
    --s1: #3987e5; --s2: #d95926; --s3: #199e70; --gray: #4e5866;
    --seq-1: #1c2c44; --seq-2: #184f95; --seq-3: #2a78d6; --seq-4: #6da7ec; --seq-5: #cde2fb;
    --div-neg-2: #e66767; --div-neg-1: #7a3534; --div-mid: #333d4a; --div-pos-1: #1f4b85; --div-pos-2: #6da7ec;
    --good: #3fc06f; --warn: #f0b84a; --bad: #f07a7a;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0c1117; --surface: #141b23; --ink: #e7ecf2; --ink-2: #b4bfcc; --muted: #8794a5;
  --line: #243040; --grid: #222c38; --axis: #33404f; --accent: #6ea8ec; --accent-wash: #16263a;
  --hero: #0a1d33; --hero-ink: #eef3f9; --hero-muted: #93a9c2;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --gray: #4e5866;
  --seq-1: #1c2c44; --seq-2: #184f95; --seq-3: #2a78d6; --seq-4: #6da7ec; --seq-5: #cde2fb;
  --div-neg-2: #e66767; --div-neg-1: #7a3534; --div-mid: #333d4a; --div-pos-1: #1f4b85; --div-pos-2: #6da7ec;
  --good: #3fc06f; --warn: #f0b84a; --bad: #f07a7a;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 64px; }
body {
  margin: 0; background: var(--page); color: var(--ink);
  font: 400 16px/1.6 var(--font); -webkit-text-size-adjust: 100%;
  font-feature-settings: "kern" 1;
}
a { color: var(--accent); text-underline-offset: 2px; }
.wrap { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 28px; } }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 2000; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Top navigation ---------- */
.topnav { position: sticky; top: 0; z-index: 900; background: var(--surface); border-bottom: 1px solid var(--line); }
.topnav-inner { display: flex; align-items: center; gap: 20px; height: 54px; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; white-space: nowrap; letter-spacing: -.01em; }
.navlinks { min-width: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; align-self: stretch; }
.navlinks::-webkit-scrollbar { display: none; }
.navlinks a { display: flex; align-items: center; padding: 0 10px; font-size: 14px; color: var(--ink-2); text-decoration: none; white-space: nowrap; border-bottom: 2px solid transparent; }
.navlinks a:hover { color: var(--ink); }
.navlinks a.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.textbtn { font: inherit; font-size: 14px; color: var(--ink-2); background: none; border: 0; padding: 6px 4px; cursor: pointer; white-space: nowrap; }
.textbtn:hover { color: var(--ink); }
@media (max-width: 720px) { .brand { display: none; } .topnav-inner { gap: 8px; } }

/* ---------- Hero ---------- */
.hero { background: var(--hero); color: var(--hero-ink); padding: 30px 0 30px; overflow: hidden; }
.hero-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 40px; align-items: center; }
.hero-meta { margin: 0 0 10px; font-size: 14px; color: var(--hero-muted); line-height: 1.5; }
.hero h1 { margin: 0 0 12px; font-weight: 800; font-size: clamp(30px, 3.8vw, 46px); line-height: 1.04; letter-spacing: -.025em; }
.hero h1 .h1-name { display: block; font-weight: 400; font-size: .52em; letter-spacing: -.01em; color: var(--hero-muted); margin-bottom: 6px; }
.hero .theme { margin: 0 0 10px; font-size: 15px; color: var(--hero-muted); max-width: 60ch; }
.hero .theme q { color: var(--hero-ink); font-style: normal; }
.hero .lede { margin: 0 0 18px; font-size: 16px; line-height: 1.55; max-width: 70ch; color: var(--hero-ink); }
.hero-tools { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-map { margin: 0; position: relative; }
.hero-map svg { display: block; width: 100%; height: auto; max-height: 250px; }
.hero-map path { fill: rgba(255,255,255,.04); stroke: rgba(222,234,247,.55); stroke-width: .8; vector-effect: non-scaling-stroke; transition: fill .2s; }
.hero-map path.big { fill: rgba(110,168,236,.28); }
.hero-map figcaption { margin-top: 10px; font-size: 13px; color: var(--hero-muted); }
@media (max-width: 860px) {
  .hero { padding: 36px 0 32px; }
  .hero-grid { grid-template-columns: 1fr; gap: 24px; }
  .hero-map { order: -1; max-width: 300px; }
  .hero-map svg { max-height: 210px; }
}

.btn { display: inline-flex; align-items: center; text-decoration: none; font: inherit; font-size: 15px; font-weight: 600; padding: 10px 18px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.hero .btn.primary { background: #fff; border-color: #fff; color: var(--hero); }
.hero .btn { background: transparent; color: var(--hero-ink); border-color: rgba(238,243,249,.35); }
.btn:disabled { opacity: .4; cursor: default; }

/* ---------- Guided story bar ---------- */
.storybar { position: sticky; top: 0; z-index: 1000; background: var(--surface); border-bottom: 1px solid var(--line); box-shadow: 0 6px 20px rgba(15, 42, 74, .10); }
.storybar-inner { display: flex; gap: 16px; align-items: center; padding-top: 12px; padding-bottom: 12px; }
.story-step { font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.story-text { margin: 0; flex: 1; font-size: 16px; }
.story-nav { display: flex; gap: 8px; }
.story-nav .btn { padding: 8px 14px; font-size: 14px; }
.spot { box-shadow: 0 0 0 3px var(--accent); transition: box-shadow .25s; }

/* ---------- Sections & chapter headers ---------- */
.section { padding: 56px 0 8px; }
#overview { padding-top: 20px; }
.glance { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; margin-top: 20px; }
.mini { margin: 0; padding: 18px 18px 14px; }
.mini h3 { font-size: 16px; }
.mini h3 a { color: inherit; text-decoration-color: var(--axis); }
.mini h3 a:hover { color: var(--accent); }
.mini .sub { margin-bottom: 8px; font-size: 13px; }
.mini .src { margin-top: 8px; padding-top: 8px; }
@media (max-width: 900px) { .glance { grid-template-columns: minmax(0, 1fr); } }
.chap { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0 22px; align-items: start; margin-bottom: 14px; }
.chap-num { font-size: 76px; line-height: .86; font-weight: 300; color: var(--accent); font-variant-numeric: lining-nums; letter-spacing: -.04em; }
.chap-name { margin: 2px 0 6px; font-size: 15px; font-weight: 600; color: var(--accent); }
.label { margin: 0 0 6px; font-size: 15px; font-weight: 600; color: var(--accent); }
.section h2 { margin: 0; font-size: clamp(24px, 3vw, 34px); line-height: 1.15; letter-spacing: -.02em; font-weight: 750; max-width: 30ch; }
.intro { margin: 14px 0 26px; max-width: 70ch; color: var(--ink-2); font-size: 17px; }
.chap + .intro { margin-top: 4px; }
@media (max-width: 600px) { .chap-num { font-size: 52px; } .chap { gap: 0 14px; } }
.note { font-size: 13px; color: var(--muted); max-width: 90ch; }

.grid { display: grid; gap: 20px; margin-bottom: 20px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.map-grid { grid-template-columns: minmax(0, 1.9fr) minmax(0, 1fr); }
@media (max-width: 900px) { .grid.two, .grid.map-grid { grid-template-columns: minmax(0, 1fr); } }

/* Chart panels */
.card { margin: 0 0 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px 22px 18px; min-width: 0; }
.grid .card { margin-bottom: 0; }
.card h3 { margin: 0 0 4px; font-size: 18px; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; }
.card .sub { margin: 0 0 14px; font-size: 14px; color: var(--muted); }
.chart { position: relative; width: 100%; }
.src { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--grid); font-size: 12.5px; color: var(--muted); line-height: 1.5; }
.callout { margin: 18px 0 0; font-size: 18px; line-height: 1.5; font-weight: 500; color: var(--ink); max-width: 46ch; }
.callout b { font-weight: 800; color: var(--accent); }

.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px; margin: 0 0 14px; font-size: 14px; }
.filters label { color: var(--muted); }
select { font: inherit; font-size: 14px; padding: 7px 30px 7px 10px; border-radius: 8px; border: 1px solid var(--axis); background: var(--surface); color: var(--ink); max-width: 100%;
  appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 52%, calc(100% - 10px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: 10px; background: var(--page); border: 1px solid var(--line); }
.seg button { font: inherit; font-size: 14px; padding: 5px 14px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); cursor: pointer; font-variant-numeric: tabular-nums; }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(15, 42, 74, .15); }

.key { white-space: nowrap; }
.key::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 5px 0 8px; vertical-align: -1px; }
.key:first-child::before { margin-left: 0; }
.k1::before { background: var(--s1); } .k2::before { background: var(--s2); } .k0::before { background: var(--gray); }

/* ---------- KPI strip ---------- */
/* 1px gaps over a line-colored background draw the dividers in every layout. */
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.kpi { padding: 18px 20px 20px; text-decoration: none; color: inherit; display: block; background: var(--surface); }
a.kpi:hover { background: var(--accent-wash); }
.kpi .head { display: flex; gap: 10px; align-items: flex-start; margin: 0 0 10px; }
.kpi .ico { flex: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; background: var(--accent-wash); color: var(--accent); }
.kpi .ico svg { width: 19px; height: 19px; }
.kpi.alert .ico { background: color-mix(in srgb, var(--bad) 12%, transparent); color: var(--bad); }
.kpi .lbl { font-size: 14px; color: var(--ink-2); margin: 0; line-height: 1.35; min-height: 2.7em; }
.kpi .val { font-size: 36px; font-weight: 750; line-height: 1; margin: 0; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.kpi .ctx { font-size: 13px; color: var(--muted); margin: 10px 0 0; line-height: 1.45; }
.kpi.alert .val { color: var(--bad); }
@media (max-width: 1080px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } .kpi:first-child { grid-column: 1 / -1; } .kpi:first-child .lbl { min-height: 0; } }
@media (max-width: 440px) { .kpis { grid-template-columns: 1fr; } .kpi .lbl { min-height: 0; } }

/* ---------- Map + profile ---------- */
.map { height: 460px; border-radius: 10px; border: 1px solid var(--line); background: var(--page); }
@media (max-width: 600px) { .map { height: 340px; } }
.leaflet-container { font: inherit; }
.leaflet-tooltip { font-size: 13px; border-radius: 8px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 10px; font-size: 12.5px; color: var(--ink-2); }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 3px; vertical-align: -2px; margin-right: 5px; }
.profile { align-self: start; position: sticky; top: 70px; }
.profile .label { margin-bottom: 2px; }
.profile h3 { font-size: 30px; margin: 0 0 4px; letter-spacing: -.02em; font-weight: 750; }
.pclass { margin: 0 0 18px; font-size: 14px; color: var(--muted); }
.pstats { display: grid; grid-template-columns: 1fr auto; margin: 0; font-size: 14.5px; }
.pstats dt, .pstats dd { padding: 7px 0; border-bottom: 1px solid var(--grid); }
.pstats dt { color: var(--ink-2); }
.pstats dd { margin: 0; font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.pnote { margin: 16px 0 0; font-size: 14.5px; color: var(--ink-2); }
@media (max-width: 900px) { .profile { position: static; } }

.tiles { display: grid; grid-template-columns: 1fr 1fr; border: 1px solid var(--line); border-radius: 10px; }
.tile { padding: 16px 18px; }
.tile + .tile { border-left: 1px solid var(--line); }
.tile .lbl { margin: 0; font-size: 14px; color: var(--ink-2); }
.tile .val { margin: 6px 0 0; font-size: 36px; font-weight: 750; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tile .ctx { margin: 6px 0 0; font-size: 13px; color: var(--muted); }

/* ---------- Tables ---------- */
details.tbl { margin-top: 10px; font-size: 13.5px; }
details.tbl summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.tblwrap { overflow-x: auto; max-height: 380px; margin-top: 10px; }
table.data { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
table.data th, table.data td { padding: 6px 10px; border-bottom: 1px solid var(--grid); text-align: right; white-space: nowrap; }
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data thead th { position: sticky; top: 0; background: var(--surface); font-weight: 600; color: var(--ink-2); }
table.data tbody th { font-weight: 500; }

.gapwrap { overflow-x: auto; }
table.gaps { border-collapse: collapse; width: 100%; font-size: 14px; min-width: 720px; }
table.gaps th, table.gaps td { padding: 12px 12px; border-bottom: 1px solid var(--grid); text-align: left; vertical-align: top; }
table.gaps thead th { font-size: 13px; font-weight: 600; color: var(--muted); border-bottom-color: var(--line); }
table.gaps tbody th { font-weight: 600; width: 22%; }
.st { display: block; font-weight: 600; font-size: 13.5px; }
.st small { display: block; font-weight: 400; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.st-ok { color: var(--good); }
.st-part { color: var(--warn); }
.st-no { color: var(--bad); }
@media (max-width: 700px) {
  table.gaps { min-width: 0; }
  table.gaps thead { display: none; }
  table.gaps tr { display: block; padding: 14px 0; border-bottom: 1px solid var(--line); }
  table.gaps th, table.gaps td { display: block; border: 0; padding: 4px 0; }
  table.gaps tbody th { width: auto; font-size: 15.5px; padding-bottom: 8px; }
  table.gaps td { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 8px; }
  table.gaps td::before { content: attr(data-label); font-size: 13px; color: var(--muted); padding-top: 1px; }
}
.legend-inline { display: flex; gap: 6px 22px; flex-wrap: wrap; margin: 14px 0 0; }
.legend-inline .st { display: inline; }

/* ---------- Findings ---------- */
.findings { list-style: none; padding: 0; margin: 22px 0 0; border-top: 1px solid var(--line); }
.findings li { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 0 12px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.findings .n { font-size: 44px; line-height: .9; font-weight: 300; color: var(--accent); font-variant-numeric: tabular-nums; }
.findings b.h { display: block; font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin-bottom: 6px; }
.findings p { margin: 0; max-width: 78ch; color: var(--ink-2); }
.findings .see { display: inline-block; margin-top: 8px; font-size: 14px; font-weight: 600; }
@media (max-width: 600px) { .findings li { grid-template-columns: 40px minmax(0, 1fr); } .findings .n { font-size: 32px; } }

/* ---------- Actions ---------- */
.actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 28px; margin-top: 24px; }
@media (max-width: 900px) { .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 600px) { .actions { grid-template-columns: 1fr; } }
.action { padding: 20px 0 24px; border-top: 1px solid var(--line); }
.action .who { font-size: 13.5px; font-weight: 600; color: var(--accent); margin: 0 0 6px; }
.action h3 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.01em; }
.action p { margin: 0; font-size: 15px; color: var(--ink-2); }
.action .why { margin-top: 10px; font-size: 13.5px; color: var(--muted); }

/* ---------- Sources ---------- */
.methods { margin-top: 24px; }
.methods > div { min-width: 0; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 22px; }
.methods h3 { font-size: 17px; margin: 0 0 10px; }
.methods h3 + ul, .methods h3 + ol { margin-top: 0; }
.methods ul, .methods ol { padding-left: 20px; margin: 0 0 20px; font-size: 14.5px; color: var(--ink-2); }
.methods li { margin-bottom: 8px; }
.methods p { font-size: 14.5px; color: var(--ink-2); margin: 0; }

/* ---------- Footer ---------- */
.foot { margin-top: 56px; padding: 32px 0 40px; background: var(--surface); border-top: 1px solid var(--line); font-size: 14.5px; }
.foot p { margin: 0 0 6px; }
.muted { color: var(--muted); }

@media (max-width: 600px) {
  .storybar-inner { flex-wrap: wrap; gap: 8px 12px; }
  .story-text { flex-basis: 100%; order: 2; font-size: 15px; }
  .story-nav { order: 3; }
  .card { padding: 16px 16px 14px; border-radius: 12px; }
  .tiles { grid-template-columns: 1fr; }
  .tile + .tile { border-left: 0; border-top: 1px solid var(--line); }
  .section { padding-top: 44px; }
  .callout { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } * { transition: none !important; } }
@media print { .topnav, .hero-tools, .storybar, .filters { display: none !important; } .card { break-inside: avoid; } }
