:root {
  --primary: #2458a6;
  --primary-dark: #163b73;
  --surface: #ffffff;
  --muted-surface: #f3f6fa;
  --border: #d9e1ec;
  --text: #172033;
  --muted: #667085;
}

body {
  background: var(--muted-surface);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sidebar {
  background: linear-gradient(180deg, var(--primary-dark), var(--primary));
  bottom: 0;
  color: #fff;
  display: flex;
  flex-direction: column;
  height: 100vh;
  left: 0;
  overflow: hidden;
  padding: 0;
  position: fixed;
  top: 0;
  width: 270px;
  z-index: 1000;
}

.brand-block {
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  flex: 0 0 auto;
  gap: 0.85rem;
  min-width: 0;
  padding: 1.25rem;
}

.brand-mark {
  align-items: center;
  background: #fff;
  border-radius: 8px;
  color: var(--primary-dark);
  display: flex;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  letter-spacing: 0;
  width: 44px;
}

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.brand-subtitle {
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.sidebar-nav {
  align-content: stretch;
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 0.35rem;
  min-height: 0;
  overscroll-behavior: contain;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 1rem 1.05rem;
  scrollbar-gutter: stable;
  width: 100%;
}

.sidebar-nav-restoring {
  visibility: hidden;
}

.sidebar-nav .nav-link,
.sidebar-group-toggle {
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.82);
  flex: 0 0 auto;
  font-weight: 600;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 0.48rem 0.75rem;
  white-space: normal;
  width: 100%;
}

.sidebar-group {
  flex: 0 0 auto;
  min-width: 0;
}

.sidebar-group-toggle {
  align-items: center;
  background: transparent;
  border: 0;
  display: flex;
  gap: 0.45rem;
  text-align: left;
}

.sidebar-group-toggle:hover,
.sidebar-group-toggle:focus,
.sidebar-group.has-active > .sidebar-group-toggle {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  outline: 0;
}

.sidebar-group-toggle:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.42);
}

.sidebar-group-caret {
  border-bottom: 4px solid transparent;
  border-left: 5px solid currentColor;
  border-top: 4px solid transparent;
  flex: 0 0 auto;
  height: 0;
  transition: transform 0.18s ease;
  width: 0;
}

.sidebar-group.expanded > .sidebar-group-toggle .sidebar-group-caret {
  transform: rotate(90deg);
}

.sidebar-group-title {
  min-width: 0;
  overflow-wrap: anywhere;
}

.sidebar-group-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.22s ease;
}

.sidebar-group.expanded > .sidebar-group-panel {
  max-height: 1600px;
}

.sidebar-nav .nav-depth-1.nav-link,
.sidebar-nav .nav-depth-1.sidebar-group {
  margin-left: 0.85rem;
  width: calc(100% - 0.85rem);
}

.sidebar-nav .nav-depth-2.nav-link,
.sidebar-nav .nav-depth-2.sidebar-group {
  margin-left: 1.45rem;
  width: calc(100% - 1.45rem);
}

.sidebar-nav .nav-depth-3.nav-link,
.sidebar-nav .nav-depth-3.sidebar-group {
  margin-left: 2rem;
  width: calc(100% - 2rem);
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-link.active {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.18);
  flex: 0 0 auto;
  min-width: 0;
  overflow-wrap: anywhere;
  padding: 1rem 1.25rem 1.25rem;
}

.sidebar-logout-area {
  flex: 0 0 auto;
  margin-bottom: 0.75rem;
  min-width: 0;
}

.sidebar-logout-area form {
  margin: 0;
}

.sidebar-logout-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: block;
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 0.75rem;
  text-align: left;
  width: 100%;
}

.sidebar-logout-button:hover,
.sidebar-logout-button:focus {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.7);
  color: #fff;
}

.sidebar-logout-button:focus-visible {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.42);
  outline: 0;
}

.nav-group-label,
.mobile-nav-label {
  color: rgba(255, 255, 255, 0.62);
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin: 0.75rem 0 0.15rem;
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  text-transform: uppercase;
  width: 100%;
}

.mobile-nav-label {
  color: var(--muted);
  margin-top: 1rem;
}

