:root {
  --bg: #f5f4ef;
  --surface: #ffffff;
  --ink: #17191c;
  --muted: #5b6068;
  --line: #e2dfd6;
  --navy: #12355b;
  --navy-ink: #ffffff;
  --gold: #b8860b;
  --danger: #b3261e;
  --ok: #1e7a4f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 24, 33, 0.06), 0 8px 24px rgba(18, 24, 33, 0.06);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }

/* Class rules that set display would otherwise override the hidden attribute. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}

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

h1 { font-size: clamp(1.7rem, 4vw, 2.4rem); line-height: 1.15; letter-spacing: -0.02em; margin: 0.2rem 0 0.6rem; }
h2 { font-size: 1.05rem; margin: 0 0 0.8rem; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--navy);
  color: var(--navy-ink);
}
.brand { color: inherit; text-decoration: none; font-weight: 800; letter-spacing: 0.04em; font-size: 1.15rem; }
.brand span { color: #e8b84a; }
.topbar nav { display: flex; gap: 4px; }
.topbar nav a {
  color: rgba(255, 255, 255, 0.78);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
}
.topbar nav a[aria-current="page"] { background: rgba(255, 255, 255, 0.14); color: #fff; }

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--gold);
}
.lead { color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: 0.88rem; margin: 0.3rem 0 0; }
small { color: var(--muted); font-weight: 400; }

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

/* Report page */
/* minmax(0, 1fr): an implicit auto column would grow to its content's min width and overflow on phones. */
.report-page {
  max-width: 620px;
  margin: 0 auto;
  padding: 28px 16px 64px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 20px;
}

.recorder { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.record-btn {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  border: 0;
  border-radius: 999px;
  padding: 16px 26px;
  background: var(--navy);
  color: #fff;
  font: 600 1.05rem var(--font);
  cursor: pointer;
}
.record-btn .dot { width: 14px; height: 14px; border-radius: 50%; background: #ff5a4f; }
.record-btn.recording { background: var(--danger); }
.record-btn.recording .dot { background: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--danger); }
.recorder audio { width: 100%; }

.field { display: grid; gap: 6px; margin-bottom: 14px; font-weight: 600; font-size: 0.93rem; }
.field input, .field textarea, .filters select {
  font: 400 1rem var(--font);
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  width: 100%;
}
.field textarea { resize: vertical; }
.field input:focus, .field textarea:focus, select:focus, button:focus-visible, a:focus-visible, tr:focus-visible {
  outline: 3px solid rgba(18, 53, 91, 0.35);
  outline-offset: 1px;
}

.location { border: 0; padding: 0; margin: 0 0 6px; }
.location legend { font-weight: 600; font-size: 0.93rem; margin-bottom: 8px; }
.locate { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.primary, .secondary, .link-btn {
  font: 600 1rem var(--font);
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}
.primary { background: var(--navy); color: #fff; border: 0; padding: 13px 20px; width: 100%; }
.primary:disabled { opacity: 0.6; cursor: progress; }
.secondary { background: #fff; color: var(--navy); border: 1px solid var(--navy); padding: 9px 14px; }
.secondary.done { border-color: var(--ok); color: var(--ok); }
.link-btn { background: none; border: 0; color: var(--danger); padding: 4px; font-size: 0.9rem; }

.privacy {
  font-size: 0.86rem;
  color: var(--muted);
  background: #f8f6f0;
  border-left: 3px solid var(--gold);
  padding: 10px 12px;
  border-radius: 6px;
}
.error { color: var(--danger); font-weight: 600; margin: 10px 0 0; }

.result h2 { margin-bottom: 12px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.steps li { color: var(--muted); padding-left: 26px; position: relative; }
.steps li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 5px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
}
.steps li.done { color: var(--ink); }
.steps li.done::before { background: var(--ok); border-color: var(--ok); }
.steps li.active { color: var(--ink); font-weight: 600; }
.steps li.active::before { border-color: var(--navy); border-top-color: transparent; animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.result-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.pill {
  --pill: #777;
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--pill);
  background: color-mix(in srgb, var(--pill) 14%, white);
}
.badge-unverified {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8a5a00;
  background: #fff4d6;
  border: 1px solid #f0d58a;
  padding: 2px 8px;
  border-radius: 6px;
}
.summary { font-size: 1.1rem; margin: 6px 0 10px; }
.facts { margin: 0 0 12px; padding-left: 18px; color: var(--muted); }
.corroborates { background: #eef5ff; border-radius: 8px; padding: 10px 12px; color: var(--navy); font-weight: 600; }
.actions { display: grid; gap: 10px; margin-top: 16px; }

/* Dashboard */
.dash {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
}
.dash-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 12px; }
.dash-head h1 { margin-bottom: 0; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; }
.filters label { display: grid; gap: 4px; font-size: 0.8rem; font-weight: 600; color: var(--muted); }
.filters select { width: auto; min-width: 150px; padding: 8px 10px; }

.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid;
  gap: 2px;
}
.kpi-value { font-size: 1.7rem; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 0.8rem; color: var(--muted); }

.dash-body { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 16px; align-items: start; }
/* Grid items default to min-width: auto, so the map canvas and the table would refuse to shrink on phones. */
.dash > *, .dash-body > *, .side > *, .report-page > * { min-width: 0; }
.map { height: 64vh; min-height: 420px; border-radius: var(--radius); border: 1px solid var(--line); overflow: hidden; }
.ranking { padding: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
thead th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
tbody th { font-weight: 600; }
tbody th small { display: block; }
tbody tr { cursor: pointer; }
tbody tr:hover { background: #f8f6f0; }
tbody tr.selected { background: #eef5ff; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.strong { font-weight: 800; }
.empty { color: var(--muted); margin: 12px 0 0; }
.disclaimer { font-size: 0.82rem; color: var(--muted); margin: 0; }
.demo-note {
  margin: 0;
  font-size: 0.86rem;
  color: #8a5a00;
  background: #fff4d6;
  border: 1px solid #f0d58a;
  border-radius: 8px;
  padding: 8px 12px;
}

.side { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; align-content: start; }
.memo h3 { margin: 0; font-size: 1.1rem; }
.memo .hint { margin-top: 2px; }
.figures { list-style: none; padding: 0; margin: 12px 0; display: flex; flex-wrap: wrap; gap: 6px; }
.figures li { background: #f1efe8; border-radius: 999px; padding: 3px 10px; font-size: 0.82rem; font-weight: 600; }
.memo-lines {
  margin: 12px 0 8px;
  padding: 12px 14px 12px 34px;
  background: #f8f6f0;
  border-left: 3px solid var(--navy);
  border-radius: 8px;
  display: grid;
  gap: 8px;
}
.memo-meta { font-size: 0.8rem; color: var(--muted); margin: 0 0 8px; }
.memo-actions { display: grid; gap: 8px; margin: 12px 0; }
.memo .disclaimer { margin-top: 10px; }

.popup p { margin: 4px 0; }
.urgency { font-size: 0.8rem; color: var(--muted); }
.maplibregl-popup-content { border-radius: 12px; padding: 14px 16px; font-family: var(--font); }

@media (max-width: 900px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpis .kpi:last-child { grid-column: span 2; }
  .dash-body { grid-template-columns: minmax(0, 1fr); }
  .map { height: 52vh; min-height: 340px; }
}

@media (max-width: 480px) {
  .row { grid-template-columns: 1fr; }
  .record-btn { width: 100%; justify-content: center; }
  .filters { width: 100%; }
  .filters label { flex: 1; }
  .filters select { min-width: 0; width: 100%; }
}
