/* =====================================================================
   台灣政治人物海外國籍與居留公開資料庫 — design system
   ===================================================================== */

:root {
  --maxw: 1200px;
  --gutter: clamp(16px, 4vw, 40px);
  --radius: 16px;
  --radius-sm: 11px;
  --radius-xs: 9px;

  /* light palette */
  --bg: #f3f1ea;
  --bg-tint: #ecefe9;
  --surface: #ffffff;
  --surface-2: #f7f8f4;
  --surface-3: #f1f3ee;
  --ink: #14201c;
  --ink-soft: #35423d;
  --muted: #6c7771;
  --line: #e2e6df;
  --line-strong: #d3d9d1;

  --brand: #0e6e64;
  --brand-strong: #0b554d;
  --brand-soft: #daeeea;
  --brand-glow: rgba(14, 110, 100, 0.16);

  /* semantic status colors */
  --c-covered: #0c8576;        --c-covered-soft: #d7efea;
  --c-pending: #a86a10;        --c-pending-soft: #f4e7cc;
  --c-audited: #3f6193;        --c-audited-soft: #dde7f3;
  --c-notinc: #6f766f;         --c-notinc-soft: #e9ece8;
  --c-unreviewed: #94a09a;     --c-unreviewed-soft: #eaeeeb;
  --c-dispute: #a93b53;        --c-dispute-soft: #f3dce1;

  --shadow-sm: 0 1px 2px rgba(20, 32, 28, 0.05), 0 2px 8px rgba(20, 32, 28, 0.05);
  --shadow: 0 12px 30px -16px rgba(20, 32, 28, 0.28), 0 2px 6px rgba(20, 32, 28, 0.05);
  --shadow-lg: 0 26px 60px -28px rgba(20, 32, 28, 0.4);

  --focus: 0 0 0 3px var(--brand-glow);
}

:root[data-theme="dark"] {
  --bg: #0b110f;
  --bg-tint: #0e1614;
  --surface: #131b19;
  --surface-2: #18211f;
  --surface-3: #1d2724;
  --ink: #e9efeb;
  --ink-soft: #c4cec9;
  --muted: #8c9a92;
  --line: #25312e;
  --line-strong: #2f3d39;

  --brand: #38c4b3;
  --brand-strong: #54d6c6;
  --brand-soft: rgba(56, 196, 179, 0.15);
  --brand-glow: rgba(56, 196, 179, 0.22);

  --c-covered: #38c4ad;        --c-covered-soft: rgba(56, 196, 173, 0.16);
  --c-pending: #d9a23f;        --c-pending-soft: rgba(217, 162, 63, 0.16);
  --c-audited: #7da6e0;        --c-audited-soft: rgba(125, 166, 224, 0.16);
  --c-notinc: #9aa39c;         --c-notinc-soft: rgba(154, 163, 156, 0.14);
  --c-unreviewed: #7d8a83;     --c-unreviewed-soft: rgba(125, 138, 131, 0.14);
  --c-dispute: #e07089;        --c-dispute-soft: rgba(224, 112, 137, 0.16);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 16px 40px -22px rgba(0, 0, 0, 0.7), 0 2px 6px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(1100px 480px at 80% -8%, var(--brand-glow), transparent 60%),
    linear-gradient(180deg, var(--bg-tint), var(--bg) 320px);
  background-attachment: fixed;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1;
}

a { color: var(--brand); text-underline-offset: 2px; }

h1, h2, h3, h4, p { margin: 0; }

.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  z-index: 50;
  padding: 8px 14px;
  border-radius: var(--radius-xs);
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}
.skip-link:focus { left: 12px; }

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
  border-radius: 8px;
}

/* ---------------------------------------------------------- masthead */

.masthead {
  width: min(var(--maxw), 100% - var(--gutter) * 2);
  margin: 0 auto;
  padding: clamp(20px, 4vw, 36px) 0 14px;
}

.masthead-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.brand { display: flex; align-items: center; gap: 16px; min-width: 0; }

.brand-mark { width: 52px; height: 52px; flex: 0 0 auto; filter: drop-shadow(0 6px 14px var(--brand-glow)); }
.bm-bg { fill: var(--brand); }
.bm-globe { fill: none; stroke: rgba(255, 255, 255, 0.92); stroke-width: 1.5; }
.bm-pin { fill: var(--c-pending); stroke: var(--surface); stroke-width: 1.6; }

.brand-text { min-width: 0; }
h1 {
  font-size: clamp(1.3rem, 1rem + 1.9vw, 2.1rem);
  line-height: 1.16;
  letter-spacing: -0.01em;
  font-weight: 850;
}