.mobile-nav .nav-link {
  color: var(--text);
  font-weight: 600;
  padding: 0.75rem 0;
}

.mobile-nav .sidebar-group-toggle {
  color: var(--text);
  padding: 0.7rem 0;
}

.mobile-nav .sidebar-group-toggle:hover,
.mobile-nav .sidebar-group-toggle:focus,
.mobile-nav .sidebar-group.has-active > .sidebar-group-toggle,
.mobile-nav .nav-link:hover,
.mobile-nav .nav-link.active {
  background: var(--muted-surface);
  color: var(--primary);
}

.mobile-nav .sidebar-group-toggle:focus-visible {
  box-shadow: 0 0 0 2px rgba(36, 88, 166, 0.28);
}

.mobile-sidebar-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.mobile-sidebar-body .mobile-nav {
  min-height: 0;
}

.mobile-sidebar-logout {
  border-top: 1px solid var(--border);
  margin: 0;
  padding: 1rem;
}

.mobile-sidebar-logout .sidebar-logout-button {
  border-color: var(--border);
  color: var(--text);
}

.mobile-sidebar-logout .sidebar-logout-button:hover,
.mobile-sidebar-logout .sidebar-logout-button:focus {
  background: var(--muted-surface);
  border-color: var(--primary);
  color: var(--primary);
}

.mobile-sidebar-logout .sidebar-logout-button:focus-visible {
  box-shadow: 0 0 0 2px rgba(36, 88, 166, 0.28);
}

.main-shell {
  margin-left: 270px;
  min-height: 100vh;
  padding: 2rem;
}

.login-shell {
  align-items: center;
  background:
    linear-gradient(rgba(22, 59, 115, 0.78), rgba(22, 59, 115, 0.78)),
    url("https://images.unsplash.com/photo-1486406146926-c627a92ad1ab?auto=format&fit=crop&w=1800&q=80");
  background-position: center;
  background-size: cover;
  display: flex;
  min-height: 100vh;
  padding: 1rem;
}

.login-panel {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.24);
  margin: 0 auto;
  max-width: 420px;
  padding: 2rem;
  width: 100%;
}

.login-header {
  margin-bottom: 1.5rem;
  text-align: center;
}

.login-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  margin-bottom: 0.25rem;
}

.login-header p,
.login-note,
.eyebrow,
.stat-card span {
  color: var(--muted);
}

.login-note {
  border-top: 1px solid var(--border);
  font-size: 0.86rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  text-align: center;
}

.flash-stack {
  margin-bottom: 1rem;
}

.ward-scope-bar,
.scope-banner {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
}

.scope-label {
  color: var(--muted);
  display: block;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.scope-selector {
  align-items: center;
  display: flex;
  gap: 0.65rem;
  min-width: 280px;
}

.scope-selector .form-select {
  min-width: 180px;
}

.page-header {
  align-items: end;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  font-size: 1.85rem;
  font-weight: 800;
  margin: 0;
}

.eyebrow {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  margin-bottom: 0.2rem;
  text-transform: uppercase;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: end;
}

.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.25rem;
}

.stat-card,
.content-section,
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}

.stat-card {
  border-left: 4px solid var(--primary);
  padding: 1rem;
}

.stat-card-link {
  color: inherit;
  cursor: pointer;
  text-decoration: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.stat-card-link:hover {
  border-color: var(--primary);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
  color: inherit;
  transform: translateY(-2px);
}

.stat-card-link:focus-visible {
  box-shadow: 0 0 0 3px rgba(36, 88, 166, 0.28);
  outline: 0;
}

.stat-card.highlight {
  border-left-color: #198754;
}

.stat-card strong {
  display: block;
  font-size: 2rem;
  line-height: 1.1;
  margin-top: 0.35rem;
}

.register-summary-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 1.25rem;
}

.register-summary-card {
  display: flex;
  flex-direction: column;
  min-height: 112px;
}

.register-summary-card strong {
  margin-top: auto;
}

.register-search-bar {
  margin-bottom: 1.25rem;
}

.detail-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.8fr);
}

.household-summary {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(0, 1fr) minmax(420px, 0.95fr);
  margin-bottom: 1.25rem;
  padding: 1rem;
}

