/* Layout: one narrow column — jar tabs, the active jar (balance, schedule, distribution strip), forecast, priority queue, journal. */
:root {
  --bg: #edf0f3;
  --surface: #ffffff;
  --sunk: #f5f7f9;
  --ink: #17212b;
  --muted: #5e6c7a;
  --line: #d7dee5;
  --track: #e2e7ec;
  --accent: #b97a12;
  --accent-soft: #f6ead3;
  --partial: #e2a93c;
  --ready: #1d9350;
  --ready-soft: #e2f4e9;
  --danger: #c2412d;
  --danger-soft: #fbe6e2;
  --on-accent: #ffffff;
  --s1: #2a78d6;
  --s2: #eb6834;
  --c1: #2a78d6; --c2: #eb6834; --c3: #1baf7a; --c4: #eda100; --c5: #e87ba4; --c6: #008300; --c7: #4a3aa7; --c8: #e34948;
  --shadow: 0 1px 2px rgba(23,33,43,.06), 0 6px 20px rgba(23,33,43,.06);
  --f-display: "Unbounded", "Segoe UI", system-ui, sans-serif;
  --f-body: "Golos Text", "Segoe UI", system-ui, sans-serif;
  --f-num: "JetBrains Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) {
  --bg: #0e141a; --surface: #171f28; --sunk: #121920; --ink: #e6ecf2; --muted: #93a1af;
  --line: #29343f; --track: #26313c; --accent: #e3a740; --accent-soft: #3a2c12;
  --partial: #d9a03a; --ready: #3fcf7f; --ready-soft: #13301f; --danger: #ef7a66; --danger-soft: #3a1b16;
  --on-accent: #1b1306; --s1: #3987e5; --s2: #d95926; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
} }
:root[data-theme="dark"] {
  --bg: #0e141a; --surface: #171f28; --sunk: #121920; --ink: #e6ecf2; --muted: #93a1af;
  --line: #29343f; --track: #26313c; --accent: #e3a740; --accent-soft: #3a2c12;
  --partial: #d9a03a; --ready: #3fcf7f; --ready-soft: #13301f; --danger: #ef7a66; --danger-soft: #3a1b16;
  --on-accent: #1b1306; --s1: #3987e5; --s2: #d95926; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.25); color-scheme: dark;
  --c1: #3987e5; --c2: #d95926; --c3: #199e70; --c4: #c98500; --c5: #d55181; --c6: #008300; --c7: #9085e9; --c8: #e66767;
}
* { box-sizing: border-box; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--f-body); }
.wrap { max-width: 760px; margin: 0 auto; padding-inline: 16px; padding-block: 28px 64px; display: grid; gap: 18px; }
.num { font-family: var(--f-num); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.stack { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); }
.stack > *, .wrap > * { min-width: 0; }
.wrap { grid-template-columns: minmax(0, 1fr); }

