/* MWSC Damage — slate field kit. Amber is for actions; color otherwise means severity or status. */
:root {
  --ground: #12171d; --panel: #181f27; --raised: #212a34; --sunk: #0e1217; --line: #2b3541; --line-soft: #222b35;
  --text: #e5e9ee; --muted: #94a1b0; --faint: #66727f;
  --act: #f2a93b; --act-ink: #1c1203; --link: #7cc0f5;
  --ok: #3ccf7a; --warn: #e8c33c; --bad: #e5484d; --info: #5aa9f0;
  --sev-minor: #7cc46a; --sev-moderate: #e8c33c; --sev-major: #f08a3c; --sev-catastrophic: #e5484d; --sev-unknown: #8e9bab;
  --sans: 'Atkinson Hyperlegible', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, Menlo, Consolas, monospace;
  --r: 8px; --top: 54px; color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --ground: #f4f5f2; --panel: #ffffff; --raised: #eceeea; --sunk: #e6e8e3; --line: #cfd3cc; --line-soft: #e1e4de;
    --text: #1b2026; --muted: #56606b; --faint: #7d8691; --act: #c9780c; --act-ink: #ffffff; --link: #1d6fb8;
    --ok: #198a4a; --warn: #a07800; --bad: #c32a2f; --info: #2672c0; color-scheme: light;
  }
}
:root[data-theme="light"] {
  --ground: #f4f5f2; --panel: #ffffff; --raised: #eceeea; --sunk: #e6e8e3; --line: #cfd3cc; --line-soft: #e1e4de;
  --text: #1b2026; --muted: #56606b; --faint: #7d8691; --act: #c9780c; --act-ink: #ffffff; --link: #1d6fb8;
  --ok: #198a4a; --warn: #a07800; --bad: #c32a2f; --info: #2672c0; color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--text); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100vh; }
a { color: var(--link); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--act); outline-offset: 2px; }
h1 { font-size: 24px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -.01em; }
h2 { font-size: 17px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .mono { font-family: var(--mono); }
.grow { flex: 1; } .nowrap { white-space: nowrap; } .hide { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; } .row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; }
.stack > * + * { margin-top: 12px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }

/* ── Top bar ── */
.top { position: sticky; top: 0; z-index: 1000; height: var(--top); display: flex; align-items: center; gap: 18px; padding: 0 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 9px; color: var(--text); text-decoration: none; font-size: 16px; white-space: nowrap; }
.brand svg { color: var(--act); flex: none; }
.brand b { font-weight: 700; }
.top nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; }
.top nav a { color: var(--muted); text-decoration: none; padding: 7px 11px; border-radius: 6px; white-space: nowrap; font-size: 14px; }
.top nav a:hover { color: var(--text); background: var(--raised); }
.top nav a.on { color: var(--text); background: var(--raised); box-shadow: inset 0 -2px 0 var(--act); }
.top nav a .count { font-family: var(--mono); font-size: 12px; color: var(--act-ink); background: var(--act); border-radius: 9px; padding: 0 6px; margin-left: 4px; }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.who form { margin: 0; }
@media (max-width: 760px) {
  .top { flex-wrap: wrap; height: auto; padding: 8px 12px 0; gap: 6px 12px; }
  .top nav { order: 3; width: 100%; margin: 0 -12px; padding: 0 8px 6px; }
  .who .name { display: none; }
}

