:root {
  --bg: #f6f5f1;
  --panel: #ffffff;
  --ink: #16181d;
  --muted: #646a76;
  --line: #e4e2db;
  --brand: #14532d;
  --brand-ink: #ffffff;
  --accent: #f5b301;
  --ok: #15803d;
  --warn: #b45309;
  --bad: #b91c1c;
  --info: #1d4ed8;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(0,0,0,.04), 0 6px 24px rgba(0,0,0,.05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1113; --panel: #171a1e; --ink: #eceef1; --muted: #9aa1ad; --line: #262a30;
    --brand: #22c55e; --brand-ink: #06130b; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font: 15px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); }
a { color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.2rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; word-break: break-all; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.stack > * + * { margin-top: 14px; }

/* Layout */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; margin: 0 6px 22px; text-decoration: none; }
.brand .dot { width: 28px; height: 28px; border-radius: 8px; background: var(--brand); display: grid; place-items: center; color: var(--brand-ink); font-size: .8rem; }
.nav a { display: block; padding: 9px 12px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.on { background: var(--bg); color: var(--ink); box-shadow: inset 3px 0 0 var(--brand); }
.side .foot { margin-top: 24px; padding: 12px; border-top: 1px solid var(--line); font-size: .85rem; }
main { padding: 28px clamp(16px, 4vw, 40px); max-width: 1180px; width: 100%; }
.topbar { display: none; }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 30; transform: translateX(-105%); transition: transform .2s; height: 100%; }
  .side.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
  main { padding: 18px 16px 60px; }
}

/* Cards & stats */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat .k { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 1.55rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .s { color: var(--muted); font-size: .85rem; }
.hero-balance { background: var(--brand); color: var(--brand-ink); border: 0; }
.hero-balance .k, .hero-balance .s { color: inherit; opacity: .8; }

/* Forms */
label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: 6px; }
input, select, textarea { width: 100%; padding: 10px 12px; border-radius: 9px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); font: inherit; }
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 50%, transparent); border-color: var(--brand); }
.field + .field { margin-top: 14px; }
.hint { font-size: .8rem; color: var(--muted); margin-top: 5px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #1b1300; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; font-size: .85rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-weight: 600; font-size: .85rem; }
.chip.on { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }

/* Tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td.wrap { white-space: normal; min-width: 220px; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; background: var(--bg); }
tr:last-child td { border-bottom: 0; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; text-transform: capitalize; background: var(--bg); border: 1px solid var(--line); }
.badge.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.badge.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 35%, transparent); }
.badge.bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }
.badge.info { color: var(--info); border-color: color-mix(in srgb, var(--info) 35%, transparent); }

.callout { padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); }
.callout.ok { background: color-mix(in srgb, var(--ok) 10%, var(--panel)); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.callout.bad { background: color-mix(in srgb, var(--bad) 8%, var(--panel)); border-color: color-mix(in srgb, var(--bad) 35%, transparent); }

/* Modal & toast */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; z-index: 50; }
.modal { background: var(--panel); border-radius: 16px; padding: 22px; width: min(480px, 100%); max-height: 90vh; overflow: auto; border: 1px solid var(--line); }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.2); }
.toast.bad { background: var(--bad); color: #fff; }
.spinner { width: 42px; height: 42px; border: 4px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .9s linear infinite; margin: 10px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Landing */
.land-nav { display: flex; justify-content: space-between; align-items: center; padding: 18px clamp(16px, 5vw, 60px); }
.land-hero { padding: 40px clamp(16px, 5vw, 60px) 60px; display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; max-width: 1200px; margin: 0 auto; }
.land-hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.land-hero .lead { font-size: 1.1rem; color: var(--muted); max-width: 540px; }
.land-sec { padding: 40px clamp(16px, 5vw, 60px); max-width: 1200px; margin: 0 auto; }
.phone-mock { background: var(--panel); border: 1px solid var(--line); border-radius: 26px; padding: 18px; box-shadow: var(--shadow); max-width: 340px; margin-left: auto; }
.bubble { background: var(--bg); border-radius: 14px 14px 14px 4px; padding: 10px 12px; margin: 8px 0; font-size: .9rem; }
.bubble b { display: block; font-size: .75rem; color: var(--muted); }
@media (max-width: 860px) { .land-hero { grid-template-columns: 1fr; } .phone-mock { margin: 0 auto; } }
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: min(420px, 100%); }
.counter { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); margin-top: 5px; }
