/* Fox Budget — palette from the design reference; system fonts, zero CDNs. */
:root {
  --bg:#f4f2ea; --surface:#faf8f3; --surface2:#fdfcf9; --offset:#eae7de;
  --border:#d6d3ca; --divider:#e3e0d8; --text:#1c1a14; --muted:#7a766d;
  --primary:#006870; --primaryHover:#074e56; --primaryHl:#daeaeb;
  --success:#3b7a1a; --warn:#975010; --error:#a02275;
  --fox:#c75c10; --foxHl:#faeee5;
  --r:14px;
  --shadow:0 1px 2px rgba(28,26,20,.04),0 4px 14px rgba(28,26,20,.07);
}
[data-theme="dark"] {
  --bg:#111009; --surface:#171512; --surface2:#1b1916; --offset:#1f1d19;
  --border:#302d28; --divider:#252320; --text:#d4d0c8; --muted:#8e8b83;
  --primary:#4aa4af; --primaryHover:#2b8a96; --primaryHl:#142628;
  --success:#64af40; --warn:#bd6a3a; --error:#ce5e9e;
  --fox:#de7a40; --foxHl:#22150c;
  --shadow:0 2px 8px rgba(0,0,0,.2),0 8px 24px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }

.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 200px; flex-shrink: 0; padding: 1.25rem 1rem; display: flex; flex-direction: column;
  background: var(--surface); border-right: 1px solid var(--divider);
}
.brand { font-weight: 700; font-size: 1.15rem; margin-bottom: 1.5rem; }
.brand-mark { color: var(--fox); }
.sidebar nav { display: flex; flex-direction: column; gap: .25rem; }
.sidebar nav a { color: var(--text); padding: .5rem .75rem; border-radius: 8px; }
.sidebar nav a:hover { background: var(--offset); text-decoration: none; }
.sidebar nav a.active { background: var(--foxHl); color: var(--fox); font-weight: 600; }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: .5rem; align-items: flex-start; }
.who { color: var(--muted); font-size: .85rem; }

.main { flex: 1; padding: 1.5rem 2rem 3rem; max-width: 1100px; }
.main-bare { display: grid; place-items: center; min-height: 100vh; width: 100%; }

.page-head { display: flex; align-items: baseline; gap: 1rem; margin-bottom: 1.25rem; flex-wrap: wrap; }
.month-nav { display: flex; align-items: center; gap: .5rem; margin-left: auto; }

.card {
  background: var(--surface); border: 1px solid var(--divider); border-radius: var(--r);
  box-shadow: var(--shadow); padding: 1.25rem; margin-bottom: 1.25rem;
}
.card-head { display: flex; align-items: baseline; gap: 1rem; justify-content: space-between; flex-wrap: wrap; margin-bottom: .5rem; }
.card-head h2 { margin: 0; }
.two-col { display: grid; grid-template-columns: 3fr 2fr; gap: 1.25rem; align-items: start; }
.account-grid { grid-template-columns: 1fr 1fr; }
.sub-card { background: var(--offset); box-shadow: none; margin-bottom: 0; display: flex; flex-direction: column; gap: .6rem; }
.sub-card h3 { margin: 0 0 .25rem; display: flex; align-items: center; gap: .5rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.kpi {
  background: var(--surface); border: 1px solid var(--divider); border-top: 3px solid var(--primary);
  border-radius: var(--r); box-shadow: var(--shadow); padding: .9rem 1rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.kpi-fox { border-top-color: var(--fox); }
.kpi-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
.kpi-value { font-size: 1.35rem; font-weight: 700; }

.btn {
  background: var(--primary); color: #fff; border: 0; border-radius: 9px;
  padding: .55rem 1rem; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--primaryHover); }
.btn-ghost {
  background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  padding: .3rem .7rem; font: inherit; font-size: .85rem; cursor: pointer; display: inline-block;
}
.btn-ghost:hover { background: var(--offset); text-decoration: none; }
.x-btn { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 1rem; padding: 0 .3rem; }
.x-btn:hover { color: var(--error); }
.inline { display: inline; }

.stack { display: flex; flex-direction: column; gap: .75rem; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--text); }
input, select {
  font: inherit; color: var(--text); background: var(--surface2);
  border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem;
}
input:focus, select:focus { outline: 2px solid var(--primaryHl); border-color: var(--primary); }
.form-error { color: var(--error); font-size: .82rem; }

