/* Oosies Budget. Dark by default, light when the device asks for it. Fonts are self-hosted (OFL). */
@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(fonts/inter-latin-400-normal.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url(fonts/inter-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 500; font-display: swap; src: url(fonts/space-grotesk-latin-500-normal.woff2) format("woff2"); }
@font-face { font-family: "Space Grotesk"; font-weight: 700; font-display: swap; src: url(fonts/space-grotesk-latin-700-normal.woff2) format("woff2"); }

:root {
  --bg: #0b0f17; --bg2: #0e1320; --panel: #121826; --panel2: #182033; --line: rgba(255,255,255,.07); --line2: rgba(255,255,255,.12);
  --fg: #e9eef6; --muted: #8b95a8; --faint: #5d677a;
  --accent: #c6f36b; --accent-ink: #0b0f17; --mint: #4fd1a5; --warn: #f5b94a; --bad: #ff6b6b; --pos: #4fd1a5;
  --glow: radial-gradient(1200px 500px at 85% -10%, rgba(198,243,107,.10), transparent 60%), radial-gradient(900px 500px at -10% 10%, rgba(79,209,165,.08), transparent 60%);
  --radius: 18px; --radius-sm: 12px;
  --shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 20px 40px -24px rgba(0,0,0,.6);
  --head: "Space Grotesk", "Inter", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f3f5f9; --bg2: #eef1f6; --panel: #ffffff; --panel2: #f6f8fb; --line: rgba(15,23,42,.08); --line2: rgba(15,23,42,.14);
    --fg: #0f172a; --muted: #5b6475; --faint: #98a1b2; --accent: #a3d94a; --accent-ink: #0f172a; --mint: #10a37f; --warn: #c98a12; --bad: #e0484d; --pos: #10a37f;
    --glow: radial-gradient(1200px 500px at 85% -10%, rgba(163,217,74,.18), transparent 60%), radial-gradient(900px 500px at -10% 10%, rgba(16,163,127,.10), transparent 60%);
    --shadow: 0 1px 2px rgba(15,23,42,.04), 0 12px 32px -20px rgba(15,23,42,.18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); background-image: var(--glow); background-attachment: fixed; color: var(--fg); font: 15px/1.5 var(--body); }
a { color: inherit; }
h1, h2, h3 { font-family: var(--head); font-weight: 700; letter-spacing: -.02em; margin: 0; }
h1 { font-size: clamp(26px, 3vw, 34px); }
h2 { font-size: 16px; font-weight: 500; margin-bottom: 14px; }
small { color: var(--muted); }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.neg { color: var(--bad) !important; } .pos { color: var(--pos) !important; } .warn { color: var(--warn); } .r { text-align: right; }

/* ---------- shell */
.shell { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.shell.bare { display: block; }
.side { position: sticky; top: 0; height: 100vh; padding: 22px 16px; display: flex; flex-direction: column; gap: 6px; border-right: 1px solid var(--line); background: color-mix(in srgb, var(--bg2) 70%, transparent); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; font: 500 17px var(--head); padding: 4px 10px 18px; }
.brand b, .auth-brand b { font-weight: 700; margin-left: 3px; color: var(--accent); }
.logo { width: 32px; height: 32px; flex: none; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; text-decoration: none; color: var(--muted); font-weight: 500; transition: background .15s, color .15s; }
.nav a:hover { background: var(--panel); color: var(--fg); }
.nav a[aria-current] { background: var(--panel2); color: var(--fg); box-shadow: inset 3px 0 0 var(--accent); }
.nav svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.signout { margin-top: auto; padding: 0 10px; }
.who { display: flex; align-items: center; gap: 10px; padding: 12px 10px 0; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(135deg, var(--accent), var(--mint)); color: var(--accent-ink); font: 700 13px var(--head); flex: none; }
.main { padding: 28px clamp(16px, 3vw, 40px) 80px; max-width: 1280px; width: 100%; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 4px; font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 20; inset: auto 0 0 0; height: auto; flex-direction: row; padding: 6px 8px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); }
  .brand, .who, .signout { display: none; }
  .nav { flex-direction: row; width: 100%; justify-content: space-around; }
  .nav a { flex-direction: column; gap: 3px; padding: 6px 4px; font-size: 11px; border-radius: 10px; }
  .nav a[aria-current] { box-shadow: none; color: var(--accent); background: transparent; }
  .main { padding-bottom: 100px; }
}

