/* ============================================================
   GWES SENTINEL — Command-Center Skin
   Presentation layer only. Keyed to the EXISTING template
   class names so no backend, view, or data binding changes.
   Drop-in replacement for dashboard/static/dashboard/dashboard.css
   ============================================================ */

:root {
  /* ---- Surfaces (cool-slate ramp, hue 245) ---- */
  --canvas:    oklch(0.16 0.012 245);
  --panel:     oklch(0.205 0.014 245);
  --card:      oklch(0.235 0.015 245);
  --card-2:    oklch(0.26 0.015 245);
  --border:    oklch(0.32 0.014 245);
  --border-2:  oklch(0.40 0.014 245);

  /* ---- Text ---- */
  --text-hi:   oklch(0.97 0.004 245);
  --text-mid:  oklch(0.80 0.010 245);
  --text-low:  oklch(0.60 0.012 245);

  /* ---- Interactive accent (never a hazard colour) ---- */
  --accent:    oklch(0.80 0.12 200);
  --accent-ink: oklch(0.18 0.03 200);

  /* ---- Severity (CAP-aligned) ---- */
  --sev1:      oklch(0.72 0.11 225);   /* Info / Minor   */
  --sev2:      oklch(0.83 0.14 92);    /* Watch / Moderate */
  --sev3:      oklch(0.72 0.17 55);    /* Warning / Severe */
  --sev4:      oklch(0.60 0.21 27);    /* Critical / Extreme */
  --sev3-ink:  oklch(0.18 0.02 55);
  --sev4-ink:  oklch(0.97 0.02 27);

  /* ---- Hazard category hues ---- */
  --cat-hydro: oklch(0.78 0.08 230);   /* FLD CST            */
  --cat-geo:   oklch(0.80 0.08 70);    /* LND LMC EQK        */
  --cat-atmos: oklch(0.80 0.08 295);   /* STM FIR AIR        */
  --cat-bio:   oklch(0.80 0.08 155);   /* AGR HLT            */
  --cat-human: oklch(0.80 0.08 350);   /* INF LOG            */

  /* ---- System ---- */
  --radius:    10px;
  --radius-sm: 6px;
  --ease:      180ms cubic-bezier(0.4, 0, 0.2, 1);
  --shadow:    0 1px 3px oklch(0 0 0 / 0.4), 0 8px 24px oklch(0 0 0 / 0.25);
  --mono:      'IBM Plex Mono', ui-monospace, 'SF Mono', monospace;
  --sans:      'IBM Plex Sans', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }

body {
  font-family: var(--sans);
  margin: 0;
  color: var(--text-mid);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

main {
  padding: 32px 40px 64px;
  max-width: 1160px;
  margin: 0 auto;
}

h1 {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.012em;
  color: var(--text-hi);
  margin: 0 0 24px;
}
h2 {
  font-size: 19px;
  font-weight: 600;
  color: var(--text-hi);
  margin: 40px 0 16px;
  letter-spacing: -0.008em;
}

a { color: var(--accent); }

/* ============================================================
   TOPBAR
   ============================================================ */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--panel);
  color: var(--text-hi);
  padding: 14px 40px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(8px);
}
.topbar .brand,
.topbar a.brand {
  font-family: var(--mono);
  font-weight: 600;
  letter-spacing: 0.18em;
  font-size: 14px;
  color: var(--text-hi);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
/* live-status dot rendered before the brand wordmark */
.topbar .brand::before,
.topbar a.brand::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: oklch(0.80 0.16 150);
  box-shadow: 0 0 0 3px oklch(0.80 0.16 150 / 0.22);
  animation: sentinel-pulse 2s ease-in-out infinite;
}
@keyframes sentinel-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }

