:root {
  --bg: #f6f4f0;
  --card: #ffffff;
  --ink: #23201c;
  --muted: #6b645b;
  --line: #ddd7cd;
  --accent: #c2500c;
  --accent-ink: #ffffff;
  --accent-soft: #fbeadd;
  --ok: #1d6b3a;
  --ok-soft: #e2f2e7;
  --warn: #8a5a00;
  --warn-soft: #fbf0d3;
  --bad: #a3231c;
  --bad-soft: #fae3e1;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h1, h2, h3, p { margin: 0; }
h2 { font-size: 1.05rem; margin-bottom: 10px; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px 16px; text-align: center; color: var(--muted); }

.top { position: sticky; top: 0; z-index: 5; background: var(--accent); color: var(--accent-ink); padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; max-width: 760px; margin: 0 auto; }
.brand { font-weight: 700; font-size: 1.05rem; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.badge.on { background: var(--ok-soft); color: var(--ok); }
.badge.off { background: var(--warn-soft); color: var(--warn); }
.link { background: none; border: 0; color: inherit; text-decoration: underline; padding: 6px 4px; cursor: pointer; font-size: .85rem; }
.site-filter { margin-top: 8px; }
.top select { width: 100%; max-width: 760px; display: block; margin: 0 auto; background: #fff; color: var(--ink); border: 0; border-radius: 8px; padding: 8px 10px; }

main { max-width: 760px; margin: 0 auto; padding: 14px 16px calc(84px + env(safe-area-inset-bottom)); display: grid; gap: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px; min-width: 0; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; }
.stat b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: .82rem; }
.muted { color: var(--muted); font-size: .88rem; }
.num { font-variant-numeric: tabular-nums; white-space: nowrap; }

.alert { border-radius: 10px; padding: 10px 12px; font-size: .92rem; }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert.secret { background: var(--accent-soft); color: var(--ink); overflow-wrap: anywhere; }
.alert.secret code { font-size: 1.1rem; font-weight: 700; }

.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: 10px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.list > li:first-child { border-top: 0; padding-top: 0; }
.list > li:last-child { padding-bottom: 0; }
.list .main { min-width: 0; overflow-wrap: anywhere; }
.list .side { text-align: right; flex-shrink: 0; }
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

form { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: .88rem; font-weight: 600; }
label small { font-weight: 400; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 46px; padding: 10px 12px; border: 1px solid #a89f92; border-radius: 8px; background: #fff; font-size: 16px; font-weight: 400; }
input[type=checkbox] { width: 22px; min-height: 22px; height: 22px; accent-color: var(--accent); flex-shrink: 0; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid #e8914f; outline-offset: 1px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 10px; font-weight: 600; min-height: 44px; }
.choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border: 0; padding: 0; margin: 0; }
.choice legend { font-size: .88rem; font-weight: 600; padding: 0; margin-bottom: 4px; }
.choice label { display: flex; align-items: center; justify-content: center; min-height: 46px; border: 1px solid #a89f92; border-radius: 8px; background: #fff; cursor: pointer; }
.choice input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.choice input:checked + span { font-weight: 700; }
.choice label:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); }
.choice label:has(input:focus-visible) { outline: 3px solid #e8914f; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.two > * { min-width: 0; }
details summary { cursor: pointer; font-weight: 600; font-size: .92rem; min-height: 32px; }
details[open] summary { margin-bottom: 10px; }

.btn { min-height: 46px; padding: 10px 16px; border: 0; border-radius: 8px; background: var(--accent); color: var(--accent-ink); font-weight: 700; cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: .88rem; font-weight: 600; }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid #a89f92; }
.btn.danger { background: #fff; color: var(--bad); border: 1px solid var(--bad); }
.btn:disabled { opacity: .6; cursor: default; }

.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .88rem; }
th, td { padding: 7px 8px; text-align: left; border-top: 1px solid var(--line); white-space: nowrap; }
thead th { border-top: 0; color: var(--muted); font-weight: 600; }
td.r, th.r { text-align: right; font-variant-numeric: tabular-nums; }

.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: #fff; border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav button { background: none; border: 0; min-height: 58px; padding: 6px 2px; cursor: pointer; color: var(--muted); font-size: .76rem; font-weight: 600; border-top: 3px solid transparent; }
.nav button[aria-current=page] { color: var(--accent); border-top-color: var(--accent); }
.login { max-width: 400px; margin: 0 auto; padding: 48px 16px; display: grid; gap: 16px; }
.login h1 { color: var(--accent); font-size: 1.5rem; }

#toast { position: fixed; left: 16px; right: 16px; bottom: calc(70px + env(safe-area-inset-bottom)); z-index: 10; display: none; max-width: 560px; margin: 0 auto; padding: 12px 14px; border-radius: 10px; background: #2b2723; color: #fff; font-size: .92rem; box-shadow: 0 4px 16px rgb(0 0 0 / .25); }
#toast.show { display: block; }
#toast.bad { background: var(--bad); }