/* ---------- cards and grid */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; min-width: 0; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; }
.grid { display: grid; gap: 18px; }
.grid > .card { margin-bottom: 0; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr)); margin-bottom: 18px; }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); margin-bottom: 18px; }

/* ---------- hero */
.hero { position: relative; overflow: hidden; border-radius: 24px; padding: 28px; margin-bottom: 18px; border: 1px solid var(--line2);
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 16%, var(--panel)) 0%, var(--panel) 45%, color-mix(in srgb, var(--mint) 10%, var(--panel)) 100%);
  display: grid; grid-template-columns: 1.2fr 1fr; gap: 24px; box-shadow: var(--shadow); }
.hero::after { content: ""; position: absolute; width: 360px; height: 360px; right: -120px; top: -160px; border-radius: 50%; background: radial-gradient(circle, color-mix(in srgb, var(--accent) 22%, transparent), transparent 70%); pointer-events: none; }
.big { font: 700 clamp(40px, 6vw, 64px)/1 var(--head); letter-spacing: -.03em; margin: 6px 0 10px; font-variant-numeric: tabular-nums; }
.sub { margin: 0 0 16px; color: var(--muted); max-width: 46ch; } .sub b { color: var(--fg); }
.cycle-nav { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; border: 1px solid var(--line2); background: var(--panel2); text-decoration: none; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; align-self: center; position: relative; z-index: 1; }
.hero-stats.compact { margin: 0; }
.stat { background: color-mix(in srgb, var(--panel) 70%, transparent); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.stat-label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font: 700 22px var(--head); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-note { font-size: 12.5px; color: var(--muted); }
.cycle-bar { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--line); overflow: hidden; }
.cycle-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--accent)); border-radius: 6px; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; padding: 22px; } .hero-stats { grid-template-columns: 1fr 1fr 1fr; } }
@media (max-width: 520px) {
  .hero-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { padding: 10px; border-radius: 12px; } .stat-value { font-size: 16px; } .stat-label { font-size: 10.5px; } .stat-note { font-size: 11px; }
  .envelopes { grid-template-columns: 1fr 1fr; gap: 10px; }
  .env { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px; }
  .env .ring { width: 48px; height: 48px; }
  .env-amt { font-size: 15px; } .env-amt small { display: block; }
}

/* ---------- alerts */
.alert { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; margin-bottom: 10px; border: 1px solid; }
.alert > div { flex: 1; }
.alert.over { background: color-mix(in srgb, var(--bad) 12%, var(--panel)); border-color: color-mix(in srgb, var(--bad) 40%, transparent); }
.alert.warn { background: color-mix(in srgb, var(--warn) 12%, var(--panel)); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: currentColor; flex: none; }
.alert.over .pulse { color: var(--bad); box-shadow: 0 0 0 0 var(--bad); animation: pulse 2s infinite; } .alert.warn .pulse { color: var(--warn); }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--bad) 60%, transparent); } 70% { box-shadow: 0 0 0 10px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }
@media (prefers-reduced-motion: reduce) { .alert.over .pulse { animation: none; } }