header.top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px 12px; flex-wrap: wrap; }
h1 { font: 700 20px/1.2 var(--f-display); margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.sub { font-size: 13px; color: var(--muted); }
.status { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.status[data-s="cloud"]::before { background: var(--ready); }
.status[data-s="saving"]::before { background: var(--partial); }
.status[data-s="error"]::before { background: var(--danger); }

/* Jar tabs */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 4px; scrollbar-width: thin; }
.tab { flex: 0 0 auto; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 8px 14px; text-align: left; display: grid; gap: 1px; min-width: 110px; }
.tab b { font-weight: 600; font-size: 14px; white-space: nowrap; }
.tab span { font: 500 12.5px var(--f-num); color: var(--muted); font-variant-numeric: tabular-nums; }
.tab[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.tab.add { border-style: dashed; color: var(--muted); display: flex; align-items: center; min-width: 0; }
.tab.add:hover { color: var(--ink); }
.newjar { display: flex; gap: 8px; flex-wrap: wrap; }

/* Jar */
.jar { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow); padding: 22px; display: grid; gap: 16px; }
.label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.bal-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.bal-acts { display: flex; gap: 6px; align-items: center; }
.bal { font: 700 clamp(30px, 7vw, 44px)/1.05 var(--f-display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.bal small, .bal-edit small { font-size: .5em; color: var(--muted); font-weight: 500; margin-left: 4px; }
.bal-btn { display: inline-block; border: 0; background: none; padding: 2px 8px; margin: 0 -8px; border-radius: 10px; text-align: left; transition: background .15s; }
.bal-btn:hover { background: var(--accent-soft); }
.bal-edit { display: flex; align-items: baseline; font: 700 clamp(30px, 7vw, 44px)/1.05 var(--f-display); }
.bal-edit input.bal { width: min(9ch, 60vw); border: 0; border-bottom: 2px solid var(--accent); background: transparent; padding: 0; font-family: var(--f-display); outline: none; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.sched-line { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 13.5px; color: var(--muted); }
.sched-line b { color: var(--ink); font-weight: 600; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent); font-weight: 500; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.pending { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; background: var(--ready-soft); border: 1px solid color-mix(in srgb, var(--ready) 40%, transparent); border-radius: 12px; padding: 10px 12px; font-size: 14px; }
.pending .row { display: flex; gap: 6px; }
.strip { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--track); gap: 2px; }
.strip > span { position: relative; min-width: 3px; background: var(--track); }
.strip > span > i { position: absolute; inset: 0 auto 0 0; background: var(--partial); }
.strip > span.ready > i { background: var(--ready); }
.facts { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 13.5px; color: var(--muted); }
.facts b { color: var(--ink); font-weight: 600; }
.facts b.good { color: var(--ready); }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 14px; font-weight: 500; line-height: 1.2; transition: background .15s, border-color .15s; white-space: nowrap; }
.btn:hover { background: var(--sunk); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.06); background: var(--accent); }
.btn.go { background: var(--ready); border-color: var(--ready); color: #fff; }
.btn.go:hover { filter: brightness(1.06); background: var(--ready); }
.btn.danger { color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--ink); background: var(--sunk); }
.btn.sm { padding: 6px 10px; font-size: 13.5px; border-radius: 8px; }
.icon { width: 32px; height: 32px; padding: 0; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); }
.icon:hover:not(:disabled) { background: var(--sunk); color: var(--ink); }
.icon:disabled { opacity: .3; cursor: default; }
.icon svg { width: 16px; height: 16px; }

