:root {
  --bg: #f7f4ee;
  --card: #ffffff;
  --ink: #1d2a33;
  --muted: #5d6b74;
  --line: #ddd6ca;
  --brand: #1f3b57;
  --yes: #2e7d4f;
  --yes-ink: #ffffff;
  --change: #1f3b57;
  --warn: #a8432f;
  --soft: #eef3ee;
  --amber: #f3e3b3;
  --focus: #d08a1f;
  --p-confirmed: #d7eedd; --p-confirmed-ink: #1f5c36;
  --p-updated: #dbe7f5;   --p-updated-ink: #1f3b57;
  --p-moved: #f6dcd6;     --p-moved-ink: #8a3423;
  --p-waiting: #ece8e0;   --p-waiting-ink: #5d6b74;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #151b20; --card: #1e262d; --ink: #ecf0f2; --muted: #a3b0b8; --line: #34404a;
    --brand: #9cc1e6; --yes: #3f9b65; --change: #3a6a98; --warn: #c45a44; --soft: #1f2f26; --amber: #4a3d18;
    --p-confirmed: #1f3a29; --p-confirmed-ink: #9fdcb3;
    --p-updated: #1f3046;   --p-updated-ink: #a9c9ec;
    --p-moved: #43251f;     --p-moved-ink: #f0b0a2;
    --p-waiting: #2a3138;   --p-waiting-ink: #a3b0b8;
  }
}
:root[data-theme="dark"] {
  --bg: #151b20; --card: #1e262d; --ink: #ecf0f2; --muted: #a3b0b8; --line: #34404a;
  --brand: #9cc1e6; --yes: #3f9b65; --change: #3a6a98; --warn: #c45a44; --soft: #1f2f26; --amber: #4a3d18;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 20px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
body.admin { font-size: 17px; }
.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
body.admin .wrap { max-width: 1040px; }
a { color: var(--brand); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.top { background: var(--card); border-bottom: 1px solid var(--line); margin-bottom: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; min-height: 64px; }
.brand { font-weight: 700; text-decoration: none; color: var(--ink); display: flex; align-items: center; gap: 10px; letter-spacing: .01em; }
.mark { width: 14px; height: 14px; border-radius: 50%; background: var(--yes); box-shadow: 10px 0 0 var(--brand); margin-right: 10px; }
.nav { display: flex; gap: 4px 16px; flex-wrap: wrap; align-items: center; font-size: 15px; padding: 8px 0; }
.nav a { text-decoration: none; color: var(--muted); padding: 4px 0; border-bottom: 2px solid transparent; }
.nav a.on, .nav a:hover { color: var(--ink); border-color: var(--yes); }

h1 { font-size: 1.7em; line-height: 1.2; margin: 0 0 12px; }
body.admin h1 { font-size: 1.6em; }
h2 { font-size: 1.1em; margin: 0 0 10px; }
.lead { font-size: 1.05em; color: var(--muted); margin: 0 0 24px; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .7em; color: var(--muted); margin: 0 0 4px; font-weight: 600; }
.small { font-size: .85em; }
.muted { color: var(--muted); }
.center { text-align: center; }
.foot { color: var(--muted); font-size: 14px; margin-top: 48px; padding-bottom: 32px; }
.flash { background: var(--amber); padding: 12px 16px; border-radius: 10px; margin-bottom: 20px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
  padding: 8px 16px; border-radius: 10px; font: inherit; font-size: 15px; font-weight: 600;
  text-decoration: none; cursor: pointer; min-height: 40px;
}
.btn.big { display: flex; width: 100%; font-size: 21px; min-height: 64px; border-radius: 14px; margin: 0 0 14px; }
.btn.yes { background: var(--yes); border-color: var(--yes); color: var(--yes-ink); }
.btn.change { background: var(--change); border-color: var(--change); color: #fff; }
.btn.warn { background: var(--warn); border-color: var(--warn); color: #fff; }
.btn.plain { background: transparent; }
.btn:hover { filter: brightness(1.05); }
.linkbtn { background: none; border: 0; color: var(--brand); font: inherit; font-size: 15px; cursor: pointer; text-decoration: underline; padding: 0; }
.linkbtn.red { color: var(--warn); }
.inline { display: inline; }
.actions { margin-top: 8px; }
body.admin .actions { display: flex; gap: 12px; flex-wrap: wrap; }
body.admin .actions .btn.big { width: auto; padding: 0 28px; }

/* Neighbor household view */
.people { display: grid; gap: 12px; margin-bottom: 24px; }
.person { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; }
.person.empty { color: var(--muted); }
.pname { font-weight: 700; font-size: 1.1em; margin-bottom: 4px; }
.pline { display: flex; gap: 12px; overflow-wrap: anywhere; }
.lbl { color: var(--muted); font-size: .8em; min-width: 54px; padding-top: .15em; text-transform: uppercase; letter-spacing: .05em; }
.note { padding: 12px 16px; border-radius: 10px; margin: 0 0 18px; }
.note.ok { background: var(--soft); }
.warnbox { background: var(--amber); }

.choices { display: grid; gap: 14px; }
.choice { display: block; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px; text-decoration: none; color: var(--ink); }
.choice strong { display: block; font-size: 1.1em; }
.choice span { color: var(--muted); }
.choice:hover { border-color: var(--yes); }

.done { text-align: center; padding: 24px 0; }
.tick { width: 84px; height: 84px; border-radius: 50%; background: var(--yes); color: #fff; font-size: 44px; line-height: 84px; margin: 0 auto 18px; }

/* Forms */
.form label { display: block; margin-bottom: 14px; font-weight: 600; }
.form input, .form textarea, .form select, .search input, .linkrow input {
  display: block; width: 100%; margin-top: 6px; font: inherit; font-weight: 400;
  padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--ink);
}
body.neighbor .form input { min-height: 54px; }
.form .check { display: flex; gap: 10px; align-items: center; font-weight: 400; font-size: .9em; color: var(--muted); }
.form .check input { width: 22px; height: 22px; margin: 0; display: inline; }
.opt { font-weight: 400; color: var(--muted); font-size: .85em; }
fieldset.pf { border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px 4px; margin: 0 0 16px; background: var(--card); }
fieldset.pf.add { border-style: dashed; background: transparent; }
fieldset.pf legend { font-weight: 700; padding: 0 6px; }
body.admin fieldset.pf { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 14px; }
body.admin fieldset.pf .check { grid-column: 1 / -1; }
.narrow { max-width: 420px; }

/* Admin */
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; margin-bottom: 20px; }
.headrow { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.headrow h1 { margin: 0; }
.headbtns { display: flex; gap: 8px; flex-wrap: wrap; }
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; text-decoration: none; color: var(--ink); border-top: 4px solid var(--line); }
.stat b { display: block; font-size: 1.7em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted); font-size: 14px; }
.stat.on { outline: 2px solid var(--brand); }
.s-confirmed { border-top-color: var(--yes); }
.s-updated { border-top-color: var(--change); }
.s-moved { border-top-color: var(--warn); }
.progress { height: 10px; background: var(--p-waiting); border-radius: 6px; overflow: hidden; }
.progress span { display: block; height: 100%; background: var(--yes); }
.search { display: flex; gap: 8px; margin: 18px 0 12px; }
.search input { margin: 0; }
.tablewrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th { text-align: left; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--line); }
table.list td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tbody tr { cursor: pointer; }
table.list tbody tr:hover { background: var(--bg); }
table.list td:first-child { white-space: nowrap; font-weight: 600; }
.pill { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.p-confirmed { background: var(--p-confirmed); color: var(--p-confirmed-ink); }
.p-updated { background: var(--p-updated); color: var(--p-updated-ink); }
.p-moved { background: var(--p-moved); color: var(--p-moved-ink); }
.p-waiting { background: var(--p-waiting); color: var(--p-waiting-ink); }
.joinrow { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.codebox { font-size: 32px !important; letter-spacing: .3em; text-align: center; font-variant-numeric: tabular-nums; }
.demo { background: var(--amber); border-radius: 12px; padding: 12px 16px; margin-bottom: 20px; font-size: 15px; }
.demomail { background: var(--card); border-radius: 8px; padding: 10px 12px; margin-top: 10px; }
.demomail pre { white-space: pre-wrap; font: 14px/1.45 ui-monospace, Consolas, monospace; margin: 8px 0 0; }
.choice { margin-top: 14px; }
.joininfo .pill { margin-left: 8px; }
.joinbtns { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.occupied { background: var(--amber); border-radius: 8px; padding: 8px 12px; margin-top: 8px; font-size: 14px; max-width: 560px; }
.change.undone { opacity: .6; }
.undo { margin-left: auto; }
.linkrow { display: flex; gap: 8px; margin-bottom: 8px; }
.linkrow input { margin: 0; font-size: 14px; }
.change { padding: 10px 0; border-top: 1px solid var(--line); font-size: 15px; }
.change:first-of-type { border-top: 0; }
.chead { display: flex; gap: 10px; flex-wrap: wrap; align-items: baseline; }
.diff { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; font-size: 14px; }
.diff > div { background: var(--bg); border-radius: 8px; padding: 8px 10px; overflow-wrap: anywhere; }
.diff .lbl { display: block; }
pre.mail { white-space: pre-wrap; background: var(--bg); padding: 14px; border-radius: 10px; font: 15px/1.5 ui-monospace, Consolas, monospace; }
.danger { margin: 28px 0; }

@media (max-width: 720px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats .stat:first-child { grid-column: 1 / -1; }
  body.admin fieldset.pf { grid-template-columns: 1fr; }
  .diff { grid-template-columns: 1fr; }
  table.list td:first-child { white-space: normal; }
}