/* ---------- envelopes */
.envelopes { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: 12px; }
.env { display: flex; align-items: center; gap: 14px; padding: 14px; border-radius: 16px; background: var(--panel2); border: 1px solid var(--line); text-decoration: none; transition: transform .15s, border-color .15s; }
.env, .env.warn, .env.over { color: var(--fg); }
.env:hover { transform: translateY(-2px); border-color: var(--line2); }
.env.over { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.env.warn { border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.env-body { display: flex; flex-direction: column; min-width: 0; }
.env-name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.env-amt { font: 700 17px var(--head); font-variant-numeric: tabular-nums; } .env-amt small { font: 400 12.5px var(--body); }
.env-left { font-size: 12.5px; color: var(--muted); }
.ring { flex: none; }
.ring .track { fill: none; stroke: var(--line2); stroke-width: 6; }
.ring .bar { fill: none; stroke: var(--mint); stroke-width: 6; stroke-linecap: round; transition: stroke-dasharray .6s ease; }
.ring.warn .bar { stroke: var(--warn); } .ring.over .bar { stroke: var(--bad); } .ring.unbudgeted .bar { stroke: var(--faint); }
.ring text { fill: var(--fg); font: 700 13px var(--head); }

/* ---------- pace chart */
.pace { width: 100%; height: 200px; display: block; }
.pace .grid { stroke: var(--line); stroke-width: 1; }
.pace .ideal { stroke: var(--faint); stroke-width: 1.5; stroke-dasharray: 5 5; fill: none; vector-effect: non-scaling-stroke; }
.pace .line { stroke: var(--accent); stroke-width: 2.5; fill: none; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.pace .area { fill: url(#pg); }
.pace .g0 { stop-color: var(--accent); stop-opacity: .28; } .pace .g1 { stop-color: var(--accent); stop-opacity: 0; }
.pace .dot { fill: var(--accent); stroke: var(--panel); stroke-width: 3; }
.pace-axis { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.legend { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-left: 8px; }
.l-actual { background: var(--accent); } .l-ideal { background: var(--faint); }

/* ---------- bars and lists */
.bar-row { display: grid; grid-template-columns: minmax(80px, 1fr) 2fr auto; gap: 12px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.bar-row:last-child { border-bottom: 0; }
.bar-row b { font-family: var(--head); font-variant-numeric: tabular-nums; }
.bar-row:has(> span + b) { grid-template-columns: 1fr auto; }
.bar { height: 8px; background: var(--line); border-radius: 8px; overflow: hidden; } .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--accent)); border-radius: 8px; }
.txns { list-style: none; margin: 0; padding: 0; }
.txns li { display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); align-items: center; }
.txns li:last-child { border-bottom: 0; }
.t-date { color: var(--muted); font-size: 13px; white-space: nowrap; }
.t-desc { min-width: 0; overflow: hidden; text-overflow: ellipsis; } .t-desc small { display: block; font-size: 12px; }
.txns .t-desc { white-space: nowrap; }
.t-amt { font-family: var(--head); font-weight: 500; font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.members, .rules { list-style: none; margin: 0 0 16px; padding: 0; }
.members li { display: flex; gap: 12px; align-items: center; padding: 8px 0; } .members small { display: block; }
.rules { max-height: 340px; overflow: auto; margin-top: 14px; }
.rules li { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 5px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.rules code { background: var(--panel2); padding: 2px 8px; border-radius: 6px; font-size: 13px; }
.kv { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--line); } .kv b { font-family: var(--head); font-variant-numeric: tabular-nums; }
.verdict h2 { font-size: 22px; } .verdict.pos h2 { color: var(--pos); } .verdict.warn h2 { color: var(--warn); } .verdict.neg h2 { color: var(--bad); }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:hover { background: color-mix(in srgb, var(--panel2) 60%, transparent); }
tr.grp th { background: var(--panel2); color: var(--fg); font-family: var(--head); text-transform: none; letter-spacing: 0; font-size: 14px; }
tfoot td { font-weight: 500; border-bottom: 0; }
.txn-table .t-desc { max-width: 380px; }
.cat-form { display: flex; align-items: center; gap: 8px; }
.cat-form select { min-width: 150px; }
.cat-form select.unset { border-color: color-mix(in srgb, var(--warn) 50%, transparent); }
.cat-form select.saved { border-color: var(--mint); }
.import-result { display: grid; gap: 2px; padding: 12px 14px; border-radius: 12px; margin-bottom: 10px; border: 1px solid var(--line2); background: var(--panel); }
.import-result.ok { border-color: color-mix(in srgb, var(--mint) 45%, transparent); } .import-result.warn { border-color: color-mix(in srgb, var(--warn) 50%, transparent); } .import-result.err { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }

/* ---------- forms */
input, select, button, textarea { font: inherit; color: inherit; }
input, select { background: var(--bg2); border: 1px solid var(--line2); border-radius: 10px; padding: 9px 12px; min-width: 0; width: 100%; }
input:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 60%, transparent); outline-offset: 1px; border-color: transparent; }
input.plain { background: transparent; border-color: transparent; padding-left: 4px; } input.plain:hover { border-color: var(--line2); }
input.money { text-align: right; max-width: 150px; font-variant-numeric: tabular-nums; } input.pct { width: 64px; text-align: right; }
label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; } label.check input { width: auto; } label.check.small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.stack { display: grid; gap: 14px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; align-items: end; margin-top: 12px; }
.inline { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; } .inline > input, .inline > select { flex: 1 1 160px; width: auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; } .filters > * { width: auto; flex: 1 1 160px; } .filters button { flex: 0 0 auto; }
button, .btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel2); cursor: pointer; text-decoration: none; font-weight: 500; white-space: nowrap; transition: filter .15s, background .15s; }
button:hover, .btn:hover { filter: brightness(1.1); }
.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
.ghost { background: transparent; } .small { padding: 5px 10px; font-size: 13px; } .icon { padding: 3px 9px; font-size: 16px; line-height: 1; }
.wide { width: 100%; }
.drop { position: relative; border: 1.5px dashed var(--line2); border-radius: 14px; padding: 26px; text-align: center; color: var(--muted); background: var(--bg2); cursor: pointer; transition: border-color .15s; }
.drop:hover, .drop.over { border-color: var(--accent); color: var(--fg); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
details summary { cursor: pointer; color: var(--muted); padding: 8px 0; } details[open] summary { margin-bottom: 4px; }
details.card summary { color: var(--fg); font-weight: 500; padding: 0; }
.flash { padding: 12px 14px; border-radius: 12px; margin-bottom: 14px; border: 1px solid var(--line2); background: var(--panel); }
.flash.ok { border-color: color-mix(in srgb, var(--mint) 45%, transparent); } .flash.err { border-color: color-mix(in srgb, var(--bad) 50%, transparent); }
.flash pre { margin: 8px 0 0; font-size: 14px; }
.empty { text-align: center; padding: 34px; } .empty .btn { margin-top: 8px; }
.qr { background: #fff; padding: 8px; border-radius: 12px; display: block; margin: 10px 0; }

/* ---------- sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line2); border-radius: 24px; padding: 32px; box-shadow: var(--shadow); }
.auth-brand { display: flex; align-items: center; gap: 10px; font: 500 18px var(--head); margin-bottom: 26px; }
.auth h1 { font-size: 26px; margin-bottom: 6px; }
.auth-card .main { padding: 0; }
.shell.bare .main { max-width: none; padding: 0; }
.pill { display: inline-block; font-size: 12px; font-weight: 500; padding: 2px 10px; border-radius: 999px; border: 1px solid var(--line2); white-space: nowrap; }
.pill.confirmed { color: var(--pos); border-color: color-mix(in srgb, var(--pos) 45%, transparent); }
.pill.assumed, .pill.manual { color: var(--mint); border-style: dashed; }
.pill.upcoming { color: var(--muted); }
.pill.not_found { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.pill.skipped { color: var(--faint); }
small.block { display: block; margin-top: 3px; }
.debit-table td.actions { white-space: nowrap; }
.debit-table input:not(.money):not(.pct) { min-width: 140px; }
.txns.debits li.not_found small { color: var(--bad); }
.txns.debits li.upcoming { opacity: .75; }
.txns.debits { max-height: 320px; overflow: auto; }
.txns.debits li { grid-template-columns: 52px 1fr auto auto; }
.txns.debits form { margin: 0; }
.paid-btn { background: color-mix(in srgb, var(--mint) 16%, var(--panel2)); border-color: color-mix(in srgb, var(--mint) 40%, transparent); color: var(--fg); }
.tick { color: var(--pos); font-weight: 700; width: 52px; text-align: center; }
.debit-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.debit-head p { margin: 0; }
.debit-table select { min-width: 160px; }
