:root {
  --ground: #FAF8F3; --panel: #FFFFFF; --panel-2: #F3F0E8; --ink: #17241E; --ink-soft: #4A574F; --ink-faint: #707B74;
  --line: #E4DFD3; --pine: #1E4A38; --pine-deep: #153428; --pine-soft: #E6EEE9; --brass: #8F6B1E; --brass-soft: #F2E9D2;
  --paid: #2E7D57; --paid-bg: #E7F1EA; --due: #8A5F0F; --due-bg: #FBF0D8; --over: #A83A34; --over-bg: #F8E6E3;
  --shadow: 0 1px 2px rgba(21,40,32,.06), 0 8px 28px rgba(21,40,32,.08); --shadow-lg: 0 24px 70px rgba(21,40,32,.24);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; --r: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --ground: #0E1B16; --panel: #14241D; --panel-2: #1B2E25; --ink: #EAF0EB; --ink-soft: #AEBDB3; --ink-faint: #8A9A90;
  --line: #26382E; --pine: #6FB794; --pine-deep: #0B140F; --pine-soft: #17291F; --brass: #D6AF63; --brass-soft: #2A2416;
  --paid: #6CC79A; --paid-bg: #16291F; --due: #E4B75A; --due-bg: #2A2413; --over: #E8857C; --over-bg: #2E1B19;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35); --shadow-lg: 0 30px 80px rgba(0,0,0,.6); color-scheme: dark; } }
:root[data-theme="dark"] {
  --ground: #0E1B16; --panel: #14241D; --panel-2: #1B2E25; --ink: #EAF0EB; --ink-soft: #AEBDB3; --ink-faint: #8A9A90;
  --line: #26382E; --pine: #6FB794; --pine-deep: #0B140F; --pine-soft: #17291F; --brass: #D6AF63; --brass-soft: #2A2416;
  --paid: #6CC79A; --paid-bg: #16291F; --due: #E4B75A; --due-bg: #2A2413; --over: #E8857C; --over-bg: #2E1B19;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 30px rgba(0,0,0,.35); --shadow-lg: 0 30px 80px rgba(0,0,0,.6); color-scheme: dark; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--ground); color: var(--ink); font-family: var(--sans); -webkit-font-smoothing: antialiased; line-height: 1.5; }
.num { font-variant-numeric: tabular-nums; }
h1, h2, h3 { text-wrap: balance; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--pine); }
.serif { font-family: var(--serif); }
.muted { color: var(--ink-faint); }
.small { font-size: 12.5px; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- buttons & fields ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 10px; padding: 11px 18px;
  font-weight: 650; font-size: 14px; border: 1px solid transparent; text-decoration: none; transition: filter .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--pine); color: #fff; }
:root[data-theme="dark"] .btn-primary { color: #0B140F; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #0B140F; } }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: var(--panel); color: var(--pine); border-color: var(--line); }
.btn-danger { background: var(--panel); color: var(--over); border-color: var(--line); }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--ink-faint); margin-top: 5px; }
.input, .field input, .field select, .field textarea { width: 100%; padding: 11px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--ground); font-size: 15px; transition: border-color .15s, box-shadow .15s; }
.field textarea { min-height: 96px; resize: vertical; }
.input:focus, .field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--pine);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--pine) 22%, transparent); }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .row2 { grid-template-columns: 1fr; } }
.err { background: var(--over-bg); color: var(--over); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }
.ok { background: var(--paid-bg); color: var(--paid); border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-bottom: 14px; }

/* ---------- shell ---------- */
.theme-btn { position: fixed; bottom: 16px; right: 16px; z-index: 40; background: var(--panel); color: var(--ink-soft);
  border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px; font-size: 12px; font-weight: 600; box-shadow: var(--shadow); }