.panel { background: var(--sunk); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: grid; gap: 10px; }
.panel .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.panel p { margin: 0; font-size: 13.5px; color: var(--muted); }
.panel h3 { margin: 0; font: 500 13px var(--f-display); }
.warn { color: var(--danger) !important; }
.field { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 8px 12px; min-width: 0; }
.field:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.field.money { width: 150px; font-family: var(--f-num); }
.field.short { width: 80px; }
.field.grow { flex: 1 1 200px; }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; color: var(--muted); }
.slist { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.slist li { display: flex; gap: 10px; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; font-size: 14px; }
.slist li span { min-width: 0; overflow-wrap: anywhere; }
.slist .tag { font-size: 11.5px; padding: 1px 7px; border-radius: 99px; background: var(--accent-soft); color: var(--ink); margin-left: 6px; }

/* Forecast */
.fc { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 10px; }
.fc-head { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; }
.fc-big { font: 700 24px/1.1 var(--f-display); font-variant-numeric: tabular-nums; }
.fc-note { font-size: 13px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 3px 10px; border-radius: 99px; background: var(--sunk); border: 1px solid var(--line); }
.chip.new { background: var(--ready-soft); border-color: color-mix(in srgb, var(--ready) 45%, transparent); }
.quick { display: flex; gap: 4px; flex-wrap: wrap; }

/* Queue */
section h2 { font: 500 14px/1.3 var(--f-display); margin: 0 0 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
section h2 span { font: 400 13px var(--f-body); color: var(--muted); }
ol.queue { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.item { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 12px 12px 6px; display: grid; grid-template-columns: 22px 28px minmax(0,1fr) auto; gap: 4px 10px; align-items: center; transition: border-color .2s, background .2s; }
.item.ready { border-color: color-mix(in srgb, var(--ready) 55%, var(--line)); background: color-mix(in srgb, var(--ready-soft) 55%, var(--surface)); }
.item.dragging { opacity: .45; }
.item.drop-before { box-shadow: 0 -3px 0 var(--accent); }
.item.drop-after { box-shadow: 0 3px 0 var(--accent); }
.handle { cursor: grab; color: var(--muted); opacity: .55; display: grid; place-items: center; height: 100%; touch-action: none; }
.handle:hover { opacity: 1; }
.handle svg { width: 12px; height: 18px; }
.rank { font: 700 13px var(--f-display); color: var(--muted); text-align: center; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--sunk); }
.item.ready .rank { background: var(--ready); color: #fff; }
.body { min-width: 0; display: grid; gap: 6px; }
.title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; }
.name { font-weight: 600; overflow-wrap: anywhere; }
.name a { color: inherit; text-decoration-color: var(--line); text-underline-offset: 3px; }
.badge { font-size: 11.5px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--ready); color: #fff; letter-spacing: .02em; }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--partial); border-radius: 3px; transition: width .4s ease; }
.item.ready .bar i { background: var(--ready); }
.meta { font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 12px; }
.meta .ok { color: var(--ready); }
.meta .bad { color: var(--danger); }
.side { display: flex; align-items: center; gap: 2px; justify-content: flex-end; flex-wrap: wrap; }
.price { font-family: var(--f-num); font-weight: 500; white-space: nowrap; margin-right: 6px; font-variant-numeric: tabular-nums; }
.item > .panel { grid-column: 3 / -1; margin-top: 6px; }
.buy-cta { margin-left: 4px; }
.add { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.empty { text-align: center; padding: 28px 16px; border: 1.5px dashed var(--line); border-radius: 14px; color: var(--muted); display: grid; gap: 10px; justify-items: center; }
.empty strong { color: var(--ink); font-weight: 600; }

/* Journal */
.hist { list-style: none; margin: 0; padding: 0; display: grid; }
.hist li { display: grid; grid-template-columns: 74px minmax(0,1fr) auto auto; gap: 10px; align-items: center; padding: 9px 4px; border-bottom: 1px solid var(--line); font-size: 14px; }
.hist li:last-child { border-bottom: 0; }
.hist .d { color: var(--muted); font-size: 12.5px; }
.hist .n { overflow-wrap: anywhere; }
.hist .diff { font-size: 12px; color: var(--muted); display: block; }
.hist .plus { color: var(--ready); }

/* Deposits */
@media (min-width: 1100px) { .wrap[data-view="deposits"], .wrap[data-view="accounts"] { max-width: 1240px; } }
.hints { display: grid; gap: 8px; }
.hint-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.hint-card .ic { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--sunk); color: var(--muted); grid-row: span 3; }
.hint-card.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 35%, transparent); }
.hint-card.bad .ic { background: var(--danger); color: #fff; }
.hint-card.warn { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.hint-card.warn .ic { background: var(--accent); color: var(--on-accent); }
.hint-card b { font-weight: 600; }
.hint-card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.hint-card .row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.dep-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--muted); }
.dep-meta b { color: var(--ink); font-weight: 600; }
.calc-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.calc-table th, .calc-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.calc-table th:first-child, .calc-table td:first-child { text-align: left; }
.calc-table th { font-size: 11.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.calc-table td { font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.calc-table td:first-child { font-family: var(--f-body); }
.calc-table tr.sel td { background: var(--accent-soft); }
.calc-table tr.best td:first-child::after { content: " · выгоднее всего"; color: var(--ready); font-size: 12px; }
.calc-wrap { overflow-x: auto; }
#dp-chart { min-height: 200px; }
#dp-chart .b1 { fill: var(--s1); }
.chart .accline { fill: none; stroke: var(--ink); stroke-width: 2; stroke-linejoin: round; pointer-events: none; }
.chart .accdot { fill: var(--ink); stroke: var(--surface); stroke-width: 2; pointer-events: none; }
.sw-dot { display: inline-block; width: 18px; height: 2px; background: var(--ink); vertical-align: 4px; margin-right: 6px; position: relative; }
.sw-dot::after { content: ""; position: absolute; left: 5px; top: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--ink); }

/* Icon badges and the icon/colour picker */
.ibadge { width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; background: var(--bc, var(--muted)); color: #fff; flex: none; }
.ibadge svg { width: 20px; height: 20px; }
.ibadge.sm { width: 26px; height: 26px; border-radius: 8px; }
.ibadge.sm svg { width: 15px; height: 15px; }
.picker { display: grid; gap: 8px; }
.picker .icons, .picker .colors { display: flex; flex-wrap: wrap; gap: 6px; }
.picker .icons button { width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); display: grid; place-items: center; color: var(--ink); padding: 0; }
.picker .icons button svg { width: 18px; height: 18px; }
.picker .icons button[aria-pressed="true"] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.picker .colors button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); padding: 0; }
.picker .colors button[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink); }

