:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --line: #e3e6ea;
  --text: #1a1d21;
  --muted: #6b7280;
  --pos: #047857;
  --neg: #b91c1c;
  --accent: #2563eb;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 24px;
  padding: 0 20px; height: 56px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; font-size: 18px; color: var(--text); }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a {
  padding: 6px 12px; border-radius: 6px; color: var(--muted); font-weight: 500;
}
.topbar nav a:hover { background: var(--bg); text-decoration: none; }
.topbar nav a.active { background: var(--accent); color: #fff; }
.who { color: var(--muted); font-size: 13px; white-space: nowrap; }

main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 60px; }

/* ---------- page head ---------- */
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.page-head h1 { margin: 0; font-size: 22px; }
.period-nav { display: flex; gap: 6px; }

/* ---------- cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px;
}
.card h1, .card h2 { margin: 0 0 14px; font-size: 16px; }
.card-narrow { max-width: 360px; margin: 60px auto; }

.split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 800px) { .split { grid-template-columns: 1fr; } }

/* ---------- tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 16px; }
.tile {
  background: var(--card); border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius); padding: 16px;
}
.tile-title { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.tile-big { font-size: 26px; font-weight: 700; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.tile-sub { font-size: 13px; color: var(--muted); }

.bar { height: 6px; background: var(--bg); border-radius: 3px; overflow: hidden; margin: 10px 0 6px; }
.bar > span { display: block; height: 100%; background: var(--accent); }

/* ---------- tables ---------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl td, .tbl th { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.group th { background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.totline { display: flex; justify-content: space-between; padding: 10px 6px 0; border-top: 2px solid var(--line); margin-top: 8px; font-size: 14px; }

.pos { color: var(--pos); }
.neg { color: var(--neg); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.pill, .chip {
  display: inline-block; padding: 1px 7px; border-radius: 999px;
  font-size: 11px; font-weight: 600; background: var(--bg); color: var(--muted);
}
.chip { background: var(--accent); color: #fff; }

/* ---------- forms ---------- */
label { display: block; margin-bottom: 12px; font-size: 13px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 6px;
  font: inherit; color: var(--text); background: #fff;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

.btn {
  display: inline-block; padding: 9px 16px; border: 0; border-radius: 6px;
  background: var(--accent); color: #fff; font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 13px; background: var(--card); color: var(--text); border: 1px solid var(--line); }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; background: #dcfce7; color: #14532d; }
.flash.err { background: #fee2e2; color: #7f1d1d; }
.error { color: var(--neg); font-size: 14px; }

/* ---------- inline row forms (entry, filters, settings) ---------- */
.row-form { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; }
.row-form label { margin-bottom: 0; flex: 1 1 150px; }
.row-form .f-date { flex: 0 0 150px; }
.row-form .f-dir  { flex: 0 0 120px; }
.row-form .f-amt  { flex: 0 0 120px; }
.row-form .f-ent, .row-form .f-acct, .row-form .f-cat { flex: 0 0 170px; }
.row-form .f-payee, .row-form .f-memo { flex: 1 1 180px; }
.row-form .f-go { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
.row-form label.chk { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.row-form label.chk input { width: auto; margin: 0; }

.hidden { display: none; }
.nowrap { white-space: nowrap; }

/* Compact inputs inside data tables */
.tbl input:not([type=checkbox]):not([type=color]), .tbl select {
  padding: 5px 7px; font-size: 13px; margin-top: 0; min-width: 90px;
}
.tbl input[type=checkbox] { width: auto; margin: 0; }
.tbl input[type=color] { padding: 2px; width: 44px; height: 30px; }
.tbl input.cell { text-align: right; width: 100px; min-width: 0; }
.bar-col { width: 130px; }
.bar-col .bar { margin: 2px 0; }

.linkbtn {
  background: none; border: 0; color: var(--muted); cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 4px;
}
.linkbtn:hover { background: #fee2e2; color: var(--neg); }

/* ---------- tabs ---------- */
.tabbar { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabbar a {
  padding: 8px 14px; color: var(--muted); font-weight: 600; font-size: 14px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabbar a:hover { color: var(--text); text-decoration: none; }
.tabbar a.active { color: var(--accent); border-bottom-color: var(--accent); }

.pager { display: flex; gap: 10px; align-items: center; justify-content: center; padding-top: 12px; }

/* A <form> inside a table row must not break the row's layout */
.tbl tr > form { display: contents; }
