:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede6;
  --text: #1f2421;
  --muted: #646b66;
  --border: #dcd8ce;
  --accent: #2f5d50;
  --accent-text: #ffffff;
  --accent-soft: #e2ece8;
  --ok: #2e7d4f;
  --warn: #a35a00;
  --warn-soft: #fbeedd;
  --danger: #b3261e;
  --danger-soft: #fbe5e3;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141816;
    --surface: #1d2220;
    --surface-2: #252b28;
    --text: #e8ebe9;
    --muted: #9aa39e;
    --border: #333b37;
    --accent: #7fc3ad;
    --accent-text: #0e1a16;
    --accent-soft: #23342e;
    --ok: #79c995;
    --warn: #f0b36a;
    --warn-soft: #3a2c1a;
    --danger: #f2877f;
    --danger-soft: #3d2220;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); line-height: 1.45; font-size: 16px; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
.loading { text-align: center; color: var(--muted); padding: 3rem 1rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 1rem; }

/* ---------- auth screens ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 2rem 1.5rem; box-shadow: var(--shadow); }
.auth-card .brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.25rem; }
.auth-card .brand img { width: 36px; height: 36px; }
.auth-card .brand span { font-weight: 650; font-size: 1.1rem; }
.auth-card p { margin: 0 0 1rem; }
.qr { display: block; margin: .5rem auto 1rem; width: 200px; height: 200px; background: #fff; padding: 6px; border-radius: 8px; }
.secret { font-family: ui-monospace, Consolas, monospace; background: var(--surface-2); padding: .5rem .6rem; border-radius: 8px; word-break: break-all; font-size: .9rem; user-select: all; }

/* ---------- forms ---------- */
label { display: block; font-weight: 550; font-size: .9rem; margin-bottom: .3rem; }
.field { margin-bottom: 1rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: .25rem; }
input[type=text], input[type=password], input[type=number], input[type=time], select, textarea {
  width: 100%; padding: .65rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-height: 44px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input.code { letter-spacing: .35em; font-size: 1.4rem; text-align: center; font-family: ui-monospace, Consolas, monospace; }
.error { background: var(--danger-soft); color: var(--danger); padding: .6rem .75rem; border-radius: 10px; font-size: .9rem; margin-bottom: 1rem; }
.notice { background: var(--warn-soft); color: var(--warn); padding: .6rem .75rem; border-radius: 10px; font-size: .9rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; }
@media (max-width: 520px) { .grid3 { grid-template-columns: 1fr; } }
.days { display: flex; flex-wrap: wrap; gap: .4rem; }
.days label { display: inline-flex; align-items: center; gap: .3rem; font-weight: 500; border: 1px solid var(--border); border-radius: 999px; padding: .35rem .7rem; margin: 0; cursor: pointer; background: var(--surface); min-height: 36px; }
.days input { margin: 0; }
.days label.on { background: var(--accent-soft); border-color: var(--accent); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .35rem; min-height: 44px; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 550; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: .3rem .65rem; font-size: .85rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: default; }
.linkbtn { background: none; border: 0; color: var(--accent); cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- shell ---------- */
header.top { position: sticky; top: 0; z-index: 5; background: var(--surface); border-bottom: 1px solid var(--border); }
header.top .inner { max-width: 860px; margin: 0 auto; padding: .6rem 16px; display: flex; align-items: center; gap: .75rem; }
header.top .brand { display: flex; align-items: center; gap: .5rem; font-weight: 650; text-decoration: none; color: var(--text); }
header.top .brand img { width: 28px; height: 28px; }
header.top .who { color: var(--muted); font-size: .85rem; }
nav.tabs { max-width: 860px; margin: 0 auto; padding: 0 16px; display: flex; gap: .25rem; overflow-x: auto; scrollbar-width: none; }
nav.tabs a { padding: .55rem .8rem; text-decoration: none; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; font-weight: 550; font-size: .95rem; }
nav.tabs a.on { color: var(--accent); border-color: var(--accent); }
main { max-width: 860px; margin: 0 auto; padding: 1.25rem 16px 4rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.section-title { margin: 1.75rem 0 .6rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; }
.section-title:first-child { margin-top: 0; }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; border: 1px dashed var(--border); border-radius: var(--radius); }

/* ---------- checklist runs ---------- */
.run-head { display: flex; align-items: flex-start; gap: .75rem; }
.run-head h2 { margin: 0; }
.run-meta { color: var(--muted); font-size: .875rem; margin-top: .15rem; }
.badge { display: inline-block; font-size: .75rem; font-weight: 650; padding: .15rem .55rem; border-radius: 999px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.badge.overdue, .badge.incomplete { background: var(--danger-soft); color: var(--danger); }
.badge.complete { background: var(--accent-soft); color: var(--ok); }
.badge.complete-late { background: var(--warn-soft); color: var(--warn); }
.progress { height: 8px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: .75rem 0 .5rem; }
.progress > div { height: 100%; background: var(--accent); width: 0; transition: width .25s; }
.progress.overdue > div { background: var(--danger); }
ul.items { list-style: none; margin: 0; padding: 0; }
ul.items li { border-top: 1px solid var(--border); }
ul.items li:first-child { border-top: 0; }
.item { display: flex; align-items: flex-start; gap: .75rem; padding: .7rem .1rem; cursor: pointer; font-weight: 450; margin: 0; font-size: 1rem; }
.item input { width: 22px; height: 22px; margin: .1rem 0 0; flex: none; accent-color: var(--accent); cursor: pointer; }
.item .text { flex: 1; }
.item.done .text { color: var(--muted); text-decoration: line-through; }
.item .by { display: block; font-size: .78rem; color: var(--muted); text-decoration: none; }
.item .by.late { color: var(--warn); }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .6rem .4rem; border-top: 1px solid var(--border); vertical-align: top; font-size: .92rem; }
table.list th { border-top: 0; color: var(--muted); font-weight: 600; font-size: .8rem; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: var(--surface-2); }
@media (max-width: 560px) { .hide-sm { display: none; } }

.tpl { display: flex; gap: .75rem; align-items: center; }
.tpl .info { flex: 1; min-width: 0; }
.tpl .info strong { display: block; }
.tpl .actions { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 560px) { .tpl { flex-direction: column; align-items: stretch; } .tpl .actions { justify-content: flex-start; } }

.item-rows .irow { display: flex; gap: .35rem; align-items: center; margin-bottom: .4rem; }
.item-rows .irow input { flex: 1; }
.iconbtn { min-width: 40px; min-height: 40px; border: 1px solid var(--border); background: var(--surface); border-radius: 8px; cursor: pointer; }
.iconbtn:hover { background: var(--surface-2); }
.iconbtn:disabled { opacity: .35; cursor: default; }

.temp-pw { font-family: ui-monospace, Consolas, monospace; font-size: 1.05rem; background: var(--surface-2); padding: .6rem; border-radius: 8px; user-select: all; word-break: break-all; }

#toast { position: fixed; left: 50%; bottom: 1.25rem; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: .65rem 1rem; border-radius: 10px; font-size: .9rem; max-width: calc(100vw - 32px); z-index: 20; box-shadow: 0 4px 16px rgba(0,0,0,.2); }
#toast.err { background: var(--danger); color: #fff; }
