/* Budget — the Workouts palette; one accent (--a) for spending bars. */
:root {
  --bg:#ECECE4; --surface:#FFFFFF; --surface-2:#F4F4EE;
  --text:#1A1C1D; --muted:#6C7072; --line:#DBDBD1;
  --a:#2C6E8F; --a-soft:#E1EEF3;
  --b:#AC5F28; --b-soft:#F5E8DB;
  --prev:#4C8A52; --prev-soft:#E3EEE2;
  --flare:#B03A33; --flare-soft:#F6E3E1;
  --learn:#6A5AA6; --learn-soft:#E9E5F3;
  --atg:#A8476B; --atg-soft:#F3E1E8;
  --accent:#1A1C1D;
  --radius:13px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg:#111317; --surface:#1B1E23; --surface-2:#23272E;
    --text:#E8E9E6; --muted:#969C9E; --line:#2C313A;
    --a:#5CA7C5; --a-soft:#16303A;
    --b:#D68A4E; --b-soft:#33241A;
    --prev:#7BB980; --prev-soft:#1A2A1D;
    --flare:#E0746C; --flare-soft:#33201E;
    --learn:#AA9BD8; --learn-soft:#231E33;
    --atg:#D2789A; --atg-soft:#33202A;
    --accent:#E8E9E6;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-feature-settings: "tnum" 1; -webkit-font-smoothing: antialiased;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}
a { color: inherit; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; margin: 14px 0 6px; }
h2.sec { font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 26px 2px 8px; }
.wrap { max-width: 720px; margin: 0 auto; padding: 8px 16px 24px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.lede { color: var(--muted); font-size: 15px; margin: 4px 0 12px; }
.kicker { font-size: 12.5px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }

/* ---- bars */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; font-size: 17px; text-decoration: none; margin-right: auto; }
.badge { font-size: 12.5px; font-weight: 700; background: var(--learn-soft); color: var(--learn);
  border-radius: 20px; padding: 3px 10px; text-decoration: none; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; display: flex;
  background: var(--surface); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tabbar a { flex: 1; text-align: center; padding: 12px 0 13px; font-size: 13px; font-weight: 600;
  color: var(--muted); text-decoration: none; }
.tabbar a.on { color: var(--text); box-shadow: inset 0 2px 0 var(--text); }

/* ---- buttons & inputs */
.btn { font: inherit; font-weight: 700; font-size: 15px; border-radius: 10px; padding: 10px 16px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text); cursor: pointer;
  text-decoration: none; display: inline-block; }
.btn.primary { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.btn.ghost { background: transparent; }
.btn.sm { font-size: 13px; padding: 6px 11px; }
.btn.big { font-size: 17px; padding: 14px 20px; }
.btn.wide { display: block; width: 100%; text-align: center; margin: 18px 0 8px; }
.btn:disabled { opacity: .5; }
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%; }
textarea { resize: vertical; }
label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin: 10px 0 0; }
label > input, label > textarea, label > select { margin-top: 4px; }
form { margin: 0; }
.flash { background: var(--prev-soft); color: var(--prev); border-radius: 10px; padding: 4px 14px; margin: 10px 0; font-size: 14px; }
.err { color: var(--flare); font-weight: 600; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin: 8px 0; }
.card.pad { padding: 4px 14px 14px; }
.card.empty { padding: 18px; text-align: center; margin-top: 24px; }
.card.list > * + * { border-top: 1px solid var(--line); }
code { font-size: 13px; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
.steps { padding-left: 22px; margin: 0; } .steps li { margin: 4px 0; }

/* ---- week / month */
.toggle { display: flex; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 3px; margin: 14px 0 6px; }
.toggle a { flex: 1; text-align: center; padding: 6px 0; font-size: 14px; font-weight: 700;
  color: var(--muted); text-decoration: none; border-radius: 8px; }
.toggle a.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgb(0 0 0 / .08); }
.period { display: flex; align-items: center; justify-content: space-between; margin: 4px 0; }
.plabel { font-weight: 700; font-size: 17px; }
.step { font-size: 28px; line-height: 1; padding: 4px 14px; text-decoration: none; color: var(--muted); }

.hero { margin: 10px 2px 4px; }
.big { font-size: 44px; font-weight: 800; letter-spacing: -.03em; line-height: 1.05; }
.over { color: var(--flare); font-weight: 600; }
.under { color: var(--prev); font-weight: 600; }

.bars { display: flex; gap: 4px; height: 120px; align-items: stretch; margin: 16px 0 6px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; text-decoration: none;
  position: relative; padding-bottom: 18px; }
.bar .fill { display: block; background: var(--a-soft); border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.on .fill { background: var(--a); }
.bar .tick { position: absolute; bottom: 0; left: 0; right: 0; text-align: center; font-size: 10px; color: var(--muted); }
.bar.on .tick { color: var(--text); font-weight: 700; }

.catrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 10px 14px; text-decoration: none; }
.cname { font-weight: 600; }
.camt { font-weight: 700; }
.cbar { grid-column: 1 / -1; height: 5px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.cbar span { display: block; height: 100%; background: var(--a); border-radius: 3px; }

/* ---- transactions */
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.chip { font-size: 13px; font-weight: 600; padding: 4px 11px; border-radius: 20px; border: 1px solid var(--line);
  background: var(--surface); color: var(--muted); text-decoration: none; }
.chip.on { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.txrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 10px; padding: 10px 14px; text-decoration: none; align-items: baseline; }
.tdesc { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.tamt { font-weight: 700; text-align: right; }
.tmeta { grid-column: 1 / -1; }
.txrow.income .tamt { color: var(--prev); }
.txrow.transfer { opacity: .55; }
.txh { font-size: 21px; word-break: break-word; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.segopt { margin: 0; }
.segopt input { position: absolute; opacity: 0; width: auto; }
.segopt span { display: inline-block; padding: 7px 12px; border-radius: 9px; border: 1px solid var(--line);
  font-size: 14px; font-weight: 600; color: var(--text); cursor: pointer; }
.segopt input:checked + span { background: var(--accent); color: var(--bg); border-color: var(--accent); }
.segopt input:focus-visible + span { outline: 2px solid var(--a); }
label.check { display: flex; gap: 8px; align-items: center; margin-top: 14px; color: var(--text); font-size: 14px; }
label.check input { width: auto; }
.login { max-width: 340px; margin: 60px auto; text-align: center; }
.login input { margin: 10px 0; }

/* ---- chat (as in Workouts) */
.thread { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.msg { max-width: 88%; padding: 9px 13px; border-radius: 14px; font-size: 15px; white-space: pre-wrap; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--bg); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.status { align-self: flex-start; font-size: 13px; color: var(--muted); background: none; padding: 0 4px; }
.msg.saved { align-self: flex-start; font-size: 12.5px; font-weight: 600; color: var(--prev); background: var(--prev-soft); }
.ask { display: flex; gap: 8px; margin-top: 12px; align-items: flex-end; }
.ask textarea { flex: 1; }
.tryit { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.tryit button { font: inherit; cursor: pointer; }
.fresh { margin-top: 18px; text-align: center; }
