:root {
  color-scheme: light;
  --red: #e11d48;
  --red-dark: #be123c;
  --blue: #0145f2;
  --blue-dark: #10235a;
  --primary: #0145f2;
  --surface: #edf1f5;
  --ink: #182230;
  --muted: #667085;
  --soft: #edf1f5;
  --panel: #ffffff;
  --line: #ccd7e4;
  --line-strong: #afbed0;
  --good: #027a48;
  --warn: #b54708;
  --danger: #b42318;
  --focus: rgba(1, 69, 242, 0.14);
  --radius: 8px;
  --control-height: 44px;
  --content-width: 1280px;
  --measure: 68ch;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 10px 24px rgba(16, 24, 40, 0.07);
  --shadow-lg: 0 18px 42px rgba(16, 24, 40, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 86px;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--surface);
  overflow-x: hidden;
  text-rendering: optimizeLegibility;
}

body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto;
  z-index: -1;
  height: 5px;
  background: var(--primary);
}

a {
  color: var(--blue);
  text-decoration: none;
  overflow-wrap: anywhere;
}

a:hover {
  text-decoration: underline;
}

.clean-link {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 28px;
  padding: 4px 9px;
  overflow: hidden;
  color: var(--blue-dark);
  background: #e8eeff;
  border: 1px solid rgba(1, 69, 242, 0.16);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  vertical-align: middle;
  white-space: nowrap;
}

.clean-link:hover {
  color: #fff;
  background: var(--blue);
  text-decoration: none;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 50;
  transform: translateY(-160%);
  padding: 9px 12px;
  color: #fff;
  background: var(--blue);
  border-radius: 8px;
  font-weight: 900;
  box-shadow: var(--shadow-md);
}

.skip-link:focus {
  transform: translateY(0);
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

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

h1 {
  max-width: 780px;
  margin-bottom: 16px;
  font-size: clamp(1.72rem, 1.24rem + 1.45vw, 2.28rem);
  line-height: 1.08;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.32rem, 1.08rem + 0.58vw, 1.58rem);
  line-height: 1.18;
  letter-spacing: 0;
}

h3 {
  margin-bottom: 8px;
  font-size: 1.06rem;
  line-height: 1.25;
}

h4 {
  margin-bottom: 6px;
}

.quiet,
small {
  color: var(--muted);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  min-height: 66px;
  padding: 8px max(20px, calc((100vw - 1500px) / 2 + 24px));
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(16, 24, 40, 0.05);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 270px;
  color: var(--ink);
}

.brand img {
  width: 34px;
  height: 34px;
  object-fit: contain;
}

.brand span {
  display: grid;
  gap: 2px;
}

.brand strong {
  line-height: 1.1;
}

.brand small {
  color: var(--muted);
}

.topbar nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.topbar nav a {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: var(--radius);
  color: var(--blue-dark);
  font-size: 0.92rem;
  font-weight: 800;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.topbar nav a:hover,
.topbar nav a.active {
  background: #e8eeff;
  text-decoration: none;
}

.topbar nav a.active {
  color: var(--blue);
  box-shadow: inset 0 -2px 0 var(--blue);
}

.topbar nav a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(1, 69, 242, 0.18);
  outline-offset: 2px;
}

main {
  width: min(var(--content-width), calc(100% - 40px));
  min-width: 0;
  margin: 0 auto;
  padding: 22px 0 56px;
}

.hero-section {
  display: block;
  padding: 0;
  color: var(--ink);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.hero-copy {
  position: relative;
  display: grid;
  justify-items: center;
  align-content: start;
  max-width: none;
  min-width: 0;
  overflow: hidden;
  padding: clamp(30px, 4vw, 50px) 28px 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.99), rgba(255, 255, 255, 0.96)),
    linear-gradient(135deg, rgba(1, 69, 242, 0.06), rgba(255, 255, 255, 0));
  border: 1px solid rgba(188, 200, 218, 0.72);
  border-top: 3px solid var(--blue);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(16, 24, 40, 0.08);
  text-align: center;
}