main.page { max-width: 1180px; margin: 0 auto; padding: 22px 16px 60px; }
main.page.narrow { max-width: 720px; }
.head { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.head p { margin: 0; }

/* ── Controls ── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 15px; border-radius: var(--r); border: 1px solid var(--line); background: var(--raised); color: var(--text); font: inherit; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--faint); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.primary { background: var(--act); border-color: var(--act); color: var(--act-ink); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--raised); }
.btn.danger { color: var(--bad); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.lg { height: 50px; font-size: 16px; padding: 0 22px; }
.btn.block { width: 100%; }
input.input, select.input, textarea.input, .input { height: 38px; padding: 0 10px; border-radius: var(--r); border: 1px solid var(--line); background: var(--sunk); color: var(--text); font: inherit; min-width: 0; width: 100%; }
textarea.input { height: auto; min-height: 96px; padding: 9px 10px; resize: vertical; line-height: 1.45; }
select.input { padding-right: 28px; }
.input:focus { outline: none; border-color: var(--act); box-shadow: 0 0 0 3px color-mix(in srgb, var(--act) 22%, transparent); }
.input.sm { height: 32px; font-size: 13px; width: auto; }
.field { display: block; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.field > span b { color: var(--text); font-weight: 700; }
.field .hint { font-size: 12px; color: var(--faint); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
@media (max-width: 600px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 14px; }
.check input { width: 18px; height: 18px; accent-color: var(--act); }

/* Chips: multi/single choice that's easy to hit with a thumb */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 13px; border-radius: 18px; border: 1px solid var(--line); background: var(--sunk); color: var(--muted); font-size: 14px; cursor: pointer; user-select: none; }
.chip span::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c, transparent); display: var(--dot, none); }
.chip input:checked + span { color: var(--text); border-color: var(--act); background: color-mix(in srgb, var(--act) 14%, var(--sunk)); }
.chip input:focus-visible + span { outline: 2px solid var(--act); outline-offset: 2px; }
.chips.sevchips .chip span { --dot: inline-block; }
.chips.sevchips .chip input:checked + span { border-color: var(--c); background: color-mix(in srgb, var(--c) 16%, var(--sunk)); }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 6px 12px; font-size: 13px; color: var(--muted); cursor: pointer; border-right: 1px solid var(--line-soft); background: var(--sunk); }
.seg label:last-child span { border-right: 0; }
.seg input:checked + span { background: var(--text); color: var(--ground); font-weight: 700; }
.seg input:focus-visible + span { outline: 2px solid var(--act); outline-offset: -2px; }