.masthead-tools { display: flex; align-items: center; gap: 12px; }

.version-chip {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
  backdrop-filter: blur(6px);
  text-align: right;
}
.version-chip span { display: block; color: var(--muted); font-size: 0.68rem; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; }
.version-chip strong { display: block; font-size: 0.95rem; font-variant-numeric: tabular-nums; }
.version-chip small { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }

.theme-toggle {
  width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--ink-soft);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}
.theme-toggle:hover { transform: translateY(-1px); border-color: var(--line-strong); background: var(--surface-2); }
.theme-toggle .ico { width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.ico-moon { display: block; }
.ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: none; }
:root[data-theme="dark"] .ico-sun { display: block; }

/* stat strip */
.statstrip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin: 22px 0 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--line);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stat-tile {
  padding: 16px 18px;
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.stat-value {
  font-size: clamp(1.6rem, 1.1rem + 1.4vw, 2.3rem);
  line-height: 1.05;
  font-weight: 850;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.stat-tile:first-child .stat-value { color: var(--brand); }
.stat-label { font-size: 0.84rem; font-weight: 800; color: var(--ink-soft); margin-top: 4px; }
.stat-sub { font-size: 0.74rem; color: var(--muted); font-weight: 700; }

/* boundary note */
.boundary {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  padding: 13px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.boundary-text { display: flex; gap: 10px; align-items: baseline; flex: 1 1 420px; min-width: 0; }
.boundary-text strong { flex: 0 0 auto; color: var(--brand); font-weight: 850; }
.boundary-text span { color: var(--ink-soft); font-size: 0.88rem; }
.downloads { display: flex; gap: 8px; margin-left: auto; }
.downloads a {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 13px;
  border-radius: var(--radius-xs);
  background: var(--brand); color: #fff;
  font-weight: 800; font-size: 0.82rem; text-decoration: none;
  transition: transform 0.14s ease, filter 0.2s ease;
}
.downloads a:hover { transform: translateY(-1px); filter: brightness(1.06); }

/* ------------------------------------------------------------- tabbar */

.tabbar {
  position: sticky;
  top: 0;
  z-index: 20;
  margin-top: 6px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
}
.tabbar-inner {
  position: relative;
  width: min(var(--maxw), 100% - var(--gutter) * 2);
  margin: 0 auto;
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabbar-inner::-webkit-scrollbar { display: none; }
.tab {
  position: relative;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 15px 14px 14px;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-weight: 800;
  font-size: 0.96rem;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.18s ease;
}
.tab:hover { color: var(--ink-soft); }
.tab[aria-selected="true"] { color: var(--ink); }
.tab-count {
  font-style: normal;
  font-size: 0.72rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--muted);
}
.tab[aria-selected="true"] .tab-count { background: var(--brand-soft); color: var(--brand); }
.tab-indicator {
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 2.5px;
  width: 0;
  border-radius: 3px;
  background: var(--brand);
  transition: transform 0.28s cubic-bezier(0.4, 0, 0.1, 1), width 0.28s cubic-bezier(0.4, 0, 0.1, 1);
}

/* --------------------------------------------------------------- views */

main {
  width: min(var(--maxw), 100% - var(--gutter) * 2);
  margin: 0 auto;
  padding: 26px 0 60px;
}
.view { display: grid; gap: 18px; }
.view[hidden] { display: none; }

.view-head { display: grid; gap: 4px; }
.view-head h2 { font-size: 1.4rem; font-weight: 850; letter-spacing: -0.01em; }
.view-lede { color: var(--muted); font-size: 0.92rem; max-width: 70ch; }
.view-lede kbd, .view kbd { font: inherit; }

kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.72rem;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--muted);
}

/* card */
.card {
  padding: clamp(16px, 2.4vw, 22px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 14px;
}
.card-head h2 { font-size: 1.16rem; font-weight: 850; }
.card-head h3 { font-size: 1.05rem; font-weight: 850; }
.head-meta { color: var(--muted); font-size: 0.84rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.card-lede { color: var(--muted); font-size: 0.9rem; margin-bottom: 14px; max-width: 80ch; }
.ghost-link { font-weight: 800; font-size: 0.86rem; text-decoration: none; white-space: nowrap; }
.ghost-link:hover { text-decoration: underline; }

/* status color carriers */
.covered { --c: var(--c-covered); --c-soft: var(--c-covered-soft); }
.pending { --c: var(--c-pending); --c-soft: var(--c-pending-soft); }
.audited { --c: var(--c-audited); --c-soft: var(--c-audited-soft); }
.notinc { --c: var(--c-notinc); --c-soft: var(--c-notinc-soft); }
.unreviewed { --c: var(--c-unreviewed); --c-soft: var(--c-unreviewed-soft); }
.empty { --c: var(--muted); --c-soft: var(--surface-3); }

.dot {
  width: 9px; height: 9px; flex: 0 0 auto;
  border-radius: 999px;
  background: var(--c, var(--muted));
}

/* ---------------------------------------------------- overview: ring */

.overview-grid {
  display: grid;
  grid-template-columns: minmax(280px, 0.9fr) minmax(320px, 1.1fr);
  gap: 18px;
}
.ring-card { display: grid; gap: 16px; align-content: start; }
.ring-wrap { position: relative; width: min(230px, 70%); margin: 4px auto 2px; }
.status-ring { display: block; width: 100%; height: auto; transform: rotate(0deg); }
.ring-track { fill: none; stroke: var(--surface-3); stroke-width: 4; }
.ring-seg {
  fill: none;
  stroke: var(--c, var(--muted));
  stroke-width: 4.2;
  stroke-linecap: butt;
  transition: opacity 0.5s ease;
}
.ring-center {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center; gap: 0;
}
.ring-center strong { font-size: 1.9rem; font-weight: 850; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-center span { font-size: 0.74rem; color: var(--muted); font-weight: 800; }
.ring-legend { display: grid; gap: 9px; }
.legend-row { display: flex; align-items: center; gap: 9px; }
.legend-name { flex: 1 1 auto; font-size: 0.86rem; font-weight: 700; color: var(--ink-soft); overflow-wrap: anywhere; }
.legend-val { flex: 0 0 auto; font-size: 0.8rem; color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; }

/* completeness */
.completion-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.mini {
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.mini span { display: block; color: var(--muted); font-size: 0.74rem; font-weight: 800; }
.mini strong { display: block; margin: 6px 0 3px; font-size: 1.55rem; line-height: 1; font-weight: 850; font-variant-numeric: tabular-nums; }
.mini small { color: var(--muted); font-weight: 700; font-variant-numeric: tabular-nums; }

/* bars (status breakdown + cohort ratios) */
.bars, .bar-list { display: grid; gap: 11px; }
.bar-row { display: grid; gap: 6px; }
.bar-label { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.bar-name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; font-size: 0.86rem; font-weight: 750; color: var(--ink-soft); overflow-wrap: anywhere; }
.bar-label strong { flex: 0 0 auto; color: var(--muted); font-size: 0.8rem; font-weight: 800; font-variant-numeric: tabular-nums; text-align: right; }
.bar-track { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.bar-track i {
  display: block; height: 100%; width: 0;
  border-radius: inherit;
  background: var(--c, var(--muted));
  transition: width 0.9s cubic-bezier(0.3, 0.8, 0.2, 1);
}
@media (prefers-reduced-motion: reduce) { .bar-track i { transition: none; } }

/* distribution */
.distribution-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.distribution-panel { padding: 16px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface-2); }
.distribution-panel h3 { margin-bottom: 13px; font-size: 0.98rem; font-weight: 850; }
.dist-list { display: grid; gap: 10px; }
.dist-row { display: grid; gap: 6px; }
.dist-label { display: flex; justify-content: space-between; gap: 10px; font-size: 0.86rem; font-weight: 750; color: var(--ink-soft); }
.dist-label span:first-child { min-width: 0; overflow-wrap: anywhere; }
.dist-label span:last-child { flex: 0 0 auto; color: var(--muted); font-weight: 800; font-variant-numeric: tabular-nums; }
.dist-bar { height: 7px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.dist-bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--c-audited); transition: width 0.9s cubic-bezier(0.3, 0.8, 0.2, 1); }

/* ----------------------------------------------------- cohort ratio cards */

.cohort-ratio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.cohort-ratio-card {
  display: grid; gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.cohort-ratio-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.cohort-ratio-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.tag { display: block; color: var(--muted); font-size: 0.68rem; font-weight: 850; letter-spacing: 0.05em; text-transform: uppercase; }
.cohort-ratio-top h3 { margin-top: 3px; font-size: 1.02rem; font-weight: 800; line-height: 1.3; }
.pill {
  flex: 0 0 auto;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand);
  font-size: 0.82rem;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}
.pill.blue { background: var(--c-audited-soft); color: var(--c-audited); }
.cohort-ratio-summary { color: var(--ink-soft); font-size: 0.88rem; font-weight: 650; }
.cohort-ratio-footer { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; align-items: center; padding-top: 2px; }
.cohort-ratio-footer small { color: var(--muted); font-weight: 800; }
.cohort-ratio-footer a { font-weight: 800; font-size: 0.84rem; text-decoration: none; }
.cohort-ratio-footer a:hover { text-decoration: underline; }

/* section divider */
.section-divider {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 14px;
  margin: 8px 0 -2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.section-divider h3 { font-size: 1.1rem; font-weight: 850; }

/* audit cards */
.audit-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.audit-card {
  display: grid; gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.audit-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.audit-card-top { display: flex; justify-content: space-between; gap: 14px; align-items: flex-start; }
.audit-card-top h3 { margin-top: 3px; font-size: 1.02rem; font-weight: 800; line-height: 1.3; }
.audit-status { color: var(--c-pending); font-weight: 850; font-size: 0.9rem; }
.audit-summary { color: var(--ink-soft); font-size: 0.88rem; }
.audit-card a { width: fit-content; font-weight: 800; font-size: 0.84rem; text-decoration: none; }
.audit-card a:hover { text-decoration: underline; }

/* ------------------------------------------------------------- toolbar */

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.search-field {
  position: relative;
  flex: 1 1 260px;
  display: flex;
  align-items: center;
}
.search-field .ico {
  position: absolute; left: 13px;
  width: 18px; height: 18px;
  fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
  pointer-events: none;
}
.search-field input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--ink);
  font: inherit;
}
.search-field input::placeholder { color: var(--muted); }
.search-field input:focus { background: var(--surface); border-color: var(--brand); }
.search-field kbd { position: absolute; right: 11px; pointer-events: none; }

.select-field { display: grid; gap: 4px; flex: 0 1 auto; }
.select-field span { font-size: 0.7rem; font-weight: 800; color: var(--muted); padding-left: 2px; }
select {
  height: 40px;
  min-width: 130px;
  padding: 0 30px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: var(--surface-2)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236c7771' d='M2 4l4 4 4-4'/%3E%3C/svg%3E")
    no-repeat right 11px center;
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  appearance: none;
  cursor: pointer;
}
select:focus { border-color: var(--brand); background-color: var(--surface); }
.toolbar-count {
  margin-left: auto;
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 850;
  font-size: 0.86rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 13px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink-soft);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, transform 0.14s ease;
}
.chip .dot { width: 8px; height: 8px; }
.chip:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.chip.is-active {
  border-color: color-mix(in srgb, var(--c, var(--brand)) 55%, var(--line));
  background: var(--c-soft, var(--brand-soft));
  color: var(--c, var(--brand));
}

/* ------------------------------------------------------- subject cards */

.subject-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(305px, 1fr)); gap: 14px; }
.subject-card {
  display: grid; gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}
.subject-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: var(--line-strong); }
.subject-heading { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.subject-titlewrap { min-width: 0; }
.subject-cohort { display: block; color: var(--muted); font-size: 0.7rem; font-weight: 850; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.subject-heading h3 { margin-top: 3px; font-size: 1.16rem; font-weight: 850; }
.status-pill {
  flex: 0 0 auto;
  max-width: 46%;
  padding: 5px 9px;
  border-radius: 999px;
  background: var(--c-soft);
  color: var(--c);
  font-size: 0.7rem;
  font-weight: 850;
  line-height: 1.25;
  text-align: center;
}
.subject-meta { color: var(--brand); font-size: 0.86rem; font-weight: 800; overflow-wrap: anywhere; }
.subject-note { color: var(--ink-soft); font-size: 0.88rem; }
.subject-audit {
  padding: 9px 11px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}
.subject-records { display: flex; flex-wrap: wrap; gap: 6px; }
.rec-chip {
  display: inline-flex; align-items: center;
  max-width: 100%;
  min-height: 26px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--c-pending-soft);
  color: var(--c-pending);
  font-size: 0.74rem;
  font-weight: 800;
  overflow-wrap: anywhere;
}
.rec-chip.muted { background: var(--surface-3); color: var(--muted); }

.subject-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 2px; }
.btn-primary, .btn-ghost {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 34px; padding: 0 12px;
  border-radius: var(--radius-xs);
  font-size: 0.82rem; font-weight: 800;
  text-decoration: none; cursor: pointer;
  transition: transform 0.14s ease, filter 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}
