:root {
  --bg: #f6f7f9; --card: #fff; --text: #111827; --muted: #6b7280; --line: #e5e7eb;
  --accent: #16a34a; --accent-ink: #fff; --warn: #dc2626; --soft: #f3f4f6;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #181b21; --text: #e5e7eb; --muted: #9ca3af; --line: #2a2e36; --soft: #22262e; --warn: #f87171; }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom); }
.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
h1 { font-size: 22px; margin: 4px 0 12px; }
h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 20px 0 8px; }
button, .btn { font: inherit; border: 0; border-radius: 10px; padding: 10px 14px; cursor: pointer;
  background: var(--soft); color: var(--text); }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
button.danger { background: transparent; color: var(--warn); }
button.link { background: none; padding: 4px 6px; color: var(--muted); text-decoration: underline; }
button:disabled { opacity: .5; }
input, select, textarea { font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); }
label { display: block; font-size: 14px; color: var(--muted); margin: 10px 0 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--muted); font-size: 14px; }
.title { font-weight: 600; overflow-wrap: anywhere; }
.overdue .due { color: var(--warn); font-weight: 600; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }
.pill { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--soft); font-size: 12px; color: var(--muted); }
.tabs { display: flex; gap: 6px; background: var(--soft); padding: 4px; border-radius: 12px; margin-bottom: 8px; }
.tabs button { flex: 1; background: none; padding: 8px; }
.tabs button.on { background: var(--card); font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.banner { background: #fef3c7; color: #78350f; border-radius: 12px; padding: 12px 14px; margin-bottom: 12px; font-size: 14px; }
@media (prefers-color-scheme: dark) { .banner { background: #3a2f12; color: #fde68a; } }
.people { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.people button { padding: 22px 10px; font-size: 18px; font-weight: 600; background: var(--card); border: 2px solid var(--line); }
.people button.on { border-color: var(--accent); }
.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.keypad button { padding: 16px; font-size: 22px; background: var(--card); border: 1px solid var(--line); }
.pinbox { text-align: center; font-size: 28px; letter-spacing: .4em; min-height: 40px; margin-top: 12px; }
.err { color: var(--warn); font-size: 14px; min-height: 20px; margin-top: 6px; }
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; display: none; z-index: 10; max-width: calc(100% - 32px); }
.empty { text-align: center; color: var(--muted); padding: 24px 0; }
.check { width: 44px; height: 44px; border-radius: 50%; padding: 0; font-size: 20px; flex: none;
  background: var(--soft); border: 2px solid var(--line); }
.check:hover { border-color: var(--accent); }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); font-size: 14px; vertical-align: top; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
dialog { border: 0; border-radius: 16px; padding: 0; width: min(520px, calc(100% - 24px)); background: var(--card); color: var(--text); }
dialog::backdrop { background: rgba(0,0,0,.4); }
dialog form { padding: 16px; }
.inline { display: flex; align-items: center; gap: 8px; color: var(--text); font-size: 15px; margin-top: 12px; }
.inline input { width: auto; }
button.link.on { color: var(--accent); text-decoration: none; font-weight: 600; }
