:root {
  --bg: #f5f5f7; --card: #fff; --text: #111316; --muted: #6b7076; --line: #e2e3e7;
  --accent: #0a8f55; --accent-bg: #ddf7ea; --warn: #b25b00; --warn-bg: #fff1dc;
  --bad: #c62828; --bad-bg: #fde7e7; --chip: #eef0f3; --tabs: rgba(255,255,255,.92);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0d10; --card: #16191d; --text: #eef0f2; --muted: #9aa0a6; --line: #262a30;
    --accent: #61e39e; --accent-bg: #10301f; --warn: #ffb74d; --warn-bg: #33250f;
    --bad: #ff6b6b; --bad-bg: #3a1515; --chip: #22262c; --tabs: rgba(22,25,29,.92);
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); overflow-x: hidden; }
body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); }
button, input, textarea, select { font: inherit; color: inherit; }
.top { position: sticky; top: 0; z-index: 5; padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--bg); border-bottom: 1px solid var(--line); }
.top .row { flex-wrap: nowrap; align-items: baseline; }
.switcher { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.switcher:empty { display: none; }
.switcher button { flex: 1; min-height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; }
.switcher button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
.tabs[hidden], .tabs button[hidden] { display: none; }
.top h1 { font-size: 20px; margin: 0; }
#who { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.top h1 { white-space: nowrap; }
main { max-width: 760px; margin: 0 auto; padding: 12px 12px 24px; outline: none; }
h2 { font-size: 17px; margin: 22px 4px 8px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; margin: 10px 0; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (min-width: 620px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-height: 84px; }
.stat b { display: block; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 13px; }
button.stat { text-align: left; width: 100%; cursor: pointer; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--chip); white-space: nowrap; }
.ok { background: var(--accent-bg); color: var(--accent); }
.warn { background: var(--warn-bg); color: var(--warn); }
.bad { background: var(--bad-bg); color: var(--bad); }
.btn { min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-weight: 600; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #002414; } }
.btn.danger { color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.block { width: 100%; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.seg button { min-height: 36px; padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); cursor: pointer; font-size: 14px; }
.seg button[aria-pressed="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }
label { display: block; font-size: 13px; color: var(--muted); margin: 12px 0 4px; }
input, textarea, select { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg); font-size: 16px; }
textarea { min-height: 88px; resize: vertical; }
.count { float: right; font-size: 12px; }
.msg { white-space: pre-wrap; overflow-wrap: anywhere; margin: 8px 0; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; font-size: 13px; margin: 6px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; overflow-wrap: anywhere; }
details summary { cursor: pointer; color: var(--accent); font-size: 14px; padding: 6px 0; }
pre.log { font: 12px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere;
  background: var(--bg); padding: 8px; border-radius: 8px; max-height: 320px; overflow: auto; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 90px; margin: 8px 0 2px; }
.bars div { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; position: relative; }
.bars div span { position: absolute; top: -17px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--muted); }
.barlabels { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.barlabels span { flex: 1; text-align: center; overflow: hidden; }
.meter { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; font-size: 14px; align-items: center; }
.meter .track { grid-column: 1 / -1; height: 6px; background: var(--chip); border-radius: 3px; overflow: hidden; margin-bottom: 6px; }
.meter .track i { display: block; height: 100%; background: var(--accent); }
.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; display: flex; background: var(--tabs);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); }
.tabs button { flex: 1; border: 0; background: none; min-height: 56px; font-size: 11px; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer; }
.tabs .ico { font-size: 20px; line-height: 1; }
.tabs button[aria-current="page"] { color: var(--accent); }
.triage { margin-top: 10px; border-top: 1px dashed var(--line); padding-top: 10px; }
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 20; display: flex; align-items: flex-end;
  justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 560px; border-radius: 18px 18px 0 0; padding: 18px 16px
  calc(18px + env(safe-area-inset-bottom)); max-height: 88vh; overflow: auto; }
@media (min-width: 620px) { .sheet-bg { align-items: center; } .sheet { border-radius: 18px; } }
.preview { border: 1px solid var(--line); border-radius: 14px; padding: 10px 12px; background: var(--bg); margin: 10px 0; }
.preview b { display: block; }
#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(80px + env(safe-area-inset-bottom));
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 30;
  opacity: 0; transition: opacity .2s; pointer-events: none; max-width: 90vw; }
#toast.on { opacity: 1; }
.login { max-width: 380px; margin: 12vh auto 0; text-align: center; }
.login .btn { margin-top: 18px; }
a { color: var(--accent); }
