:root {
  --bg: #f3f2ef; --panel: #ffffff; --ink: #1c1f24; --muted: #6b6f76; --line: #e2e0da;
  --chrome: #1c1f24; --chrome-ink: #f3f2ef; --amber: #f5a524; --amber-ink: #1c1f24;
  --ok: #1f9d55; --info: #3b6fd4; --watch: #c98a06; --act: #e2611b; --stop: #d0312d;
  --ok-bg: #e7f5ec; --info-bg: #eaf0fb; --watch-bg: #fdf4dd; --act-bg: #fdeadf; --stop-bg: #fbe3e2;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a; --panel: #1f2226; --ink: #ecebe7; --muted: #9a9ea5; --line: #30343a;
    --ok-bg: #16301f; --info-bg: #1a2640; --watch-bg: #33290d; --act-bg: #3a2113; --stop-bg: #3d1716;
    --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-font-smoothing: antialiased; padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.05rem; }
.top { position: sticky; top: 0; z-index: 10; background: var(--chrome); color: var(--chrome-ink); display: flex; align-items: center; justify-content: space-between; padding: calc(10px + env(safe-area-inset-top)) 16px 10px; }
.brand { display: flex; align-items: center; gap: 10px; background: none; border: 0; color: inherit; font-weight: 700; font-size: 1.05rem; padding: 0; cursor: pointer; }
.top-right { display: flex; gap: 10px; align-items: center; }
.src-dot { width: 10px; height: 10px; border-radius: 50%; background: #5b5f66; }
.src-dot.live { background: var(--ok); box-shadow: 0 0 0 3px rgba(31,157,85,.25); }
.src-dot.stale { background: var(--watch); }
#view { max-width: 760px; margin: 0 auto; padding: 16px; }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 10; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--panel); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.tabs button { background: none; border: 0; padding: 8px 0 9px; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .72rem; color: var(--muted); cursor: pointer; }
.tabs svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs[hidden], .tabs button[hidden] { display: none; }
.tabs button.on { color: var(--ink); font-weight: 600; }
.tabs button.on svg { stroke: var(--amber); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .8rem; }
.stack > * + * { margin-top: 10px; }
.btn { border: 1px solid var(--line); background: var(--panel); border-radius: 10px; padding: 9px 14px; cursor: pointer; font-weight: 600; min-height: 42px; }
.btn.primary { background: var(--amber); border-color: var(--amber); color: var(--amber-ink); }
.btn.dark { background: var(--chrome); border-color: var(--chrome); color: var(--chrome-ink); }
.btn.danger { color: var(--stop); }
.btn.sm { padding: 5px 10px; min-height: 34px; font-size: .85rem; }
.btn:disabled { opacity: .45; cursor: default; }
.pill { font-size: .75rem; font-weight: 700; padding: 3px 9px; border-radius: 99px; text-transform: uppercase; letter-spacing: .03em; }
.lv-ok { background: var(--ok-bg); color: var(--ok); } .lv-info { background: var(--info-bg); color: var(--info); }
.lv-watch { background: var(--watch-bg); color: var(--watch); } .lv-act { background: var(--act-bg); color: var(--act); }
.lv-stop { background: var(--stop-bg); color: var(--stop); }
.top .pill.lv-ok { background: var(--ok); color: #fff; } .top .pill.lv-watch { background: var(--watch); color: #fff; }
.top .pill.lv-act { background: var(--act); color: #fff; } .top .pill.lv-stop { background: var(--stop); color: #fff; } .top .pill.lv-info { background: var(--info); color: #fff; }

.phases { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin: 10px 0 2px; }
.phases button { border: 1px solid var(--line); background: var(--bg); border-radius: 8px; padding: 7px 2px; font-size: .78rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.phases button.on { background: var(--chrome); color: var(--chrome-ink); border-color: var(--chrome); }
.phases button.done { color: var(--ink); }

.alert { border-left: 5px solid; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; background: var(--panel); border-top: 1px solid var(--line); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.alert.stop { border-left-color: var(--stop); } .alert.act { border-left-color: var(--act); } .alert.watch { border-left-color: var(--watch); }
.alert.info { border-left-color: var(--info); } .alert.ok { border-left-color: var(--ok); }
.alert h3 { font-size: .98rem; display: flex; justify-content: space-between; gap: 8px; }
.alert .val { font-variant-numeric: tabular-nums; font-weight: 700; white-space: nowrap; }
.alert .do { margin: 6px 0 4px; font-weight: 500; }
.alert .why { font-size: .8rem; color: var(--muted); }
.oks { font-size: .85rem; color: var(--muted); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.metric { background: var(--bg); border-radius: 10px; padding: 10px 12px; }
.metric .k { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.metric .v { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.metric .s { font-size: .72rem; color: var(--muted); }
.gauge { height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--ok) 0 33%, var(--watch) 33% 66%, var(--stop) 66%); position: relative; margin-top: 6px; }
.gauge i { position: absolute; top: -4px; width: 4px; height: 16px; background: var(--ink); border-radius: 2px; transform: translateX(-2px); }

canvas.chart { width: 100%; height: 200px; display: block; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: .75rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 10px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 4px; }

label.f { display: block; font-size: .8rem; color: var(--muted); font-weight: 600; }
label.f > input, label.f > select, label.f > textarea { display: block; width: 100%; margin-top: 4px; padding: 9px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--bg); color: var(--ink); font-weight: 400; font-size: 16px; }
.fgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.fgrid .full { grid-column: 1 / -1; }

.truck { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; }
.timer { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--ok); }

.check { display: grid; grid-template-columns: 28px 1fr auto; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.check:first-of-type { border-top: 0; }
.check input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--amber); margin: 2px 0 0; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.thumbs img { width: 56px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; }

.log { list-style: none; padding: 0; margin: 0; }
.log li { display: grid; grid-template-columns: 64px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .88rem; }
.log li:first-child { border-top: 0; }
.log time { color: var(--muted); font-variant-numeric: tabular-nums; font-size: .78rem; }
.tag { font-size: .68rem; font-weight: 700; text-transform: uppercase; color: var(--muted); margin-right: 6px; }

.proj { display: flex; justify-content: space-between; align-items: center; gap: 10px; cursor: pointer; }
.proj:hover { border-color: var(--amber); }
.disclaimer { font-size: .8rem; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); padding: 10px 12px; }
.empty { text-align: center; padding: 30px 10px; }
.hero h1 { font-size: 1.4rem; margin-bottom: 4px; }

dialog { border: 0; border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 40px); background: var(--panel); color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 18px; }
dialog h2 { margin-bottom: 12px; }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
dialog img.full { width: 100%; border-radius: 10px; }
.toast { position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: var(--chrome); color: var(--chrome-ink); padding: 10px 16px; border-radius: 10px; font-size: .9rem; opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100vw - 32px); z-index: 20; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ---------- print report ---------- */
#report { display: none; }
@media print {
  body { background: #fff; color: #000; padding: 0; font-size: 11pt; }
  .top, .tabs, #view, .toast, dialog { display: none !important; }
  #report { display: block; }
  #report h1 { font-size: 18pt; } #report h2 { font-size: 13pt; margin: 16pt 0 6pt; border-bottom: 1px solid #999; }
  #report table { width: 100%; border-collapse: collapse; font-size: 9pt; }
  #report td, #report th { border-bottom: 1px solid #ddd; padding: 3pt 4pt; text-align: left; vertical-align: top; }
  #report img.ph { width: 46%; margin: 1%; break-inside: avoid; }
  #report img.chart { width: 100%; }
}

/* ---------- Site tab ---------- */
.vtbl { width: 100%; border-collapse: collapse; font-size: .85rem; }
.vtbl th, .vtbl td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--line); vertical-align: top; }
.vtbl th { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); border-top: 0; }
.vtbl .note { color: var(--muted); font-size: .78rem; margin-top: 3px; }
.st { font-size: .68rem; font-weight: 800; text-transform: uppercase; padding: 2px 7px; border-radius: 99px; white-space: nowrap; }
.st-pending { background: var(--bg); color: var(--muted); } .st-confirms { background: var(--ok-bg); color: var(--ok); }
.st-better { background: var(--info-bg); color: var(--info); } .st-worse { background: var(--stop-bg); color: var(--stop); }
.st-differs { background: var(--watch-bg); color: var(--watch); } .st-info { background: var(--info-bg); color: var(--info); }
.sflag { border-left: 4px solid var(--line); padding: 6px 10px; margin: 6px 0; background: var(--bg); border-radius: 0 8px 8px 0; font-size: .86rem; }
.sflag.critical { border-left-color: var(--stop); } .sflag.caution { border-left-color: var(--act); } .sflag.consider { border-left-color: var(--watch); }
.sflag.ok { border-left-color: var(--ok); } .sflag.info { border-left-color: var(--info); }
.sflag b { display: block; }
.checks { list-style: none; padding: 0; margin: 6px 0 0; font-size: .82rem; }
.checks li::before { content: '✓ '; color: var(--ok); font-weight: 800; } .checks li.no::before { content: '✗ '; color: var(--stop); }
.m-only { display: none; }
.progress { height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; } .progress > i { display: block; height: 100%; background: var(--amber); transition: width .3s; }
@media (max-width: 420px) { .tabs button { font-size: .66rem; } .tabs svg { width: 20px; height: 20px; } .vtbl td:nth-child(2) { display: none; } .vtbl th:nth-child(2) { display: none; } .m-only { display: block; } }