.topbar nav {
  display: flex;
  align-items: center;
  gap: 26px;
}
.topbar nav a {
  color: var(--text-mid);
  text-decoration: none;
  font-size: 14px;
  padding: 4px 0;
  border-bottom: 2px solid transparent;
  transition: color var(--ease), border-color var(--ease);
}
.topbar nav a:hover {
  color: var(--text-hi);
  border-bottom-color: var(--accent);
}
.topbar .langswitch select {
  background: var(--card);
  color: var(--text-hi);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color var(--ease);
}
.topbar .langswitch select:hover { border-color: var(--accent); }

.inline { display: inline; }
.linklike {
  background: none;
  border: none;
  color: var(--text-low);
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  transition: color var(--ease);
}
.linklike:hover { color: var(--text-hi); }

/* ============================================================
   MESSAGES
   ============================================================ */
.messages {
  list-style: none;
  padding: 12px 40px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.messages li {
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--panel);
  font-size: 14px;
  border-left: 3px solid var(--border-2);
}
.messages .success { border-left-color: oklch(0.78 0.16 150); color: oklch(0.86 0.12 150); }
.messages .error   { border-left-color: var(--sev4); color: oklch(0.84 0.13 27); }

/* ============================================================
   TABLES
   ============================================================ */
table {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
th, td {
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 12px 14px;
  text-align: left;
  font-size: 13.5px;
}
th {
  background: var(--card);
  color: var(--text-low);
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
td { color: var(--text-mid); }
tbody tr { transition: background var(--ease); }
tbody tr:hover { background: var(--card); }
tbody tr:last-child td { border-bottom: none; }
td a { color: var(--accent); text-decoration: none; font-family: var(--mono); }
td a:hover { text-decoration: underline; }

/* severity accent rail on alert rows */
tr.sev4 td:first-child { box-shadow: inset 3px 0 0 var(--sev4); }
tr.sev3 td:first-child { box-shadow: inset 3px 0 0 var(--sev3); }
tr.sev2 td:first-child { box-shadow: inset 3px 0 0 var(--sev2); }
tr.sev1 td:first-child { box-shadow: inset 3px 0 0 var(--sev1); }

/* ============================================================
   BADGES — severity + generic
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-mid);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  vertical-align: middle;
  line-height: 1.4;
}
.badge.sev1 { background: oklch(0.72 0.11 225 / 0.18); border-color: oklch(0.72 0.11 225 / 0.4); color: oklch(0.82 0.10 225); }
.badge.sev2 { background: oklch(0.83 0.14 92 / 0.18);  border-color: oklch(0.83 0.14 92 / 0.4);  color: oklch(0.86 0.13 92); }
.badge.sev3 { background: var(--sev3); border-color: var(--sev3); color: var(--sev3-ink); }
.badge.sev4 { background: var(--sev4); border-color: var(--sev4); color: var(--sev4-ink); }

/* ============================================================
   HAZARD CHIPS — category-coloured, code-led
   Additive: <span class="hz hz-FLD">FLD</span>
   ============================================================ */
.hz {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.02em;
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text-mid);
}
.hz::before {
  content: "";
  width: 7px; height: 7px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.9;
}
/* Hydrological */
.hz-FLD, .hz-CST { color: var(--cat-hydro); background: oklch(0.78 0.08 230 / 0.14); border-color: oklch(0.78 0.08 230 / 0.4); }
/* Geological */
.hz-LND, .hz-LMC, .hz-EQK { color: var(--cat-geo); background: oklch(0.80 0.08 70 / 0.14); border-color: oklch(0.80 0.08 70 / 0.4); }
/* Atmospheric */
.hz-STM, .hz-FIR, .hz-AIR { color: var(--cat-atmos); background: oklch(0.80 0.08 295 / 0.14); border-color: oklch(0.80 0.08 295 / 0.4); }
/* Environmental / Biological */
.hz-AGR, .hz-HLT { color: var(--cat-bio); background: oklch(0.80 0.08 155 / 0.14); border-color: oklch(0.80 0.08 155 / 0.4); }
/* Human systems */
.hz-INF, .hz-LOG { color: var(--cat-human); background: oklch(0.80 0.08 350 / 0.14); border-color: oklch(0.80 0.08 350 / 0.4); }

/* ============================================================
   FORMS / FILTERS / BUTTONS
   ============================================================ */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin-bottom: 20px;
}
.filters select, .filters button,
.authform input[type=text], .authform input[type=password], .authform input[type=file],
form input[type=text] {
  padding: 9px 12px;
  font: inherit;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--card);
  color: var(--text-hi);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.filters select { cursor: pointer; }