.household-summary-main {
  border-left: 4px solid var(--primary);
  padding-left: 1rem;
}

.household-summary-main span,
.household-summary-stats span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
}

.household-summary-main strong {
  display: block;
  font-size: 1.45rem;
  line-height: 1.2;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
}

.household-summary-main p {
  color: var(--muted);
  margin: 0.35rem 0 0;
}

.household-summary-stats {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.household-summary-stats div {
  background: var(--muted-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  padding: 0.85rem;
}

.household-summary-stats strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1.1;
  margin-top: 0.25rem;
}

.death-summary {
  align-items: stretch;
  grid-template-columns: minmax(260px, 0.85fr) minmax(420px, 1.4fr);
}

.death-summary .household-summary-main,
.death-summary .household-summary-stats div {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.death-summary .household-summary-main strong,
.death-summary .household-summary-stats strong {
  line-height: 1.05;
  overflow-wrap: normal;
  white-space: nowrap;
}

.death-summary .household-summary-main strong {
  font-size: 1.8rem;
}

.death-summary .household-summary-stats {
  grid-template-columns: repeat(3, minmax(150px, 1fr));
}

.death-summary .household-summary-stats div {
  min-height: 96px;
  padding: 0.75rem 0.85rem;
}

.death-summary .household-summary-stats span {
  font-size: 0.9rem;
  font-weight: 600;
}

.death-summary .household-summary-stats strong {
  font-size: 1.45rem;
}

.content-section,
.filter-bar {
  margin-bottom: 1.25rem;
  padding: 1rem;
}

.section-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.section-header h2,
.section-title {
  font-size: 1.05rem;
  font-weight: 800;
  margin: 0;
}

.form-section {
  padding: 1.25rem;
}

.form-subtitle {
  border-top: 1px solid var(--border);
  font-size: 1rem;
  font-weight: 800;
  margin: 0.5rem 0 0;
  padding-top: 1rem;
}

.relationship-card {
  background: var(--muted-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
}

.relationship-card-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
  margin-bottom: 0.9rem;
}

.relationship-card-header h3 {
  font-size: 0.98rem;
  font-weight: 800;
  margin: 0;
}

.relationship-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.relationship-mode label {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  gap: 0.4rem;
  margin: 0;
  min-height: 36px;
  padding: 0.35rem 0.65rem;
}

.relationship-mode input {
  margin: 0;
}

.relationship-external-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.citizen-lookup {
  position: relative;
}

.citizen-lookup-results {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow);
  left: 0;
  margin-top: 0.25rem;
  max-height: 240px;
  overflow-y: auto;
  position: absolute;
  right: 0;
  top: 100%;
  z-index: 20;
}

.citizen-lookup-option {
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--border);
  display: block;
  padding: 0.55rem 0.75rem;
  text-align: left;
  width: 100%;
}

.citizen-lookup-option:last-child {
  border-bottom: 0;
}

.citizen-lookup-option:hover,
.citizen-lookup-option:focus {
  background: var(--muted-surface);
  outline: 0;
}

.citizen-lookup-name {
  color: var(--text);
  display: block;
  font-weight: 800;
}

.citizen-lookup-meta {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  line-height: 1.25;
  margin-top: 0.1rem;
}

@media (max-width: 991.98px) {
  .relationship-external-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .relationship-card-header {
    align-items: stretch;
    flex-direction: column;
  }

  .relationship-mode {
    flex-direction: column;
  }

  .relationship-external-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.form-actions {
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
}

.form-actions-top {
  border-top: 0;
  margin-top: 0;
  margin-bottom: 1.25rem;
  padding-top: 0;
}

.household-register-form {
  padding: 1.5rem;
}

.household-form-grid {
  display: grid;
  gap: 1rem;
}

.top-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.9fr);
}

.top-grid > div:nth-child(n + 3) {
  grid-column: span 1;
}

.top-grid > div:nth-child(3) {
  grid-column: 1;
}

.top-grid > div:nth-child(4),
.top-grid > div:nth-child(5) {
  grid-column: span 1;
}

.two-column-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
}

.span-left {
  grid-column: 1;
}

