:root {
  --brand: #1f7a5a;
  --brand-soft: #ddefe6;
  --bg: #f4f7f5;
  --card: #ffffff;
  --text: #17201c;
  --muted: #5c6b64;
  --line: #e3e9e5;
  --good: #1b873f;
  --bad: #d12c1f;
  --warn: #c25e00;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 32, 24, .06), 0 2px 8px rgba(16, 32, 24, .04);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --brand: #7fd8b0; --brand-soft: #22352c; --bg: #0f1412; --card: #171c1a; --text: #e6ece9; --muted: #98a6a0;
    --line: #26302b; --good: #7ddc95; --bad: #ff8a80; --warn: #ffb45c; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.good { color: var(--good); } .bad { color: var(--bad); } .warn { color: var(--warn); }
.small { font-size: 13px; }

/* Layout: sidebar on wide screens, top bar on narrow ones. */
.shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side { padding: 24px 16px; border-right: 1px solid var(--line); position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; padding: 0 8px 18px; }
.brand img { width: 28px; height: 28px; }
.household-name { font-size: 13px; color: var(--muted); padding: 0 8px 12px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text); text-decoration: none; border: 0; background: none; cursor: pointer; text-align: left; width: 100%; }
.nav:hover { background: var(--brand-soft); }
.nav[aria-current="page"] { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.side .spacer { flex: 1; }
.sync { font-size: 12.5px; color: var(--muted); padding: 8px 12px; }
main { padding: 32px clamp(16px, 4vw, 48px) 64px; max-width: 1100px; width: 100%; }
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 12px; }
  .brand { padding: 0 8px 0 0; }
  .household-name, .side .spacer { display: none; }
  .nav { width: auto; }
  .sync { padding: 4px 8px; }
  main { padding-top: 20px; }
}

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
h1 { font-size: 26px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 13px; font-weight: 600; color: var(--brand); text-transform: uppercase; letter-spacing: .04em; margin: 28px 4px 10px; }
.grid2 { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 24px; align-items: start; }
@media (max-width: 960px) { .grid2 { grid-template-columns: 1fr; } }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); min-height: 56px; }
.row:first-child { border-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.right { text-align: right; }
.empty { padding: 20px 16px; color: var(--muted); }
.footer-note { font-size: 13px; color: var(--muted); margin: 8px 4px 0; }

.status { padding: 22px 24px; }
.status .label { color: var(--muted); }
.status .big { font-size: 38px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }

.avatar { width: 32px; height: 32px; border-radius: 50%; color: #fff; font-weight: 600; font-size: 14px; display: grid; place-items: center; flex: none; }
.c-blue { background: #007aff; } .c-green { background: #34c759; } .c-orange { background: #ff9500; } .c-pink { background: #ff2d55; }
.c-purple { background: #af52de; } .c-teal { background: #30b0c7; } .c-yellow { background: #e6b800; } .c-red { background: #ff3b30; }
.icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand); flex: none; font-size: 15px; }

.btn { border: 1px solid transparent; background: var(--brand); color: #fff; border-radius: 10px; padding: 8px 14px; font-weight: 600; cursor: pointer; white-space: nowrap; }
@media (prefers-color-scheme: dark) { .btn { color: #00391f; } }
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .45; cursor: default; }
.btn.secondary { background: var(--brand-soft); color: var(--brand); }
.btn.ghost { background: none; color: var(--brand); padding: 6px 8px; }
.btn.danger { background: none; color: var(--bad); border-color: var(--line); }
.btn.small { padding: 5px 10px; font-size: 13.5px; }

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

dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 32px)); background: var(--card); color: var(--text); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(10, 20, 15, .4); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px 6px; }
.dialog-head h3 { margin: 0; font-size: 18px; }
.dialog-body { padding: 8px 20px 4px; display: grid; gap: 12px; max-height: 70vh; overflow: auto; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px 18px; }
label.field { display: grid; gap: 5px; font-size: 13px; color: var(--muted); }
input[type=text], input[type=search], input[type=date], select, textarea { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font-size: 15px; }
input:focus, select:focus, textarea:focus, button:focus-visible, .nav:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.amount-input { font-size: 24px !important; font-variant-numeric: tabular-nums; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { flex: 1; border: 0; background: none; padding: 6px; border-radius: 8px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--card); box-shadow: var(--shadow); font-weight: 600; }
.split-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; }
.split-row .grow { flex: 1; }
.split-row input[type=text] { width: 110px; text-align: right; }
.error { color: var(--bad); font-size: 14px; }

/* Link screen */
.link-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.link-card { display: grid; grid-template-columns: 1fr auto; gap: 40px; align-items: center; max-width: 860px; padding: 40px; }
@media (max-width: 760px) { .link-card { grid-template-columns: 1fr; padding: 24px; } }
.link-card h1 { font-size: 30px; margin-bottom: 8px; }
.link-card ol { padding-left: 20px; margin: 20px 0; display: grid; gap: 10px; }
.qr { width: 280px; height: 280px; background: #fff; border-radius: 16px; padding: 14px; display: grid; place-items: center; border: 1px solid var(--line); }
.qr svg { width: 100%; height: 100%; }
.privacy { font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 14px; margin-top: 14px; }
details summary { cursor: pointer; color: var(--brand); font-weight: 500; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 14px; }

/* Compact controls inside list rows size to their content instead of filling the row. */
.row select { width: auto; flex: none; padding: 6px 10px; font-size: 13.5px; }
.row .grow { min-width: 120px; }
@media (max-width: 560px) { .row select { display: none; } }