.demo-tag { background: var(--brass); color: #241c08; text-align: center; font-size: 12px; font-weight: 700; padding: 6px 12px; }
.demo-tag a { color: inherit; }
.topbar { background: var(--panel); border-bottom: 1px solid var(--line); padding: 0 20px; min-height: 62px; display: flex;
  align-items: center; justify-content: space-between; gap: 12px; position: sticky; top: 0; z-index: 20; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; min-width: 0; }
.brand b { font-family: var(--serif); font-size: 16px; font-weight: 600; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand span { display: block; font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-faint); }
.seal { width: 34px; height: 34px; border-radius: 50%; flex: none; background: linear-gradient(160deg, #1E4A38, #153428);
  display: grid; place-items: center; color: #fff; border: 1.5px solid color-mix(in srgb, #A9812C 55%, transparent); }
.seal svg { width: 18px; height: 18px; }
.seal.lg { width: 60px; height: 60px; margin: 0 auto 16px; } .seal.lg svg { width: 30px; height: 30px; }
.who { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.who .nm { text-align: right; } .who .nm b { display: block; } .who .nm span { font-size: 11.5px; color: var(--ink-faint); }
@media (max-width: 640px) { .who .nm { display: none; } }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brass-soft); color: var(--brass); display: grid;
  place-items: center; font-weight: 700; font-size: 13px; flex: none; }
.container { max-width: 1040px; margin: 0 auto; padding: 28px 20px 70px; }
.container.narrow { max-width: 960px; }
.pagehead { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.pagehead h1, .hello h2 { font-family: var(--serif); font-size: 26px; font-weight: 600; letter-spacing: -.01em; }
.pagehead p, .hello p { margin: 4px 0 0; color: var(--ink-faint); font-size: 14px; }
.hello { margin-bottom: 22px; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); }
.pad { padding: 22px 24px; }
@media (max-width: 560px) { .pad { padding: 18px 16px; } }
.card h3 { font-size: 13px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-faint); margin-bottom: 14px; font-weight: 700; }
.grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; align-items: start; }
.grid > * { min-width: 0; }
@media (max-width: 800px) { .grid { grid-template-columns: 1fr; } }
.stack > * + * { margin-top: 20px; }
.eyebrow { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.balance-card { position: relative; overflow: hidden; }
.balance-card::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: linear-gradient(90deg, var(--paid), var(--pine)); }
.balance-card.owes::before { background: linear-gradient(90deg, var(--over), var(--due)); }
.balance-amt { font-family: var(--serif); font-size: 46px; font-weight: 600; letter-spacing: -.02em; margin: 6px 0 2px; }
.balance-amt small { font-size: 20px; color: var(--ink-faint); font-weight: 500; }
.breakdown { margin: 16px 0 20px; border-top: 1px dashed var(--line); padding-top: 14px; display: flex; flex-direction: column; gap: 9px; }
.breakdown .row { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.breakdown .row span:first-child { color: var(--ink-soft); }
.breakdown .row.fee span { color: var(--over); font-weight: 600; }
.breakdown .row.total { border-top: 1px solid var(--line); padding-top: 9px; font-weight: 700; font-size: 15px; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.over { background: var(--over-bg); color: var(--over); } .pill.paid { background: var(--paid-bg); color: var(--paid); }
.pill.due { background: var(--due-bg); color: var(--due); } .pill.neutral { background: var(--panel-2); color: var(--ink-soft); }
.pay-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.pay-row .btn-primary { flex: 1; min-width: 180px; padding: 13px 22px; font-size: 15px; }
.policy .line { display: flex; gap: 10px; font-size: 13px; color: var(--ink-soft); margin-bottom: 11px; }
.policy .line svg { width: 15px; height: 15px; flex: none; color: var(--brass); margin-top: 3px; }
.policy b { color: var(--ink); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; }
.table-wrap table { min-width: 620px; }
thead th { text-align: left; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; }
tbody td { padding: 13px 16px; font-size: 13.5px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
.right { text-align: right !important; }
td small { display: block; color: var(--ink-faint); font-size: 12px; }
.tag { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px; white-space: nowrap; }
.tag.paid { background: var(--paid-bg); color: var(--paid); } .tag.over { background: var(--over-bg); color: var(--over); }
.tag.neutral { background: var(--panel-2); color: var(--ink-soft); }
.amt-neg { color: var(--paid); }
.empty { padding: 28px; text-align: center; color: var(--ink-faint); font-size: 14px; }

/* ---------- board ---------- */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px; }
@media (max-width: 860px) { .kpis { grid-template-columns: repeat(2, 1fr); } }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.tile::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--line); }
.tile.paid::before { background: var(--paid); } .tile.over::before { background: var(--over); } .tile.brass::before { background: var(--brass); }
.k-label { font-size: 12px; font-weight: 600; color: var(--ink-faint); }
.k-val { font-family: var(--serif); font-size: 28px; font-weight: 600; margin-top: 4px; }
.k-val small { font-size: 15px; color: var(--ink-faint); }
.k-sub { font-size: 12.5px; color: var(--ink-faint); }
.bar { height: 6px; border-radius: 99px; background: var(--panel-2); margin-top: 10px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--paid); border-radius: 99px; }
.tabs { display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); margin-bottom: 22px; scrollbar-width: none; }
.tabs a { padding: 11px 14px; font-size: 14px; font-weight: 600; color: var(--ink-faint); text-decoration: none; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--pine); border-bottom-color: var(--pine); }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--panel-2); border-radius: 10px; padding: 3px; }
.seg button { border: none; background: none; padding: 7px 12px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--ink-faint); }
.seg button.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.search { flex: 1; min-width: 200px; }
.feed .ev { display: flex; gap: 11px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.feed .ev:last-child { border-bottom: none; }
.feed .t { color: var(--ink-faint); font-size: 12px; }
.check { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); align-items: flex-start; }
.check:last-child { border-bottom: none; }
.check .ic { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; flex: none; font-size: 13px; font-weight: 800; }
.check .ic.ok { background: var(--paid-bg); color: var(--paid); margin: 0; padding: 0; }
.check .ic.warn { background: var(--due-bg); color: var(--due); } .check .ic.miss { background: var(--over-bg); color: var(--over); }
.check b { display: block; font-size: 14px; } .check span { font-size: 12.5px; color: var(--ink-faint); }
.linkbox { display: flex; gap: 8px; } .linkbox input { flex: 1; font-size: 12.5px; }

