/* CrashMap — Road Crash Data System
   Government of Solomon Islands · Ministry of Infrastructure Development
*/

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Solomon Islands government palette */
  --navy-dark:    #091D3E;   /* gov-bar */
  --navy:         #0F2B54;   /* header / primary chrome — SI gov website */
  --blue:         #1A6FA8;   /* interactive / links */
  --green:        #166534;   /* SI national green */
  --gold:         #B8860B;   /* SI gold accent */
  --gold-pale:    #F5C518;   /* gold on dark backgrounds */
  --red:          #C0392B;   /* fatal */
  --orange:       #D35400;   /* serious */
  --amber:        #A0720A;   /* minor */

  /* Neutral scale */
  --grey-50:      #F9FAFB;
  --grey-100:     #F3F4F6;
  --grey-200:     #E5E7EB;
  --grey-300:     #D1D5DB;
  --grey-400:     #9CA3AF;
  --grey-600:     #4B5563;
  --grey-800:     #1F2937;

  /* Layout */
  --govbar-h:     26px;
  --header-h:     64px;
  --sidebar-w:    300px;
  --maptb-h:      40px;

  font-family: 'Inter', system-ui, sans-serif;
}

html, body { height: 100%; overflow: hidden; }

/* ── App grid ────────────────────────────────────────── */

#app {
  display: grid;
  grid-template-rows: var(--govbar-h) var(--header-h) 1fr;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
}

/* ── Government identity bar ─────────────────────────── */

#gov-bar {
  grid-column: 1 / -1;
  grid-row: 1;
  height: var(--govbar-h);
  background: var(--navy-dark);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.gov-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.65);
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.gov-bar-divider {
  width: 1px;
  height: 12px;
  background: rgba(255,255,255,0.2);
}

.gov-bar-ministry {
  color: rgba(255,255,255,0.4);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.gov-bar-right {
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
}

.gov-bar-login {
  font-size: 10px;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.03em;
  text-decoration: none;
  transition: color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65%;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}
.gov-bar-login:hover { color: rgba(255,255,255,0.85); }
.gov-bar-public {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ── Header ─────────────────────────────────────────── */

#header {
  grid-column: 1 / -1;
  grid-row: 2;
  height: var(--header-h);
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  z-index: 1000;
  border-bottom: 2px solid rgba(184,134,11,0.5);
  flex-shrink: 0;
}

.header-brand { display: flex; align-items: center; gap: 14px; }

.brand-emblem { height: 44px; width: auto; flex-shrink: 0; object-fit: contain; }

.brand-text  { color: #fff; display: flex; flex-direction: column; gap: 2px; }
.brand-name  { font-family: 'Barlow Condensed', sans-serif; font-size: 32px; font-weight: 700; letter-spacing: 0.02em; white-space: nowrap; line-height: 1; }
.brand-sub   { font-size: 9.5px; font-weight: 500; color: rgba(255,255,255,0.45); letter-spacing: 0.14em; text-transform: uppercase; white-space: nowrap; }

.map-logo-overlay {
  position: absolute;
  top: calc(var(--maptb-h) + 10px);
  right: 0;
  z-index: 500;
  pointer-events: none;
  padding: 14px 16px;
}
.map-logo-card {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.18);
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.map-logo-label {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--grey-400);
}
.map-logo-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.map-logo {
  height: 72px;
  width: auto;
  display: block;
}

.header-nav { display: flex; align-items: center; gap: 8px; }

.btn-field {
  background: transparent;
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 5px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  letter-spacing: 0.03em;
}
.btn-field:hover { background: rgba(255,255,255,0.1); color: #fff; border-color: rgba(255,255,255,0.4); }

.btn-report {
  background: var(--gold);
  color: var(--navy-dark);
  border: none;
  border-radius: 5px;
  padding: 8px 18px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.btn-report:hover { background: #9A6E08; }

.btn-login {
  background: none;
  color: rgba(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 5px;
  padding: 7px 14px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: color 0.15s, border-color 0.15s;
  letter-spacing: 0.03em;
}
.btn-login:hover { color: #fff; border-color: rgba(255,255,255,0.7); }

/* ── Sidebar ─────────────────────────────────────────── */

#sidebar {
  grid-column: 1;
  grid-row: 3;
  background: #fff;
  border-right: 1px solid var(--grey-200);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sb-section {
  padding: 14px;
  border-bottom: 1px solid var(--grey-100);
  flex-shrink: 0;
}
.sb-section--grow { flex: 1; border-bottom: none; }

.sb-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--grey-400);
  margin-bottom: 11px;
}

/* Stats */
.sb-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  text-align: center;
  margin-bottom: 10px;
}
.sb-stat {
  padding: 6px 2px;
  border-right: 1px solid var(--grey-100);
}
.sb-stat:last-child { border-right: none; }
.sb-stat-n {
  display: block;
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--grey-800);
}
.sb-stat--fatal   .sb-stat-n { color: var(--red); }
.sb-stat--serious .sb-stat-n { color: var(--orange); }
.sb-stat--minor   .sb-stat-n { color: var(--amber); }
.sb-stat-l {
  display: block;
  font-size: 9px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--grey-400);
  margin-top: 3px;
}
.sb-blackspot {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  background: var(--grey-50);
  border: 1px solid var(--grey-100);
  border-radius: 5px;
}
.sb-blackspot-n {
  font-size: 15px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: #6B21A8;
  flex-shrink: 0;
}
.sb-blackspot-l {
  font-size: 11px;
  color: var(--grey-600);
  line-height: 1.3;
}

/* Filters */
.sb-field { margin-bottom: 9px; }
.sb-field:last-of-type { margin-bottom: 0; }

.sb-field-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--grey-600);
  margin-bottom: 5px;
  letter-spacing: 0.02em;
}

