/* Safety ALRT Admin Console — no framework, no build step. */

:root {
  --navy: #05123d;
  --navy-soft: #12224f;
  --blue: #3b6dff;
  --pink: #ff4a8d;
  --ink: #1e293b;
  --ink-soft: #64748b;
  --line: #e2e8f0;
  --bg: #f1f5f9;
  --card: #ffffff;
  --ok: #12805c;
  --warn: #b45309;
  --bad: #b91c1c;
  --radius: 10px;
  --shadow: 0 1px 3px rgb(2 6 23 / 0.08), 0 8px 24px rgb(2 6 23 / 0.06);
}

@media (prefers-color-scheme: dark) {
  :root {
    --ink: #e2e8f0;
    --ink-soft: #94a3b8;
    --line: #1e293b;
    --bg: #0b1220;
    --card: #111a2e;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.4);
  }
}

* { box-sizing: border-box; }

/* The UA stylesheet hides [hidden] with display:none, but any author
   `display` rule outranks it — and .login-shell / #app both set display:grid.
   Without this, hide()/show() silently do nothing and the sign-in screen
   renders on top of the console. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

.skip-link {
  position: absolute; left: -9999px;
  background: var(--card); padding: 10px 16px; z-index: 100; border-radius: 8px;
}
.skip-link:focus { left: 12px; top: 12px; }

/* ── Brand ─────────────────────────────────────────────────────── */
.brand { font-size: 1.15rem; font-weight: 800; letter-spacing: -0.02em; color: #fff; }
.brand span { color: var(--pink); }
.brand-lg { font-size: 1.7rem; color: var(--navy); }
@media (prefers-color-scheme: dark) { .brand-lg { color: #fff; } }

/* ── Sign-in ───────────────────────────────────────────────────── */
.login-shell {
  min-height: 100%;
  display: grid; place-items: center;
  background: linear-gradient(160deg, var(--navy), #0b1c52 60%, #16265c);
  padding: 24px;
}
.login-card {
  width: 100%; max-width: 380px;
  background: var(--card); border-radius: 14px; padding: 30px;
  box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.login-sub { margin: 4px 0 20px; color: var(--ink-soft); font-weight: 600; }
.login-card label { font-size: 0.82rem; font-weight: 700; margin-bottom: 5px; }
.login-card input { margin-bottom: 14px; }

/* ── Layout ────────────────────────────────────────────────────── */
#app { display: grid; grid-template-columns: 232px 1fr; min-height: 100%; }

.sidebar {
  background: var(--navy); color: #cbd5e1;
  padding: 22px 16px; display: flex; flex-direction: column; gap: 22px;
  position: sticky; top: 0; height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-item {
  color: #cbd5e1; text-decoration: none; padding: 9px 12px;
  border-radius: 8px; font-size: 0.92rem; font-weight: 600;
}
.nav-item:hover { background: var(--navy-soft); color: #fff; }
.nav-item[aria-current="page"] { background: var(--blue); color: #fff; }

.sidebar-foot { border-top: 1px solid rgb(255 255 255 / 0.12); padding-top: 14px; }
.who-name { color: #fff; font-weight: 700; font-size: 0.9rem; }
.who-role { color: #94a3b8; font-size: 0.78rem; text-transform: capitalize; }
.btn-quiet { background: transparent; color: #cbd5e1; border: 1px solid rgb(255 255 255 / 0.2); margin-top: 10px; }
.btn-quiet:hover { background: var(--navy-soft); color: #fff; }

main { padding: 26px 30px 60px; overflow-x: hidden; }
main:focus { outline: none; }

@media (max-width: 820px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  main { padding: 18px; }
}

/* ── Page furniture ────────────────────────────────────────────── */
.page-head { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
h1 { font-size: 1.4rem; margin: 0; letter-spacing: -0.01em; }
.page-sub { color: var(--ink-soft); font-size: 0.9rem; margin: 4px 0 0; }
h2 { font-size: 1rem; margin: 26px 0 10px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }

/* ── Stat tiles ────────────────────────────────────────────────── */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(168px, 1fr)); gap: 12px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 17px; box-shadow: var(--shadow); }
.tile-label { font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); font-weight: 700; }
.tile-value { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.02em; margin-top: 5px; font-variant-numeric: tabular-nums; }
.tile-note { font-size: 0.8rem; color: var(--ink-soft); margin-top: 2px; }
.tile-value.alert { color: var(--warn); }

/* ── Tables ────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
thead th { text-align: left; padding: 11px 14px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-soft); border-bottom: 1px solid var(--line); white-space: nowrap; }
tbody td { padding: 11px 14px; border-top: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: rgb(59 109 255 / 0.04); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ── Controls ──────────────────────────────────────────────────── */
input, select, textarea {
  font: inherit; color: inherit; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus, .btn:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 1px;
}
textarea { min-height: 92px; resize: vertical; }

.btn {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  border-radius: 8px; padding: 8px 15px;
}
.btn:hover { border-color: var(--blue); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #fff; }
.btn-primary:hover { background: #2b5be0; }
.btn-danger { color: var(--bad); border-color: rgb(185 28 28 / 0.35); }
.btn-danger:hover { background: rgb(185 28 28 / 0.08); border-color: var(--bad); }
.btn-sm { padding: 5px 10px; font-size: 0.84rem; }
.btn-block { width: 100%; }

.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input, .toolbar select { width: auto; min-width: 170px; }
.spacer { flex: 1; }

/* ── Badges ────────────────────────────────────────────────────── */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 0.75rem; font-weight: 700; border: 1px solid transparent; white-space: nowrap; }
.badge-emergency { background: rgb(185 28 28 / 0.12); color: var(--bad); border-color: rgb(185 28 28 / 0.3); }
.badge-watchAndAct { background: rgb(180 83 9 / 0.12); color: var(--warn); border-color: rgb(180 83 9 / 0.3); }
.badge-advice { background: rgb(59 109 255 / 0.12); color: var(--blue); border-color: rgb(59 109 255 / 0.3); }
.badge-info, .badge-unknown { background: rgb(100 116 139 / 0.12); color: var(--ink-soft); border-color: rgb(100 116 139 / 0.3); }
.badge-accepted { background: rgb(18 128 92 / 0.12); color: var(--ok); border-color: rgb(18 128 92 / 0.3); }
.badge-pending { background: rgb(180 83 9 / 0.12); color: var(--warn); border-color: rgb(180 83 9 / 0.3); }
.badge-rejected { background: rgb(185 28 28 / 0.12); color: var(--bad); border-color: rgb(185 28 28 / 0.3); }

/* ── Map ───────────────────────────────────────────────────────── */
#hazmap { height: min(70vh, 640px); border-radius: var(--radius); border: 1px solid var(--line); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 10px; font-size: 0.83rem; color: var(--ink-soft); }
.legend i { width: 11px; height: 11px; border-radius: 50%; display: inline-block; margin-right: 5px; vertical-align: middle; }

/* ── Modal ─────────────────────────────────────────────────────── */
.modal-back { position: fixed; inset: 0; background: rgb(2 6 23 / 0.55); display: grid; place-items: center; padding: 20px; z-index: 50; }
.modal { background: var(--card); border-radius: 12px; padding: 22px; width: 100%; max-width: 560px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal h3 { margin: 0 0 4px; font-size: 1.1rem; }
.modal .field { margin-bottom: 13px; }
.modal label { display: block; font-size: 0.82rem; font-weight: 700; margin-bottom: 5px; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 20px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

/* ── Misc ──────────────────────────────────────────────────────── */
.hint { font-size: 0.82rem; color: var(--ink-soft); margin: -8px 0 14px; }
.form-error { color: var(--bad); font-size: 0.86rem; font-weight: 600; margin: 10px 0 0; }
.muted { color: var(--ink-soft); }
.empty { padding: 40px; text-align: center; color: var(--ink-soft); }
.readonly-note { background: rgb(59 109 255 / 0.08); border: 1px solid rgb(59 109 255 / 0.25); color: var(--ink); padding: 9px 13px; border-radius: 8px; font-size: 0.86rem; margin-bottom: 14px; }

.bar { height: 7px; background: var(--line); border-radius: 999px; overflow: hidden; min-width: 90px; }
.bar > span { display: block; height: 100%; background: var(--blue); }

.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 11px; }
.icon-cell { border: 1px solid var(--line); border-radius: 9px; padding: 11px; text-align: center; background: var(--bg); }
.icon-cell img { width: 42px; height: 42px; object-fit: contain; }
.icon-cell .t { font-size: 0.72rem; color: var(--ink-soft); margin-top: 6px; word-break: break-word; }

.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 11px 20px; border-radius: 9px; font-weight: 600; font-size: 0.9rem; box-shadow: var(--shadow); z-index: 90; }
.toast.bad { background: var(--bad); }

.swatch { width: 13px; height: 13px; border-radius: 3px; display: inline-block; vertical-align: middle; margin-right: 6px; border: 1px solid rgb(0 0 0 / 0.15); }
