:root {
  --bg: #f3f1ea;
  --card: #ffffff;
  --ink: #16201d;
  --muted: #6b736f;
  --line: #e4e0d5;
  --brand: #16302b;
  --brand-ink: #f3f1ea;
  --accent: #e0a526;
  --ok: #2f7d4f;
  --warn: #b5621b;
  --o-Nos: #2a7a6a;
  --o-Halline: #c24f78;
  --o-Pierre: #3563b4;
  --o-Rent: #b58114;
  --o-Wedding: #7a58b3;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(22, 32, 29, .05), 0 6px 20px rgba(22, 32, 29, .06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1513;
    --card: #18201d;
    --ink: #eef0ea;
    --muted: #96a09b;
    --line: #26302c;
    --brand: #1d3a34;
    --brand-ink: #eef0ea;
    --o-Nos: #4fb39e;
    --o-Halline: #e57aa0;
    --o-Pierre: #6f9be6;
    --o-Rent: #d9a640;
    --o-Wedding: #a88ae0;
    --shadow: none;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font-family: Manrope, system-ui, -apple-system, Segoe UI, sans-serif; font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
.num, .amt { font-variant-numeric: tabular-nums; }
#app { max-width: 720px; margin: 0 auto; min-height: 100vh; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
main { padding: calc(14px + env(safe-area-inset-top)) 16px 16px; }
.boot { padding: 40vh 0; text-align: center; color: var(--muted); }

/* nav */
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 4px;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
#nav button { flex: 1; max-width: 160px; background: none; border: 0; padding: 6px 0 2px; display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--muted); font-size: 11.5px; font-weight: 600; border-radius: 12px; }
#nav svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#nav button.on { color: var(--ink); }
#nav .nav-add svg { background: var(--brand); color: var(--brand-ink); stroke: var(--brand-ink); border-radius: 10px; width: 34px; height: 26px; padding: 3px 8px; }

/* header */
.ph { margin: 4px 2px 14px; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
h1 { font-size: 26px; line-height: 1.15; margin: 2px 0 4px; font-weight: 800; letter-spacing: -.02em; }
h2 { font-size: 15px; margin: 22px 2px 8px; font-weight: 700; }
.sub { color: var(--muted); font-size: 13.5px; }
.back { background: none; border: 0; padding: 4px 0; color: var(--muted); font-weight: 600; margin-bottom: 4px; }

/* pay cards */
.pay { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.paycard { background: var(--card); border-radius: var(--radius); padding: 14px 14px 12px; box-shadow: var(--shadow); border: 1px solid var(--line); position: relative; overflow: hidden; }
.paycard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--c); }
.paycard .who { font-weight: 700; font-size: 13px; color: var(--c); }
.paycard .big { font-size: 25px; font-weight: 800; letter-spacing: -.02em; margin: 2px 0 6px; }
.paycard .bd { font-size: 12px; color: var(--muted); display: grid; gap: 1px; }
.paycard .bd span { display: flex; justify-content: space-between; gap: 6px; }
.cardtotal { margin-top: 10px; background: var(--brand); color: var(--brand-ink); border-radius: var(--radius); padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; font-size: 13.5px; }
.cardtotal b { font-size: 17px; }
.cardtotal small { display: block; opacity: .75; font-size: 12px; }

/* chips */
.chips { display: flex; gap: 6px; overflow-x: auto; margin: 14px -16px 0; padding: 2px 16px 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--card); border-radius: 999px; padding: 6px 11px; font-size: 13px; font-weight: 600; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); }
.chip .num { color: var(--muted); font-weight: 600; }
.chip.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.on .num { color: inherit; opacity: .8; }

.banner { margin-top: 12px; display: flex; align-items: center; gap: 10px; background: color-mix(in srgb, var(--accent) 16%, var(--card)); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); border-radius: 14px; padding: 10px 12px; font-size: 13.5px; width: 100%; text-align: left; }
.banner b { font-weight: 800; }
.banner .go { margin-left: auto; font-weight: 700; white-space: nowrap; }

.search { width: 100%; margin-top: 12px; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px; outline: none; }
.search:focus { border-color: var(--ink); }

