:root {
  --ink: #18212f;
  --muted: #627083;
  --line: #d9e2ec;
  --paper: #f6f8fb;
  --panel: #ffffff;
  --teal: #0f766e;
  --teal-dark: #0b4f4a;
  --gold: #b45309;
  --gold-soft: #f8d477;
  --red: #b42318;
  --blue: #2563eb;
  --shadow: 0 18px 45px rgba(24, 33, 47, .09);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(15, 118, 110, .05), transparent 320px),
    var(--paper);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
a { color: inherit; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 260px;
  padding: 24px 18px;
  color: #fff;
  background: linear-gradient(180deg, #102236 0%, #0e3145 54%, #0b4f4a 100%);
  box-shadow: 8px 0 30px rgba(16, 34, 54, .18);
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 28px;
}
.brand.centered { justify-content: center; color: var(--ink); }
.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: #f4b942;
  color: #102236;
  font-weight: 800;
}
.brand span { display: block; color: #aeb9c8; font-size: 12px; margin-top: 2px; }
.brand.light span { color: rgba(255,255,255,.72); }
.sidebar-logo-wrap {
  display: grid;
  place-items: center;
  padding: 10px;
  margin-bottom: 24px;
  border-radius: 8px;
  background: #fff;
}
.sidebar-logo {
  width: 100%;
  height: auto;
  display: block;
}
.sidebar nav { display: grid; gap: 6px; }
.sidebar a {
  padding: 11px 12px;
  border-radius: 8px;
  color: #e8edf4;
  text-decoration: none;
}
.sidebar a:hover { background: rgba(255,255,255,.09); }
.shell { margin-left: 260px; padding: 28px; }
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}
.topbar-main {
  flex: 1;
  min-width: 0;
}
.topbar-logo-center {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}
.topbar-title { text-align: left; }
.header-logo {
  width: min(540px, 58vw);
  height: auto;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(24, 33, 47, .08);
}
.eyebrow { margin: 0 0 4px; color: var(--teal); font-size: 12px; font-weight: 700; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
.user-menu { display: flex; align-items: center; gap: 12px; color: var(--muted); }
button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  color: #fff;
  background: var(--teal);
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}
button:hover, .button:hover { background: var(--teal-dark); }
.button.secondary, .user-menu button { color: var(--ink); background: #e9eef5; }
.button.secondary:hover, .user-menu button:hover { background: #dbe4ef; }
.button.compact {
  min-height: 30px;
  padding: 0 9px;
  border-radius: 7px;
  font-size: 12px;
}
.filters {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
  padding: 16px;
  margin-bottom: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
label span { display: block; margin-bottom: 6px; color: var(--muted); font-size: 12px; font-weight: 700; }
select, input {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(130px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.kpi {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}
.kpi::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--teal);
}
.kpi span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; }
.kpi strong { display: block; margin-top: 9px; font-size: 25px; }
.kpi.ok strong { color: var(--teal); }
.kpi.warn strong { color: var(--red); }
.layout-two {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, .7fr);
  gap: 18px;
}
.layout-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 22px;
}
.supervisor-counts-panel {
  margin-bottom: 22px;
}
.consent-panel {
  margin-bottom: 22px;
}
.supervisor-followup-table th:nth-child(4),
.supervisor-followup-table td:nth-child(4) {
  min-width: 320px;
}
.area-followup-table th:nth-child(7),
.area-followup-table td:nth-child(7) {
  min-width: 360px;
}
.id-chip-list {
  display: flex;
  max-width: 620px;
  flex-wrap: wrap;
  gap: 6px;
}
.id-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid rgba(15, 118, 110, .18);
  border-radius: 999px;
  color: var(--teal-dark);
  background: rgba(15, 118, 110, .08);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}