/* Accounts */
.acc-groups { display: grid; gap: 12px; }
.acc-group { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.acc-group h3 { margin: 0; padding: 12px 14px; display: flex; justify-content: space-between; align-items: center; gap: 10px; font: 500 13.5px var(--f-display); }
.acc-group h3 .num { font: 600 14px var(--f-num); }
.acc-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto auto; gap: 6px 12px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.acc-row .nm { min-width: 0; }
.acc-row .nm b { font-weight: 600; overflow-wrap: anywhere; }
.acc-row .sub { font-size: 12.5px; color: var(--muted); }
.acc-row .amt { text-align: right; font-family: var(--f-num); font-variant-numeric: tabular-nums; white-space: nowrap; }
.acc-row .amt small { display: block; color: var(--muted); font-size: 12px; font-family: var(--f-body); }
.amt-btn { border: 0; background: none; padding: 4px 6px; margin: -4px -6px; border-radius: 8px; font: inherit; text-align: right; }
.amt-btn:hover { background: var(--accent-soft); }
.acc-row .acts { display: flex; gap: 2px; }
.acc-row form { display: flex; gap: 6px; align-items: center; justify-content: flex-end; }
.cur-chips { display: flex; flex-wrap: wrap; gap: 6px; }
@media (max-width: 640px) {
  .acc-row { grid-template-columns: auto minmax(0, 1fr) auto; }
  .acc-row .acts { grid-column: 2 / -1; justify-content: flex-end; }
}

/* Undo toast */
.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 12px; background: var(--ink); color: var(--bg); padding: 10px 10px 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; max-width: calc(100vw - 32px); }
.toast span { overflow-wrap: anywhere; }
.toast button { border: 0; background: transparent; color: var(--accent); font-weight: 600; padding: 6px 10px; border-radius: 8px; white-space: nowrap; }
.toast button:hover { background: rgba(127,127,127,.18); }
@media (max-width: 640px) { .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); } }

/* Info button with a hover/tap explanation */
.info { position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; border-radius: 50%; border: 1px solid var(--muted); color: var(--muted); background: transparent; font: italic 600 10.5px/1 Georgia, "Times New Roman", serif; padding: 0; margin-left: 6px; vertical-align: 1px; cursor: help; text-transform: none; letter-spacing: 0; }
.info:hover, .info:focus { color: var(--ink); border-color: var(--ink); outline: none; }
.info:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.info::after { content: attr(data-tip); position: absolute; left: 50%; top: calc(100% + 8px); transform: translateX(-50%); width: max-content; max-width: min(280px, 78vw); white-space: normal; text-align: left; text-transform: none; letter-spacing: normal; background: var(--ink); color: var(--bg); font: 400 13px/1.45 var(--f-body); padding: 10px 12px; border-radius: 10px; box-shadow: var(--shadow); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .15s; z-index: 30; }
.info:hover::after, .info:focus::after { opacity: 1; visibility: visible; }
.info.left::after { left: -8px; transform: none; }
.info.up::after { top: auto; bottom: calc(100% + 8px); }

/* Views switch */
.views { display: inline-flex; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 2px; }
.views button { border: 0; background: transparent; padding: 6px 14px; border-radius: 9px; font-weight: 500; color: var(--muted); }
.views button:hover { color: var(--ink); }
.views button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }
.head-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

