/* Hearth & Ledger — warm, homey household budget planner. System fonts only, no network. */
:root {
  --cream: #faf7f1;
  --card: #fffdf9;
  --ink: #22302a;
  --muted: #6f7a72;
  --line: #e7dfd3;
  --green: #1e4d3b;
  --green-soft: #e4efe8;
  --terra: #c96f4a;
  --terra-soft: #fbe9df;
  --gold: #d9a441;
  --red: #b3402e;
  --red-soft: #fbe4de;
  --blue: #3b6ea5;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(34, 48, 42, 0.08), 0 4px 14px rgba(34, 48, 42, 0.05);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
}
.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }
a { color: var(--green); }
h1 { font-size: 26px; margin: 0 0 4px; letter-spacing: -0.01em; }
h2 { font-size: 17px; margin: 0; }
.sub { color: var(--muted); margin: 0 0 18px; }

/* Top bar */
.topbar { background: var(--green); color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar-inner { display: flex; align-items: center; gap: 24px; height: 56px; }
.brand { color: #fff; text-decoration: none; font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand-mark { color: var(--gold); margin-right: 2px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  color: #d8e6dc; text-decoration: none; padding: 6px 12px; border-radius: 8px;
  font-size: 14px; white-space: nowrap;
}
.nav a:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.nav a.active { background: rgba(255, 255, 255, 0.18); color: #fff; font-weight: 600; }
.month-pick { color: #d8e6dc; font-size: 13px; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.month-pick select {
  border: 1px solid rgba(255, 255, 255, 0.4); background: rgba(255, 255, 255, 0.12);
  color: #fff; border-radius: 8px; padding: 6px 8px; font-size: 14px;
}
.month-pick select option { color: var(--ink); }

/* Page */
#app { padding: 24px 20px 32px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; }

/* Stat cards */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 0 0 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.stat-value { font-size: 26px; font-weight: 700; letter-spacing: -0.01em; }
.stat-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.stat-value.green { color: var(--green); }
.stat-value.terra { color: var(--terra); }
.stat-value.gold { color: #9a6d1a; }
.good { color: var(--green); font-weight: 600; }
.bad { color: var(--red); font-weight: 600; }
.warn { color: #9a6d1a; font-weight: 600; }

/* Cards and grids */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 14px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head .more { font-size: 13px; }
.donut-wrap { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.donut-wrap canvas { flex: 0 0 auto; }
.legend { list-style: none; margin: 0; padding: 0; flex: 1; min-width: 200px; }
.legend li { display: flex; align-items: center; gap: 8px; padding: 3px 0; font-size: 14px; }
.legend .swatch { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }
.legend .lg-amt { margin-left: auto; font-weight: 600; }
.legend .lg-pct { color: var(--muted); width: 44px; text-align: right; }

/* Progress bars */
.bar-row { margin: 12px 0; }
.bar-top { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.bar-top b { font-weight: 600; }
.bar-track { height: 10px; background: #efe9dd; border-radius: 6px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--green); }
.bar-fill.over { background: var(--red); }
.bar-fill.near { background: var(--gold); }
.bar-sub { font-size: 13px; color: var(--muted); margin-top: 4px; }
.tag { display: inline-block; font-size: 12px; font-weight: 700; padding: 1px 8px; border-radius: 20px; }
.tag.over { background: var(--red-soft); color: var(--red); }
.tag.ok { background: var(--green-soft); color: var(--green); }
.tag.soon { background: #fdf3d7; color: #9a6d1a; }

/* Tables */
.tx-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tx-table th { text-align: left; color: var(--muted); font-weight: 600; font-size: 13px; padding: 8px 10px; border-bottom: 2px solid var(--line); }
.tx-table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tx-table tr:last-child td { border-bottom: none; }
.amt { font-weight: 600; text-align: right; white-space: nowrap; }
.amt.exp { color: var(--red); }
.amt.inc { color: var(--green); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 20px; background: var(--green-soft); color: var(--green); white-space: nowrap; }
.pill.inc { background: #e0f2e6; }
.pill.sav { background: #e8eef7; color: var(--blue); }
.row-actions { white-space: nowrap; text-align: right; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--muted); font-size: 14px; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: #f0eadd; color: var(--ink); }
.icon-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.totals { display: flex; gap: 24px; flex-wrap: wrap; padding-top: 12px; font-size: 14px; }
.totals b { font-size: 16px; }

/* Filters */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type="search"], .filters select {
  border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px; font-size: 14px; background: #fff; color: var(--ink);
}
.filters input[type="search"] { flex: 1; min-width: 180px; }

/* Buttons */
.btn { border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 9px; padding: 8px 14px; font-size: 14px; cursor: pointer; font-weight: 600; }
.btn:hover { background: #f4efe6; }
.btn-primary { background: var(--green); border-color: var(--green); color: #fff; }
.btn-primary:hover { background: #16392c; }
.btn-terra { background: var(--terra); border-color: var(--terra); color: #fff; }
.btn-terra:hover { background: #a85a38; }
.btn-danger { background: #fff; border-color: #e5b6ac; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.linklike { background: none; border: none; color: var(--green); cursor: pointer; text-decoration: underline; font-size: inherit; padding: 0; }

/* Goals */
.goal-card { display: flex; flex-direction: column; gap: 8px; }
.goal-top { display: flex; justify-content: space-between; align-items: baseline; }
.goal-name { font-weight: 700; font-size: 16px; }
.goal-amt { font-size: 14px; color: var(--muted); }
.goal-amt b { color: var(--ink); font-size: 16px; }
.goal-note { font-size: 13px; color: var(--muted); }
.goal-actions { display: flex; gap: 8px; margin-top: 4px; }

/* Insights */
.insight-num { font-size: 30px; font-weight: 700; letter-spacing: -0.01em; }
.insight-label { font-size: 13px; color: var(--muted); margin-bottom: 2px; }
.insight-note { font-size: 13px; color: var(--muted); margin-top: 6px; }
.compare-row { display: flex; align-items: center; gap: 10px; margin: 8px 0; font-size: 14px; }
.compare-row .cmp-label { width: 110px; flex: 0 0 auto; }
.compare-row .bar-track { flex: 1; }
.compare-row .cmp-val { width: 86px; text-align: right; font-weight: 600; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(34, 48, 42, 0.45); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 50; }
.modal { background: var(--card); border-radius: 16px; padding: 22px 24px; width: 100%; max-width: 460px; box-shadow: 0 12px 40px rgba(0, 0, 0, 0.25); }
.modal h2 { margin-bottom: 14px; }
.form-row { margin-bottom: 12px; }
.form-row label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 4px; color: var(--muted); }
.form-row input, .form-row select, .form-row textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 9px; padding: 9px 10px; font-size: 15px; background: #fff; color: var(--ink);
}
.form-row.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.form-error { color: var(--red); font-size: 13px; margin: 4px 0 0; min-height: 18px; }

/* Footer */
.foot { color: var(--muted); font-size: 13px; padding-bottom: 28px; }
.empty { color: var(--muted); padding: 18px 4px; text-align: center; }

@media (max-width: 760px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .topbar-inner { gap: 8px; flex-wrap: wrap; height: auto; padding: 10px 0; }
  .nav { order: 3; flex: 1 1 100%; }
  .brand { font-size: 16px; }
  .month-pick span { display: none; }
  .tx-table .hide-m { display: none; }
  h1 { font-size: 22px; }
  .stat-value { font-size: 22px; }
}
