:root {
  --bg: #f6f7f9; --surface: #fff; --text: #1d2330; --muted: #6b7280; --border: #e3e6eb;
  --accent: #2f6fde; --accent-text: #fff; --neg: #b42318; --pos: #067647; --warn: #b54708;
  --ok-bg: #ecfdf3; --callout-bg: #eef4ff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; font-size: 15px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b; --surface: #1b1f27; --text: #e6e8ec; --muted: #9aa3b2; --border: #2c323d;
    --accent: #6c9bf0; --accent-text: #0d1117; --neg: #f97066; --pos: #47cd89; --warn: #fdb022;
    --ok-bg: #0f2a1d; --callout-bg: #1a2540;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); }
main { max-width: 1100px; margin: 0 auto; padding: 16px; }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 8px 0 16px; }
h2 { font-size: 1.15rem; margin: 20px 0 10px; }
.muted { color: var(--muted); } .small { font-size: .85em; }
.error { color: var(--neg); } .ok { color: var(--pos); } .warn { color: var(--warn); font-weight: 600; }
.nowrap { white-space: nowrap; }

.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.topbar .brand { font-weight: 700; text-decoration: none; color: var(--text); }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.topbar nav a { padding: 6px 10px; border-radius: 6px; text-decoration: none; color: var(--text); }
.topbar nav a.active { background: var(--callout-bg); color: var(--accent); }
.logout { display: flex; gap: 8px; align-items: center; margin: 0; }

.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 14px 16px; margin: 0 0 12px; text-decoration: none; color: inherit; }
.callout { background: var(--callout-bg); } .callout.ok { background: var(--ok-bg); }
.login { max-width: 360px; margin: 10vh auto; display: flex; flex-direction: column; gap: 12px; }
.login label, .card > label { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }

input, select, button { font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 6px 8px; max-width: 100%; }
button { cursor: pointer; }
button.primary, .button { background: var(--accent); color: var(--accent-text); border-color: var(--accent);
  padding: 7px 14px; border-radius: 6px; text-decoration: none; display: inline-block; }
button.link { border: none; background: none; color: var(--accent); padding: 2px 4px; }
button.link.danger { color: var(--neg); }
.narrow { width: 5em; }
.row, .filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.check { display: inline-flex; gap: 6px; align-items: center; flex-direction: row !important; }

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-weight: 600; color: var(--muted); font-size: .85em; }
tr:last-child td { border-bottom: none; }
td.amount, th.amount, .amount { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.neg { color: var(--neg); } .pos { color: var(--pos); }
tr.transfer, tr.off { opacity: .6; }
.merchant { font-weight: 600; }
.desc { min-width: 220px; }
.tx select { max-width: 220px; }
.tag { font-size: .75em; padding: 1px 6px; border-radius: 10px; background: var(--callout-bg); color: var(--accent);
  font-weight: 500; margin-left: 4px; }
.note { color: var(--muted); }
.pager { display: flex; gap: 16px; justify-content: center; margin: 16px 0; }

.inbox-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.inbox-head .amount { font-size: 1.15em; font-weight: 600; }
.purpose { margin: 6px 0; word-break: break-word; }
.inbox-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 10px; }
.inbox-form select { flex: 1 1 220px; }
.inbox-item.done { background: var(--ok-bg); }
.preview { padding-left: 18px; }

@media (max-width: 640px) {
  th:nth-child(1), td:nth-child(1) { display: none; }
  .tx td:nth-child(4) { display: block; }
  .tx select { max-width: 100%; }
}

.suggestion { margin-top: 8px; padding: 6px 10px; border-radius: 8px; background: var(--callout-bg); }
.suggestion.high { background: var(--ok-bg); }
.suggestion.low { opacity: .8; }
.stats td, .stats th { text-align: right; } .stats td:first-child, .stats th:first-child { text-align: left; }
.progress { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; margin: 8px 0; }
.progress > div { height: 100%; background: var(--accent); }