.id-chip.warning {
  border-color: rgba(180, 35, 24, .2);
  color: var(--red);
  background: rgba(180, 35, 24, .08);
}
.id-chip.success {
  border-color: rgba(15, 118, 110, .22);
  color: var(--teal-dark);
  background: rgba(15, 118, 110, .12);
}
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}
.overview-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px;
  margin-bottom: 22px;
  border: 1px solid rgba(15, 118, 110, .18);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(15, 118, 110, .12), rgba(180, 83, 9, .08)),
    #fff;
  box-shadow: var(--shadow);
}
.overview-band h2 {
  margin-bottom: 8px;
  font-size: 24px;
}
.overview-band p:last-child {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}
.overview-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--line);
}
.panel-subtitle {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}
.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.legend-dot {
  width: 12px;
  height: 12px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(24, 33, 47, .18);
}
.legend-dot.inside { background: var(--teal); }
.legend-dot.outside { background: var(--red); }
.legend-line {
  width: 22px;
  height: 0;
  border-top: 3px solid var(--blue);
  box-shadow: 0 2px 8px rgba(24, 33, 47, .18);
}
.legend-line.subzone { border-top-style: solid; }
.panel > canvas, .panel > dl, .panel > p { margin: 18px; }
.actions { display: flex; gap: 10px; margin: -4px 0 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
.muted-text {
  color: var(--muted);
  font-size: 12px;
}
.pill {
  display: inline-flex;
  padding: 4px 8px;
  border-radius: 999px;
  background: #e9eef5;
  font-size: 12px;
  font-weight: 700;
}
.pill.high { color: #fff; background: var(--red); }
.pill.medium { color: #fff; background: var(--gold); }
.pill.low { color: #fff; background: var(--blue); }
.pill.ok { color: #fff; background: var(--teal); }
.map-shell {
  position: relative;
  min-height: 640px;
  background: #eef4f1;
}
#bahdaMap {
  position: relative;
  z-index: 2;
  height: 640px;
  border-radius: 0;
}
.map-status {
  position: absolute;
  z-index: 500;
  left: 14px;
  top: 14px;
  max-width: min(520px, calc(100% - 28px));
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.9);
  box-shadow: 0 10px 26px rgba(24, 33, 47, .14);
  font-size: 12px;
  font-weight: 800;
}
.map-hidden { display: none; }
.map-plot {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  border-top: 1px solid var(--line);
  background:
    radial-gradient(circle at 68% 30%, rgba(15, 118, 110, .16), transparent 24%),
    linear-gradient(135deg, rgba(37, 99, 235, .08), rgba(15, 118, 110, .08)),
    #edf5f2;
}
.fallback-active .map-plot { z-index: 3; }
.leaflet-ready .map-plot {
  z-index: 1;
  opacity: 0;
  pointer-events: none;
}
.map-plot-grid {
  position: absolute;
  inset: 42px;
  border: 1px solid rgba(15, 118, 110, .28);
  background-image:
    linear-gradient(rgba(15, 118, 110, .12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 118, 110, .12) 1px, transparent 1px);
  background-size: 10% 10%;
}
.plot-point {
  position: absolute;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 3px 10px rgba(15, 118, 110, .42);
}
.plot-point:nth-of-type(3n) { background: var(--gold); }
.plot-point:nth-of-type(4n) { background: var(--blue); }
.plot-point.outside {
  width: 15px;
  height: 15px;
  margin: -7px 0 0 -7px;
  background: var(--red);
  box-shadow: 0 3px 14px rgba(180, 35, 24, .5);
}
.leaflet-control-layers {
  border: 0 !important;
  border-radius: 8px !important;
  box-shadow: 0 12px 32px rgba(24, 33, 47, .16) !important;
}
.subzone-hover-label,
.gps-hover-label {
  border: 1px solid rgba(16, 34, 54, .18) !important;
  border-radius: 6px !important;
  color: #102236 !important;
  background: rgba(255, 255, 255, .94) !important;
  box-shadow: 0 6px 18px rgba(24, 33, 47, .16) !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  letter-spacing: 0 !important;
  padding: 5px 8px !important;
}
.gps-hover-label {
  border-color: rgba(15, 118, 110, .3) !important;
  font-size: 11px !important;
  line-height: 1.4 !important;
}
.subzone-hover-label::before,
.gps-hover-label::before { display: none; }
.gps-submission-marker {
  cursor: pointer;
  filter: drop-shadow(0 4px 8px rgba(16, 34, 54, .34));
}
.gps-submission-marker:hover {
  stroke-width: 4;
}
.bahda-map-label {
  width: auto !important;
  height: auto !important;
  border: 0 !important;
  background: transparent !important;
  pointer-events: none;
}
.bahda-map-label.subzone,
.bahda-map-label.major-zone {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  border: 1px solid rgba(16, 34, 54, .16) !important;
  border-radius: 7px;
  color: #102236;
  background: rgba(255, 255, 255, .72) !important;
  box-shadow: 0 8px 18px rgba(24, 33, 47, .16);
  font-weight: 900;
  letter-spacing: 0;
  backdrop-filter: blur(2px);
}
.bahda-map-label.subzone {
  min-width: 34px;
  padding: 2px 6px;
  font-size: 10px;
}
.bahda-map-label.major-zone {
  min-width: 58px;
  padding: 5px 9px;
  color: #fff;
  background: rgba(16, 34, 54, .78) !important;
  font-size: 12px;
}
.leaflet-popup-content {
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 13px;
  line-height: 1.45;
}
.map-label {
  position: absolute;
  z-index: 2;
  padding: 5px 8px;
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255,255,255,.82);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 8px 22px rgba(24, 33, 47, .1);
}
.map-label.north { top: 14px; left: 50%; transform: translateX(-50%); }
.map-label.south { bottom: 14px; left: 50%; transform: translateX(-50%); }
.map-label.west { left: 14px; top: 50%; transform: translateY(-50%); }
.map-label.east { right: 14px; top: 50%; transform: translateY(-50%); }
.map-state {
  display: grid;
  height: 100%;
  place-items: center;
  color: var(--muted);
  font-weight: 700;
}
.panel-footer {
  padding: 14px 18px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: #fff;
  font-size: 13px;
}
.map-inspection-panel {
  margin-top: 18px;
}
.inspection-table td:first-child {
  min-width: 142px;
  white-space: nowrap;
}
.inspection-table .button + .button {
  margin-left: 6px;
}
.inspection-table .row-warning {
  background: rgba(180, 35, 24, .06);
}
.inspection-table .row-warning td {
  border-bottom-color: rgba(180, 35, 24, .18);
}
.messages { margin-bottom: 16px; }
.message { padding: 12px 14px; border-radius: 8px; background: #e9eef5; }
.message.error { color: #fff; background: var(--red); }
.login-screen {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(135deg, rgba(16,34,54,.96), rgba(11,79,74,.94)),
    #102236;
}
.login-shell {
  display: grid;
  width: min(1050px, 100%);
  min-height: 620px;
  grid-template-columns: 1.2fr .8fr;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 32px 90px rgba(0,0,0,.28);
}
.login-identity {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 38px;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(16,34,54,.24), rgba(16,34,54,.82)),
    linear-gradient(135deg, #0f766e, #102236 58%, #b45309);
}
.identity-copy h1 {
  max-width: 620px;
  margin: 0 0 22px;
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.02;
}
.light-text { color: var(--gold-soft); }
.identity-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.identity-metrics div {
  padding: 14px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 8px;
  background: rgba(255,255,255,.1);
}
.identity-metrics strong { display: block; font-size: 18px; }
.identity-metrics span { display: block; margin-top: 4px; color: rgba(255,255,255,.72); font-size: 12px; }
.login-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 42px;
  background: #fff;
}
.brand.compact { margin-bottom: 34px; }
.login-logo {
  width: 100%;
  max-width: 500px;
  height: auto;
  margin: 0 auto 28px;
  display: block;
}
.login-heading { margin-bottom: 24px; }
.login-heading h2 { font-size: 32px; }
.login-card form { display: grid; gap: 14px; }
.login-card label { color: var(--muted); font-size: 13px; font-weight: 700; }
.login-card input {
  margin-top: 7px;
  height: 46px;
  font-size: 15px;
}
.login-card button { height: 46px; margin-top: 4px; }
.login-card a { display: block; margin-top: 18px; color: var(--teal); text-align: center; }
@media (max-width: 1050px) {
  .sidebar { position: static; width: auto; }
  .shell { margin-left: 0; padding: 18px; }
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .layout-two, .layout-three, .filters, .login-shell { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-logo-center { justify-content: flex-start; }
  .header-logo { width: min(100%, 520px); }
  .login-shell { min-height: auto; }
  .login-identity { min-height: 430px; }
  .overview-band { align-items: flex-start; flex-direction: column; }
}
