:root {
  --bg: #f4f6f8; --card: #fff; --text: #1b2430; --muted: #66727f; --line: #dde3e9;
  --accent: #1f5f8b; --accent-soft: #e3eef6; --ok: #2e7d4f; --warn: #b26a00; --danger: #b3261e;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b; --card: #1c222a; --text: #e6ebf0; --muted: #94a0ad; --line: #2c3540;
    --accent: #6aaee0; --accent-soft: #1f3243; --ok: #6cc596; --warn: #e0a64a; --danger: #ef7d74;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }

.topbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 8px;
  padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
  background: var(--accent); color: #fff; }
.topbar h1 { font-size: 18px; margin: 0; flex: 1; }
.topbar .brand { font-weight: 700; font-size: 13px; letter-spacing: .04em; text-transform: uppercase;
  padding-right: 10px; margin-right: 2px; border-right: 1px solid rgba(255,255,255,.35); white-space: nowrap; }
@media (prefers-color-scheme: dark) { .topbar { background: #173a54; } }

main { max-width: 760px; margin: 0 auto; padding: 12px 16px; }

.tabs { position: fixed; bottom: 0; left: 0; right: 0; z-index: 5; display: flex;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
body.locked .tabs, body.locked #syncPill { display: none; }
.tabs button { flex: 1; border: 0; background: none; color: var(--muted); padding: 6px 2px 8px;
  font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; cursor: pointer; }
.tabs .ico { font-size: 20px; line-height: 1; }
.tabs button.active { color: var(--accent); font-weight: 600; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px; }
.card h2 { font-size: 15px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row > .grow { flex: 1; min-width: 0; }
.right { margin-left: auto; }
.hidden { display: none !important; }

label { display: block; font-size: 13px; color: var(--muted); margin: 8px 0 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: var(--bg);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; }
textarea { min-height: 60px; resize: vertical; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
.check { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; margin: 10px 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0 10px; }

button.btn { font: inherit; border: 1px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 8px; padding: 9px 14px; cursor: pointer; }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
@media (prefers-color-scheme: dark) { button.btn.primary { color: #0d1a24; } }
button.btn.danger { color: var(--danger); }
button.btn.big { width: 100%; padding: 14px; font-size: 17px; }
button.btn:disabled { opacity: .5; }
button.btn.chip { padding: 6px 10px; font-size: 13px; border-radius: 99px; }
button.btn.chip.active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.timer .check { margin: 8px 0; }
code { font-size: 12px; word-break: break-all; }
button.link { border: 0; background: none; color: var(--accent); font: inherit; padding: 0; cursor: pointer; }

.timer { text-align: center; }
.timer .clock { font-size: 44px; font-variant-numeric: tabular-nums; font-weight: 600; margin: 6px 0; }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; }
.list li.tap { cursor: pointer; }
.day { font-weight: 600; margin: 14px 0 4px; font-size: 13px; color: var(--muted); text-transform: capitalize; }
.dur { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }

.pill { display: inline-block; font-size: 11px; padding: 2px 7px; border-radius: 99px;
  background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.pill.ok { background: color-mix(in srgb, var(--ok) 15%, transparent); color: var(--ok); }
.pill.warn { background: color-mix(in srgb, var(--warn) 15%, transparent); color: var(--warn); }
.topbar .pill { background: rgba(255,255,255,.2); color: #fff; }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; }
.kpi .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi .l { font-size: 12px; color: var(--muted); }
.kpi.tap, .tap { cursor: pointer; }

.bar { height: 8px; background: var(--accent-soft); border-radius: 4px; overflow: hidden; margin-top: 4px; }
.bar > i { display: block; height: 100%; background: var(--accent); }

table.tot { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
table.tot td { padding: 5px 0; border-top: 1px solid var(--line); }
table.tot td:last-child { text-align: right; }
table.tot tr.sum td { font-weight: 700; }

dialog { border: 0; border-radius: var(--radius); padding: 0; width: min(520px, calc(100vw - 24px));
  background: var(--card); color: var(--text); max-height: 90vh; }
dialog::backdrop { background: rgba(0,0,0,.45); }
dialog form { padding: 16px; }
dialog h2 { margin: 0 0 6px; font-size: 17px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; flex-wrap: wrap; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(76px + env(safe-area-inset-bottom));
  background: #222; color: #fff; padding: 10px 16px; border-radius: 8px; z-index: 20; max-width: 90vw; }
.empty { text-align: center; color: var(--muted); padding: 24px 8px; }
pre.recap { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-size: 13px; margin: 8px 0 0; }