.sev-pills { display: flex; gap: 4px; }
.sev-pill { flex: 1; cursor: pointer; }
.sev-pill input { display: none; }
.sev-pill span {
  display: block;
  text-align: center;
  padding: 4px 0;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--grey-200);
  color: #6B7280;
  background: var(--grey-50);
  transition: all 0.12s;
  cursor: pointer;
}
.sev-pill span:hover { border-color: var(--grey-300); background: var(--grey-100); }
.sev-pill--fatal   input:checked + span { background: #FEF0EF; border-color: #FCA5A5; color: var(--red); }
.sev-pill--serious input:checked + span { background: #FEF5EC; border-color: #FDD9AE; color: var(--orange); }
.sev-pill--minor   input:checked + span { background: #FFFBEC; border-color: #F5E0A0; color: var(--amber); }

.date-range { display: flex; align-items: center; gap: 5px; }
.date-range .form-input { margin-bottom: 0; }
.date-range-sep { color: var(--grey-400); font-size: 13px; flex-shrink: 0; }

.form-input {
  width: 100%;
  border: 1px solid var(--grey-200);
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 12px;
  margin-bottom: 0;
  outline: none;
  transition: border-color 0.15s;
  color: var(--grey-800);
  background: #fff;
  font-family: inherit;
}
.form-input:focus { border-color: var(--blue); }

.btn-primary {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 5px;
  padding: 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
  margin-top: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-family: inherit;
}
.btn-primary:hover { background: var(--navy-dark); }

#active-filter-bar {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 8px; padding: 8px 10px;
  background: var(--grey-50); border-radius: 6px;
  border: 1px solid var(--grey-200);
}
#active-filter-chips {
  display: flex; flex-wrap: wrap; gap: 4px; align-items: center;
}
.filter-chip {
  font-size: 10px; font-weight: 600; padding: 3px 9px;
  background: var(--navy); color: #fff;
  border-radius: 10px; white-space: nowrap;
}
.btn-clear-filters {
  font-size: 10px; font-weight: 600; padding: 3px 9px;
  background: none; border: 1px solid var(--grey-300); border-radius: 10px;
  color: var(--grey-500); cursor: pointer; font-family: inherit;
  align-self: flex-start; white-space: nowrap;
}
.btn-clear-filters:hover { border-color: var(--red); color: var(--red); }

.blackspot-marker {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: #7B1FA2;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #7B1FA2, 0 2px 8px rgba(123,31,162,.4);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

/* Safe Systems breakdown */
.ss-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  font-size: 11px;
}
.ss-row:last-child { margin-bottom: 0; }
.ss-label { flex: 0 0 94px; font-weight: 600; font-size: 10px; text-transform: uppercase; letter-spacing: 0.02em; }
.ss-bar-wrap { flex: 1; height: 5px; background: var(--grey-100); border-radius: 3px; overflow: hidden; }
.ss-bar { height: 100%; border-radius: 3px; transition: width 0.4s ease; }
.ss-count { flex: 0 0 20px; text-align: right; font-weight: 700; color: var(--grey-600); font-size: 11px; }

/* Recent list */
.recent-item {
  padding: 9px 0;
  border-bottom: 1px solid var(--grey-100);
  cursor: pointer;
  transition: background 0.1s;
}
.recent-item:last-child { border-bottom: none; }
.recent-item:hover { background: var(--grey-50); margin: 0 -14px; padding: 9px 14px; border-radius: 4px; }

.recent-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 2px;
}