.btn-primary { border: 1px solid var(--brand); background: var(--brand); color: #fff; }
.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.07); }
.btn-ghost { border: 1px solid var(--line); background: var(--surface-2); color: var(--brand); }
.btn-ghost:hover { transform: translateY(-1px); border-color: var(--line-strong); background: var(--surface-3); }

/* --------------------------------------------------------------- records */

.records { display: grid; gap: 14px; }
.record {
  display: grid;
  grid-template-columns: 1fr minmax(250px, 0.42fr);
  gap: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.record:hover { box-shadow: var(--shadow); border-color: var(--line-strong); }
.record-title { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 9px; }
.record-title h3 { font-size: 1.12rem; font-weight: 850; }
.badge {
  --c: var(--c-audited); --c-soft: var(--c-audited-soft);
  display: inline-flex; align-items: center;
  min-height: 26px; padding: 3px 10px;
  border-radius: 999px;
  background: var(--c-soft); color: var(--c);
  font-size: 0.76rem; font-weight: 800;
}
.badge.self { --c: var(--c-covered); --c-soft: var(--c-covered-soft); }
.badge.family { --c: var(--c-pending); --c-soft: var(--c-pending-soft); }
.badge.dispute { --c: var(--c-dispute); --c-soft: var(--c-dispute-soft); }
.summary { margin-bottom: 13px; color: var(--ink-soft); }
.meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 0; }
.meta div { min-width: 0; padding: 9px; border-radius: var(--radius-xs); background: var(--surface-2); border: 1px solid var(--line); }
.meta dt { color: var(--muted); font-size: 0.7rem; font-weight: 800; }
.meta dd { margin: 3px 0 0; overflow-wrap: anywhere; font-weight: 750; font-size: 0.9rem; }
.record details { border-left: 1px solid var(--line); padding-left: 18px; }
.record summary { cursor: pointer; color: var(--brand); font-weight: 800; font-size: 0.9rem; }
.sources { display: grid; gap: 8px; padding-left: 18px; margin: 10px 0 0; }
.sources li { color: var(--muted); font-size: 0.86rem; }
.note { margin-top: 10px; color: var(--muted); font-size: 0.86rem; }

