:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef3f8;
  --ink: #17202a;
  --muted: #5e6b78;
  --line: #d9e1ea;
  --brand: #126b58;
  --brand-2: #8b5d14;
  --danger: #a33434;
  --shadow: 0 16px 40px rgba(31, 47, 70, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Noto Sans Devanagari", "Nirmala UI", "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  min-height: 38px;
  padding: 0 14px;
}

.header-actions a {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  display: inline-flex;
  min-height: 38px;
  padding: 0 14px;
  text-decoration: none;
}

button:hover,
.header-actions a:hover {
  border-color: var(--brand);
  color: var(--brand);
}

.topbar {
  align-items: center;
  background: linear-gradient(135deg, #fbfcfd 0%, #e6f1ee 100%);
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px clamp(16px, 4vw, 44px);
}

.eyebrow {
  color: var(--brand-2);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 6px;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.8rem, 4vw, 3rem);
  line-height: 1.05;
  margin-bottom: 8px;
}

h2 {
  font-size: 1.35rem;
  margin-bottom: 0;
}

.subhead {
  color: var(--muted);
  margin-bottom: 0;
}

.header-actions {
  display: flex;
  gap: 10px;
}

.layout {
  display: grid;
  gap: 18px;
  margin: 0 auto;
  max-width: 1440px;
  padding: 22px clamp(12px, 3vw, 32px) 40px;
}

.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(140px, 1fr));
}

.stats-grid article,
.controls,
.ward-card,
.family-panel,
.result-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.stats-grid article {
  min-height: 96px;
  padding: 16px;
}

.stats-grid span {
  color: var(--muted);
  display: block;
  font-size: 0.86rem;
  margin-bottom: 8px;
}

.stats-grid strong {
  font-size: 1.7rem;
  line-height: 1;
}

.controls {
  display: grid;
  gap: 14px;
  padding: 16px;
}

label span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 6px;
}

input,
select {
  background: #fbfdff;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-height: 42px;
  padding: 0 12px;
  width: 100%;
}

input:focus,
select:focus {
  border-color: var(--brand);
  outline: 3px solid rgba(18, 107, 88, 0.15);
}

.search-field input {
  font-size: 1.05rem;
}

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

.quick-wards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-wards button.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.ward-overview {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
}

.ward-card {
  padding: 14px;
}

.ward-card h3 {
  font-size: 1.05rem;
  margin: 0 0 8px;
}

.ward-card p {
  color: var(--muted);
  font-size: 0.88rem;
  margin-bottom: 12px;
  min-height: 42px;
}

.ward-card .numbers {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(3, 1fr);
}

.numbers span {
  background: var(--surface-2);
  border-radius: 6px;
  color: var(--muted);
  display: grid;
  font-size: 0.76rem;
  min-height: 48px;
  padding: 6px;
}

.numbers strong {
  color: var(--ink);
  font-size: 1rem;
}

.family-panel,
.result-panel {
  overflow: hidden;
}

.panel-head,
.pager {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
}

.table-wrap {
  overflow-x: auto;
}

.family-note {
  color: var(--muted);
  font-size: 0.9rem;
}

.family-groups {
  display: grid;
  gap: 12px;
  padding: 0 16px 16px;
}

.family-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.family-card header {
  background: #f7faf8;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding: 12px;
}

.family-card h3 {
  font-size: 1rem;
  margin: 0;
}

.family-card table {
  min-width: 860px;
}

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

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

th {
  background: #f0f5f8;
  color: #344250;
  font-size: 0.78rem;
  position: sticky;
  top: 0;
  z-index: 1;
}

tbody tr:hover {
  background: #f8fbfb;
}

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

.badge {
  background: #e8f2ef;
  border-radius: 999px;
  color: var(--brand);
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 3px 8px;
}

.local-id {
  background: #fff7df;
  border: 1px solid #efd083;
  border-radius: 999px;
  color: #805b10;
  display: inline-block;
  font-size: 0.78rem;
  font-weight: 800;
  padding: 3px 8px;
}

.match {
  background: #fff1a8;
  border-radius: 3px;
}

.empty-row td {
  color: var(--muted);
  padding: 28px 12px;
  text-align: center;
}

@media (max-width: 980px) {
  .topbar,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid,
  .ward-overview,
  .control-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .stats-grid,
  .ward-overview,
  .control-row {
    grid-template-columns: 1fr;
  }

  .header-actions,
  .pager {
    width: 100%;
  }

  .header-actions button,
  .pager button {
    flex: 1;
  }
}

@media print {
  .controls,
  .header-actions,
  .pager {
    display: none;
  }

  body {
    background: #fff;
  }

  .topbar,
  .stats-grid article,
  .ward-card,
  .result-panel {
    box-shadow: none;
  }
}
