:root {
  --primary: #7A9E7E;
  --primary-dark: #2A6F5E;
  --secondary: #F4A261;
  --error: #DC2626;
  --bg: #F7F7F4;
  --text: #1F2320;
  --muted: #5F6B61;
  --line: #E3E7E2;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
[hidden] { display: none !important; }
h1 { font-size: 1.35rem; margin: 0.2rem 0 0.6rem; }
h2 { font-size: 1.05rem; margin: 1rem 0 0.5rem; }
.topbar { display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: var(--primary); color: #fff;
  padding-top: max(12px, env(safe-area-inset-top)); }
.brand { font-weight: 600; }
main { max-width: 720px; margin: 0 auto; padding: 16px; }
.card { background: #fff; border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  border: 1px solid var(--line); }
.narrow { max-width: 420px; margin: 40px auto; }
.hero .balance { font-size: 1.8rem; font-weight: 700; margin: 6px 0; }
.balance.owed { color: var(--error); }
.balance.credit, .balance.clear { color: var(--primary-dark); }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.error { color: var(--error); }
.center { display: flex; justify-content: center; padding: 60px 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.spread { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
button, .button { font: inherit; border-radius: 10px; border: 1px solid var(--line);
  padding: 10px 14px; background: #fff; color: var(--text); cursor: pointer; text-decoration: none;
  display: inline-block; text-align: center; }
button:disabled { opacity: 0.6; cursor: default; }
.primary { background: var(--primary-dark); border-color: var(--primary-dark); color: #fff; }
.link { background: transparent; border: none; color: inherit; text-decoration: underline; padding: 6px; }
.chip { border-radius: 999px; padding: 6px 12px; }
.chip.selected { background: var(--primary); color: #fff; border-color: var(--primary); }
input, textarea, select { font: inherit; width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; margin: 4px 0 10px; }
#codeInput { font-size: 1.6rem; letter-spacing: 0.5rem; text-align: center; }
label { font-size: 0.9rem; color: var(--muted); }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin: 8px 0 12px; padding-bottom: 4px; }
.tabs button { white-space: nowrap; border-radius: 999px; }
.tabs button[aria-selected="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.list { list-style: none; padding: 0; margin: 0; }
.list li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 8px; }
.list li.clickable { cursor: pointer; }
.status { font-size: 0.8rem; border-radius: 999px; padding: 2px 8px; background: var(--line); }
.status.owed { background: #FDE2E2; color: var(--error); }
.status.ok { background: #DCEBDD; color: var(--primary-dark); }
.update { margin: 6px 0 2px; padding: 8px 10px; border-radius: 8px; background: #F2F6F2; font-size: 0.9rem; }
.photos { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.photos img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line);
  border-top-color: var(--primary-dark); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.notice { background: #FFF4E5; border: 1px solid #F8D3A4; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.success { background: #E7F2E8; border: 1px solid #BFD9C2; border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
dialog { border: none; border-radius: var(--radius); width: min(92vw, 460px); padding: 18px; }
dialog::backdrop { background: rgba(0,0,0,0.35); }
@media print {
  body * { visibility: hidden; }
  dialog, dialog * { visibility: visible; }
  dialog { position: absolute; inset: 0; width: 100%; }
  dialog .row { display: none; }
}
