/* Deliberate light theme, big plain type, no motion (owner reads small/low-contrast text poorly). */
:root {
  color-scheme: light;
  --bg: #f2f4f7;
  --card: #ffffff;
  --ink: #0b0f14;
  --ink-2: #3b4551;
  --line: #c9ced6;
  --field: #6b7480;
  --accent: #1c5cab;
  --series-1: #2a78d6;
  --income: #006300;
  --danger: #b42318;
  --good: #0ca30c;
  --warning: #fab219;
  --critical: #d03b3b;
  --radius: 16px;
  font: 17px/1.45 "Atkinson Hyperlegible Next", "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); -webkit-text-size-adjust: 100%; }
h1 { font-size: 26px; margin: 0; }
h2 { font-size: 20px; margin: 0 0 12px; }
button, input, select { font: inherit; color: inherit; }
.muted { color: var(--ink-2); }
.income { color: var(--income); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* Layout */
.top, main { max-width: 560px; margin: 0 auto; padding-left: 16px; padding-right: 16px; }
.top { position: sticky; top: 0; z-index: 2; background: var(--bg); padding-top: max(12px, env(safe-area-inset-top)); padding-bottom: 8px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
main { padding-bottom: calc(110px + env(safe-area-inset-bottom)); }
.card { display: block; width: 100%; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; text-align: left; }
button.card { cursor: pointer; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.empty { color: var(--ink-2); margin: 8px 0; }

/* Controls */
button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 48px; padding: 10px 16px; border-radius: 12px; border: 2px solid var(--field);
  background: var(--card); font-weight: 700; cursor: pointer;
}
.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.danger { color: var(--danger); border-color: var(--danger); }
.wide { width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
input, select { width: 100%; min-height: 48px; padding: 10px 12px; border: 2px solid var(--field); border-radius: 12px; background: #fff; }
input[type="color"] { padding: 4px; }
label { display: block; font-weight: 700; margin: 0 0 14px; }
label > input, label > select { margin-top: 6px; font-weight: 400; }
#walletFilter { width: auto; max-width: 55%; }
#search { margin: 4px 0 6px; }

/* Month switcher */
.month { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.month span { font-weight: 700; font-size: 19px; }
.month button { width: 48px; padding: 0; font-size: 26px; }

/* Overview */
.hero .big { display: block; font-size: 36px; line-height: 1.15; margin: 2px 0 12px; font-variant-numeric: tabular-nums; }
.stats div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid var(--line); }
.stats b { font-size: 18px; font-variant-numeric: tabular-nums; white-space: nowrap; }
#donut svg { display: block; width: min(240px, 70%); margin: 0 auto 12px; }
.legend { list-style: none; padding: 0; margin: 0; }
.legend li { display: grid; grid-template-columns: 14px 1fr auto; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.legend .val { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.legend .pct { display: block; color: var(--ink-2); font-size: 16px; }
.swatch { width: 14px; height: 14px; border-radius: 4px; background: var(--c); }
#line svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
#line .axis { display: flex; justify-content: space-between; color: var(--ink-2); font-size: 15px; }
#line .tip { margin: 8px 0 0; font-weight: 700; }

/* Transactions */
.day { display: flex; justify-content: space-between; font-size: 16px; color: var(--ink-2); margin: 18px 0 6px; }
.txn {
  display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; width: 100%;
  border: 1px solid var(--line); border-radius: 14px; background: var(--card); padding: 10px 12px; margin-bottom: 8px;
  text-align: left; font-weight: 400; min-height: 64px;
}
.ico {
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; font-size: 22px;
  background: color-mix(in srgb, var(--c) 22%, #fff); border: 2px solid var(--c);
}
.main { min-width: 0; }
.main b, .main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.main small { font-size: 16px; color: var(--ink-2); }
.amt { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.amt.income { color: var(--income); }
.amt .to { display: block; text-align: right; font-size: 16px; font-weight: 400; color: var(--ink-2); }
.tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.tag { font-size: 15px; padding: 1px 8px; border-radius: 999px; background: #e6ebf2; color: var(--ink); }

/* Budgets & wallets */
.budget small, .wallet small { display: block; color: var(--ink-2); font-size: 16px; margin: 2px 0 10px; }
.bar { display: block; height: 12px; border-radius: 6px; background: #e3e7ed; overflow: hidden; margin-bottom: 8px; }
.bar span { display: block; height: 100%; border-radius: 6px; }
.bar .good { background: var(--good); }
.bar .warning { background: var(--warning); }
.bar .critical { background: var(--critical); }
.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; font-size: 16px; }
.status::before { content: ""; width: 12px; height: 12px; border-radius: 50%; }
.status.good::before { background: var(--good); }
.status.warning::before { background: var(--warning); }
.status.critical::before { background: var(--critical); }
.wallet .big, .budget .big { font-size: 20px; font-variant-numeric: tabular-nums; }
.budget .big { display: block; }
.budget small:last-child { margin-bottom: 0; }
.catrow { display: flex; align-items: center; gap: 12px; width: 100%; justify-content: flex-start; margin-bottom: 8px; font-weight: 400; border-width: 1px; border-color: var(--line); }
.catrow .kind { margin-left: auto; color: var(--ink-2); }
.rate { display: flex; align-items: center; gap: 8px; }
.rate input { width: 9em; margin: 0; }

/* Floating add button + tab bar */
.fab {
  position: fixed; right: max(16px, calc(50% - 264px)); bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 3;
  width: 62px; height: 62px; border-radius: 50%; font-size: 34px; padding: 0;
  background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 14px rgb(0 0 0 / 0.25);
}
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; display: flex; justify-content: center;
  background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tabs button {
  flex: 1; max-width: 112px; flex-direction: column; gap: 0; border: 0; border-radius: 0; min-height: 66px;
  background: none; font-size: 13.5px; font-weight: 700; color: var(--ink-2); padding: 6px 2px;
}
.tabs button span { font-size: 22px; }
.tabs button[aria-current="page"] { color: var(--accent); box-shadow: inset 0 3px 0 var(--accent); }

/* Dialogs */
dialog {
  width: min(520px, calc(100% - 20px)); max-height: calc(100dvh - 20px); border: 0; border-radius: 20px;
  padding: 20px; background: var(--card); color: var(--ink);
}
dialog::backdrop { background: rgb(11 15 20 / 0.55); }
label.opt:has(:disabled) { display: none; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; border: 0; padding: 0; margin: 0 0 16px; }
.seg label { margin: 0; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; text-align: center; padding: 12px 4px; border: 2px solid var(--field); border-radius: 12px; }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -6px 0 14px; }
.chips button { min-height: 40px; padding: 4px 12px; border-width: 1px; font-weight: 400; }
.checks { border: 1px solid var(--line); border-radius: 12px; margin: 0 0 14px; padding: 10px 12px; }
.checks legend { font-weight: 700; padding: 0 4px; }
.checks label { display: flex; align-items: center; gap: 10px; font-weight: 400; margin: 6px 0; }
.checks input { width: 22px; min-height: 22px; height: 22px; margin: 0; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.actions .danger { margin-right: auto; }
