:root {
  --bg: #f4f5f4; --card: #ffffff; --text: #1b1f1d; --muted: #66706b; --line: #e3e6e4;
  --accent: #0f766e; --accent-soft: #e0f2ef; --high: #c2410c; --high-soft: #fdebe1; --medium: #a16207;
  --medium-soft: #fdf4d8; --info: #2563eb; --ok: #15803d; --off: #8a918d;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111413; --card: #1a1e1c; --text: #e7ebe9; --muted: #98a29d; --line: #2a302d;
    --accent: #2dd4bf; --accent-soft: #11332f; --high: #fb923c; --high-soft: #3a2014; --medium: #facc15;
    --medium-soft: #332b10; --info: #60a5fa; --ok: #4ade80; --off: #6b736f;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; padding-bottom: env(safe-area-inset-bottom); }
h1 { font-size: 18px; margin: 0; }
h2 { font-size: 15px; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
button { font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; background: var(--accent); color: #fff; cursor: pointer; }
button.secondary { background: var(--accent-soft); color: var(--accent); width: 100%; margin-top: 10px; }
button.link { background: none; color: var(--muted); padding: 4px 0; }
.muted { color: var(--muted); }
.error { color: var(--high); }
.empty { margin: 4px 0; }

.bar { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top)); background: var(--card); border-bottom: 1px solid var(--line); }
.bar #logout { margin-left: auto; }
.live { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); }
.live::before { content: "●"; margin-right: 4px; }
.live.off { background: var(--line); color: var(--muted); }
.banner { margin: 10px 16px 0; padding: 10px 12px; border-radius: 10px; background: var(--medium-soft); color: var(--text); font-size: 14px; }

main { max-width: 720px; margin: 0 auto; padding: 12px 16px 24px; display: grid; gap: 12px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.login { display: grid; gap: 12px; margin-top: 24px; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { font: inherit; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); }

.box-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.box-state { font-size: 13px; }
.box-state.ok { color: var(--ok); }
.box-state.bad { color: var(--high); }
.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.chip { background: var(--bg); border-radius: 10px; padding: 8px 10px; min-width: 0; }
.chip span { display: block; font-size: 12px; color: var(--muted); }
.chip b { font-weight: 600; overflow-wrap: anywhere; }
.chip.warn b { color: var(--medium); }
.chip.bad b { color: var(--high); }
.chip a { color: var(--accent); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stats div { background: var(--bg); border-radius: 10px; padding: 10px; }
.stats b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.stats span { font-size: 12px; color: var(--muted); }

.count { font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 99px; background: var(--high-soft); color: var(--high); }
.count:empty { display: none; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; }
.row > button { all: unset; box-sizing: border-box; display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center;
  width: 100%; padding: 10px 2px; cursor: pointer; }
.row > button:focus-visible { outline: 2px solid var(--accent); border-radius: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--off); }
.dot.high { background: var(--high); } .dot.medium { background: var(--medium); } .dot.info { background: var(--info); }
.title { min-width: 0; }
.title small { display: block; color: var(--muted); font-size: 12px; }
.when { color: var(--muted); font-size: 12px; text-align: right; white-space: nowrap; }
.detail { padding: 0 2px 12px 19px; font-size: 13px; }
.detail dl { display: grid; grid-template-columns: max-content 1fr; gap: 3px 12px; margin: 0 0 10px; }
.detail dt { color: var(--muted); }
.detail dd { margin: 0; overflow-wrap: anywhere; }
.detail code { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }

.day { margin-top: 12px; }
.day:first-child { margin-top: 0; }
.day-head { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); padding: 6px 2px; border-bottom: 1px solid var(--line); }
.day-head b { color: var(--text); }
.fill > button { grid-template-columns: 52px 1fr auto; }
.fill .time { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.fill .litres { font-weight: 600; font-variant-numeric: tabular-nums; }
.fill .kind { font-size: 12px; color: var(--muted); }
.fill .amt { font-variant-numeric: tabular-nums; text-align: right; font-size: 13px; }
.fill.new { animation: flash 2.5s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