.toast {
  background: var(--primaryHl); color: var(--primary); border-radius: 9px;
  padding: .6rem .9rem; margin-bottom: 1rem; font-weight: 600;
}
.banner {
  background: var(--foxHl); border: 1px solid var(--divider); border-radius: 9px;
  padding: .6rem .9rem; margin-bottom: 1rem; display: flex; gap: .5rem; flex-wrap: wrap; align-items: center;
}

.anchor-row { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; margin: .75rem 0 1rem; }
.spend-form { display: flex; gap: .75rem; align-items: flex-end; flex-wrap: wrap; }

.strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-bottom: 1rem; }
.strip-cell { background: var(--offset); border-radius: 9px; padding: .55rem .75rem; display: flex; flex-direction: column; }
.strip-label { color: var(--muted); font-size: .78rem; }
.strip-value { font-weight: 700; font-size: 1.05rem; }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th { text-align: left; color: var(--muted); font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; padding: .4rem .5rem; border-bottom: 1px solid var(--border); }
td { padding: .45rem .5rem; border-bottom: 1px solid var(--divider); vertical-align: middle; }
.num { text-align: right; }
th.num { text-align: right; }
.pos { color: var(--success); }
.neg { color: var(--error); font-weight: 600; }
.row-cleared td { opacity: .55; }
.row-late { background: var(--foxHl); }
.row-actions { white-space: nowrap; }
.balance-cell { font-weight: 600; }

.register .clear-box { width: 1.1rem; height: 1.1rem; accent-color: var(--fox); }
.override-box { width: 6.5rem; text-align: right; padding: .25rem .4rem; }
.pay-link { font-size: .8rem; margin-left: .35rem; }

.pill {
  display: inline-block; font-size: .7rem; font-weight: 600; border-radius: 999px;
  padding: .1rem .5rem; background: var(--offset); color: var(--muted);
}
.pill-bill { background: var(--primaryHl); color: var(--primary); }
.pill-deposit { background: var(--foxHl); color: var(--success); }
.pill-spend { background: var(--offset); color: var(--muted); }
.pill-cc { background: var(--foxHl); color: var(--fox); }
.pill-warn { background: var(--foxHl); color: var(--warn); }
.pill-error { background: var(--foxHl); color: var(--error); }

.bar-row { margin-bottom: .8rem; }
.bar-head { display: flex; justify-content: space-between; font-size: .88rem; margin-bottom: .25rem; }
.bar { height: 9px; background: var(--offset); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--primary); border-radius: 999px; }
.bar-over { background: var(--error); }

.donut-row { display: flex; gap: 1.25rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; flex-shrink: 0; }
.donut-center { font-size: .32rem; font-weight: 700; text-anchor: middle; fill: var(--text); }
.donut-seg { transition: stroke-width .15s; }
.seg-0 { stroke: #006870; fill: #006870; } .seg-1 { stroke: #c75c10; fill: #c75c10; }
.seg-2 { stroke: #3b7a1a; fill: #3b7a1a; } .seg-3 { stroke: #a02275; fill: #a02275; }
.seg-4 { stroke: #975010; fill: #975010; } .seg-5 { stroke: #4aa4af; fill: #4aa4af; }
.legend { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; font-size: .88rem; }
.swatch { display: inline-block; width: .7rem; height: .7rem; border-radius: 3px; margin-right: .45rem; stroke: none; }
.chip-list { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: .4rem; }
.chip-list li { display: flex; align-items: center; }

.login-card { width: min(360px, 92vw); }
.login-brand { font-size: 1.4rem; margin-bottom: .25rem; }
.tiny { font-size: .78rem; }
.muted { color: var(--muted); }
.row-edit { display: inline-flex; gap: .35rem; align-items: center; }
.row-edit input[type=number] { width: 6.5rem; }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: .6rem 1rem; gap: 1rem; border-right: 0; border-bottom: 1px solid var(--divider); }
  .brand { margin-bottom: 0; }
  .sidebar nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { margin-top: 0; margin-left: auto; flex-direction: row; align-items: center; }
  .main { padding: 1rem; }
  .kpis, .strip { grid-template-columns: repeat(2, 1fr); }
  .two-col, .row2, .account-grid { grid-template-columns: 1fr; }
}