.severity-badge {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 3px;
  letter-spacing: 0.05em;
}
.severity-badge.fatal   { background: #FEF0EF; color: var(--red); }
.severity-badge.serious { background: #FEF5EC; color: var(--orange); }
.severity-badge.minor   { background: #FFFBEC; color: var(--amber); }

.recent-road  { font-size: 12px; font-weight: 600; color: var(--grey-800); flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-date  { font-size: 11px; color: var(--grey-600); }
.recent-notes { font-size: 11px; color: var(--grey-600); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Recent incidents — login gate */
.recent-gated {
  position: relative;
  overflow: hidden;
  flex: 1;
  min-height: 120px;
}
.recent-gated #recent-list {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
  opacity: 0.6;
}
.recent-gate-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(to bottom, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.82) 35%);
}
.recent-gate-inner {
  text-align: center;
  padding: 0 18px;
}
.recent-gate-inner p {
  font-size: 11.5px;
  color: var(--grey-700);
  line-height: 1.5;
  margin: 0 0 12px;
}
.recent-gate-btn {
  display: inline-block;
  padding: 7px 20px;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  border-radius: 4px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  transition: background 0.15s;
}
.recent-gate-btn:hover { background: var(--navy-dark); }

/* Sidebar footer */
.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--grey-100);
  font-size: 9px;
  color: var(--grey-400);
  text-align: center;
  line-height: 1.7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── Map area & toolbar ──────────────────────────────── */

#map-area {
  grid-column: 2;
  grid-row: 3;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

#map-toolbar {
  flex-shrink: 0;
  height: var(--maptb-h);
  background: #fff;
  border-bottom: 1px solid var(--grey-200);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 12px;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.maptb-group-wrap {
  display: flex;
  align-items: center;
  gap: 7px;
}

.maptb-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--grey-400);
  white-space: nowrap;
}

.maptb-group {
  display: flex;
  background: var(--grey-100);
  border-radius: 5px;
  padding: 2px;
  gap: 1px;
}

.maptb-btn {
  font-family: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--grey-600);
  background: transparent;
  border: none;
  border-radius: 4px;
  padding: 3px 10px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  white-space: nowrap;
  letter-spacing: 0.02em;
  line-height: 1.4;
}
.maptb-btn:hover { background: var(--grey-200); color: var(--grey-800); }
.maptb-btn.active { background: var(--navy); color: #fff; }

.maptb-sep {
  width: 1px;
  height: 20px;
  background: var(--grey-200);
  margin: 0 6px;
  flex-shrink: 0;
}

.maptb-spacer { flex: 1; }


.maptb-icon-btn {
  font-family: inherit;
  font-size: 16px;
  background: transparent;
  border: 1px solid var(--grey-200);
  border-radius: 5px;
  padding: 2px 9px;
  cursor: pointer;
  color: var(--grey-600);
  line-height: 1.4;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.maptb-icon-btn:hover { background: var(--grey-100); color: var(--grey-800); border-color: var(--grey-300); }

/* ── Map ─────────────────────────────────────────────── */

#map {
  flex: 1;
  z-index: 0;
}

/* Custom marker icons */
.crash-marker {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2.5px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.45);
}