/* transaction list */
.day { font-size: 12px; font-weight: 700; color: var(--muted); margin: 16px 4px 6px; text-transform: uppercase; letter-spacing: .05em; }
.list { background: var(--card); border-radius: var(--radius); border: 1px solid var(--line); box-shadow: var(--shadow); overflow: hidden; }
.tx { width: 100%; display: flex; align-items: center; gap: 10px; padding: 11px 12px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; position: relative; }
.tx:last-child { border-bottom: 0; }
.tx:active { background: color-mix(in srgb, var(--ink) 5%, transparent); }
.tx.review { background: color-mix(in srgb, var(--accent) 10%, transparent); }
.tx.review::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.tx-main { flex: 1; min-width: 0; }
.tx-desc { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tx-right { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex: none; }
.amt { font-weight: 700; }
.amt.neg { color: var(--ok); }
.pill { font-size: 11.5px; font-weight: 700; padding: 2px 9px; border-radius: 999px; color: #fff; background: var(--c, var(--muted)); }
.pill.pay { background: none; color: var(--muted); border: 1px dashed var(--line); }
.o-Nos { --c: var(--o-Nos); } .o-Halline { --c: var(--o-Halline); } .o-Pierre { --c: var(--o-Pierre); } .o-Rent { --c: var(--o-Rent); } .o-Wedding { --c: var(--o-Wedding); }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }

/* buttons */
.btn { border: 0; border-radius: 14px; padding: 13px 16px; font-weight: 700; background: var(--brand); color: var(--brand-ink); width: 100%; }
.btn.ghost { background: var(--card); color: var(--ink); border: 1px solid var(--line); }
.btn.small { width: auto; padding: 8px 12px; font-size: 13px; border-radius: 10px; }
.btn.danger { background: none; color: #c0392b; border: 1px solid color-mix(in srgb, #c0392b 40%, transparent); }
.btn:disabled { opacity: .5; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.actions { display: grid; gap: 8px; margin-top: 18px; }

/* drop zone */
.drop { display: block; border: 2px dashed color-mix(in srgb, var(--ink) 25%, transparent); border-radius: 22px; padding: 38px 18px; text-align: center; background: var(--card); transition: .15s; cursor: pointer; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--card)); }
.drop svg { width: 42px; height: 42px; stroke: var(--ink); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; opacity: .8; }
.drop b { display: block; font-size: 17px; margin: 8px 0 2px; }
.drop span { color: var(--muted); font-size: 13.5px; }
.drop input { display: none; }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.panel + .panel { margin-top: 10px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13.5px; }
.check .ic { flex: none; width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 13px; }
.check.ok .ic { background: var(--ok); } .check.bad .ic { background: var(--warn); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.stat { background: var(--bg); border-radius: 12px; padding: 9px 10px; }
.stat b { display: block; font-size: 20px; font-weight: 800; }
.stat span { font-size: 12px; color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.toggle:last-child { border-bottom: 0; }
.toggle input { width: 20px; height: 20px; accent-color: var(--brand); }

/* periods list */
.pcard { width: 100%; text-align: left; display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 13px 14px; box-shadow: var(--shadow); margin-bottom: 10px; }
.pcard .top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pcard .name { font-weight: 800; font-size: 16px; }
.pcard .dates { color: var(--muted); font-size: 12.5px; }
.pcard .tot { font-weight: 800; }
.pcard .pp { display: flex; gap: 14px; margin-top: 6px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pcard .pp b { color: var(--c); }
.badge { white-space: nowrap; display: inline-block; font-size: 11px; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #2a1d00; margin-left: 6px; vertical-align: 2px; }
.badge.gray { background: var(--line); color: var(--muted); }
.bar { display: flex; height: 6px; border-radius: 6px; overflow: hidden; margin-top: 9px; background: var(--line); }
.bar i { display: block; background: var(--c); }

/* settings */
.set { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.set:last-child { border-bottom: 0; }
.set label { font-weight: 600; }
.set small { display: block; color: var(--muted); font-weight: 500; font-size: 12.5px; }
.set select, .field input, .field select { border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); }
.field { display: grid; gap: 4px; margin-bottom: 10px; font-size: 13px; font-weight: 600; }
.field input, .field select { width: 100%; font-weight: 500; font-size: 15px; }
.muted { color: var(--muted); }
.note { font-size: 13px; color: var(--muted); margin: 8px 2px; }

/* sign in */
.hero { min-height: 78vh; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center; gap: 12px; padding: 20px; }
.logo { width: 76px; height: 76px; border-radius: 22px; background: var(--brand); display: grid; place-items: center; box-shadow: var(--shadow); }
.logo svg { width: 44px; height: 44px; }
.hero p { color: var(--muted); max-width: 340px; margin: 0; }
.gbtn { display: inline-flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 18px; font-weight: 700; box-shadow: var(--shadow); }
.steps { text-align: left; font-size: 13.5px; color: var(--muted); max-width: 380px; padding-left: 18px; }

/* bottom sheet */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.sheet-bg { position: absolute; inset: 0; background: rgba(10, 15, 13, .45); animation: fade .15s; }
.sheet-card { position: relative; width: 100%; max-width: 560px; max-height: 88vh; overflow: auto; background: var(--card); border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom)); animation: up .2s ease-out; }
.sheet-card::before { content: ""; display: block; width: 38px; height: 4px; border-radius: 4px; background: var(--line); margin: 0 auto 12px; }
@media (min-width: 700px) { .sheet { align-items: center; } .sheet-card { border-radius: 22px; } }
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.sh-title { font-weight: 800; font-size: 18px; line-height: 1.25; }
.sh-amt { font-size: 28px; font-weight: 800; margin: 2px 0 10px; letter-spacing: -.02em; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 13px; margin-bottom: 12px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.why { font-size: 12.5px; background: var(--bg); border-radius: 10px; padding: 8px 10px; margin-bottom: 12px; color: var(--muted); }
.why b { color: var(--ink); }
.owners { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0 12px; }
.owners button { border: 2px solid transparent; background: color-mix(in srgb, var(--c) 14%, var(--card)); color: var(--c); font-weight: 800; border-radius: 14px; padding: 13px 6px; }
.owners button.on { background: var(--c); color: #fff; }
.toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 13.5px; z-index: 60; max-width: 90vw; text-align: center; box-shadow: var(--shadow); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--ink); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 10px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