.filters select:focus,
.authform input:focus,
form input[type=text]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.80 0.12 200 / 0.18);
}

/* base typography for all actionable controls */
button, .button, a.button {
  font-family: var(--sans);
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: filter var(--ease), transform var(--ease), border-color var(--ease);
}
/* PRIMARY: explicit .button/links, filter buttons, and any form submit button */
.filters button, .button, a.button, button[type="submit"] {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  padding: 9px 18px;
  text-decoration: none;
  display: inline-block;
}
.filters button:hover, .button:hover, a.button:hover,
button[type="submit"]:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}
/* keep the language/logout link-buttons as plain links (override primary) */
.topbar .linklike, button.linklike {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-low);
  font-weight: 400;
  transform: none;
}
.topbar .linklike:hover, button.linklike:hover { color: var(--text-hi); filter: none; transform: none; }

/* ============================================================
   AUTH FORM
   ============================================================ */
.authform {
  max-width: 360px;
  display: grid;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}

/* ============================================================
   ACTIONS (detail page)
   ============================================================ */
.actions {
  display: flex;
  gap: 14px;
  margin: 24px 0;
  align-items: center;
  flex-wrap: wrap;
}
.actions h1 { margin: 0; flex: 1; }
.actions form { display: inline-flex; align-items: center; gap: 8px; }
.actions button {
  background: var(--card);
  color: var(--text-hi);
  border: 1px solid var(--border-2);
  padding: 9px 18px;
}
.actions button:hover { border-color: var(--accent); }
.actions .danger,
.rowactions .danger,
button.danger {
  background: var(--sev4);
  color: var(--sev4-ink);
  border: none;
  padding: 9px 18px;
}
.actions .danger:hover, button.danger:hover { filter: brightness(1.1); }
.actions label { font-size: 13.5px; color: var(--text-mid); display: inline-flex; gap: 6px; align-items: center; }

/* ============================================================
   META definition list (detail page)
   ============================================================ */
.meta {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 20px;
  margin: 20px 0;
  overflow: hidden;
}
.meta dt {
  font-family: var(--mono);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-low);
  float: left;
  clear: left;
  width: 9rem;
  padding: 12px 0;
}
.meta dd {
  margin-left: 11rem;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-hi);
  font-size: 14px;
}
.meta dd:last-of-type { border-bottom: none; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  margin-top: 20px;
  display: flex;
  gap: 16px;
  align-items: center;
  font-size: 13.5px;
  color: var(--text-low);
}
.pagination a {
  color: var(--accent);
  text-decoration: none;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--ease), background var(--ease);
}
.pagination a:hover { border-color: var(--accent); background: var(--card); }

/* ============================================================
   MONO / MESSAGE TEXT / HINTS
   ============================================================ */
.msg  { font-family: var(--mono); font-size: 13px; color: var(--text-mid); line-height: 1.55; }
.mono { font-family: var(--mono); }
.error { color: oklch(0.80 0.14 27); }
.hint { color: var(--text-low); font-size: 12.5px; }

/* ============================================================
   MAP
   ============================================================ */
#map {
  height: 75vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}
.draw-map {
  height: 55vh;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 6px;
  overflow: hidden;
}
/* Leaflet dark harmonisation (presentation only) */
.leaflet-container { background: oklch(0.22 0.018 250) !important; }
.leaflet-tile { filter: brightness(0.85) saturate(0.9) hue-rotate(180deg) invert(0.92); }
.leaflet-control-zoom a,
.leaflet-bar a {
  background: var(--panel) !important;
  color: var(--text-hi) !important;
  border-color: var(--border) !important;
}
.leaflet-popup-content-wrapper, .leaflet-popup-tip {
  background: var(--panel) !important;
  color: var(--text-hi) !important;
  border: 1px solid var(--border);
}