/* Popup */
.crash-popup { min-width: 230px; font-family: 'Inter', system-ui, sans-serif; }
.crash-popup h4 {
  font-size: 13px; font-weight: 700; margin-bottom: 8px; color: var(--grey-800);
  border-bottom: 2px solid var(--grey-100); padding-bottom: 7px; line-height: 1.3;
}
.crash-popup .meta { display: flex; gap: 5px; flex-wrap: wrap; margin-bottom: 9px; }
.crash-popup .badge {
  font-size: 9px; font-weight: 700; text-transform: uppercase;
  padding: 2px 7px; border-radius: 3px; letter-spacing: 0.05em;
}
.crash-popup .badge.fatal   { background: #FEF0EF; color: var(--red); }
.crash-popup .badge.serious { background: #FEF5EC; color: var(--orange); }
.crash-popup .badge.minor   { background: #FFFBEC; color: var(--amber); }
.crash-popup .badge.agency  { background: var(--grey-100); color: var(--grey-800); }
.crash-popup table { width: 100%; border-collapse: collapse; font-size: 12px; }
.crash-popup td { padding: 3px 0; vertical-align: top; }
.crash-popup td:first-child {
  font-weight: 700; width: 78px; color: var(--grey-400);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.04em;
}
.crash-popup .notes {
  font-size: 12px; color: var(--grey-600); margin-top: 8px;
  padding-top: 8px; border-top: 1px solid var(--grey-100); line-height: 1.5;
}
.crash-popup .record-id {
  font-size: 10px; color: var(--grey-400); margin-top: 6px;
  padding-top: 6px; border-top: 1px solid var(--grey-100);
  font-variant-numeric: tabular-nums; letter-spacing: 0.03em;
  text-transform: uppercase;
}
.popup-blurred {
  filter: blur(4px);
  user-select: none;
  pointer-events: none;
}
.popup-login-prompt {
  display: block; margin-top: 9px; padding-top: 8px;
  border-top: 1px solid var(--grey-100);
  font-size: 11px; font-weight: 600; color: var(--blue);
  text-decoration: none; text-align: center;
}
.popup-login-prompt:hover { text-decoration: underline; }

/* ── Login modal ─────────────────────────────────────── */
.modal-backdrop {
  display: none; position: fixed; inset: 0; z-index: 9999;
  background: rgba(9,29,62,0.55); backdrop-filter: blur(3px);
  align-items: center; justify-content: center;
}
.modal-backdrop.open { display: flex; }
.modal-box {
  background: #fff; border-radius: 12px; padding: 32px 28px 24px;
  width: 100%; max-width: 380px; position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  font-family: 'Inter', system-ui, sans-serif;
}
.modal-close {
  position: absolute; top: 14px; right: 16px;
  background: none; border: none; font-size: 22px; line-height: 1;
  color: var(--grey-400); cursor: pointer; padding: 2px 6px;
}
.modal-close:hover { color: var(--grey-800); }
.modal-brand {
  display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
}
.modal-emblem { width: 36px; height: 36px; object-fit: contain; }
.modal-title { font-size: 18px; font-weight: 800; color: var(--navy); letter-spacing: -0.02em; }
.modal-sub   { font-size: 11px; color: var(--grey-400); text-transform: uppercase; letter-spacing: 0.06em; }
.modal-desc  { font-size: 13px; color: var(--grey-600); margin-bottom: 20px; line-height: 1.5; }
.modal-error { font-size: 13px; color: var(--red); background: #FEF0EF; border: 1px solid #FECAC8; border-radius: 6px; padding: 9px 12px; margin-bottom: 14px; }
.login-pending {
  text-align: center;
  padding: 8px 0 16px;
  color: var(--navy);
}
.login-pending svg { color: #1A7A3F; margin-bottom: 12px; }
.login-pending p { font-size: 14px; line-height: 1.6; margin: 0 0 4px; }
.login-pending strong { font-weight: 700; }
.modal-label {
  display: block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--grey-600); margin-bottom: 5px;
}
.modal-input {
  display: block; width: 100%; padding: 10px 12px; margin-bottom: 14px;
  border: 1.5px solid var(--grey-200); border-radius: 7px;
  font-size: 14px; font-family: inherit; color: var(--grey-800);
  outline: none; transition: border-color 0.15s;
}
.modal-input:focus { border-color: var(--blue); }
.modal-btn {
  width: 100%; padding: 11px; background: var(--navy); color: #fff;
  border: none; border-radius: 7px; font-size: 14px; font-weight: 700;
  font-family: inherit; cursor: pointer; margin-top: 2px; transition: background 0.15s;
}
.modal-btn:hover { background: var(--blue); }
.modal-agencies {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--grey-100);
  font-size: 10px; color: var(--grey-400); text-transform: uppercase; letter-spacing: 0.05em;
}
.modal-agency-tag {
  background: var(--grey-100); color: var(--grey-600);
  font-size: 10px; font-weight: 700; padding: 2px 8px; border-radius: 4px;
}

/* ── Administrative boundary tooltips ───────────────── */
.boundary-label {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  font-family: inherit !important;
  font-weight: 600;
  pointer-events: none;
  white-space: nowrap;
}
.adm2-label { font-size: 11px; color: #1A6FA8; }
.adm3-label { font-size: 10px; font-weight: 700; color: #1F2937; text-shadow: 0 0 3px #fff, 0 0 6px #fff; letter-spacing: 0.02em; }
.adm4-label { font-size: 9px;  color: #666; }

/* ── Legend ─────────────────────────────────────────── */

.map-legend {
  position: absolute;
  bottom: 30px;
  right: 10px;
  z-index: 500;
  background: #fff;
  border-radius: 6px;
  border: 1px solid var(--grey-200);
  border-top: 3px solid var(--navy);
  padding: 10px 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,.15);
  font-size: 12px;
}
.map-legend .legend-title {
  font-weight: 700; margin-bottom: 8px; color: var(--grey-800);
  font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
}
.map-legend .legend-item { display: flex; align-items: center; gap: 7px; margin-bottom: 5px; }
.map-legend .legend-item:last-child { margin-bottom: 0; }
.legend-dot {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(0,0,0,.2); flex-shrink: 0;
}

/* ── Report page ─────────────────────────────────────── */

body.report-page { overflow: auto; background: var(--grey-100); }

body.report-page #app { display: block; height: auto; min-height: 100vh; }

body.report-page #gov-bar,
body.report-page #header { grid-column: unset; grid-row: unset; }

.report-container {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.report-card {
  background: #fff;
  border-radius: 8px;
  border: 1px solid var(--grey-200);
  border-top: 4px solid var(--navy);
  padding: 28px;
  margin-top: 20px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.06);
}

.report-card h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 4px;
}
.report-card .subtitle {
  font-size: 13px;
  color: var(--grey-600);
  margin-bottom: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--grey-100);
}

.restricted-notice {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #7B1FA2;
  background: #F5EDFF;
  border: 1px solid #DBBCFF;
  border-radius: 3px;
  padding: 4px 9px;
  margin-bottom: 18px;
  display: block;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: 11px; font-weight: 700; color: var(--grey-800);
  margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.05em;
}
.form-group label .req { color: var(--red); margin-left: 2px; }

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--grey-300);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
  color: var(--grey-800);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(0,91,170,.1); }
.form-group textarea { resize: vertical; min-height: 80px; }

.form-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--grey-600);
  border-top: 1px solid var(--grey-200);
  padding-top: 18px;
  margin: 18px 0 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.form-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--grey-100);
}

#location-map {
  height: 240px;
  border-radius: 6px;
  border: 1px solid var(--grey-300);
  margin-bottom: 8px;
}