.hero-copy::after {
  content: "";
  position: absolute;
  inset: auto calc(100% / 6) 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  opacity: 0.85;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero-copy p {
  max-width: 760px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.command-kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(118px, 1fr));
  gap: 8px;
  width: min(820px, 100%);
  margin-top: 14px;
}

.command-kpis span {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 5px;
  min-height: var(--control-height);
  padding: 7px 12px;
  color: var(--blue-dark);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(188, 200, 218, 0.86);
  border-radius: var(--radius);
  font-size: 0.82rem;
  font-weight: 800;
  box-shadow: var(--shadow-sm);
}

.command-kpis strong {
  color: var(--blue);
  font-size: 1rem;
}

.hero-search {
  display: grid;
  grid-template-columns: minmax(136px, 0.62fr) minmax(150px, 0.72fr) minmax(280px, 1.48fr) minmax(128px, 0.56fr) 80px;
  gap: 10px;
  align-items: end;
  width: min(1040px, 100%);
  max-width: 100%;
  margin-top: 0;
  padding: 10px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid rgba(188, 200, 218, 0.78);
  border-radius: var(--radius);
  box-shadow: 0 14px 32px rgba(16, 24, 40, 0.09);
  text-align: left;
}

.hero-search label {
  min-width: 0;
  color: #59677c;
  font-size: 0.76rem;
}

.hero-search input,
.hero-search select {
  min-height: 46px;
  border-color: #c7d2e3;
  background: #fbfdff;
  font-size: 0.92rem;
}