/* ============================================================
   LANDING CARDS
   ============================================================ */
.cards {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin: 8px 0 28px;
}
.card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 13rem;
  flex: 1;
  padding: 22px 24px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--text-mid);
  transition: border-color var(--ease), transform var(--ease), box-shadow var(--ease);
}
a.card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.card-num {
  font-size: 38px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-hi);
  font-variant-numeric: tabular-nums;
}
.card-label { color: var(--text-low); font-size: 13px; }
.card-warn {
  border-left: 3px solid var(--sev4);
}
.card-warn .card-num { color: oklch(0.80 0.14 27); }

.quicklinks {
  display: flex;
  gap: 24px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.quicklinks a {
  color: var(--accent);
  text-decoration: none;
  font-size: 14px;
  transition: opacity var(--ease);
}
.quicklinks a:hover { opacity: 0.75; }

/* ============================================================
   VOLUNTEER FORM
   ============================================================ */
.volform {
  max-width: 780px;
  display: grid;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.volform label { display: block; font-weight: 600; margin-bottom: 6px; color: var(--text-hi); font-size: 14px; }
.volform input[type=text], .volform select {
  padding: 9px 12px;
  min-width: 18rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--card);
  color: var(--text-hi);
  font: inherit;
}
.volform input[type=text]:focus, .volform select:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px oklch(0.80 0.12 200 / 0.18);
}

/* ============================================================
   ROW ACTIONS (triage)
   ============================================================ */
.rowactions { display: flex; gap: 8px; }
.rowactions button {
  padding: 6px 14px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--card);
  color: var(--text-hi);
  font-size: 13px;
  font-weight: 500;
}
.rowactions button:hover { border-color: var(--accent); }
.rowactions .danger { background: var(--sev4); color: var(--sev4-ink); border: none; }

/* ============================================================
   LOADING SKELETON (opt-in: <div class="skeleton-row"></div>)
   ============================================================ */
.skeleton-row {
  height: 14px;
  border-radius: 5px;
  background: linear-gradient(90deg,
    oklch(0.26 0.015 245) 0%,
    oklch(0.33 0.016 245) 40%,
    oklch(0.26 0.015 245) 80%);
  background-size: 360px 100%;
  animation: sentinel-shimmer 1.4s linear infinite;
  margin: 10px 0;
}
@keyframes sentinel-shimmer {
  0%   { background-position: -360px 0; }
  100% { background-position: 360px 0; }
}

/* ============================================================
   AUTH WRAPPER (login) — centres the .authform card
   opt-in: wrap the <form class="authform"> in <div class="auth-wrap">
   ============================================================ */
.auth-wrap {
  min-height: 60vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
}
.auth-wrap h1 { text-align: center; }
.auth-wrap .authform { width: 100%; }
.authform label { display: grid; gap: 6px; font-size: 13.5px; color: var(--text-mid); }
.authform input { width: 100%; }
.authform button { width: 100%; justify-content: center; text-align: center; }

/* ============================================================
   STATUS PILLS — active / inactive volunteer
   opt-in: <span class="pill pill-on">yes</span> / <span class="pill pill-off">no</span>
   ============================================================ */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-on  { background: oklch(0.78 0.16 150 / 0.16); color: oklch(0.84 0.13 150); }
.pill-off { background: var(--sev4 / 0.16); background: oklch(0.60 0.21 27 / 0.16); color: oklch(0.82 0.14 27); }

/* paragraph-wrapped form fields (volunteer_form, export inline labels) */
.volform p, form > p { margin: 0; display: grid; gap: 6px; }
form > label { display: inline-grid; gap: 6px; font-size: 13.5px; color: var(--text-mid); margin-right: 12px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
