:root {
  --bg: #f3f6f8;
  --card: #ffffff;
  --text: #13232b;
  --muted: #5d6f78;
  --line: #dde5ea;
  --accent: #0b5c7a;
  --accent-soft: #e2f0f5;
  --ok: #1d7a46;
  --warn: #a35a00;
  --bad: #b3261e;
  --bad-soft: #fbe9e7;
  --warn-soft: #fff3e0;
  --depth: #0b6e99;
  --temp: #c25b12;
  --radius: 14px;
  --tabs-h: 58px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d1b22; --card: #15262e; --text: #e6eef2; --muted: #93a7b1; --line: #243a44;
    --accent: #5cc0e6; --accent-soft: #163845; --ok: #5fcf8d; --warn: #f0a94a; --bad: #ff8a80;
    --bad-soft: #3a1c1a; --warn-soft: #3a2a12; --depth: #5cc0e6; --temp: #f0a050; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d1b22; --card: #15262e; --text: #e6eef2; --muted: #93a7b1; --line: #243a44;
  --accent: #5cc0e6; --accent-soft: #163845; --ok: #5fcf8d; --warn: #f0a94a; --bad: #ff8a80;
  --bad-soft: #3a1c1a; --warn-soft: #3a2a12; --depth: #5cc0e6; --temp: #f0a050; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 16px);
}
a { color: var(--accent); }
.top {
  position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line);
  padding: calc(env(safe-area-inset-top) + 10px) 16px 10px;
}
.brand { display: inline-flex; gap: 8px; align-items: center; font-weight: 650; color: var(--text); text-decoration: none; font-size: 17px; }
main { max-width: 760px; margin: 0 auto; padding: 16px; }
h1 { font-size: 24px; margin: 4px 0 12px; }
h2 { font-size: 17px; margin: 22px 0 8px; }
h3 { font-size: 15px; margin: 0 0 6px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 12px; }
.list { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 12px; }
.row { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); color: inherit; text-decoration: none; min-height: 56px; }
.row:first-child { border-top: 0; }
a.row:active { background: var(--accent-soft); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .sub { color: var(--muted); font-size: 14px; }
.row .num { text-align: right; font-variant-numeric: tabular-nums; }
.row .num b { font-size: 18px; }
.chev { color: var(--muted); }
.day { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 18px 4px 6px; }

.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); vertical-align: middle; }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.stat .v { font-size: 22px; font-weight: 650; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 14px; font-weight: 500; color: var(--muted); }
.stat.big { grid-column: span 3; display: flex; justify-content: space-between; align-items: baseline; }
.stat.big .v { font-size: 34px; }

.banner { border-radius: 12px; padding: 10px 14px; margin-bottom: 12px; font-size: 15px; }
.banner.bad { background: var(--bad-soft); color: var(--bad); }
.banner.warn { background: var(--warn-soft); color: var(--warn); }
.banner.info { background: var(--accent-soft); color: var(--text); }

.chart { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 4px 4px; margin-bottom: 12px; position: relative; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid line { stroke: var(--line); stroke-width: 1; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .depth { fill: none; stroke: var(--depth); stroke-width: 2; }
.chart .depth-fill { fill: color-mix(in srgb, var(--depth) 14%, transparent); stroke: none; }
.chart .temp { fill: none; stroke: var(--temp); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .mark line { stroke: var(--muted); stroke-dasharray: 2 3; }
.chart .mark text { fill: var(--muted); font-size: 11px; font-weight: 600; }
.chart .cursor line { stroke: var(--text); stroke-width: 1; }
.chart .readout { position: absolute; top: 10px; right: 12px; font-size: 13px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; font-variant-numeric: tabular-nums; pointer-events: none; }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--muted); padding: 0 12px 6px; }
.legend i { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--depth); vertical-align: middle; margin-right: 4px; }
.legend i.t { border-top: 2px dashed var(--temp); }

dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; font-variant-numeric: tabular-nums; }

form { margin: 0; }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 16px; margin: 12px 0; }
.check input { width: 22px; height: 22px; min-height: 0; }
button, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 600; font-size: 16px; min-height: 44px; padding: 10px 16px;
  border-radius: 10px; border: 1px solid transparent; background: var(--accent); color: #fff; cursor: pointer; text-decoration: none;
}
:root[data-theme="dark"] button:not(.ghost):not(.danger), :root[data-theme="dark"] .btn:not(.ghost) { color: #062430; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) button:not(.ghost):not(.danger), :root:not([data-theme="light"]) .btn:not(.ghost) { color: #062430; } }
button.ghost, .btn.ghost { background: transparent; color: var(--accent); border-color: var(--line); }
button.danger { background: transparent; color: var(--bad); border-color: var(--line); }
button:disabled { opacity: .5; }
button.small, .btn.small { min-height: 36px; padding: 6px 12px; font-size: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.full { width: 100%; }
.err { color: var(--bad); font-size: 14px; margin-top: 8px; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; word-break: break-all; }
.secret { background: var(--bg); border: 1px dashed var(--line); border-radius: 10px; padding: 10px 12px; margin: 6px 0; }

.sup { display: grid; grid-template-columns: 1fr auto; padding-bottom: 8px; border-bottom: 1px solid var(--line); gap: 8px; align-items: center; margin-bottom: 8px; }
.sup input { min-width: 0; }
.sup input[name=name] { grid-column: 1 / -1; }
@media (min-width: 560px) { .sup { grid-template-columns: 1fr 1fr auto; border: 0; padding: 0; } .sup input[name=name] { grid-column: auto; } }
.sup .duty { margin: 0; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--muted); }
.sup .duty input { width: 22px; height: 22px; min-height: 0; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: flex; background: var(--card);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; height: var(--tabs-h); font-size: 12px; color: var(--muted); text-decoration: none; }
.tabs a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs a.on { color: var(--accent); }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom) + 12px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 15px; z-index: 10; max-width: calc(100% - 32px); }
.empty { text-align: center; padding: 32px 16px; color: var(--muted); }
.center { max-width: 380px; margin: 8vh auto 0; }

@media (min-width: 700px) {
  .stats { grid-template-columns: repeat(6, 1fr); }
  .stat.big { grid-column: span 2; display: block; }
}