.section-divider {
  align-items: center;
  color: var(--primary);
  display: flex;
  font-size: 0.9rem;
  font-weight: 800;
  gap: 0.75rem;
  letter-spacing: 0;
  margin: 1.5rem 0 0.75rem;
  text-transform: uppercase;
}

.section-divider::after {
  background: var(--border);
  content: "";
  flex: 1;
  height: 1px;
}

.section-divider.in-panel {
  margin-top: 0;
}

.readonly-value {
  color: var(--muted);
  min-height: 38px;
  padding: 0.375rem 0;
}

.required-mark {
  color: #dc3545;
}

.residence-population-panel {
  background: #f2f6fb;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 0.85fr);
  margin-top: 1.25rem;
  padding: 1rem;
}

.residence-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
}

.resident-help-box,
.linked-records-box {
  border-radius: 8px;
  margin-top: 1rem;
  padding: 0.9rem 1rem;
}

.resident-help-box {
  background: #fff8db;
  border: 1px solid #f0d47b;
}

.resident-help-box ul {
  margin: 0.5rem 0 0;
}

.linked-records-box {
  background: #eef6ff;
  border: 1px solid #b8d7ff;
}

.linked-records-box p {
  margin: 0.25rem 0 0;
}

.population-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  align-self: start;
  padding: 1rem;
}

.population-panel h2 {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
}

.population-panel p {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.household-population-cards {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.household-population-cards div {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem;
  text-align: center;
}

.household-population-cards span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
}

.household-population-cards strong {
  color: var(--primary);
  display: block;
  font-size: 1.35rem;
  margin-top: 0.45rem;
}

.nested-form-section {
  margin-top: 1.25rem;
}

.household-detail-summary {
  padding-bottom: 0.75rem;
}

.summary-field-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.summary-field-grid div {
  background: var(--muted-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  padding: 0.8rem;
}

.summary-field-grid span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
}

.summary-field-grid strong {
  display: block;
  font-size: 0.98rem;
  margin-top: 0.25rem;
  overflow-wrap: anywhere;
}

.household-detail-stat-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.compact-info-list div {
  grid-template-columns: 230px minmax(0, 1fr);
  padding: 0.7rem 0;
}

.filter-checks {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding-top: 0.35rem;
}

.filter-checks .form-check {
  align-items: center;
  display: flex;
  gap: 0.35rem;
  margin: 0;
}

.pagination-bar {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.85rem;
}

.pagination-summary {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
  margin-right: auto;
}

.pagination-controls,
.pagination-size-form {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pagination-size-form .form-select {
  min-width: 86px;
}

.info-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.info-list div {
  border-top: 1px solid var(--border);
  display: grid;
  gap: 1rem;
  grid-template-columns: 190px minmax(0, 1fr);
  padding: 0.85rem 0;
}

.info-list div:first-child {
  border-top: 0;
}

.info-list dt {
  color: var(--muted);
  font-weight: 700;
}

.info-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.compact-stat-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-stat {
  background: var(--muted-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  display: block;
  padding: 0.85rem;
  text-decoration: none;
}

a.compact-stat {
  cursor: pointer;
}

.compact-stat:hover {
  border-color: var(--primary);
  color: inherit;
}

a.compact-stat:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.2);
  outline: none;
}

.compact-stat span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
}

.compact-stat strong {
  display: block;
  font-size: 1.5rem;
  line-height: 1.2;
  margin-top: 0.25rem;
}

.compact-stat .name-stat {
  font-size: 1rem;
  overflow-wrap: anywhere;
}

.analytics-summary-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.module-card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.module-card {
  align-items: flex-start;
  background: var(--muted-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  height: 100%;
  min-width: 0;
  padding: 1rem;
  text-decoration: none;
}

.module-card:hover {
  border-color: var(--primary);
  color: inherit;
}

.module-card-icon {
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--primary);
  display: flex;
  font-weight: 800;
  height: 44px;
  justify-content: center;
  width: 44px;
}

.module-card-body {
  min-width: 0;
}

.module-card h3 {
  font-size: 1rem;
  font-weight: 800;
  margin: 0 0 0.35rem;
}

.module-card strong {
  display: block;
  font-size: 1.2rem;
  line-height: 1.2;
  margin-bottom: 0.35rem;
  overflow-wrap: anywhere;
}