.location-hint {
  font-size: 12px;
  color: var(--blue);
  margin-bottom: 10px;
  padding: 8px 12px;
  background: rgba(26,111,168,0.07);
  border-radius: 5px;
  border-left: 3px solid var(--blue);
}

.lat-lng-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-submit {
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: 13px 24px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: 8px;
  transition: background 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-family: inherit;
}
.btn-submit:hover { background: #0B1929; }
.btn-submit:disabled { background: var(--grey-400); cursor: not-allowed; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  margin-top: 14px;
}
.back-link:hover { text-decoration: underline; }

.alert {
  padding: 12px 16px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  border-left-width: 3px;
  border-left-style: solid;
}
.alert.success { background: #EDF7EE; color: #1B5E20; border-color: #2E7D32; border-right: 1px solid #A5D6A7; border-top: 1px solid #A5D6A7; border-bottom: 1px solid #A5D6A7; }
.alert.error   { background: #FDECEA; color: #B71C1C; border-color: #C62828; border-right: 1px solid #FFCDD2; border-top: 1px solid #FFCDD2; border-bottom: 1px solid #FFCDD2; }

/* ── Government footer (report page) ────────────────── */

.gov-footer {
  background: var(--navy);
  color: rgba(255,255,255,0.5);
  padding: 24px 20px;
  margin-top: 48px;
  border-top: 3px solid var(--gold);
}

.gov-footer-inner {
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.gov-footer-primary {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gov-footer-secondary {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
}

.gov-footer-divider {
  width: 40px;
  height: 1px;
  background: rgba(255,255,255,0.15);
  margin: 4px 0;
}

.gov-footer-partners {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.gov-footer-partners span { color: var(--gold-pale); font-weight: 700; }


/* ── Layer control ───────────────────────────────────── */
.leaflet-control-layers {
  border-radius: 6px !important;
  border: 1px solid rgba(0,0,0,0.15) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15) !important;
  font-family: inherit !important;
  font-size: 12px !important;
}
.leaflet-control-layers-toggle {
  background-size: 18px 18px !important;
}
.leaflet-control-layers-expanded {
  padding: 8px 12px !important;
}
.leaflet-control-layers label {
  font-size: 12px !important;
  color: #2C3540 !important;
  margin-bottom: 2px !important;
}

/* ── Attribution (collapsed by default) ─────────────── */
.leaflet-control-attribution {
  max-width: 22px;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
  transition: max-width 0.25s ease;
  opacity: 0.7;
}
.leaflet-control-attribution::before {
  content: 'ⓘ';
  font-size: 14px;
  line-height: 1;
  display: inline-block;
  vertical-align: middle;
}
.leaflet-control-attribution.attr-open {
  max-width: 500px;
  opacity: 1;
}
.leaflet-control-attribution.attr-open::before {
  content: none;
}

/* ── Responsive ─────────────────────────────────────── */

@media (max-width: 768px) { #gov-bar { display: none; } }

@media (max-width: 640px) {
  :root {
    --govbar-h:  0px;
    --header-h:  52px;
    --sidebar-w: 100vw;
    --maptb-h:   36px;
  }

  /* ── Layout ── */
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: var(--govbar-h) var(--header-h) 1fr;
  }
  #gov-bar  { display: none; }
  #sidebar  { display: none; }
  #map-area { grid-column: 1; }

  /* ── Header ── */
  #header { padding: 0 12px; }
  .brand-emblem { height: 30px; }
  .brand-name   { font-size: 22px; }
  .brand-sub    { display: none; }
  .btn-field    { display: none; }
  .btn-report   { display: none; }
  .btn-login    { font-size: 11px; padding: 6px 10px; }

  /* ── Map toolbar ── */
  #map-toolbar  { padding: 0 6px; gap: 4px; overflow-x: auto; }
  .maptb-label  { display: none; }
  .maptb-sep    { display: none; }
  .maptb-btn    { font-size: 11px; padding: 4px 8px; }
  .maptb-icon-btn { width: 28px; height: 28px; font-size: 13px; }

  /* ── Logo overlay ── */
  .map-logo-overlay { display: none; }

  /* ── Stats page ── */
  .stats-main       { padding: 12px 10px 48px; }
  .stats-page-title { font-size: 17px; }
  .stats-page-sub   { font-size: 11px; }
  .kpi-row          { grid-template-columns: repeat(2, 1fr); gap: 6px; }
  .kpi-num          { font-size: 26px; }
  .kpi-label        { font-size: 10px; }
  .insight-strip    { grid-template-columns: 1fr 1fr; gap: 8px; }
  .insight-val      { font-size: 19px; }
  .insight-sub      { display: none; }
  .stats-section    { padding: 14px 12px; }
  .stats-section h2 { font-size: 11px; margin-bottom: 12px; }
  .chart-wrap       { height: 180px; }
  .export-btn       { font-size: 11px; padding: 7px 12px; }

  /* ── Capture page ── */
  .field-form        { padding: 10px; gap: 10px; }
  .field-card-header { font-size: 12px; padding: 10px 12px; }
  .counts-row        { gap: 6px; }

  /* ── Modal ── */
  .modal-box { padding: 20px 16px; margin: 12px; }
}

/* ── Shared: field-help text ─────────────────────────────────────────────────── */

.field-help {
  font-size: 11px;
  color: var(--grey-600);
  margin-top: 4px;
  line-height: 1.4;
}

/* ── Field Capture page (capture.php) ────────────────────────────────────────── */

body.capture-page { overflow: auto; background: #F0F2F5; overscroll-behavior: none; }
body.capture-page #app { display: block; height: auto; min-height: 100vh; }
body.capture-page #gov-bar,
body.capture-page #header { grid-column: unset; grid-row: unset; }

.field-header {
  background: var(--navy);
  padding: 14px 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 3px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 100;
}

.field-header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
}

.field-header-icon {
  width: 36px; height: 36px;
  background: rgba(200,160,23,0.2);
  border: 1px solid rgba(200,160,23,0.4);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}

.field-header-title { font-size: 15px; font-weight: 700; line-height: 1.2; }
.field-header-sub   { font-size: 10px; opacity: 0.55; letter-spacing: 0.05em; text-transform: uppercase; }

.field-header-badge {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  padding: 4px 8px;
  border-radius: 3px;
  background: rgba(200,160,23,0.15);
  color: #F0D869;
  border: 1px solid rgba(200,160,23,0.35);
}

.field-form {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-width: 560px;
  margin: 0 auto;
  padding-bottom: 40px;
}

.field-card {
  background: #fff;
  border-radius: 12px;
  border: 1px solid #DDE1E6;
  overflow: hidden;
}

.field-card-header {
  background: var(--navy);
  color: rgba(255,255,255,0.9);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 9px 14px;
}

.fc-optional {
  opacity: 0.6;
  font-weight: 400;
  text-transform: none;
  letter-spacing: 0;
}

.field-card-body { padding: 14px; }

.agency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.agency-btn {
  border: 2px solid #DDE1E6;
  border-radius: 10px;
  padding: 14px 10px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  transition: all 0.15s;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  -webkit-user-select: none; user-select: none;
}

.agency-btn-icon  { font-size: 24px; line-height: 1; }
.agency-btn-label { font-size: 12px; font-weight: 700; color: var(--grey-800); text-transform: uppercase; letter-spacing: 0.04em; }
.agency-btn-sub   { font-size: 10px; color: var(--grey-600); font-weight: 500; }

.agency-btn.selected.police    { background: #E8F0FF; border-color: #3060C0; }
.agency-btn.selected.ambulance { background: #FFF0F0; border-color: #C02020; }
.agency-btn.selected.sja       { background: #FFF0F0; border-color: #C02020; }
.agency-btn.selected.mid       { background: #F0FFF4; border-color: #2E7D50; }
.agency-btn.selected.public    { background: #F5F0FF; border-color: #6040B0; }

.severity-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }

.sev-btn {
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 16px 8px;
  text-align: center;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
  -webkit-user-select: none; user-select: none;
}

.sev-btn.fatal   { background: #FEF0EF; border-color: #FECAC8; }
.sev-btn.serious { background: #FEF5EC; border-color: #FDD9AE; }
.sev-btn.minor   { background: #FFFBEC; border-color: #F5E8A0; }

.sev-btn.selected.fatal   { background: var(--red);    border-color: var(--red);    color: #fff; }
.sev-btn.selected.serious { background: var(--orange); border-color: var(--orange); color: #fff; }
.sev-btn.selected.minor   { background: var(--amber);  border-color: var(--amber);  color: #fff; }

.sev-btn-label {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  display: block;
}
.sev-btn.fatal   .sev-btn-label { color: var(--red); }
.sev-btn.serious .sev-btn-label { color: var(--orange); }
.sev-btn.minor   .sev-btn-label { color: var(--amber); }
.sev-btn.selected .sev-btn-label { color: #fff; }

.sev-btn-sub {
  font-size: 10px;
  color: var(--grey-600);
  display: block;
  margin-top: 3px;
  line-height: 1.3;
}
.sev-btn.selected .sev-btn-sub { color: rgba(255,255,255,0.75); }

.type-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.type-btn {
  border: 2px solid #DDE1E6;
  border-radius: 10px;
  padding: 12px 10px;
  text-align: left;
  cursor: pointer;
  background: #fff;
  font-family: inherit;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 10px;
  -webkit-user-select: none; user-select: none;
}

.type-btn-icon { font-size: 20px; flex-shrink: 0; }
.type-btn-text { font-size: 12px; font-weight: 600; color: var(--grey-800); line-height: 1.3; }
.type-btn.selected { background: #EEF3FF; border-color: #3060C0; }
.type-btn.selected .type-btn-text { color: #1A3A80; }

.gps-btn {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 16px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: background 0.15s;
  letter-spacing: 0.03em;
}
.gps-btn:active { background: #001F48; }
.gps-btn.got-gps { background: var(--green); }

.gps-coords {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--grey-100);
  border-radius: 8px;
  font-size: 12px;
  color: var(--grey-600);
  font-variant-numeric: tabular-nums;
  display: none;
}
.gps-coords.visible { display: block; }
.gps-coords strong  { color: var(--grey-800); }

#capture-map {
  height: 200px;
  border-radius: 8px;
  margin-top: 10px;
  border: 1px solid #DDE1E6;
  display: none;
}
#capture-map.visible { display: block; }

.map-hint {
  font-size: 11px;
  color: var(--grey-600);
  margin-top: 6px;
  text-align: center;
  display: none;
}
.map-hint.visible { display: block; }

.field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--grey-600);
  margin-bottom: 6px;
  display: block;
}

.field-input {
  width: 100%;
  border: 2px solid #DDE1E6;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 16px;
  font-family: inherit;
  color: var(--grey-800);
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
}
.field-input:focus { border-color: var(--navy); }

.counts-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.count-group { text-align: center; }
.count-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey-600); margin-bottom: 6px; display: block; }

.count-input {
  width: 100%;
  border: 2px solid #DDE1E6;
  border-radius: 8px;
  padding: 12px 8px;
  font-size: 22px;
  font-weight: 700;
  font-family: inherit;
  color: var(--grey-800);
  text-align: center;
  outline: none;
  transition: border-color 0.15s;
  background: #fff;
  -moz-appearance: textfield;
}
.count-input::-webkit-outer-spin-button,
.count-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.count-input:focus { border-color: var(--navy); }

.cf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media (max-width: 520px) { .cf-grid { grid-template-columns: 1fr; } }

.cf-field { display: flex; flex-direction: column; gap: 4px; }

.cf-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--navy);
  line-height: 1.2;
}
.cf-label-pijin {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: var(--grey-400);
  margin-top: 1px;
}

.cf-select-wrap { position: relative; }
.cf-select-wrap::after {
  content: '';
  pointer-events: none;
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 10px;
  height: 6px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%236B7280' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;
}

.cf-select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  font-size: 13px;
  font-family: inherit;
  color: var(--grey-800);
  background: #F8F9FB;
  border: 1.5px solid #D6DAE0;
  border-radius: 6px;
  padding: 9px 34px 9px 11px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  line-height: 1.4;
}
.cf-select:focus { border-color: var(--navy); background: #fff; }
.cf-select:hover:not(:focus) { border-color: #B0B8C4; }
.cf-select option { color: var(--grey-800); }

.submit-btn {
  width: 100%;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 18px 24px;
  font-size: 16px;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  box-shadow: 0 4px 16px rgba(0,43,92,0.35);
}
.submit-btn:active   { background: #001F48; }
.submit-btn:disabled { background: #A8B0BB; box-shadow: none; cursor: not-allowed; }

.capture-notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #EFF4FB;
  border: 1px solid #BDD0EA;
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 13px;
  color: #2C4A6E;
  line-height: 1.5;
  margin-bottom: 4px;
}
.capture-notice svg { flex-shrink: 0; margin-top: 2px; opacity: 0.7; }
.capture-notice strong { font-weight: 600; display: block; margin-bottom: 3px; }
.capture-notice-pijin { display: block; font-size: 11px; color: #4A6A8A; margin-bottom: 5px; font-style: italic; }
.capture-notice-link {
  display: inline-block;
  margin-top: 4px;
  font-size: 12px;
  font-weight: 600;
  color: var(--blue);
  text-decoration: none;
}
.capture-notice-link:hover { text-decoration: underline; }

.field-alert {
  padding: 14px 16px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  border-left: 4px solid;
  display: none;
}
.field-alert.error   { background: #FEF0EF; color: var(--red);   border-color: var(--red); }
.field-alert.success { background: #EDF7EE; color: var(--green); border-color: var(--green); }
.field-alert.visible { display: block; }

.success-id {
  font-size: 24px;
  font-weight: 800;
  color: var(--green);
  text-align: center;
  margin: 8px 0;
}

.success-actions {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.success-actions a {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.btn-another { background: var(--navy); color: #fff; }
.btn-map     { background: #EEF3FF; color: #1A3A80; border: 1px solid #B0C0E8; }

.field-card.invalid { border-color: var(--red); box-shadow: 0 0 0 2px rgba(198,40,40,0.15); }

/* ── Stats page (stats.php) ──────────────────────────────────────────────────── */

body.stats-page { overflow: auto; background: #EAECF0; }
body.stats-page #app { display: block; height: auto; min-height: 100vh; }
body.stats-page #gov-bar,
body.stats-page #header,
body.stats-page #agency-bar { grid-column: unset; grid-row: unset; }

.stats-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 16px 64px;
}

.stats-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.stats-page-title { font-size: 22px; font-weight: 700; color: var(--navy); line-height: 1.2; margin-bottom: 4px; }
.stats-page-sub   { font-size: 13px; color: var(--grey-600); }

.stats-header-right {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.stats-filter-bar {
  display: flex; align-items: center; gap: 8px;
}
.stats-filter-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--grey-600);
}
.stats-filter-select {
  font-size: 13px; font-family: inherit; padding: 6px 10px;
  border: 1.5px solid var(--grey-200); border-radius: 6px;
  background: #fff; color: var(--grey-800); cursor: pointer;
  outline: none;
}
.stats-filter-select:focus { border-color: var(--blue); }
.stats-filter-clear {
  font-size: 12px; font-weight: 600; color: var(--grey-400);
  text-decoration: none; padding: 4px 8px; border-radius: 4px;
  background: var(--grey-100); transition: background 0.15s;
}
.stats-filter-clear:hover { background: var(--grey-200); color: var(--grey-800); }

/* ── Insight strip ───────────────────────────────────────────────────────────── */
.insight-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
@media (max-width: 900px) { .insight-strip { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .insight-strip { grid-template-columns: 1fr; } }

.insight-tile {
  background: #fff;
  border-radius: 5px;
  padding: 16px 18px 14px;
  border: 1px solid #D6D9DF;
  border-left: 3px solid var(--blue);
}
.insight-val {
  font-size: 24px; font-weight: 700;
  color: var(--navy); letter-spacing: -0.02em;
  line-height: 1.1; margin-bottom: 4px;
  font-family: 'Barlow Condensed', 'Inter', system-ui;
}
.insight-label {
  font-size: 11px; font-weight: 600;
  color: var(--grey-600); margin-bottom: 3px;
}
.insight-sub { font-size: 11px; color: var(--grey-400); line-height: 1.4; }

/* ── KPI YoY delta badge ─────────────────────────────────────────────────────── */
.kpi-delta {
  display: inline-block; font-size: 10px; font-weight: 700;
  padding: 2px 7px; border-radius: 4px; margin-top: 5px; letter-spacing: 0.02em;
}
.kpi-delta.worse   { background: #FEF0EF; color: var(--red); }
.kpi-delta.better  { background: #F0FDF4; color: #166534; }
.kpi-delta.neutral { background: var(--grey-100); color: var(--grey-600); }

.export-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--navy);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 18px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.export-btn:hover { background: #001F48; }

.kpi-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-bottom: 20px;
}

.kpi-card {
  background: #fff;
  border: 1px solid #D6D9DF;
  border-radius: 5px;
  padding: 14px 14px 12px;
  text-align: left;
}
.kpi-card.fatal      { background: #FDF3F3; border-color: #F5C6C6; }
.kpi-card.serious    { background: #FEF8F0; border-color: #F5DCBA; }
.kpi-card.minor      { background: #FEFCF0; border-color: #EDE8B0; }
.kpi-card.blackspot  { background: #F9F4FD; border-color: #D9C4EF; }
.kpi-card.casualties { background: #F4F6FA; border-color: #C8D0DC; }

.kpi-num {
  display: block;
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  color: var(--grey-800);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.kpi-card.fatal      .kpi-num { color: var(--red); }
.kpi-card.serious    .kpi-num { color: var(--orange); }
.kpi-card.minor      .kpi-num { color: #7A6800; }
.kpi-card.blackspot  .kpi-num { color: #6A1B9A; }

.kpi-label {
  display: block;
  font-size: 11px;
  font-weight: 500;
  color: var(--grey-500);
  margin-top: 5px;
}

.stats-section {
  background: #fff;
  border: 1px solid #D6D9DF;
  border-radius: 5px;
  padding: 20px;
  margin-bottom: 12px;
}

.stats-section h2 {
  font-size: 12px;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--grey-100);
  letter-spacing: 0;
  text-transform: none;
}

.stats-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 680px) { .stats-grid-2 { grid-template-columns: 1fr; } }

.chart-wrap { position: relative; height: 240px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th { font-size: 11px; font-weight: 600; color: var(--grey-500); text-align: left; padding: 0 8px 10px; border-bottom: 1px solid var(--grey-200); }
.data-table th.right { text-align: right; }
.data-table td { padding: 9px 8px; border-bottom: 1px solid var(--grey-50); color: var(--grey-800); vertical-align: middle; }
.data-table td.right { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: var(--grey-50); }

.bar-cell { display: flex; align-items: center; gap: 8px; }
.bar-track { flex: 1; height: 6px; background: var(--grey-100); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar-fill  { height: 100%; border-radius: 3px; }

.sev-pips { display: flex; gap: 4px; }
.sev-pip  { padding: 1px 5px; border-radius: 3px; font-weight: 700; font-size: 10px; }
.sev-pip.fatal   { background: #FEF0EF; color: var(--red); }
.sev-pip.serious { background: #FEF5EC; color: var(--orange); }
.sev-pip.minor   { background: #FFFBEC; color: #8A7000; }

.rank-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--grey-100); font-size: 10px; font-weight: 700; color: var(--grey-600); flex-shrink: 0;
}
tr:first-child  .rank-num { background: var(--gold);  color: #fff; }
tr:nth-child(2) .rank-num { background: var(--grey-400); color: #fff; }
tr:nth-child(3) .rank-num { background: #B87333; color: #fff; }

.empty-msg { color: var(--grey-400); font-size: 12px; padding: 16px 0; text-align: center; }