:root {
  --bg: #f3f4f6; --surface: #ffffff; --text: #111418; --muted: #5d6573; --line: #dde1e7;
  --accent: #0b5fff; --go: #12814a; --red: #d92d20; --amber: #b54708; --amber-bg: #fff4e5;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0e1115; --surface: #181d24; --text: #eef1f5; --muted: #98a2b3; --line: #2a313b; --accent: #5b93ff; --go: #2fb872; --red: #ff6b5e; --amber: #f7a54a; --amber-bg: #3a2a12; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 8px 14px; min-height: 40px; }
button.go { background: var(--go); border-color: var(--go); color: #fff; font-weight: 700; }
button.ghost { background: transparent; }
button.big { font-size: 20px; font-weight: 700; padding: 14px 26px; min-height: 56px; }
h2 { font-size: 14px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 28px 0 10px; }

.bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.brand span { color: var(--muted); }
.conn { font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 99px; background: var(--line); }
.conn.ok { background: color-mix(in srgb, var(--go) 18%, transparent); color: var(--go); }
.conn.bad { background: color-mix(in srgb, var(--red) 18%, transparent); color: var(--red); }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tabs button, .tabs a { border: 0; background: none; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-weight: 600; text-decoration: none; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.tabs [aria-selected="true"] { background: var(--bg); color: var(--text); }
.count { background: var(--red); color: #fff; border-radius: 99px; padding: 0 8px; font-size: 12px; }
.bar-actions { margin-left: auto; display: flex; gap: 6px; }
.banner { padding: 10px 16px; background: var(--red); color: #fff; font-weight: 600; }
.banner.warn { background: var(--amber-bg); color: var(--amber); }

main { max-width: 1100px; margin: 0 auto; padding: 16px; }
.list { display: grid; gap: 10px; }
.empty { color: var(--muted); }
.req { display: flex; gap: 16px; justify-content: space-between; align-items: center; background: var(--surface); border: 1px solid var(--line); border-left: 6px solid var(--accent); border-radius: 12px; padding: 14px 16px; }
.req.urgent { border-left-color: var(--red); }
.req.onway { border-left-color: var(--go); opacity: .85; }
.req-room { font-size: 22px; font-weight: 800; }
.req-item { font-size: 17px; font-weight: 600; }
.req-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; align-items: center; color: var(--muted); }
.age { font-variant-numeric: tabular-nums; font-weight: 700; }
.req-note { margin-top: 6px; font-style: italic; }
.thumb { margin-top: 8px; max-height: 90px; border-radius: 8px; border: 1px solid var(--line); }
.req-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--bg); color: var(--muted); margin-left: 4px; }
.tag.red { background: var(--red); color: #fff; }
.tag.amber { background: var(--amber-bg); color: var(--amber); }
.tag.onway, .tag.done { background: color-mix(in srgb, var(--go) 18%, transparent); color: var(--go); }
.done-row { display: grid; grid-template-columns: 110px 140px 1fr auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.done-row strong { color: var(--text); }
@media (max-width: 640px) {
  .req { flex-direction: column; align-items: stretch; }
  .done-row { grid-template-columns: 1fr 1fr; }
}

.filters { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.filters input, .filters select { font: inherit; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); min-height: 40px; }
.filters input { flex: 1; min-width: 200px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: 12px; overflow: hidden; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; color: var(--muted); }
.tile .num { font-size: 30px; font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }
.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 130px 1fr 40px; gap: 10px; align-items: center; }
.bar-track { background: var(--line); border-radius: 4px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.bar-n { text-align: right; font-variant-numeric: tabular-nums; }
ol.top li { margin-bottom: 4px; }

/* arming + alert overlays */
.arm, .alert { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 92%, transparent); }
.arm-card { max-width: 480px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.alert { background: var(--accent); color: #fff; animation: flash 1.2s steps(2, jump-none) infinite; }
.alert.urgent { background: var(--red); animation-duration: .6s; }
.alert.escalated { background: var(--amber); }
@keyframes flash { 50% { filter: brightness(1.25); } }
@media (prefers-reduced-motion: reduce) { .alert { animation: none; } }
.alert-card { text-align: center; max-width: 900px; width: 100%; }
.alert-kind { font-size: 20px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; opacity: .9; }
.alert-room { font-size: clamp(56px, 12vw, 140px); font-weight: 900; line-height: 1; margin: 10px 0; overflow-wrap: anywhere; }
.alert-item { font-size: clamp(24px, 4vw, 44px); font-weight: 700; }
.alert-note { font-size: 22px; margin-top: 14px; font-style: italic; }
.alert-photo { max-height: 30vh; max-width: 100%; margin-top: 14px; border-radius: 12px; border: 3px solid #fff; }
.alert-actions { display: flex; gap: 14px; justify-content: center; margin-top: 28px; flex-wrap: wrap; }
.alert-actions button { border: 3px solid #fff; background: rgba(255,255,255,.15); color: #fff; }
.alert-actions button.go { background: #fff; color: #111; }
.alert-queue { margin-top: 16px; font-weight: 700; font-size: 18px; }

/* login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; width: 100%; max-width: 360px; display: grid; gap: 12px; }
.login-card h1 { margin: 0; }
.login-card p { margin: 0; color: var(--muted); }
.login-card label { display: grid; gap: 6px; font-weight: 600; }
.login-card input { font: inherit; padding: 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }
.login-card button { background: var(--accent); color: #fff; border: 0; font-weight: 700; }
.err { color: var(--red); }