.module-card p {
  color: var(--muted);
  margin: 0;
}

.module-card-action {
  margin-top: auto;
}

.dashboard-summary-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.info-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0;
}

.info-grid div,
.import-type-option {
  background: var(--muted-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  padding: 0.85rem;
}

.info-grid dt,
.import-type-option small {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
}

.info-grid dd {
  font-weight: 700;
  margin: 0.2rem 0 0;
  overflow-wrap: anywhere;
}

.import-type-option {
  cursor: pointer;
  display: flex;
  gap: 0.7rem;
  height: 100%;
}

.import-type-option.disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.import-type-option strong {
  display: block;
  margin-bottom: 0.2rem;
}

.document-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.document-card {
  background: #edf7f0;
  border: 1px solid #b9e0c2;
  border-radius: 8px;
  padding: 0.85rem;
}

.document-card.missing {
  background: #fff4ed;
  border-color: #ffd2b8;
}

.document-card span,
.document-card small {
  color: var(--muted);
  display: block;
  font-weight: 700;
}

.document-card strong {
  display: block;
  font-size: 1.15rem;
  margin: 0.2rem 0;
}

.chart-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.chart-panel {
  background: var(--muted-surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  min-width: 0;
  padding: 1rem;
}

.chart-panel h3 {
  font-size: 0.95rem;
  font-weight: 800;
  margin: 0 0 0.75rem;
}

.chart-frame {
  height: 280px;
  position: relative;
}

.nested-tab-content {
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 8px 8px;
  padding: 0 1rem 1rem;
}

.table {
  margin-bottom: 0;
}

.table thead th {
  color: #344054;
  font-size: 0.78rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
}

.table-actions {
  min-width: 190px;
  white-space: nowrap;
}

.register-column-filter-form,
.citizen-column-filter-form {
  margin: 0;
}

.register-filter-row th,
.citizen-filter-row th {
  background: var(--muted-surface);
  padding-bottom: 0.45rem;
  padding-top: 0.45rem;
  vertical-align: top;
}

.register-filter-row .form-control,
.register-filter-row .form-select,
.citizen-filter-row .form-control,
.citizen-filter-row .form-select {
  min-width: 96px;
}

.row-return-highlight > * {
  animation: returnHighlight 3.5s ease-out;
}

.household-action-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1080;
  max-width: min(360px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  border-radius: 8px;
  box-shadow: 0 18px 40px rgba(16, 24, 40, 0.18);
  color: #fff;
  font-weight: 700;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.household-action-toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.household-action-toast-success {
  background: #047857;
}

.household-action-toast-danger {
  background: #b42318;
}

@keyframes returnHighlight {
  0% {
    background-color: rgba(255, 193, 7, 0.42);
  }
  70% {
    background-color: rgba(255, 193, 7, 0.18);
  }
  100% {
    background-color: transparent;
  }
}

.name-column {
  min-width: 130px;
}

.report-tabs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  padding: 0.5rem 0.5rem 0;
}

.report-tabs + .content-section {
  border-radius: 0 0 8px 8px;
}

.section-tabs {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  padding: 0.5rem;
}

.section-tabs a {
  border-radius: 8px;
  color: var(--text);
  font-weight: 700;
  padding: 0.55rem 0.8rem;
  text-decoration: none;
}

.section-tabs a.active,
.section-tabs a:hover {
  background: var(--primary);
  color: #fff;
}

.stacked-form {
  display: grid;
  gap: 1rem;
}

.btn,
.form-control,
.form-select,
.alert {
  border-radius: 8px;
}

@media (max-width: 1199.98px) {
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .register-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .detail-grid {
    grid-template-columns: 1fr;
  }

  .household-summary {
    grid-template-columns: 1fr;
  }

  .death-summary {
    grid-template-columns: 1fr;
  }

  .death-summary .household-summary-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .top-grid,
  .two-column-grid,
  .residence-population-panel,
  .residence-grid,
  .summary-field-grid {
    grid-template-columns: 1fr;
  }

  .top-grid > div:nth-child(n),
  .span-left {
    grid-column: auto;
  }

  .chart-grid {
    grid-template-columns: 1fr;
  }

}

@media (max-width: 991.98px) {
  .main-shell {
    margin-left: 0;
    padding: 1rem;
  }

  .page-header {
    align-items: stretch;
    flex-direction: column;
  }

  .ward-scope-bar,
  .scope-banner {
    align-items: stretch;
    flex-direction: column;
  }

  .scope-selector {
    align-items: stretch;
    flex-direction: column;
    min-width: 0;
  }

  .header-actions {
    justify-content: start;
  }

  .module-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 575.98px) {
  .stat-grid {
    grid-template-columns: 1fr;
  }

  .register-summary-grid {
    grid-template-columns: 1fr;
  }

  .compact-stat-grid,
  .analytics-summary-grid,
  .module-card-grid,
  .document-grid,
  .info-grid,
  .household-summary-stats,
  .household-population-cards,
  .household-detail-stat-grid,
  .info-list div {
    grid-template-columns: 1fr;
  }

  .info-list div {
    gap: 0.25rem;
  }

  .death-summary .household-summary-main strong,
  .death-summary .household-summary-stats strong {
    font-size: 1.25rem;
    white-space: normal;
  }

  .pagination-bar,
  .pagination-controls {
    align-items: stretch;
    flex-direction: column;
  }

  .pagination-summary {
    margin-right: 0;
  }

.table-actions .btn,
.table-actions form {
  margin-top: 0.25rem;
}
}

.duplicate-review-dialog {
  border-left: 4px solid #b58100;
}

.duplicate-live-panel {
  border: 1px solid #d8b45a;
  border-left: 4px solid #b58100;
  border-radius: 6px;
  background: #fff8e5;
  padding: 0.75rem;
}

.duplicate-live-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.duplicate-live-match {
  align-items: center;
  background: #fff;
  border: 1px solid #ead79d;
  border-radius: 6px;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.65rem 0.75rem;
}

.duplicate-live-match + .duplicate-live-match {
  margin-top: 0.5rem;
}

.duplicate-high {
  border-color: #c45f00;
}

.sector-card {
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sector-card:hover,
.sector-card:focus-visible {
  border-color: var(--primary);
  box-shadow: 0 0.25rem 0.75rem rgba(31, 78, 121, 0.12);
  outline: none;
  transform: translateY(-1px);
}
.location-map { width: 100%; height: clamp(320px, 52vh, 560px); min-height: 320px; border: 1px solid #ced4da; border-radius: .5rem; background: #eef2f5; }
.map-mode-control { display: flex; flex-wrap: wrap; gap: .5rem; }
.map-mode-control [aria-disabled="true"] { cursor: not-allowed; opacity: .65; }
.leaflet-container img.leaflet-tile { max-width: none !important; max-height: none !important; }
.map-filter-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) auto; gap: .75rem; align-items: end; }
.map-filter-grid label { display: grid; gap: .35rem; font-weight: 600; }
.ward-map-dashboard .map-filter-panel { margin-bottom: 1rem; }
.map-summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.ward-map-layout { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 1rem; transition: grid-template-columns .15s ease; }
.ward-map-layout.legend-hidden { grid-template-columns: minmax(0, 1fr); }
.map-layer-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem 1rem; margin-bottom: 1rem; }
.map-layer-toggle { display: inline-flex; align-items: center; gap: .35rem; min-height: 36px; }
.map-legend { border: 1px solid #d7dee7; border-radius: .5rem; padding: 3.25rem 1rem 1rem; background: #fff; }
.map-legend[hidden] { display: none !important; }
.map-legend h3 { font-size: 1rem; }
.map-legend-toggle { position: absolute; z-index: 900; top: .75rem; right: .75rem; width: auto; box-shadow: 0 1px 4px rgba(0,0,0,.16); background: #fff; }
.map-legend-symbol { display: inline-grid; place-items: center; width: 1.6rem; height: 1.6rem; color: #fff; border-radius: 50%; font-weight: 800; }
.map-symbol-house, .map-marker-house { background: #2563eb; }
.map-symbol-school, .map-marker-school { background: #15803d; transform: rotate(45deg); border-radius: .25rem !important; }
.map-symbol-church, .map-marker-church { background: #7e22ce; border-radius: 0 !important; clip-path: polygon(50% 0,100% 100%,0 100%); }
.map-symbol-infrastructure, .map-marker-infrastructure { background: #c2410c; border-radius: .15rem !important; }
.map-symbol-school { display: inline-flex; transform: none; clip-path: polygon(50% 0,100% 50%,50% 100%,0 50%); }
.map-symbol-church { display: inline-flex; }
.ward-map-hit-target { background: transparent; display: grid; place-items: center; }
.ward-map-marker { display: grid; place-items: center; width: 10px; height: 10px; color: transparent; border: 2px solid #fff; border-radius: 50%; box-shadow: 0 1px 4px rgba(0,0,0,.75); font-size: 0; transition: transform .12s ease, width .12s ease, height .12s ease; }
.ward-map-hit-target:hover .ward-map-marker, .ward-map-hit-target:focus .ward-map-marker, .ward-map-hit-target.leaflet-marker-icon:focus .ward-map-marker { width: 16px; height: 16px; transform: scale(1.1); }
.map-marker-school { transform: none; clip-path: polygon(50% 0,100% 50%,50% 100%,0 50%); }
.ward-map-dashboard:fullscreen, .ward-map-dashboard.map-fullscreen-active { width: 100vw; height: 100vh; max-width: none; margin: 0; padding: 1rem; border: 0; border-radius: 0; background: #f8fafc; display: flex; flex-direction: column; overflow: hidden; }
.ward-map-dashboard:fullscreen .ward-map-header, .ward-map-dashboard.map-fullscreen-active .ward-map-header { flex: 0 0 auto; margin-bottom: .5rem; }
.ward-map-dashboard:fullscreen .map-filter-panel, .ward-map-dashboard.map-fullscreen-active .map-filter-panel { flex: 0 0 auto; }
.ward-map-dashboard:fullscreen .map-layer-toolbar, .ward-map-dashboard.map-fullscreen-active .map-layer-toolbar { flex: 0 0 auto; margin-bottom: .5rem; }
.ward-map-dashboard:fullscreen .ward-map-layout, .ward-map-dashboard.map-fullscreen-active .ward-map-layout { flex: 1 1 auto; min-height: 0; }
.ward-map-dashboard:fullscreen .location-map, .ward-map-dashboard.map-fullscreen-active .location-map { height: 100%; min-height: 220px; }
.ward-map-dashboard.map-fullscreen-active { position: fixed; inset: 0; z-index: 2000; }
.map-fallback-scroll-lock { overflow: hidden !important; }
.ward-map-dashboard:fullscreen .leaflet-control, .ward-map-dashboard.map-fullscreen-active .leaflet-control { z-index: 800; }
.ward-map-dashboard button:focus-visible, .ward-map-dashboard input:focus-visible, .ward-map-dashboard select:focus-visible { outline: 3px solid #f59e0b; outline-offset: 2px; }
.geographic-location-summary form { display: flex; gap: .5rem; align-items: center; }
@media (max-width: 768px) { .location-map { min-height: 320px; } .geographic-location-summary form { align-items: stretch; flex-direction: column; } .map-filter-grid, .ward-map-layout { grid-template-columns: 1fr; } .map-layer-toolbar .btn { flex: 1 1 100%; } .map-legend { order: -1; } .ward-map-dashboard:fullscreen, .ward-map-dashboard.map-fullscreen-active { padding: .5rem; overflow-y: auto; } .ward-map-dashboard:fullscreen .ward-map-header, .ward-map-dashboard.map-fullscreen-active .ward-map-header { position: sticky; top: 0; z-index: 1000; background: #f8fafc; padding-bottom: .35rem; } .ward-map-dashboard:fullscreen .map-filter-panel, .ward-map-dashboard.map-fullscreen-active .map-filter-panel { max-height: 30vh; overflow-y: auto; } .ward-map-dashboard:fullscreen .ward-map-layout, .ward-map-dashboard.map-fullscreen-active .ward-map-layout { display: flex; flex-direction: column; min-height: 58vh; } .ward-map-dashboard:fullscreen .location-map, .ward-map-dashboard.map-fullscreen-active .location-map { flex: 1 1 55vh; min-height: 50vh; } }