/* ── Panels, tables ── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 18px; }
.panel + .panel { margin-top: 14px; }
.panel h2 { display: flex; align-items: center; gap: 8px; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-weight: 400; font-size: 12px; color: var(--faint); padding: 6px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-family: var(--mono); font-size: 13px; }
.table th.num { font-family: var(--sans); font-size: 12px; }
.table-wrap { overflow-x: auto; }
.empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.error { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 40%, transparent); padding: 9px 12px; border-radius: var(--r); font-size: 14px; }
.note { background: var(--sunk); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; font-size: 14px; color: var(--muted); }

/* Status + severity */
.st { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 1px 8px; border-radius: 10px; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); white-space: nowrap; }
.sev { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
.sev::before { content: ''; width: 10px; height: 10px; border-radius: 2px; background: var(--c); }
.num-tag { font-family: var(--mono); font-size: 13px; letter-spacing: .02em; color: var(--text); }
.threat { color: var(--bad); font-weight: 700; font-size: 12px; white-space: nowrap; }

/* ── Toast ── */
.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--text); color: var(--ground); padding: 11px 14px; border-radius: var(--r); font-size: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.toast.bad { background: var(--bad); color: #fff; }

/* ── Sign-in ── */
body.center { display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.signin { width: min(440px, 100%); }
.signin .brand { font-size: 20px; margin-bottom: 6px; }
.signin .lead { margin-bottom: 20px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; }
.tabs button { background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; padding: 9px 10px; cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--act); }

/* ── Report form ── */
.form-sec { padding: 18px 0; border-top: 1px solid var(--line); }
.form-sec:first-of-type { border-top: 0; padding-top: 0; }
.form-sec > h2 { font-size: 16px; margin-bottom: 12px; }
.form-sec > h2 small { font-weight: 400; color: var(--faint); font-size: 13px; margin-left: 6px; }
.pick-map { height: 280px; border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; }
.loc-line { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; font-size: 13px; color: var(--muted); }
.loc-line .mono { color: var(--text); }
.photos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 8px; }
.ph { position: relative; aspect-ratio: 1; border-radius: var(--r); overflow: hidden; background: var(--sunk); border: 1px solid var(--line); }
.ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph button { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 13px; border: 0; background: rgba(0,0,0,.65); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.ph .pub { position: absolute; left: 4px; bottom: 4px; font-size: 11px; background: rgba(0,0,0,.65); color: #fff; padding: 1px 6px; border-radius: 8px; }
.add-photo { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; aspect-ratio: 1; border-radius: var(--r); border: 1px dashed var(--faint); color: var(--muted); cursor: pointer; font-size: 13px; text-align: center; }
.add-photo:hover { color: var(--text); border-color: var(--act); }
.add-photo input { display: none; }
details.more { border-top: 1px solid var(--line); padding: 14px 0 0; }
details.more > summary { cursor: pointer; font-weight: 700; padding: 4px 0 12px; list-style: none; display: flex; align-items: center; gap: 8px; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary::before { content: '▸'; color: var(--act); transition: transform .15s; }
details.more[open] > summary::before { transform: rotate(90deg); }
.q-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 14px; }
.q-row:last-child { border-bottom: 0; }
@media (max-width: 520px) { .q-row { flex-direction: column; align-items: flex-start; gap: 6px; } }
.sendbar { position: sticky; bottom: 0; z-index: 900; background: color-mix(in srgb, var(--ground) 92%, transparent); backdrop-filter: blur(6px); border-top: 1px solid var(--line); padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); margin-top: 20px; display: flex; gap: 10px; align-items: center; }
.queue-note { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border-radius: var(--r); border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent); background: color-mix(in srgb, var(--warn) 10%, transparent); font-size: 14px; margin-bottom: 16px; }
.done-card { text-align: center; padding: 40px 18px; }
.done-card .num-tag { font-size: 22px; display: block; margin: 8px 0 14px; }