/* ---------- auth / landing ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 40px 16px;
  background: radial-gradient(120% 90% at 50% -10%, color-mix(in srgb, var(--pine) 16%, transparent), transparent 60%), var(--ground); }
.auth-card { width: 100%; max-width: 410px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 36px 32px 28px; }
@media (max-width: 440px) { .auth-card { padding: 28px 20px; } }
.auth-card .brandline { text-align: center; margin-bottom: 24px; }
.auth-card .est { font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--brass); font-weight: 700; }
.auth-card h1 { font-family: var(--serif); font-size: 25px; margin: 5px 0 4px; font-weight: 600; }
.auth-card .brandline p { margin: 0; font-size: 13px; color: var(--ink-faint); }
.tied { margin-top: 20px; padding: 12px 14px; background: var(--pine-soft); border-radius: 10px; font-size: 12.5px; color: var(--ink-soft); }
.hero { padding: 64px 20px 40px; text-align: center; max-width: 820px; margin: 0 auto; }
.hero .est { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--brass); font-weight: 700; }
.hero h1 { font-family: var(--serif); font-size: clamp(32px, 6vw, 52px); line-height: 1.08; letter-spacing: -.02em; margin: 12px 0 14px; font-weight: 600; }
.hero p { font-size: 18px; color: var(--ink-soft); margin: 0 auto 26px; max-width: 620px; }
.hero .cta { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 1040px; margin: 20px auto 0; padding: 0 20px; }
@media (max-width: 800px) { .features { grid-template-columns: 1fr; } }
.features .card h4 { margin: 0 0 6px; font-size: 16px; } .features .card p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.price { max-width: 520px; margin: 40px auto; text-align: center; }
.price .amt { font-family: var(--serif); font-size: 44px; font-weight: 600; }
.price ul { text-align: left; color: var(--ink-soft); font-size: 14.5px; padding-left: 20px; }
.footer { text-align: center; color: var(--ink-faint); font-size: 12.5px; padding: 30px 20px 60px; line-height: 1.7; }

/* ---------- modal & toast ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(10,20,15,.55); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 60; padding: 16px; }
.modal { background: var(--panel); border-radius: 18px; max-width: 460px; width: 100%; padding: 26px; box-shadow: var(--shadow-lg); border: 1px solid var(--line); max-height: calc(100vh - 32px); overflow: auto; }
.modal h3 { font-family: var(--serif); font-size: 21px; font-weight: 600; margin-bottom: 6px; letter-spacing: 0; text-transform: none; color: var(--ink); }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--ground); padding: 11px 18px;
  border-radius: 10px; font-size: 14px; z-index: 70; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }
.spinner { padding: 60px; text-align: center; color: var(--ink-faint); }

/* ---------- receipt ---------- */
@media print { .topbar, .theme-btn, .no-print, .demo-tag { display: none !important; } body { background: #fff; } .card { box-shadow: none; } }
