@import url("/static/fonts/fonts.css");

/* Tokens. The sidebar is navy in both themes; it's the app's fixed frame. */
/* Tokens. Dark is the default look; light is opt-in (Settings, or the switch in the sidebar). */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #070b16;
  --bg-glow: rgb(91 116 255 / .16);
  --dots: rgb(148 163 210 / .09);
  --panel: #0e1526;
  --panel-2: #141d33;
  --panel-hi: rgb(255 255 255 / .045);
  --line: #1d2843;
  --line-2: #2a3962;
  --ink: #e8edf8;
  --ink-2: #a3afc7;
  --ink-3: #6f7c99;
  --accent: #7d95ff;
  --accent-2: #a9b9ff;
  --accent-ink: #070b16;
  --accent-soft: rgb(125 149 255 / .14);
  --good: #3fd193;
  --warn: #f0b440;
  --bad: #ff6f63;
  --good-soft: rgb(63 209 147 / .12);
  --warn-soft: rgb(240 180 64 / .12);
  --bad-soft: rgb(255 111 99 / .12);
  --series-1: #7d95ff;
  --plan: #4f5d7f;
  --rail: #050812;
  --rail-2: #111a2e;
  --rail-ink: #e8edf8;
  --rail-ink-2: #7f8baa;
  --shadow: 0 1px 0 var(--panel-hi) inset, 0 12px 32px -18px rgb(0 0 0 / .7);
  --radius: 10px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --cond: "IBM Plex Sans Condensed", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eef1f7;
  --bg-glow: rgb(52 81 209 / .10);
  --dots: rgb(14 23 38 / .07);
  --panel: #ffffff;
  --panel-2: #f4f6fa;
  --panel-hi: rgb(255 255 255 / 0);
  --line: #dde2ec;
  --line-2: #c5cddc;
  --ink: #0e1726;
  --ink-2: #4a5568;
  --ink-3: #6f7a8f;
  --accent: #3451d1;
  --accent-2: #2a43b3;
  --accent-ink: #ffffff;
  --accent-soft: rgb(52 81 209 / .09);
  --good: #137a4b;
  --warn: #93600a;
  --bad: #c23a2f;
  --good-soft: #e3f3eb;
  --warn-soft: #fbf0dc;
  --bad-soft: #fbe6e3;
  --series-1: #3451d1;
  --plan: #9aa4b5;
  --rail: #0b1222;
  --rail-2: #18233a;
  --shadow: 0 1px 2px rgb(14 23 38 / .05), 0 10px 24px -18px rgb(14 23 38 / .25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--ink); font: 15px/1.55 var(--sans); font-variant-numeric: tabular-nums;
  background-color: var(--bg);
  /* one soft light at the top, over a fine dot grid */
  background-image: radial-gradient(1200px 520px at 60% -180px, var(--bg-glow), transparent 70%),
                    radial-gradient(var(--dots) 1px, transparent 1.2px);
  background-size: 100% 100%, 22px 22px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
}
::selection { background: var(--accent-soft); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1 { font: 600 1.6rem/1.2 var(--cond); margin: 0; letter-spacing: -0.005em; }
h2 { font: 600 1.05rem/1.3 var(--cond); margin: 0 0 12px; letter-spacing: .005em; }
h3 { font: 600 .95rem/1.3 var(--sans); margin: 24px 0 8px; color: var(--ink); }
p { margin: 0 0 12px; max-width: 72ch; }
.muted { color: var(--ink-2); }
.small { font-size: .85rem; }
.num { text-align: right; white-space: nowrap; }
.pos { color: var(--good); }
code { background: var(--panel-2); border: 1px solid var(--line); padding: 0 5px; border-radius: 4px; font-size: .84em; overflow-wrap: anywhere; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- app frame ---------- */
.frame { min-height: 100vh; }
.rail {
  position: fixed; inset: 0 auto 0 0; width: 224px; background: var(--rail); color: var(--rail-ink);
  display: flex; flex-direction: column; padding: 20px 14px; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--rail-ink); font: 600 1.2rem var(--cond); padding: 0 8px 20px; }
.brand:hover { text-decoration: none; }
.brand svg { width: 22px; height: 22px; }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail nav a { color: var(--rail-ink-2); padding: 8px 10px; border-radius: 6px; font-weight: 500; }
.rail nav a:hover { color: var(--rail-ink); background: var(--rail-2); text-decoration: none; }
.rail nav a[aria-current="page"] { color: var(--rail-ink); background: var(--rail-2); box-shadow: inset 2px 0 0 #7b93ff; }
.rail-foot { margin-top: auto; padding: 0 8px; display: grid; gap: 10px; font-size: .82rem; color: var(--rail-ink-2); }
.rail-foot a { color: var(--rail-ink-2); }
.rail-foot a:hover { color: var(--rail-ink); }
.sync { display: flex; align-items: center; gap: 8px; }
.sync .led { width: 8px; height: 8px; border-radius: 50%; background: #3dc48a; box-shadow: 0 0 0 3px rgb(61 196 138 / .18); flex: none; }
.sync.fail .led { background: #f2695c; box-shadow: 0 0 0 3px rgb(242 105 92 / .18); }
.sync.none .led { background: var(--rail-ink-2); box-shadow: none; }

.topbar { display: none; }
.tabbar { display: none; }
main { margin-left: 224px; padding: 28px 32px 64px; max-width: 1240px; }

@media (max-width: 899px) {
  .rail { display: none; }
  main { margin-left: 0; padding: 16px 16px 96px; }
  .topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    position: sticky; top: 0; z-index: 20; background: var(--rail); color: var(--rail-ink);
    padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  }
  .topbar .brand { padding: 0; font-size: 1.1rem; }
  .topbar .sync { font-size: .8rem; color: var(--rail-ink-2); }
  .tabbar {
    display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; inset: auto 0 0 0; z-index: 20;
    background: var(--rail); padding-bottom: env(safe-area-inset-bottom);
  }
  .tabbar a { text-align: center; padding: 12px 2px 13px; font-size: .78rem; font-weight: 500; color: var(--rail-ink-2); }
  .tabbar a[aria-current="page"] { color: var(--rail-ink); box-shadow: inset 0 2px 0 #7b93ff; }
  .tabbar a:hover { text-decoration: none; }
}

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 4px 0 0; }

/* ---------- panels & layout ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; }
.grid { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.grid > * { min-width: 0; }
@media (min-width: 1080px) { .grid.two { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); } }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; margin-bottom: 8px; }
.panel-head h2 { margin: 0; }

/* ---------- forms ---------- */
input, select, textarea, button { font: inherit; color: inherit; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=file], select, textarea {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-width: 0;
}
input:hover, select:hover, textarea:hover { border-color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; }
label { display: block; font-size: .84rem; color: var(--ink-2); margin-bottom: 4px; }
label.row { display: flex; color: var(--ink); margin-bottom: 12px; }
.field { margin-bottom: 12px; }
.field input, .field select { width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-block; border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  padding: 7px 14px; border-radius: 6px; cursor: pointer; font-weight: 500; white-space: nowrap; line-height: 1.4;
  transition: background-color .15s, border-color .15s;
}
.btn:hover { background: var(--panel-2); border-color: var(--ink-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.link { border: 0; background: none; color: var(--accent); padding: 4px 6px; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: .85rem; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; background: var(--accent-soft); border: 1px solid var(--line); }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: transparent; }

/* ---------- period switcher ---------- */
.period { display: inline-flex; align-items: center; gap: 2px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); margin-top: 8px; }
.period a, .period span.disabled { padding: 4px 10px; font-size: 1.05rem; line-height: 1.3; color: var(--ink-2); }
.period a:hover { background: var(--panel-2); color: var(--ink); text-decoration: none; }
.period span.disabled { color: var(--line); }
.period strong { font-weight: 500; font-size: .9rem; padding: 0 6px; }

/* ---------- overview hero: readout + cycle strip ---------- */
.hero { padding: 22px 24px 20px; }
.readout { display: grid; gap: 20px 32px; grid-template-columns: minmax(0, 1fr); align-items: end; }
@media (min-width: 760px) { .readout { grid-template-columns: minmax(0, 1.3fr) minmax(0, 2fr); } }
.readout-main .label { color: var(--ink-2); font-size: .9rem; }
.figure { font: 600 clamp(2.8rem, 6vw, 4.25rem)/1 var(--cond); letter-spacing: -0.02em; margin: 6px 0 8px; }
.figure.negative { color: var(--bad); }
.readout-main .note { font-size: .84rem; color: var(--ink-3); margin: 0; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat { padding: 0 16px; border-left: 1px solid var(--line); }
.stat .label { font-size: .82rem; color: var(--ink-2); }
.stat .value { font: 600 1.45rem/1.2 var(--cond); margin: 2px 0; }
.stat .note { font-size: .78rem; color: var(--ink-3); }
@media (max-width: 759px) { .stat { padding: 0 10px; } .stat:first-child { border-left: 0; padding-left: 0; } .stat .value { font-size: 1.15rem; } }

.cycle { margin-top: 26px; }
.cycle-head { display: flex; justify-content: space-between; gap: 12px; font-size: .84rem; color: var(--ink-2); margin-bottom: 8px; }
.track {
  position: relative; height: 34px; border-radius: 6px; background-color: var(--panel-2);
  border: 1px solid var(--line);
  background-image: repeating-linear-gradient(to right, transparent 0, transparent calc(100% / var(--days) - 1px), var(--line) calc(100% / var(--days) - 1px), var(--line) calc(100% / var(--days)));
}
.track .elapsed { position: absolute; inset: 0 auto 0 0; background: var(--accent-soft); border-radius: 5px 0 0 5px; }
.track .today { position: absolute; top: -6px; bottom: -6px; width: 2px; margin-left: -1px; background: var(--accent); border-radius: 1px; }
.track .today span {
  position: absolute; top: -20px; left: 50%; transform: translateX(-50%); font-size: .72rem; font-weight: 600;
  color: var(--accent); white-space: nowrap;
}
.mark {
  position: absolute; top: 50%; width: 22px; height: 22px; margin: -11px 0 0 -11px; padding: 0; border: 0;
  background: none; cursor: default; display: grid; place-items: center;
}
.mark i { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--ink-3); background: var(--panel); display: block; }
.mark.paid i, .mark.over i { background: var(--good); border-color: var(--good); }
.mark.overdue i { border-color: var(--bad); background: var(--bad-soft); }
.mark .tip { display: none; }
.mark:hover .tip, .mark:focus-visible .tip {
  display: block; position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: var(--ink); color: var(--panel); padding: 6px 10px; border-radius: 6px; font-size: .78rem;
  white-space: nowrap; text-align: left; line-height: 1.4;
}
@media (max-width: 600px) { .mark i { width: 9px; height: 9px; border-width: 1.5px; } }
.cycle-foot { display: flex; justify-content: space-between; font-size: .78rem; color: var(--ink-3); margin-top: 6px; }
.cycle-key { display: flex; gap: 16px; flex-wrap: wrap; font-size: .78rem; color: var(--ink-2); margin-top: 10px; }
.cycle-key i { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--ink-3); margin-right: 6px; vertical-align: -1px; }
.cycle-key i.paid { background: var(--good); border-color: var(--good); }
.cycle-key i.overdue { border-color: var(--bad); background: var(--bad-soft); }

/* ---------- status tags: dot + text, colour never alone ---------- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 500; white-space: nowrap; color: var(--ink-2); }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); flex: none; }
.pill.ok, .pill.paid { color: var(--good); }
.pill.ok::before, .pill.paid::before { background: var(--good); }
.pill.ahead, .pill.unbudgeted { color: var(--warn); }
.pill.ahead::before, .pill.unbudgeted::before { background: var(--warn); }
.pill.over, .pill.overdue { color: var(--bad); }
.pill.over::before, .pill.overdue::before { background: var(--bad); }
.pill.due::before { background: transparent; border: 1.5px solid var(--ink-3); width: 5px; height: 5px; }

/* ---------- budget lines ---------- */
.lines { list-style: none; margin: 0; padding: 0; }
.line { padding: 11px 0; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; padding-top: 4px; }
.line-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }
.line-name { font-weight: 500; min-width: 0; overflow-wrap: anywhere; }
.line-name a { color: inherit; }
.line-meta { display: flex; justify-content: space-between; gap: 8px; font-size: .82rem; color: var(--ink-2); margin-top: 3px; }
.of { color: var(--ink-3); font-size: .85rem; font-weight: 400; }
.bar { position: relative; height: 6px; background: var(--panel-2); border-radius: 3px; margin-top: 9px; box-shadow: inset 0 0 0 1px var(--line); }
.bar-fill { position: absolute; inset: 0 auto 0 0; border-radius: 3px; background: var(--series-1); max-width: 100%; }
.bar-fill.over { background: var(--bad); }
.bar-fill.ahead { background: var(--warn); }
.bar-pace { position: absolute; top: -4px; bottom: -4px; width: 2px; margin-left: -1px; background: var(--ink); border-radius: 1px; }

/* compact rows for fixed payments */
.fixed { display: grid; grid-template-columns: minmax(0, 1fr) 150px 104px; gap: 4px 16px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.fixed:first-of-type { border-top: 0; }
.fixed .name { font-weight: 500; overflow-wrap: anywhere; }
.fixed .name a { color: inherit; }
.fixed .amt { text-align: right; white-space: nowrap; }
@media (max-width: 520px) { .fixed { grid-template-columns: minmax(0, 1fr) auto; } .fixed .pill { grid-column: 1; } .fixed .amt { grid-row: 1; grid-column: 2; } }
.group-total { color: var(--ink-3); font: 400 .85rem var(--sans); }

/* ---------- chart ---------- */
.chart { position: relative; }
.chart svg { width: 100%; height: auto; display: block; overflow: visible; touch-action: pan-y; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; }
.chart .axis-label { fill: var(--ink-3); font: 11px var(--sans); }
.chart .actual { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--accent-soft); stroke: none; }
.chart .plan { fill: none; stroke: var(--plan); stroke-width: 1.5; stroke-dasharray: 4 4; }
.chart .dot { fill: var(--series-1); stroke: var(--panel); stroke-width: 2; }
.chart .cross { stroke: var(--ink-3); stroke-width: 1; }
.chart .tip {
  position: absolute; pointer-events: none; background: var(--ink); color: var(--panel); border-radius: 6px;
  padding: 6px 10px; font-size: .8rem; white-space: nowrap; transform: translate(-50%, -115%); line-height: 1.4;
}
.chart .tip .muted { color: inherit; opacity: .7; }
.legend { display: flex; gap: 16px; font-size: .8rem; color: var(--ink-2); margin-bottom: 10px; flex-wrap: wrap; }
.legend .key { display: inline-block; width: 16px; height: 0; border-top: 2px solid var(--series-1); vertical-align: middle; margin-right: 6px; }
.legend .key.plan { border-top: 2px dashed var(--plan); }

/* ---------- tables ---------- */
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: .8rem; color: var(--ink-3); font-weight: 500; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table td { padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }

/* ---------- transactions ---------- */
.tx { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); }
.tx:first-child, .day-head + .tx { border-top: 0; }
.tx-desc { font-weight: 500; overflow-wrap: anywhere; }
.tx-desc .small { font-weight: 400; }
.tx-amt { text-align: right; font-weight: 600; white-space: nowrap; font-family: var(--cond); font-size: 1.02rem; }
.tx-sub { grid-column: 1 / -1; display: flex; gap: 4px 12px; align-items: center; flex-wrap: wrap; font-size: .8rem; color: var(--ink-3); }
.tx-sub select { padding: 3px 6px; font-size: .8rem; max-width: 190px; }
.tx.uncat .tx-sub select { border-color: var(--warn); }
.day-head { font-size: .8rem; color: var(--ink-2); font-weight: 600; margin: 0 -20px; padding: 6px 20px; background: var(--panel-2); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.day-head:first-child { margin-top: -18px; border-top: 0; border-radius: var(--radius) var(--radius) 0 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.filters input[type=search] { flex: 1 1 200px; }

/* ---------- budget editor rows ---------- */
.cat-row { display: grid; grid-template-columns: minmax(0, 1fr) 22% 16% 11% 128px; gap: 8px; padding: 5px 0; align-items: center; }
.cat-row input { width: 100%; }
.cat-head { padding-bottom: 2px; }
@media (max-width: 720px) {
  .cat-head { display: none; }
  .cat-row { grid-template-columns: 1fr 1fr; padding: 12px 0; border-top: 1px solid var(--line); }
  .cat-row input[name=name] { grid-column: 1 / -1; font-weight: 600; }
}

/* ---------- misc ---------- */
@media (min-width: 900px) { .mobile-only { display: none !important; } }
.auth { max-width: 380px; margin: 14vh auto 0; }
.auth .brand { color: var(--ink); padding: 0 0 16px; }
.empty { text-align: center; padding: 32px 16px; color: var(--ink-2); }
.empty p { margin-left: auto; margin-right: auto; }
details summary { cursor: pointer; color: var(--accent); }
ol.steps { padding-left: 20px; margin: 0 0 12px; }
ol.steps li { margin-bottom: 6px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* rule suggestions */
.suggest { display: grid; grid-template-columns: minmax(0, 1fr) 110px 170px auto; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.suggest:first-of-type { border-top: 0; }
.suggest input { width: 100%; }
@media (max-width: 640px) { .suggest { grid-template-columns: 1fr auto; } .suggest input { grid-column: 1 / -1; } }
.fixed .diff { display: block; font-size: .75rem; font-weight: 500; }
.fixed .diff.up { color: var(--bad); }
.fixed .diff.down { color: var(--good); }
.typical { font-size: .75rem; color: var(--ink-3); margin-top: 2px; }
.typical.off { color: var(--warn); }

/* ================= sleek layer ================= */
.card { box-shadow: var(--shadow); }
.rail { border-right: 1px solid var(--line); }
.rail nav a { display: flex; align-items: center; gap: 10px; transition: background-color .15s, color .15s; }
.rail nav a svg, .tabbar a svg { width: 17px; height: 17px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; opacity: .85; }
.rail nav a[aria-current="page"] { box-shadow: inset 2px 0 0 var(--accent); }
.rail nav a[aria-current="page"] svg { opacity: 1; color: var(--accent-2); }
.tabbar a { display: grid; justify-items: center; gap: 3px; }
.tabbar a[aria-current="page"] { color: var(--rail-ink); box-shadow: inset 0 2px 0 var(--accent); }
.tabbar a[aria-current="page"] svg { color: var(--accent-2); }
.theme-toggle { background: none; border: 1px solid var(--rail-2); color: var(--rail-ink-2); border-radius: 6px; padding: 5px 9px; font-size: .78rem; cursor: pointer; text-align: left; }
.theme-toggle:hover { color: var(--rail-ink); border-color: var(--rail-ink-2); }

/* live status light */
.sync .led { position: relative; }
.sync:not(.fail):not(.none) .led::after {
  content: ""; position: absolute; inset: -3px; border-radius: 50%; border: 1px solid #3fd193; opacity: 0;
  animation: ping 2.8s ease-out infinite;
}
@keyframes ping { 0% { transform: scale(.6); opacity: .7; } 80%, 100% { transform: scale(1.9); opacity: 0; } }

/* figures read like an instrument */
.num strong, .tx-amt, .fixed .amt, .stat .value, .of, .group-total,
.table td.num, .saving, .figure-sm, .typical { font-family: var(--mono); font-weight: 500; letter-spacing: -0.01em; }
.stat .value { font-size: 1.3rem; }
.tx-amt { font-size: .95rem; }
.figure { letter-spacing: -0.025em; }
.figure .pence { font-size: .45em; color: var(--ink-3); letter-spacing: 0; margin-left: 2px; vertical-align: .9em; }

/* hero */
.hero { position: relative; overflow: hidden; }
.hero::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: .55;
}
.track { background-color: var(--panel-2); }
.track .today { box-shadow: 0 0 0 3px var(--accent-soft); }
.mark { transition: transform .15s; }
.mark:hover { transform: scale(1.15); }

/* rows react to the pointer */
.tx, .fixed, .line { transition: background-color .15s; }
.fixed:hover, .tx:hover { background: linear-gradient(90deg, transparent, var(--accent-soft) 12%, var(--accent-soft) 88%, transparent); }

/* buttons & inputs */
.btn { border-radius: 7px; }
.btn.primary { box-shadow: 0 1px 0 rgb(255 255 255 / .18) inset; }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=search], input[type=file], select, textarea {
  background: var(--panel-2); border-color: var(--line); border-radius: 7px;
}
input:focus, select:focus, textarea:focus { background: var(--panel); }

/* one orchestrated entrance on the overview */
@media (prefers-reduced-motion: no-preference) {
  .boot .bar-fill, .boot .track .elapsed { transform-origin: left; animation: grow .9s cubic-bezier(.2, .7, .2, 1) both; }
  .boot .track .today, .boot .mark { animation: fade .5s ease .55s both; }
  .boot .chart .actual { stroke-dasharray: 2000; stroke-dashoffset: 2000; animation: draw 1.2s ease .2s forwards; }
}
@keyframes grow { from { transform: scaleX(0); } }
@keyframes fade { from { opacity: 0; } }
@keyframes draw { to { stroke-dashoffset: 0; } }

/* advisor */
.advice-head { display: grid; gap: 10px 24px; grid-template-columns: minmax(0, 1fr) auto; align-items: center; }
.advice-head .small { grid-column: 1 / -1; }
.advice-headline { font: 500 1.15rem/1.45 var(--sans); margin: 0; max-width: 60ch; }
.advice-total { text-align: right; }
.advice-total .label { display: block; font-size: .82rem; color: var(--ink-2); }
.figure-sm { font-size: 2rem; color: var(--good); }
.figure-sm small, .saving small { font-size: .5em; color: var(--ink-3); margin-left: 3px; }
.saving { color: var(--good); font-size: 1.1rem; white-space: nowrap; }
.suggestion p { color: var(--ink-2); }
.tag { border: 1px solid var(--line-2); border-radius: 5px; padding: 1px 7px; font-size: .76rem; }
.effort-easy { color: var(--good); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.effort-hard { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.watch { margin: 0; padding-left: 18px; color: var(--ink-2); }
.watch li { margin-bottom: 8px; }
.ask.busy button { opacity: .7; pointer-events: none; }
.ask .busy-note { display: none; color: var(--accent-2); font-size: .85rem; margin-top: 8px; }
.ask.busy .busy-note { display: flex; align-items: center; gap: 8px; }
.spinner { width: 12px; height: 12px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ================= sign in ================= */
.gate { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; }
.gate-visual {
  position: relative; overflow: hidden; padding: 48px; display: flex; flex-direction: column; justify-content: space-between;
  background: radial-gradient(900px 500px at 20% 0%, rgb(125 149 255 / .22), transparent 65%), var(--rail);
  color: var(--rail-ink); border-right: 1px solid var(--line);
}
.gate-visual::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgb(148 163 210 / .06) 1px, transparent 1px), linear-gradient(90deg, rgb(148 163 210 / .06) 1px, transparent 1px);
  background-size: 44px 44px; mask-image: linear-gradient(180deg, #000 30%, transparent 95%);
}
.gate-visual .brand { padding: 0; position: relative; z-index: 1; }
.gate-copy { position: relative; z-index: 1; max-width: 30ch; }
.gate-copy h1 { font: 600 clamp(2rem, 3.6vw, 3rem)/1.08 var(--cond); letter-spacing: -0.02em; margin: 0 0 14px; }
.gate-copy p { color: var(--rail-ink-2); margin: 0; }
.demo-strip { position: relative; z-index: 1; }
.demo-strip .track { --days: 30; height: 30px; background-color: rgb(255 255 255 / .03); border-color: rgb(255 255 255 / .08); }
.demo-strip .elapsed { width: 0; background: rgb(125 149 255 / .2); animation: sweep 6s cubic-bezier(.4, 0, .2, 1) infinite alternate; }
.demo-strip .mark i { border-color: #6f7c99; background: var(--rail); }
.demo-strip .mark.paid i { background: #3fd193; border-color: #3fd193; }
.demo-strip .cycle-foot { color: var(--rail-ink-2); }
@keyframes sweep { from { width: 6%; } to { width: 72%; } }
.gate-form { display: grid; place-items: center; padding: 32px 20px; }
.gate-form .card { width: 100%; max-width: 380px; padding: 28px; }
.gate-form h2 { font-size: 1.4rem; margin-bottom: 4px; }
.gate-form .btn.primary { width: 100%; padding: 10px 14px; margin-top: 4px; }
.gate-foot { margin-top: 18px; font-size: .78rem; color: var(--ink-3); text-align: center; }
.gate-foot a { color: var(--ink-3); }
@media (max-width: 820px) {
  .gate { grid-template-columns: 1fr; }
  .gate-visual { padding: 28px 20px; min-height: 0; gap: 28px; border-right: 0; border-bottom: 1px solid var(--line); }
  .gate-copy h1 { font-size: 1.9rem; }
}
@media (prefers-reduced-motion: reduce) { .demo-strip .elapsed { animation: none; width: 55%; } .sync .led::after { animation: none !important; } }

/* phones: hero figures as rows so long amounts never collide */
@media (max-width: 600px) {
  .stats { grid-template-columns: 1fr; border-top: 1px solid var(--line); }
  .stat, .stat:first-child { display: grid; grid-template-columns: 1fr auto; align-items: baseline; gap: 0 12px;
    padding: 10px 0; border-left: 0; border-bottom: 1px solid var(--line); }
  .stat .label { font-size: .9rem; color: var(--ink); }
  .stat .value { font-size: 1.1rem; margin: 0; grid-row: 1; grid-column: 2; }
  .stat .note { grid-column: 1 / -1; }
  .readout { gap: 14px; }
  .cycle-key { gap: 10px; }
}

/* inline "make a rule" offer on the transactions page */
.rule-offer { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-top: 6px; padding: 8px 10px; border-radius: 8px; background: var(--accent-soft); font-size: .84rem; }
.rule-offer input { flex: 1 1 140px; min-width: 0; padding: 4px 8px; font-size: .84rem; }
.saved-tick { color: var(--good); font-size: .8rem; }
@media (max-width: 600px) { .tx-desc .small { display: none; } .filters select { flex: 1 1 40%; } }