/* ── Review queue: list + detail ── */
.split { display: grid; grid-template-columns: minmax(320px, 400px) 1fr; height: calc(100vh - var(--top)); }
.split .list { border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.split .detail { overflow-y: auto; min-height: 0; }
.filters { padding: 10px; border-bottom: 1px solid var(--line); display: grid; gap: 6px; }
.filters .row > * { flex: 1; }
.items { overflow-y: auto; flex: 1; }
.item { display: grid; grid-template-columns: 4px 1fr; gap: 0 10px; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--line-soft); cursor: pointer; text-decoration: none; color: inherit; }
.item::before { content: ''; background: var(--c); grid-row: 1 / 4; border-radius: 0 2px 2px 0; }
.item:hover { background: var(--raised); }
.item.on { background: color-mix(in srgb, var(--act) 9%, var(--raised)); }
.item .l1 { display: flex; align-items: center; gap: 8px; }
.item .l2 { font-size: 13px; color: var(--muted); }
.item .l3 { font-size: 13px; color: var(--text); overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.items .more-btn { margin: 10px; }
@media (max-width: 860px) {
  .split { grid-template-columns: 1fr; height: auto; }
  .split .detail { display: none; }
  .split .list { border-right: 0; }
  .items { overflow: visible; }
}

/* Report detail */
.rep { padding: 22px 24px 60px; max-width: 980px; }
.rep-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 4px; }
.rep-head .num-tag { font-size: 20px; }
.rep-sub { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.rep-grid { display: grid; grid-template-columns: 1fr 300px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .rep-grid { grid-template-columns: 1fr; } }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; font-size: 14px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.mini-map { height: 220px; border-radius: var(--r); border: 1px solid var(--line); overflow: hidden; }
.desc { white-space: pre-wrap; font-size: 15px; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.gallery figure { margin: 0; }
.gallery .ph { display: block; aspect-ratio: 4 / 3; }
.gallery figcaption { font-size: 12px; color: var(--muted); margin-top: 3px; display: flex; gap: 6px; align-items: center; }
.history { list-style: none; padding: 0; margin: 0; font-size: 13px; }
.history li { padding: 6px 0; border-bottom: 1px solid var(--line-soft); }
.history time { color: var(--faint); font-family: var(--mono); font-size: 12px; margin-right: 6px; }
.review-box { position: sticky; top: 14px; }
.review-box .seg { display: flex; flex-wrap: wrap; }
.review-box .seg label { flex: 1 1 auto; }
.review-box .seg span { text-align: center; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.92); z-index: 4000; display: flex; align-items: center; justify-content: center; padding: 20px; }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox button { position: absolute; top: 14px; right: 14px; }

/* ── Dashboard ── */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; text-decoration: none; color: inherit; border-top: 3px solid var(--c, var(--line)); }
.stat b { display: block; font-size: 26px; font-family: var(--mono); font-weight: 400; line-height: 1.2; }
.stat span { font-size: 13px; color: var(--muted); }
a.stat:hover { border-color: var(--faint); border-top-color: var(--c, var(--faint)); }
.bar { height: 6px; background: var(--sunk); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar i { display: block; height: 100%; background: var(--act); }

/* ── Maps ── */
.map-page { height: calc(100vh - var(--top)); position: relative; }
.map-page #map { position: absolute; inset: 0; }
.map-panel { position: absolute; z-index: 800; top: 12px; left: 12px; width: min(330px, calc(100% - 24px)); background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.3); max-height: calc(100% - 24px); overflow: auto; }
.map-panel h1 { font-size: 19px; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 13px; margin-top: 10px; }
.leaflet-container { background: var(--sunk); font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); border: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.leaflet-popup-content { margin: 12px 14px; font-size: 14px; line-height: 1.45; }
.leaflet-popup-content a { color: var(--link); }
.leaflet-control-layers, .leaflet-bar a { background: var(--panel) !important; color: var(--text) !important; border-color: var(--line) !important; }
.pop-ph { display: flex; gap: 4px; margin-top: 8px; }
.pop-ph img { width: 72px; height: 54px; object-fit: cover; border-radius: 4px; }
@media (max-width: 600px) {
  .map-panel { top: auto; bottom: 10px; left: 10px; right: 10px; width: auto; max-height: 45%; }
}

/* ── Admin bits ── */
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.toolbar .input { width: auto; }
dialog { background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 12px; padding: 20px; width: min(520px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0,0,0,.6); }
dialog h2 { margin-bottom: 14px; }
dialog .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; }
.pill { font-size: 12px; border: 1px solid var(--line); border-radius: 10px; padding: 0 8px; color: var(--muted); white-space: nowrap; }
.code-big { font-family: var(--mono); font-size: 15px; letter-spacing: .04em; }
.state-group > summary { cursor: pointer; padding: 10px 0; font-weight: 700; }
.apps { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .apps { grid-template-columns: 1fr; } }
.subnav { display: flex; gap: 4px; flex-wrap: wrap; margin: -6px 0 18px; border-bottom: 1px solid var(--line); }
.subnav a { color: var(--muted); text-decoration: none; padding: 8px 12px; font-size: 14px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.subnav a:hover { color: var(--text); }
.subnav a.on { color: var(--text); border-bottom-color: var(--act); }
.pick-list { max-height: 220px; overflow: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 6px 10px; background: var(--sunk); }
.pick-list label { display: flex; gap: 8px; padding: 3px 0; font-size: 14px; }
.secret { font-family: var(--mono); font-size: 16px; background: var(--sunk); border: 1px dashed var(--act); padding: 10px 12px; border-radius: var(--r); user-select: all; }
/* Phones pinch to zoom; the buttons would sit on the panel */
@media (max-width: 600px) { .map-page .leaflet-control-zoom { display: none; } }