/* ------------------------------------------------------------- pending */

.pending-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.pending-card {
  display: grid; gap: 7px; align-content: start;
  padding: 16px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.pending-card h3 { font-size: 0.98rem; font-weight: 800; }
.pending-card p { color: var(--ink-soft); font-size: 0.88rem; }
.pending-card small a { font-weight: 800; font-size: 0.84rem; text-decoration: none; }
.pending-card small a:hover { text-decoration: underline; }

/* method + about */
.rule-list { margin: 0; padding-left: 20px; display: grid; gap: 7px; color: var(--ink-soft); font-size: 0.9rem; }
.rule-list strong { color: var(--ink); }
.method-list { margin: 0; padding-left: 22px; display: grid; gap: 9px; color: var(--ink-soft); }
.method-list strong { color: var(--ink); }

/* footer */
.appfoot {
  width: min(var(--maxw), 100% - var(--gutter) * 2);
  margin: 0 auto;
  padding: 22px 0 40px;
  display: flex; justify-content: space-between; flex-wrap: wrap; gap: 10px;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.82rem; font-weight: 700;
}
.appfoot strong { color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* empty state */
.empty {
  grid-column: 1 / -1;
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--muted);
  text-align: center;
  font-weight: 700;
}

/* motion */
@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.rise { animation: rise 0.4s cubic-bezier(0.3, 0.8, 0.2, 1) both; }
@media (prefers-reduced-motion: reduce) {
  .rise { animation: none; }
  .tab-indicator { transition: none; }
  * { scroll-behavior: auto !important; }
}

/* --------------------------------------------------------- responsive */

@media (max-width: 900px) {
  .statstrip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat-tile:last-child { grid-column: 1 / -1; }
  .overview-grid { grid-template-columns: 1fr; }
  .distribution-grid { grid-template-columns: 1fr; }
  .audit-grid { grid-template-columns: 1fr; }
  .record { grid-template-columns: 1fr; }
  .record details { border-left: 0; border-top: 1px solid var(--line); padding: 12px 0 0; }
  .toolbar { gap: 8px; }
  .select-field { flex: 1 1 140px; }
}

@media (max-width: 560px) {
  .masthead-inner { flex-direction: column; }
  .masthead-tools { width: 100%; justify-content: space-between; }
  .statstrip { grid-template-columns: 1fr; }
  .stat-tile:last-child { grid-column: auto; }
  .completion-grid { grid-template-columns: 1fr; }
  .subject-grid { grid-template-columns: 1fr; }
  .cohort-ratio-grid { grid-template-columns: 1fr; }
  .pending-grid { grid-template-columns: 1fr; }
  .meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bar-label { flex-direction: column; gap: 3px; align-items: stretch; }
  .bar-label strong { text-align: left; }
  .downloads { margin-left: 0; }
  .boundary-text { flex-basis: 100%; }
  .select-field { flex: 1 1 100%; }
  select { min-width: 0; width: 100%; }
  .toolbar-count { margin-left: 0; }
}