.hero-search button {
  width: 80px;
  min-width: 80px;
  min-height: 46px;
  padding: 11px 14px;
  color: #fff;
  background: linear-gradient(180deg, #1f5cff, var(--primary));
  border: 0;
  border-radius: var(--radius);
  box-shadow: 0 8px 18px rgba(1, 69, 242, 0.2);
  font-weight: 900;
  line-height: 1;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.hero-search button:hover {
  background: #0038ce;
  box-shadow: 0 12px 24px rgba(1, 69, 242, 0.26);
  transform: translateY(-1px);
}

.hero-search-summary {
  display: none;
  grid-column: 1 / -1;
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  text-align: center;
}

.province-chips {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(980px, 100%);
  margin-top: 16px;
}

.province-chips button {
  min-height: 40px;
  padding: 8px 14px;
  color: var(--blue-dark);
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(188, 200, 218, 0.78);
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.035);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.province-chips button:hover,
.province-chips button.active {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}

.province-chips button:hover {
  transform: translateY(-1px);
}

.province-insight {
  display: grid;
  grid-template-columns: minmax(180px, 1.2fr) repeat(3, minmax(110px, 0.7fr));
  gap: 10px;
  width: min(980px, 100%);
  margin-top: 12px;
  text-align: left;
}

.province-insight span {
  display: grid;
  gap: 2px;
  min-height: 50px;
  padding: 10px 12px;
  color: var(--muted);
  background: rgba(252, 253, 255, 0.92);
  border: 1px solid rgba(188, 200, 218, 0.82);
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 800;
  box-shadow: 0 8px 20px rgba(16, 24, 40, 0.035);
}

.province-insight strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.district-chips {
  display: grid;
  gap: 7px;
  width: min(980px, 100%);
  margin-top: 12px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(188, 200, 218, 0.74);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(16, 24, 40, 0.06);
}

.district-chip-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.district-chip-head strong {
  color: var(--blue-dark);
  font-size: 0.9rem;
}

.district-chip-head span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.district-chip-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-height: 118px;
  overflow: auto;
  padding-right: 2px;
}

.district-chip-list button {
  min-height: 36px;
  padding: 7px 11px;
  color: var(--blue-dark);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 900;
  white-space: nowrap;
}

.district-chip-list button:hover,
.district-chip-list button.active {
  color: #fff;
  background: var(--primary);
  border-color: var(--primary);
}

.metric-grid,
.coverage-dashboard {
  display: grid;
  gap: 16px;
}

.metric-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.metric-grid article,
.province-card,
.detail-panel,
.table-panel,
.local-picker,
.pending-panel,
.ward-card,
.ward-empty {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(188, 200, 218, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.metric-grid article {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "label value"
    "note value";
  column-gap: 14px;
  align-items: center;
  min-height: 82px;
  padding: 14px 15px;
  background: rgba(255, 255, 255, 0.96);
  overflow: hidden;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.metric-grid article:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.metric-grid article::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--blue);
}

.metric-grid article:nth-child(2n)::before {
  background: #5b87ff;
}

.metric-grid span,
.province-card span,
.table-title span {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1.25;
}

.metric-grid strong {
  grid-area: value;
  display: block;
  margin: 0;
  color: var(--blue);
  font-size: clamp(1.45rem, 1.1rem + 0.9vw, 1.9rem);
  line-height: 1;
}

.metric-grid p,
.province-card p,
.section-heading p {
  color: var(--muted);
  line-height: 1.6;
}

.metric-grid p {
  grid-area: note;
  margin-bottom: 0;
  font-size: 0.82rem;
  line-height: 1.35;
}

.metric-grid article > span {
  grid-area: label;
}

.section-block {
  margin-top: 30px;
  padding: 22px 0 0;
}

.section-heading {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.72fr);
  gap: 28px;
  align-items: end;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.section-heading::before {
  content: "";
  position: absolute;
  inset: auto auto -1px 0;
  width: min(220px, 36%);
  height: 2px;
  background: linear-gradient(90deg, var(--primary), rgba(1, 69, 242, 0.16));
}

.section-heading > p {
  max-width: var(--measure);
  margin-bottom: 0;
}

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.35fr) repeat(5, minmax(136px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid rgba(188, 200, 218, 0.72);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

#unifiedFilterBar {
  grid-template-columns: minmax(260px, 1.55fr) repeat(5, minmax(148px, 1fr));
  padding: 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(247, 250, 255, 0.96)),
    linear-gradient(90deg, rgba(1, 69, 242, 0.035), rgba(255, 255, 255, 0));
}

.filter-bar.compact {
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  width: 100%;
}

.filter-bar.vertical {
  grid-template-columns: 1fr;
  margin-bottom: 14px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  user-select: none;
}

input,
select {
  width: 100%;
  min-height: var(--control-height);
  padding: 9px 12px;
  color: var(--ink);
  background: #fbfcfe;
  border: 1px solid #becadd;
  border-radius: var(--radius);
  outline: none;
}

.filter-bar input,
.filter-bar select {
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.filter-bar input::placeholder {
  color: #98a2b3;
  opacity: 1;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus);
}

select:disabled {
  color: #98a2b3;
  background: #f1f4f9;
}

.coverage-dashboard {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  margin: 12px 0 18px;
}

.province-card {
  display: grid;
  gap: 10px;
  min-height: 150px;
  padding: 15px;
  border-top: 3px solid var(--primary);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.province-card:focus-visible {
  outline: 3px solid rgba(1, 69, 242, 0.18);
  outline-offset: 2px;
}

.province-card:hover,
.province-card.selected {
  border-color: rgba(1, 69, 242, 0.32);
  box-shadow: 0 0 0 2px rgba(1, 69, 242, 0.08), 0 16px 34px rgba(16, 24, 40, 0.07);
}

.province-card.selected {
  background: #fbfdff;
  transform: translateY(-1px);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.card-head strong {
  color: var(--good);
  font-size: 1.34rem;
}

.province-card p {
  min-height: 0;
  margin-bottom: 0;
  font-size: 0.8rem;
  line-height: 1.5;
}

.progress-track {
  overflow: hidden;
  height: 8px;
  margin: 2px 0 4px;
  background: #dbe4f0;
  border-radius: 999px;
}

.progress-track span {
  display: block;
  height: 100%;
  background: var(--good);
  border-radius: inherit;
}

dl {
  display: grid;
  gap: 10px;
  margin: 0;
}

.province-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  padding-top: 2px;
}

.province-facts span {
  display: grid;
  gap: 1px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.15;
}

.province-facts strong {
  color: var(--ink);
  font-size: 0.98rem;
  line-height: 1;
}

dt {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

dd {
  margin: 2px 0 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.table-panel {
  overflow: hidden;
  box-shadow: var(--shadow-md);
}

.table-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 18px;
  background: linear-gradient(180deg, #ffffff, #f9fbfe);
  border-bottom: 1px solid var(--line);
}

.table-title.inline {
  padding: 0;
  margin: 18px 0 10px;
  background: transparent;
  border: 0;
}

.table-title h3 {
  margin: 0;
}

.table-scroll {
  max-width: 100%;
  max-height: min(66vh, 680px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scrollbar-gutter: stable both-edges;
}

#coverage .table-scroll {
  max-height: min(58vh, 560px);
}

#directory .table-scroll {
  max-height: min(70vh, 720px);
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  position: sticky;
  top: 0;
  z-index: 2;
  color: var(--muted);
  background: #f7faff;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr[data-gov-id],
tbody tr[data-local-id],
tbody tr[data-ward-local-id] {
  cursor: pointer;
}

tbody tr[data-gov-id] td:first-child,
tbody tr[data-local-id] td:first-child,
tbody tr[data-ward-local-id] td:first-child {
  font-weight: 800;
}

tbody tr:hover {
  background: #f5f8ff;
  box-shadow: inset 3px 0 0 rgba(1, 69, 242, 0.4);
}

tbody tr.selected-row {
  background: #f3f7ff;
  box-shadow: inset 3px 0 0 var(--blue);
}

.status-badge,
.type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.2;
}

.type-badge {
  color: var(--blue-dark);
  background: #e8eef8;
}

.status-badge.complete,
.status-badge.verified {
  color: var(--good);
  background: #ecfdf3;
}

.status-badge.partial {
  color: var(--warn);
  background: #fff4e5;
}

.status-badge.pending {
  color: var(--danger);
  background: #fff1f3;
}

.status-badge.muted-badge {
  color: #475467;
  background: #edf1f5;
  border: 1px solid #d5dee9;
}

.segmented-control {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(188, 200, 218, 0.86);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.segmented-control button {
  min-height: var(--control-height);
  padding: 9px 14px;
  color: var(--blue-dark);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 900;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.segmented-control button.active {
  color: #fff;
  background: var(--blue);
  box-shadow: 0 8px 18px rgba(1, 69, 242, 0.18);
}

.detail-panel {
  display: grid;
  grid-template-columns: minmax(260px, 0.72fr) minmax(0, 1.28fr);
  gap: 20px;
  min-width: 0;
  margin-bottom: 18px;
  padding: 20px;
  border-left: 3px solid var(--blue);
  box-shadow: var(--shadow-sm);
}

.detail-panel > *,
.ward-layout > *,
.ward-main,
.ward-records,
.ward-card,
.ward-card header,
.local-picker,
.local-list button {
  min-width: 0;
  max-width: 100%;
}

.detail-panel h3 {
  font-size: 1.3rem;
}

.detail-panel dl {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-list,
.member-list ul {
  display: grid;
  gap: 8px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.compact-list li,
.member-list li {
  display: grid;
  gap: 2px;
}

.empty-cell {
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.ward-layout {
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  min-width: 0;
  overflow: hidden;
}

.local-picker {
  position: sticky;
  top: 92px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}

.local-list {
  display: grid;
  gap: 8px;
  max-height: 680px;
  overflow: auto;
  padding-right: 4px;
}

.local-list button {
  display: grid;
  gap: 5px;
  width: 100%;
  min-height: 64px;
  padding: 14px;
  color: var(--ink);
  background: #fbfdff;
  border: 1px solid rgba(188, 200, 218, 0.82);
  border-radius: 8px;
  text-align: left;
}

.local-list button:hover {
  border-color: var(--line-strong);
  background: #f6f9ff;
}

.local-list button.active {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--focus);
}

.local-list small {
  line-height: 1.35;
}

.local-list span {
  justify-self: start;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 900;
}

.local-list .complete,
.local-list .verified {
  color: var(--good);
  background: #ecfdf3;
}

.local-list .partial {
  color: var(--warn);
  background: #fff4e5;
}

.local-list .pending {
  color: var(--danger);
  background: #fff1f3;
}

.pending-panel {
  margin-bottom: 16px;
  padding: 16px;
  background: #fff7f9;
  border-color: #f7c6d0;
  border-left: 4px solid var(--primary);
}

.pending-panel p,
.ward-empty p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.6;
}

.ward-records {
  display: grid;
  gap: 14px;
  min-width: 0;
  max-width: 100%;
  max-height: min(76vh, 900px);
  overflow: auto;
  padding-right: 4px;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.ward-card,
.ward-empty {
  min-width: 0;
  max-width: 100%;
  padding: 20px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.ward-card {
  border-left: 3px solid var(--blue);
}

.ward-card header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.ward-card header p {
  margin-bottom: 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.person-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.person-grid > div {
  min-width: 0;
  padding: 12px;
  background: #f8fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.person-grid .missing {
  background: #fff7f9;
  border-color: #f7c6d0;
}

.person-grid small {
  display: block;
  overflow-wrap: anywhere;
}

.member-list {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.member-list dt {
  margin-bottom: 8px;
}

.padded {
  padding: 12px;
}

@media (max-width: 1200px) {
  h1 {
    font-size: 2rem;
  }

  .hero-search {
    grid-template-columns: repeat(2, minmax(0, 1fr)) minmax(240px, 1.2fr) minmax(120px, 0.7fr) 80px;
  }

  .hero-search label:nth-child(2) {
    grid-column: auto;
  }

  .province-insight {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .district-chip-list {
    max-height: 124px;
  }

  .metric-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .coverage-dashboard {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .filter-bar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  #unifiedFilterBar {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .detail-panel,
  .detail-panel dl,
  .person-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding: 12px 16px;
  }

  .topbar nav {
    justify-content: flex-start;
  }

  main {
    width: min(100% - 24px, 1440px);
    padding-top: 14px;
  }

  h1 {
    font-size: 1.8rem;
  }

  h2 {
    font-size: 1.55rem;
  }

  .hero-section,
  .section-heading,
  .ward-layout,
  .detail-panel,
  .detail-panel dl,
  .person-grid {
    grid-template-columns: 1fr;
  }

  .section-block {
    padding: 18px 0 0;
  }

  .hero-section {
    padding: 0;
  }

  .hero-copy {
    padding: 26px 16px 20px;
  }

  .hero-search {
    grid-template-columns: 1fr;
  }

  .hero-search button {
    width: 100%;
    min-width: 0;
  }

  .hero-search label:nth-child(2),
  .hero-search-summary {
    grid-column: auto;
  }

  .command-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .province-insight {
    grid-template-columns: 1fr;
  }

  .district-chip-list {
    max-height: 180px;
  }

  .metric-grid,
  .coverage-dashboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar,
  .filter-bar.compact {
    grid-template-columns: 1fr;
  }

  #unifiedFilterBar {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    padding: 10px;
  }

  table {
    min-width: 680px;
  }

  .local-picker {
    position: static;
  }

  .local-list {
    max-height: 460px;
  }
}

@media (max-width: 560px) {
  .brand {
    min-width: 0;
  }

  .brand img {
    width: 38px;
    height: 38px;
  }

  .topbar nav a {
    min-height: 38px;
    padding: 7px 8px;
    font-size: 0.85rem;
  }

  h1 {
    font-size: 1.55rem;
  }

  .hero-copy p {
    font-size: 0.92rem;
  }

  .command-kpis {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .province-chips button {
    flex: 1 1 calc(50% - 8px);
  }

  .metric-grid,
  .coverage-dashboard {
    grid-template-columns: 1fr;
  }

  .metric-grid article {
    min-height: 86px;
  }

  .metric-grid strong {
    font-size: 1.85rem;
  }

  th,
  td {
    padding: 11px 12px;
  }

  table {
    min-width: 620px;
  }

  .ward-card header {
    display: grid;
  }
}