/* Budget */
.ynav { display: flex; align-items: center; gap: 8px 12px; flex-wrap: wrap; justify-content: space-between; }
.ynav .yr { display: flex; align-items: center; gap: 4px; }
.ynav b { font: 700 20px var(--f-display); min-width: 4ch; text-align: center; font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 4px; min-width: 0; align-content: start; }
.tile .v { font: 700 20px/1.15 var(--f-display); overflow-wrap: anywhere; }
.tile .v.pos { color: var(--ready); }
.tile .v.neg { color: var(--danger); }
.tile .s { font-size: 12.5px; color: var(--muted); }
.chart-card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 14px 8px; }
.legend { display: flex; gap: 6px 16px; font-size: 13px; color: var(--muted); margin-bottom: 6px; flex-wrap: wrap; align-items: center; }
.legend .hint { margin: 0 0 0 auto; }
.sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.sw.s1 { background: var(--s1); } .sw.s2 { background: var(--s2); }
.chart { min-height: 220px; min-width: 0; overflow: hidden; }
.card > *, .chart-card > * { min-width: 0; }
.chart svg { display: block; }
.chart .gl { stroke: var(--line); stroke-width: 1; }
.chart .base { stroke: var(--muted); stroke-opacity: .5; stroke-width: 1; }
.chart .ax { fill: var(--muted); font: 11px var(--f-body); font-variant-numeric: tabular-nums; }
.chart .ax.cur { fill: var(--ink); font-weight: 600; }
.chart .b1 { fill: var(--s1); } .chart .b2 { fill: var(--s2); }
.chart .selbg { fill: var(--accent-soft); }
.chart .hoverbg { fill: var(--sunk); }
.chart .hit { cursor: pointer; fill: transparent; }
.tip { position: absolute; top: 44px; pointer-events: none; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 10px; padding: 8px 10px; font-size: 13px; display: grid; gap: 3px; min-width: 190px; z-index: 4; }
.tip div { display: flex; justify-content: space-between; gap: 14px; }
.tip .num { color: var(--ink); }
.bd { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bd li { display: grid; grid-template-columns: minmax(90px, 190px) minmax(0, 1fr) auto 42px; gap: 10px; align-items: center; font-size: 14px; }
.bd .n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bdbar { height: 8px; background: var(--track); border-radius: 4px; overflow: hidden; }
.bdbar i { display: block; height: 100%; background: var(--s2); border-radius: 0 4px 4px 0; }
.bd .pct { color: var(--muted); text-align: right; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.grid-wrap { overflow: auto; max-height: 78vh; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
table.grid { border-collapse: separate; border-spacing: 0; font-size: 13.5px; min-width: 100%; }
.grid th, .grid td { padding: 0; border-bottom: 1px solid var(--line); white-space: nowrap; text-align: right; height: 34px; }
.grid thead th { position: sticky; top: 0; background: var(--surface); z-index: 2; font-weight: 600; color: var(--muted); font-size: 11.5px; padding: 0 10px; text-transform: uppercase; letter-spacing: .05em; }
.grid .sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; text-align: left; min-width: 170px; max-width: 210px; border-right: 1px solid var(--line); }
.grid thead .sticky { z-index: 3; padding-left: 12px; }
.catbtn { border: 0; background: none; width: 100%; text-align: left; padding: 0 12px; height: 34px; overflow: hidden; text-overflow: ellipsis; font-weight: 500; display: block; }
.cellbtn { border: 0; background: none; width: 100%; min-width: 84px; height: 34px; padding: 0 10px; text-align: right; font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.cellbtn:hover, .catbtn:hover { background: var(--accent-soft); }
.grid .cur { background: color-mix(in srgb, var(--accent-soft) 50%, var(--surface)); }
.grid .sel { box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--accent) 45%, transparent); }
.cellin { width: 100%; min-width: 84px; height: 34px; border: 2px solid var(--accent); border-radius: 6px; padding: 0 8px; text-align: right; font-family: var(--f-num); background: var(--surface); outline: none; }
.cellin.bad, .field.bad { border-color: var(--danger); }
.grid .tot, .grid .avg, .grid .nm { padding: 0 10px; font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.grid .tot { font-weight: 500; color: var(--ink); }
.grid tr.total td { font-weight: 500 !important; }
.grid .avg { color: var(--muted); }
.grid tr.sec th { font: 500 13px var(--f-display); padding: 16px 12px 6px; text-align: left; color: var(--ink); }
.grid tr.sec td { background: var(--surface); }
.grid tr.total th, .grid tr.total td { font-weight: 600; background: var(--sunk); }
.grid tr.total th, .grid tr.saldo th { padding: 0 12px; }
.grid tr.saldo th { font-weight: 600; }
.grid .pos { color: var(--ready); } .grid .neg { color: var(--danger); }
.grid tr.addrow td { border-bottom: 0; padding: 6px 0; text-align: left; }
.addcat { position: sticky; left: 0; display: flex; gap: 6px; padding: 0 8px; width: min(420px, calc(100vw - 48px)); }
.addcat .field { flex: 1; padding: 6px 10px; }
.grid tr.catedit td { padding: 8px 0; text-align: left; white-space: normal; height: auto; }
.catedit .panel { position: sticky; left: 8px; width: min(540px, calc(100vw - 56px)); margin: 0 8px; }
textarea.field { width: 100%; font: 12.5px/1.4 var(--f-num); resize: vertical; }

/* Segmented toggle (budget mode) */
.seg { display: inline-flex; background: var(--sunk); border: 1px solid var(--line); border-radius: 10px; padding: 2px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; font-size: 13.5px; color: var(--muted); font-weight: 500; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* Budget: month view */
.mnav { display: flex; align-items: center; gap: 4px; }
.mnav b { font: 600 17px var(--f-display); min-width: 9.5em; text-align: center; }
.mlists { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); }
.mlist { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.mlist h3 { margin: 0; padding: 12px 14px 8px; font: 500 13px var(--f-display); display: flex; justify-content: space-between; gap: 10px; }
.mrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-top: 1px solid var(--line); }
.mrow .catbtn { height: 44px; }
.mrow .cellbtn { min-width: 120px; height: 44px; font-size: 14.5px; padding: 0 14px; }
.mrow .cellin { min-width: 120px; height: 44px; width: 140px; margin-right: 6px; }
.mrow .share { grid-column: 1 / -1; height: 3px; background: var(--track); margin: -6px 14px 8px; border-radius: 2px; overflow: hidden; }
.mrow .share i { display: block; height: 100%; background: var(--s2); }
.muted { color: var(--muted); }
.mlist .addcat { position: static; width: auto; padding: 10px 14px; border-top: 1px solid var(--line); }
.mlist .catedit-wrap { padding: 8px 14px 12px; }

/* Wide screens */
.wrap[data-view="budget"] { max-width: 1440px; }
.jars-layout { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.jars-layout > div { display: grid; gap: 22px; min-width: 0; }
.b-top { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.bd-card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
@media (min-width: 1100px) {
  .wrap[data-view="jars"] { max-width: 1240px; }
  .jars-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .b-top { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
  .mlists { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}

/* Plan */
.plan-layout { display: grid; gap: 22px; grid-template-columns: minmax(0, 1fr); align-items: start; }
.plan-layout > div { display: grid; gap: 16px; min-width: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: grid; gap: 10px; min-width: 0; }
.card h3 { margin: 0; font: 500 13px var(--f-display); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.card h3 span { font: 400 12.5px var(--f-body); color: var(--muted); }
.inc-row { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bigmoney { font: 700 26px/1.2 var(--f-display) !important; width: min(230px, 100%); padding: 6px 10px; font-variant-numeric: tabular-nums; }
.ystrip { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 4px; }
.ystrip button { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 0 3px; display: grid; justify-items: center; font-size: 12px; color: var(--muted); line-height: 1.25; }
.ystrip button b { font-size: 12px; color: var(--ink); font-weight: 600; }
.ystrip button[aria-current="true"] { border-color: var(--accent); background: var(--accent-soft); }
.ystrip .st-ok { color: var(--ready); font-weight: 700; }
.ystrip .st-bad { color: var(--danger); font-weight: 700; }
.ystrip .st-cur { color: var(--accent); }
.stack-bar { display: flex; height: 16px; border-radius: 8px; overflow: hidden; background: var(--track); gap: 2px; }
.stack-bar span { min-width: 3px; background: var(--gc); }
.stack-bar span.free { background: transparent; min-width: 0; }
.stack-bar.over { outline: 2px solid var(--danger); outline-offset: 2px; }
.lg { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 12.5px; color: var(--muted); }
.lg span { display: inline-flex; align-items: center; gap: 5px; }
.dot { width: 10px; height: 10px; border-radius: 3px; background: var(--gc); flex: none; display: inline-block; }
.pg { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: grid; gap: 8px; min-width: 0; }
.pg-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pg-head b { font-weight: 600; overflow-wrap: anywhere; }
.pg-head .kind { font-size: 11.5px; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); }
.pg-amt { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.pg-amt .field { width: 120px; padding: 6px 10px; text-align: right; font-family: var(--f-num); }
.pct { font-size: 12.5px; color: var(--muted); min-width: 3em; text-align: right; font-variant-numeric: tabular-nums; }
/* Custom range: the browser's own track changes colour per accent, so draw it ourselves */
.slider { -webkit-appearance: none; appearance: none; width: 100%; margin: 0; height: 24px; background: transparent; cursor: pointer; }
.slider:focus { outline: none; }
.slider::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--gc) var(--fill, 0%), var(--track) var(--fill, 0%)); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 18px; height: 18px; margin-top: -6px; border-radius: 50%; background: var(--gc); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--gc); }
.slider:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 1px var(--gc), 0 0 0 4px var(--accent-soft); }
.slider::-moz-range-track { height: 6px; border-radius: 3px; background: var(--track); }
.slider::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--gc); }
.slider::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--gc); border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--gc); }
.pcats { font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.pfact { display: grid; gap: 6px; font-size: 13px; }
.pfact:empty { display: none; }
.ftrack { position: relative; height: 8px; background: var(--track); border-radius: 4px; }
.ftrack i { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; background: var(--ready); }
.ftrack i.bad { background: var(--danger); }
.ftrack i.warn { background: var(--partial); }
.ftrack .mark { position: absolute; top: -4px; bottom: -4px; width: 2px; background: var(--ink); border-radius: 1px; }
.ftrack .pace { position: absolute; top: -4px; bottom: -4px; border-left: 2px dotted var(--muted); }
.frow { display: flex; justify-content: space-between; gap: 6px 10px; flex-wrap: wrap; align-items: center; color: var(--muted); }
.frow b { color: var(--ink); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 2px 9px; border-radius: 99px; white-space: nowrap; }
.pill.ok, .pill.good { background: var(--ready-soft); color: var(--ready); }
.pill.bad { background: var(--danger-soft); color: var(--danger); }
.pill.warn { background: var(--accent-soft); color: var(--accent); }
.pill.neutral { background: var(--sunk); color: var(--muted); }
.verdict { font: 700 18px/1.25 var(--f-display); }
.verdict.ok { color: var(--ready); }
.verdict.bad { color: var(--danger); }
.cmp { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 6px 14px; font-size: 13.5px; align-items: baseline; }
.cmp .h { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.cmp .v { text-align: right; font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.cmp .v.muted { color: var(--muted); }
.catgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 12px; }
.catgrid label { display: flex; gap: 6px; align-items: flex-start; font-size: 13.5px; min-width: 0; }
.catgrid small { color: var(--muted); }
.glist { display: grid; gap: 6px; }
.grow-row { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 6px 6px 12px; flex-wrap: wrap; }
@media (min-width: 1100px) {
  .wrap[data-view="plan"] { max-width: 1240px; }
  .plan-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
}
@media (max-width: 640px) {
  .ystrip { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .pg-amt { margin-left: 0; width: 100%; }
  .pg-amt .field { flex: 1; }
}

/* Phone: bottom navigation, bigger targets, 16px inputs (no zoom on focus) */
.bottom-nav { display: none; }
@media (max-width: 640px) {
  .wrap { padding-block: 16px 96px; gap: 14px; }
  h1 { font-size: 17px; }
  header .views { display: none; }
  .bottom-nav { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--surface); border-top: 1px solid var(--line); padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px)); gap: 8px; }
  .bottom-nav button { flex: 1; border: 0; background: transparent; border-radius: 12px; padding: 8px 6px; display: grid; justify-items: center; gap: 2px; font-size: 12px; font-weight: 500; color: var(--muted); }
  .bottom-nav button svg { width: 22px; height: 22px; }
  .bottom-nav button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }
  .field, .cellin, textarea.field, select.field { font-size: 16px; }
  .bal-edit input.bal { font-size: inherit; }
  .icon { width: 40px; height: 40px; }
  .btn.sm { padding: 8px 12px; }
  .jar { padding: 18px 16px; }
  .tiles { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
  .tile { padding: 12px; }
  .tile .v { font-size: 17px; }
  .mnav b { min-width: 0; flex: 1; font-size: 16px; }
  .ynav { gap: 10px; }
}

@media (max-width: 560px) {
  .bd li { grid-template-columns: minmax(0, 1fr) auto 38px; }
  .bd .bdbar { grid-column: 1 / -1; grid-row: 2; }
  .grid .sticky { min-width: 130px; max-width: 150px; }
}

@media (max-width: 560px) {
  .item { grid-template-columns: 18px 26px minmax(0,1fr); padding-right: 10px; }
  .side { grid-column: 2 / -1; justify-content: flex-start; }
  .price { margin-right: auto; }
  .item > .panel { grid-column: 1 / -1; }
  .hist li { grid-template-columns: minmax(0,1fr) auto auto; }
  .hist .d { grid-column: 1 / -1; }
  .field.money { width: 130px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* Backup footer */
.data-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }
.data-foot label.btn { cursor: pointer; }
