/* One stylesheet, no framework, no web font: the page must render the moment
   it arrives, on a laptop that has never seen it before, with no second
   request to anywhere. The tokens and their reasons are in
   docs/superpowers/specs/2026-09-24-web-design-design.md §3. */

:root {
    color-scheme: light dark;
    --bg: #f7f6f3;
    --surface: #ffffff;
    --sunken: #f0eeea;
    --ink: #242521;
    --muted: #686b64;
    --line: #e7e5df;
    --line-strong: #d8d6cf;
    --accent: #b94316;
    --accent-ink: #ffffff;
    --accent-tint: #fff0e8;
    --income: #1d7446;
    /* One palette with the phone (spec §9, "Palette"): income is green,
       expense is the ordinary ink, red is for errors and destruction only. */
    --expense: #242521;
    --expense-bar: #7f878a;
    --danger: #ae3128;
    --warn: #875600;
    --warn-tint: #faf1e0;
    --skeleton: #e4e7e4;
    --shadow: 0 12px 40px rgb(20 30 30 / 0.18);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-md: 15px;
    --fs-lg: 17px;
    --fs-xl: 20px;
    --fs-2xl: 26px;
    --fs-3xl: 32px;

    --sp-1: 4px;
    --sp-2: 8px;
    --sp-3: 12px;
    --sp-4: 16px;
    --sp-5: 24px;
    --sp-6: 32px;
    --sp-7: 48px;

    --radius: 6px;
    --radius-lg: 10px;
    --sidebar: 208px;
    --tabbar: 60px;
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #131516;
        --surface: #1b1e1f;
        --sunken: #202425;
        --ink: #e7e9e6;
        --muted: #9ba3a3;
        --line: #2c3133;
        --line-strong: #3a4043;
        --accent: #ff9b72;
        --accent-ink: #24160f;
        --accent-tint: #37251e;
        --income: #6fc795;
        --expense: #e7e9e6;
        --expense-bar: #7b8486;
        --danger: #f08b80;
        --warn: #e2b252;
        --warn-tint: #2a2416;
        --skeleton: #24292a;
        --shadow: 0 12px 40px rgb(0 0 0 / 0.5);
    }
}

/* ------------------------------------------------------------- base */

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--ink);
    font: var(--fs-md)/1.5 var(--font);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.005em; }
h1 { font-size: var(--fs-2xl); line-height: 1.2; }
h2 { font-size: var(--fs-lg); line-height: 1.3; }
h3 { font-size: var(--fs-md); }
p { margin: 0; }
a { color: var(--accent); text-underline-offset: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 3px; }
.visually-hidden {
    position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.muted { color: var(--muted); }
.small { font-size: var(--fs-sm); }

/* Figures: tabular, right-aligned, never wrapped; the code muted beside. */
.figure, .num { font-variant-numeric: tabular-nums; white-space: nowrap; }
.figure { text-align: right; }
.code { color: var(--muted); font-size: 0.8em; margin-left: 0.3em; font-weight: 400; }
.tone-income { color: var(--income); }
.tone-expense { color: var(--expense); }
.mark { color: var(--warn); }
.mark-inline { color: var(--warn); margin-left: 0.25em; cursor: help; }

/* ---------------------------------------------------------- controls */

button, .button {
    font: inherit; font-size: var(--fs-sm); font-weight: 500;
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    min-height: 34px; padding: 0 var(--sp-3);
    border-radius: var(--radius); border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--ink); cursor: pointer;
    text-decoration: none; white-space: nowrap;
}
button:hover, .button:hover { border-color: var(--muted); }
button[disabled] { opacity: 0.45; cursor: default; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover { filter: brightness(1.08); }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); }
button.quiet:hover { color: var(--ink); background: var(--sunken); }
button.danger { color: var(--danger); }
button.link { border: none; background: none; min-height: 0; padding: 0; color: var(--accent); font-size: inherit; font-weight: 500; }
button.link:hover { text-decoration: underline; }
button.icon { width: 34px; padding: 0; }
button svg, .button svg, .tab svg, .place svg { flex: none; }

input, select, textarea {
    font: inherit; font-size: var(--fs-md);
    width: 100%; min-height: 38px; padding: 0 var(--sp-3);
    border-radius: var(--radius); border: 1px solid var(--line-strong);
    background: var(--surface); color: var(--ink);
}
textarea { padding: var(--sp-2) var(--sp-3); resize: vertical; line-height: 1.45; }
input[type="checkbox"] { width: auto; min-height: 0; accent-color: var(--accent); }
input[type="file"] { padding: var(--sp-2); }
input:hover, select:hover, textarea:hover { border-color: var(--muted); }
input[aria-invalid="true"] { border-color: var(--danger); }

fieldset { border: 0; padding: 0; min-width: 0; }
.field { display: block; margin: 0 0 var(--sp-4); }
.field > span:first-child { display: block; margin-bottom: var(--sp-1); font-size: var(--fs-sm); font-weight: 500; color: var(--ink); }
.hint { display: block; margin-top: var(--sp-1); font-size: var(--fs-xs); color: var(--muted); }
.hint.warn { color: var(--warn); }
.form-error { color: var(--danger); font-size: var(--fs-sm); margin: 0 0 var(--sp-3); }
.form-actions { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: center; margin-top: var(--sp-2); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 var(--sp-3); }
.checks { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); margin: var(--sp-1) 0 var(--sp-4); }
.checks label { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }

/* A bordered object: an inline edit, the conflict panel, a settings form. */
.panel {
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--radius-lg); padding: var(--sp-4);
}
.panel + .panel { margin-top: var(--sp-3); }

.segmented { display: inline-flex; padding: 3px; gap: 2px; background: var(--sunken); border-radius: var(--radius); }
.segmented button { border: none; background: transparent; min-height: 30px; color: var(--muted); }
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 0 0 1px var(--line-strong); }

.badge {
    display: inline-block; font-size: var(--fs-xs); line-height: 18px; padding: 0 6px;
    border-radius: 4px; background: var(--sunken); color: var(--muted); margin-right: var(--sp-1);
}
.badge.warn { background: var(--warn-tint); color: var(--warn); }

details > summary { cursor: pointer; color: var(--accent); font-weight: 500; font-size: var(--fs-sm); list-style: none; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "+"; display: inline-block; width: 1em; }
details[open] > summary::before { content: "−"; }
details.fold { border-top: 1px solid var(--line); padding: var(--sp-3) 0; }
details.fold[open] > summary { margin-bottom: var(--sp-3); }

/* ------------------------------------------------------------- shell */

.shell { min-height: 100vh; display: grid; grid-template-columns: var(--sidebar) minmax(0, 1fr); }
.sidebar {
    position: sticky; top: 0; height: 100vh; overflow-y: auto;
    display: flex; flex-direction: column; gap: var(--sp-2);
    padding: var(--sp-5) var(--sp-3) var(--sp-4);
    border-right: 1px solid var(--line);
}
.brand { font-size: var(--fs-lg); font-weight: 650; padding: 0 var(--sp-2); margin-bottom: var(--sp-3); letter-spacing: -0.01em; }
.sidebar .add-button { justify-content: space-between; margin: 0 0 var(--sp-4); min-height: 38px; }
.sidebar .add-button kbd { font: inherit; font-size: var(--fs-xs); opacity: 0.75; border: 1px solid currentColor; border-radius: 4px; padding: 0 5px; line-height: 16px; }
.places { display: flex; flex-direction: column; gap: 2px; }
.place {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: 7px var(--sp-2); border-radius: var(--radius);
    color: var(--ink); text-decoration: none; font-size: var(--fs-md);
}
.place svg { color: var(--muted); }
.place:hover { background: var(--sunken); }
.place[aria-current="page"] { background: var(--accent-tint); color: var(--accent); font-weight: 600; }
.place[aria-current="page"] svg { color: var(--accent); }
.sidebar hr { border: 0; border-top: 1px solid var(--line); margin: var(--sp-3) var(--sp-2); }
.sidebar-foot { margin-top: auto; padding: var(--sp-3) var(--sp-2) 0; border-top: 1px solid var(--line); display: flex; flex-direction: column; gap: var(--sp-2); align-items: flex-start; }

.topbar, .tabbar { display: none; }

.main { min-width: 0; padding: var(--sp-6) var(--sp-6) var(--sp-7); overflow-x: clip; }
.page { max-width: 64rem; }
.page.narrow { max-width: 44rem; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-5); }
.page-head .sub { color: var(--muted); font-size: var(--fs-sm); margin-top: var(--sp-1); }
.page-head .tools { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.crumbs { display: flex; gap: var(--sp-2); align-items: baseline; font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--sp-1); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

.notice { display: flex; gap: var(--sp-3); align-items: baseline; padding: var(--sp-3) var(--sp-4); border-radius: var(--radius); margin-bottom: var(--sp-4); font-size: var(--fs-sm); }
.notice.error { background: color-mix(in srgb, var(--danger) 10%, var(--surface)); color: var(--danger); }
.notice.ok { background: color-mix(in srgb, var(--income) 10%, var(--surface)); color: var(--income); }
.notice.warn { background: var(--warn-tint); color: var(--warn); }

section.block { margin-top: var(--sp-6); }
section.block > h2, .block-head { margin-bottom: var(--sp-3); }
.block-head { display: flex; justify-content: space-between; align-items: baseline; gap: var(--sp-3); flex-wrap: wrap; }
.block-head h2 { margin: 0; }

/* ------------------------------------------------------------- lists */

/* A list is rows divided by hairlines. Label left, figures right. */
.rows { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.row {
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: var(--sp-1) var(--sp-4);
    align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line);
}
.row.cols-3 { grid-template-columns: minmax(0, 1fr) minmax(8rem, auto) minmax(9rem, auto); }
.row .label { min-width: 0; }
.row .label .title { overflow-wrap: anywhere; }
.row .label .meta { color: var(--muted); font-size: var(--fs-sm); overflow-wrap: anywhere; }
.row .figures { text-align: right; }
.row .figures .secondary { color: var(--muted); font-size: var(--fs-sm); }
.row.head { padding: var(--sp-2) 0; color: var(--muted); font-size: var(--fs-xs); font-weight: 500; }
.row.excluded .label, .row.archived .label { color: var(--muted); }
.group-title { font-size: var(--fs-sm); font-weight: 600; color: var(--muted); margin: var(--sp-5) 0 var(--sp-2); }
.group:first-of-type .group-title, .group-title:first-child { margin-top: var(--sp-2); }
.group + .group .group-title { margin-top: var(--sp-5); }
.group .rows { border-top: 0; }
.group-title { padding-bottom: var(--sp-2); margin-bottom: 0; border-bottom: 1px solid var(--line); }

/* The row's own buttons: visible on touch, on hover and focus elsewhere. */
.row-actions { display: flex; gap: var(--sp-1); justify-content: flex-end; }
@media (hover: hover) and (pointer: fine) {
    .row .row-actions { opacity: 0; }
    .row:hover .row-actions, .row:focus-within .row-actions, .row-actions.pinned { opacity: 1; }
}
.row-actions button { min-height: 28px; padding: 0 var(--sp-2); font-size: var(--fs-xs); }

table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
th, td { text-align: left; padding: var(--sp-2) var(--sp-3); border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: var(--fs-xs); }
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
th.figure, td.figure { text-align: right; }
td.actions { white-space: nowrap; text-align: right; width: 1%; min-width: 7.5rem; }
/* Stacked, each as wide as the widest label, right-aligned. */
td.actions button { display: block; width: 100%; white-space: nowrap; min-height: 26px;
    padding: 0 var(--sp-2); font-size: var(--fs-xs); margin: 0 0 var(--sp-1); }
td select { width: auto; min-width: 9.5rem; min-height: 32px; font-size: var(--fs-sm); }
td.source { min-width: 11rem; }
tr.excluded td:not(.actions) { opacity: 0.55; text-decoration: line-through; }
tr.differs td { font-weight: 600; }
tr.differs td:first-child { color: var(--warn); }
.table-scroll { position: relative; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 940px; }

/* ----------------------------------------------------- the headline */

.headline { padding-bottom: var(--sp-5); border-bottom: 1px solid var(--line); }
.headline .caption { color: var(--muted); font-size: var(--fs-sm); margin-bottom: var(--sp-1); }
.headline .amount { font-size: var(--fs-3xl); font-weight: 600; line-height: 1.1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.headline .amount .code { font-size: var(--fs-xl); font-weight: 500; margin-left: 0.35em; }
.headline .absent { font-size: var(--fs-xl); color: var(--warn); margin-top: var(--sp-1); }
.parts { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-6); margin-top: var(--sp-4); }
.part .name { color: var(--muted); font-size: var(--fs-sm); }
.part .value { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.headline .month-line { margin-top: var(--sp-4); font-size: var(--fs-sm); color: var(--muted); }
.headline .month-line a { color: inherit; }
.overview-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 0; }

/* A strip of figures side by side, divided by hairlines (portfolio). */
.figures-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-4); }
.figures-strip > div { padding: var(--sp-3) var(--sp-4) var(--sp-3) 0; }
.figures-strip > div + div { padding-left: var(--sp-4); border-left: 1px solid var(--line); }
.figures-strip .name { color: var(--muted); font-size: var(--fs-xs); }
.figures-strip .value { font-size: var(--fs-lg); font-variant-numeric: tabular-nums; white-space: nowrap; }
.figures-strip .note { color: var(--muted); font-size: var(--fs-xs); }

/* -------------------------------------------------------- transactions */

.toolbar { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-4); }
.month-switch { display: inline-flex; align-items: center; gap: var(--sp-1); }
.month-switch .current { min-width: 9.5rem; text-align: center; font-weight: 600; }
.search { flex: 1 1 14rem; max-width: 22rem; }
.tx-layout { display: grid; grid-template-columns: minmax(0, 1fr) 19rem; gap: var(--sp-6); align-items: start; }
.tx-summary { position: sticky; top: var(--sp-5); }
.tx-summary .side + .side { margin-top: var(--sp-5); }
.tx-summary .total { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; white-space: nowrap; }
.tx-summary .conv { font-size: var(--fs-xs); color: var(--muted); margin-top: 2px; }
.cat-row { display: flex; justify-content: space-between; gap: var(--sp-3); font-size: var(--fs-sm); padding: 5px 0; border-bottom: 1px solid var(--line); }
.cat-row .name { min-width: 0; overflow-wrap: anywhere; }
.day-head { display: flex; justify-content: space-between; font-size: var(--fs-sm); font-weight: 600; color: var(--muted); padding: var(--sp-5) 0 var(--sp-2); border-bottom: 1px solid var(--line); }
.day-group:first-child .day-head { padding-top: 0; }
.tx-row { grid-template-columns: minmax(0, 1fr) auto auto; }
.tx-row .amount { font-weight: 500; }
.edit-slot { padding: var(--sp-3) 0 var(--sp-4); border-bottom: 1px solid var(--line); }

/* ------------------------------------------------------------ charts */

figure { margin: 0; }
.chart { margin-top: var(--sp-5); }
.chart-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); margin-bottom: var(--sp-2); }
.chart-head h3 { font-size: var(--fs-md); }
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-1) var(--sp-4); font-size: var(--fs-xs); color: var(--muted); list-style: none; margin: 0; padding: 0; }
.legend li { display: inline-flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 14px; height: 0; border-top: 2px solid currentColor; }
.swatch.value { color: var(--accent); }
.swatch.cost { color: var(--muted); border-top-style: dashed; }
.swatch.gain { color: var(--ink); }
.swatch.zero { color: var(--line-strong); }
.swatch.bar { height: 10px; width: 10px; border: 0; border-radius: 2px; background: currentColor; }
.swatch.income { color: var(--income); }
.swatch.expense { color: var(--expense-bar); }
.plot-wrap { display: grid; grid-template-columns: auto minmax(0, 1fr); column-gap: var(--sp-2); padding-top: var(--sp-2); }
.share-row > .num { text-align: right; }
.y-axis { position: relative; min-width: 2.5rem; font-size: var(--fs-xs); color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.y-axis span { position: absolute; right: 0; transform: translateY(-50%); white-space: nowrap; line-height: 1; }
.plot { position: relative; height: 180px; }
.plot.short { height: 120px; }
.plot svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; display: block; }
.x-axis { grid-column: 2; position: relative; height: 20px; font-size: var(--fs-xs); color: var(--muted); }
.x-axis span { position: absolute; top: 4px; transform: translateX(-50%); white-space: nowrap; }
.x-axis span.first { transform: none; }
.x-axis span.last { transform: translateX(-100%); }
.x-axis span.mark { color: var(--warn); }
.chart .grid { stroke: var(--line); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .zero { stroke: var(--line-strong); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart .line { fill: none; stroke-width: 2; vector-effect: non-scaling-stroke; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.value, .chart .line.total { stroke: var(--accent); }
.chart .line.cost { stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 5 4; }
.chart .line.gain { stroke: var(--ink); stroke-width: 1.75; }
.chart .bar.income, .share .bar.income { fill: var(--income); }
.chart .bar.expense, .share .bar.expense { fill: var(--expense-bar); }
.chart .bar.incomplete { opacity: 0.55; }
.chart-note { font-size: var(--fs-xs); color: var(--muted); margin-top: var(--sp-2); }
.charts-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 var(--sp-6); }

/* Category ranking with a share bar. */
.charts-1 { display: block; }
.share-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(4rem, 10rem) 8.5rem; gap: var(--sp-3); align-items: center; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: var(--fs-sm); }
.share-row .name { overflow-wrap: anywhere; min-width: 0; }
.share svg { display: block; width: 100%; height: 8px; }
.share .track { fill: var(--sunken); }
.stats-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-6); }
.stat-totals { display: flex; flex-wrap: wrap; gap: var(--sp-3) var(--sp-7); padding: var(--sp-4) 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.stat-totals .name { font-size: var(--fs-sm); color: var(--muted); }
.stat-totals .value { font-size: var(--fs-2xl); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; letter-spacing: -0.01em; }
form.controls { display: flex; flex-wrap: wrap; gap: var(--sp-3); align-items: flex-end; margin-bottom: var(--sp-5); }
form.controls .field { margin: 0; flex: 1 1 9rem; max-width: 13rem; }
form.controls button { min-height: 38px; }

/* ----------------------------------------------------------- portfolio */

.account-block { margin-top: var(--sp-6); }
.account-block > h2 { margin-bottom: var(--sp-3); }
.pos-row { grid-template-columns: minmax(0, 1fr) auto; }
.pos-row .title button.link { font-size: var(--fs-md); text-align: left; white-space: normal; }
.pos-row .notes { font-size: var(--fs-xs); color: var(--warn); }
.pos-row .inline-sync { margin-left: var(--sp-2); min-height: 24px; font-size: var(--fs-xs); padding: 0 var(--sp-2); }

/* --------------------------------------------------------- assistant */

.chat { display: flex; flex-direction: column; gap: var(--sp-4); padding-bottom: var(--sp-4); }
.intro { color: var(--muted); font-size: var(--fs-sm); }
.turn .who { font-size: var(--fs-xs); color: var(--muted); margin-bottom: 2px; }
.turn p { white-space: pre-wrap; }
.turn.user { align-self: flex-end; max-width: 85%; background: var(--accent-tint); padding: var(--sp-2) var(--sp-3); border-radius: var(--radius-lg); }
.turn.user .who { text-align: right; }
.turn.assistant { max-width: 100%; }
.turn.question p { color: var(--warn); }
.action-card { border: 1px solid var(--line-strong); border-radius: var(--radius-lg); padding: var(--sp-3) var(--sp-4); margin-top: var(--sp-3); background: var(--surface); }
.action-card .summary { font-weight: 600; margin-bottom: var(--sp-2); }
.action-card dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px var(--sp-4); margin: 0 0 var(--sp-2); font-size: var(--fs-sm); }
.action-card dt { color: var(--muted); }
.action-card dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.action-card .actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.action-card.cancelled, .action-card.done { opacity: 0.7; }
.action-card .status { font-size: var(--fs-sm); color: var(--muted); }
.action-card .error { color: var(--danger); font-size: var(--fs-sm); }
.chat-input {
    position: sticky; bottom: 0; display: flex; gap: var(--sp-2); align-items: flex-end;
    padding: var(--sp-3) 0 var(--sp-4); background: var(--bg); border-top: 1px solid var(--line);
}
.chat-input textarea { flex: 1; }
.chat-input button { min-height: 38px; }
.thinking { color: var(--muted); font-size: var(--fs-sm); }
.chat-notice { color: var(--danger); font-size: var(--fs-sm); }

/* ------------------------------------------------------------ settings */

.subnav { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--line); margin-bottom: var(--sp-5); }
.subnav a { padding: var(--sp-2) var(--sp-3); color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; font-size: var(--fs-sm); }
.subnav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--accent); }
.inline-form { display: flex; flex-wrap: wrap; gap: var(--sp-2); align-items: flex-end; padding: var(--sp-3) 0; }
.inline-form .field { margin: 0; flex: 1 1 9rem; }
.inline-form .field.wide { flex: 2 1 14rem; }
.rename-form { display: flex; gap: var(--sp-2); flex-wrap: wrap; width: 100%; }
.rename-form input { flex: 1 1 12rem; width: auto; }
.lang-switch { display: flex; gap: var(--sp-2); }
.lang-switch a { font-size: var(--fs-sm); }
.lang-switch a[aria-current="true"] { color: var(--ink); font-weight: 600; text-decoration: none; }

/* The «Ещё» list on the phone. */
.menu { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.menu li { border-bottom: 1px solid var(--line); }
.menu a, .menu button { display: flex; width: 100%; justify-content: flex-start; gap: var(--sp-3); align-items: center; padding: var(--sp-4) 0; min-height: 52px; color: var(--ink); text-decoration: none; font-size: var(--fs-md); font-weight: 400; border: 0; border-radius: 0; background: none; }
.menu svg { color: var(--muted); }

/* ------------------------------------------------------------- dialog */

dialog.add-dialog {
    width: min(30rem, calc(100vw - 32px)); max-height: calc(100vh - 32px);
    padding: 0; border: 1px solid var(--line); border-radius: var(--radius-lg);
    background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog.add-dialog::backdrop { background: rgb(10 14 15 / 0.42); }
.dialog-head { display: flex; justify-content: space-between; align-items: center; padding: var(--sp-4) var(--sp-4) 0; }
.dialog-body { padding: var(--sp-4); }
.dialog-body .segmented { width: 100%; margin-bottom: var(--sp-4); }
.dialog-body .segmented button { flex: 1; }
.amount-field input { font-size: var(--fs-2xl); min-height: 52px; font-variant-numeric: tabular-nums; font-weight: 500; }
.amount-field .with-code { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--sp-2); }
.amount-field .with-code .code { font-size: var(--fs-lg); margin: 0; }
@media (prefers-reduced-motion: no-preference) {
    dialog.add-dialog[open] { animation: dialog-in 120ms ease-out; }
    @keyframes dialog-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
}

/* ------------------------------------------------------------ states */

.skeleton { display: flex; flex-direction: column; gap: var(--sp-3); }
.skeleton i { display: block; height: 14px; border-radius: 4px; background: var(--skeleton); }
.skeleton i.big { height: 40px; width: 16rem; max-width: 70%; }
.skeleton i.w80 { width: 80%; }
.skeleton i.w60 { width: 60%; }
.skeleton i.w40 { width: 40%; }
.skeleton .gap { height: var(--sp-4); }
@media (prefers-reduced-motion: no-preference) {
    .skeleton i { animation: pulse 1.6s ease-in-out infinite; }
    @keyframes pulse { 50% { opacity: 0.45; } }
}
.empty { color: var(--muted); padding: var(--sp-5) 0; }
.foot-notes { margin-top: var(--sp-3); font-size: var(--fs-xs); color: var(--muted); display: flex; flex-direction: column; gap: 2px; }

/* ------------------------------------------------------------ sign-in */

.signin { min-height: 100vh; display: grid; place-items: center; padding: var(--sp-4); }
.signin form { width: min(22rem, 100%); }
.signin .brand { padding: 0; margin-bottom: var(--sp-1); font-size: var(--fs-2xl); }
.signin .lead { color: var(--muted); margin-bottom: var(--sp-5); font-size: var(--fs-sm); }
.signin .form-actions { flex-direction: column; align-items: stretch; }
.signin .form-actions button { min-height: 40px; }

/* The "changed elsewhere" comparison. */
.conflict { border-color: var(--warn); margin-bottom: var(--sp-5); }
.conflict h2 { color: var(--warn); margin-bottom: var(--sp-2); }
.conflict p { margin-bottom: var(--sp-3); font-size: var(--fs-sm); }

/* ---------------------------------------------------- narrow screens */

@media (max-width: 1100px) {
    .tx-layout { grid-template-columns: minmax(0, 1fr); }
    .tx-summary { position: static; order: -1; display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
    .tx-summary .side + .side { margin-top: 0; }
    .charts-2 { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
    :root { --fs-3xl: 34px; --fs-2xl: 22px; }
    .shell { display: block; }
    .sidebar { display: none; }
    .topbar {
        display: flex; position: sticky; top: 0; z-index: 5;
        align-items: center; justify-content: space-between; gap: var(--sp-3);
        height: 52px; padding: 0 var(--sp-4);
        background: var(--bg); border-bottom: 1px solid var(--line);
    }
    .topbar .title { font-weight: 600; font-size: var(--fs-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .main { padding: var(--sp-4) var(--sp-4) calc(var(--tabbar) + var(--sp-6) + env(safe-area-inset-bottom)); }
    .page-head { margin-bottom: var(--sp-4); }
    .page-head h1.screen-title { display: none; }
    .page-head:not(:has(.crumbs, .tools, .sub)) { display: none; }
    .tabbar {
        display: grid; grid-template-columns: repeat(5, 1fr);
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
        height: calc(var(--tabbar) + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface); border-top: 1px solid var(--line);
    }
    .tab {
        display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        color: var(--muted); text-decoration: none; font-size: 11px; font-weight: 500;
    }
    .tab[aria-current="page"] { color: var(--accent); }
    .row.cols-3 { grid-template-columns: minmax(0, 1fr) auto; }
    .row.cols-3 .own { grid-column: 2; grid-row: 1; }
    .row.cols-3 .conv { grid-column: 2; grid-row: 2; color: var(--muted); font-size: var(--fs-sm); }
    .row.head.cols-3 { display: none; }
    .tx-row { grid-template-columns: minmax(0, 1fr) auto; }
    .tx-row .label { grid-column: 1; grid-row: 1 / span 2; }
    .tx-row .figures { grid-column: 2; grid-row: 1; }
    .tx-row .row-actions { grid-column: 2; grid-row: 2; }
    .tx-row .row-actions button { min-height: 24px; }
    .tx-summary { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
    .tx-summary .total { font-size: var(--fs-lg); }
    .search { max-width: none; flex-basis: 100%; }
    .month-switch { width: 100%; justify-content: space-between; }
    .stats-cols { grid-template-columns: minmax(0, 1fr); gap: 0; }
    .stat-totals { gap: var(--sp-3) var(--sp-5); }
    .stat-totals .value { font-size: var(--fs-xl); }
    form.controls .field { max-width: none; flex-basis: calc(50% - var(--sp-3)); }
    form.controls button { flex: 1 1 100%; }
    .share-row { grid-template-columns: minmax(0, 1fr) auto; }
    .share-row .share { grid-column: 1 / -1; grid-row: 2; }
    .figures-strip { grid-template-columns: 1fr 1fr; }
    .figures-strip > div:nth-child(odd) { padding-left: 0; border-left: 0; }
    .figures-strip > div:nth-child(n+3) { border-top: 1px solid var(--line); }
    .grid-2 { grid-template-columns: minmax(0, 1fr); }
    .plot { height: 150px; }
    dialog.add-dialog { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border: 0; border-radius: 0; }
    .headline .amount .code { font-size: var(--fs-lg); }
    .parts { gap: var(--sp-3) var(--sp-5); }
    .turn.user { max-width: 92%; }
    .chat-input { bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
}
.inline-form button, .rename-form button { min-height: 38px; }
.title .badge { margin-left: var(--sp-2); vertical-align: 1px; }
.figures-strip > div { min-width: 0; }
.figures-strip .absent-text { font-size: var(--fs-sm); color: var(--warn); white-space: normal; padding-top: 3px; }
.row .figures { min-width: 0; }
@media (max-width: 720px) {
    .pos-row { grid-template-columns: minmax(0, 1fr); }
    .pos-row .figures { text-align: left; display: flex; flex-wrap: wrap; gap: 0 var(--sp-3); align-items: baseline; }
}
.panel > p.small:first-child { margin-bottom: var(--sp-4); }

/* The operations table fits the content column on a desktop instead of
   scrolling sideways in its box (with scrollbars hidden that read as clipped
   buttons): the note and "after" cells wrap, the kind select takes its
   content's width, and only a narrow screen scrolls. */
@media (min-width: 721px) {
    .table-scroll table.ops-table { min-width: 0; }
}
.ops-table td.source { white-space: normal; max-width: 13rem; }
.ops-table td.after { white-space: nowrap; }
.ops-table td select { min-width: 0; }
/* Headers wrap: «После: количество, стоимость покупки» on one line made its
   column 261px — the table's overflow at 1440px was that header alone. */
.ops-table th { white-space: normal; vertical-align: bottom; }
.ops-table th.figure { max-width: 9rem; }

/* ----------------------------------------- operations as cards

   Below the width the eight columns need, each operation is two lines and
   nothing scrolls sideways: day · kind · quantity · price (· commission)
   first; the source with its notes, the "after" figures and the actions
   second. A container query, so the decision is the column's width, not a
   guess about the window: on the rig the table needs 927px (at a 1200px
   window it overflowed a 904px column), so the cards take over at 960px of
   column — a window of about 1256px beside the sidebar, every phone, and the
   1180px the owner named with room to spare. The markup stays a table (with explicit roles, see
   operationsScreen); the column headers stay for a screen reader, and the
   figures whose place no longer names them carry their `data-label`. */
.ops-scroll { container: ops / inline-size; }
@container ops (max-width: 960px) {
    .table-scroll table.ops-table { min-width: 0; }
    .ops-table, .ops-table tbody { display: block; }
    .ops-table thead {
        position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
        overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
    }
    .ops-table tr {
        display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-3);
        padding: var(--sp-3) 0; border-bottom: 1px solid var(--line);
    }
    .ops-table td { display: block; padding: 0; border: 0; min-width: 0; max-width: none; text-align: left; }
    .ops-table td.day { order: 1; color: var(--muted); }
    .ops-table td.kind { order: 2; }
    .ops-table td.qty { order: 3; font-weight: 600; }
    .ops-table td.price { order: 4; }
    .ops-table td.commission { order: 5; }
    .ops-table td.commission:empty { display: none; }
    /* The line break: a zero-height item as wide as the row. */
    .ops-table tr::after { content: ""; order: 6; flex-basis: 100%; height: 0; }
    .ops-table td.source { order: 7; flex: 1 1 8rem; white-space: normal; }
    .ops-table td.after { order: 8; display: flex; gap: var(--sp-2); }
    .ops-table td.actions { order: 9; margin-left: auto; width: auto; min-width: 0; display: flex; flex-wrap: wrap; gap: var(--sp-1); }
    .ops-table td.actions button { display: inline-flex; width: auto; margin: 0; }
    .ops-table td[data-label]:not(:empty)::before {
        content: attr(data-label); color: var(--muted); font-size: var(--fs-xs); margin-right: var(--sp-1);
    }
    .ops-table td.price .mark { display: inline; margin-left: var(--sp-1); }
    .ops-table td select { min-height: 30px; }
    .ops-table tr.edit-row { display: block; padding-top: 0; }
    .ops-table tr.edit-row td { display: block; }
    .ops-table tr.edit-row::after { content: none; }
}

/* ------------------------------------- row actions on a touch screen

   With no hover to reveal them, Edit and Delete showed on every row. They
   now show for the tapped row only. The tap lands on `.row-toggle`, a real
   button stretched over the row (transparent; its focus ring is the row's),
   so the state is announced (`aria-expanded`) and a keyboard reaches it; the
   row's own buttons sit above it. A row being edited, or waiting for the
   second click of a delete, keeps its actions (`.pinned`). */
.row-toggle { display: none; }
@media (hover: none) {
    .tx-row { position: relative; }
    .tx-row .row-toggle {
        display: block; position: absolute; inset: 0; z-index: 0;
        width: auto; min-height: 0; padding: 0; margin: 0;
        border: 0; border-radius: var(--radius); background: transparent;
        -webkit-tap-highlight-color: transparent;
    }
    .tx-row .row-toggle:focus-visible { outline-offset: 0; }
    .tx-row .row-actions { position: relative; z-index: 1; }
    .tx-row:not(.selected) .row-actions:not(.pinned) { display: none; }
    .tx-row.selected { background: var(--sunken); box-shadow: -8px 0 0 var(--sunken), 8px 0 0 var(--sunken); }
}

/* ------------------------------------------------- chart readout */

.plot { touch-action: pan-y; }
.plot:focus-visible { outline-offset: 4px; }
.readout-layer { position: absolute; inset: 0; pointer-events: none; }
.readout-rule { position: absolute; top: 0; bottom: 0; width: 0; border-left: 1px solid var(--line-strong); }
.readout-band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, var(--ink) 7%, transparent); border-radius: 2px; }
.readout-dot {
    position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%;
    background: var(--bg); border: 2px solid currentColor;
}
.readout-dot.value, .readout-dot.total { color: var(--accent); }
.readout-dot.cost { color: var(--muted); }
.readout-dot.gain { color: var(--ink); }
.readout {
    position: absolute; top: var(--sp-1); z-index: 2; pointer-events: none;
    min-width: 11rem; max-width: 16rem; padding: var(--sp-2) var(--sp-3);
    background: var(--surface); color: var(--ink); border: 1px solid var(--line-strong);
    border-radius: var(--radius); box-shadow: 0 4px 14px rgb(20 30 30 / 0.12);
    font-size: var(--fs-xs); line-height: 1.4;
}
.readout.bottom { top: auto; bottom: var(--sp-1); }
.readout.start { margin-left: var(--sp-2); }
.readout.middle { transform: translateX(-50%); }
.readout.end { transform: translateX(-100%); margin-left: calc(-1 * var(--sp-2)); }
.readout-title { font-weight: 600; margin-bottom: 2px; white-space: nowrap; }
.readout dl { display: grid; grid-template-columns: auto auto; gap: 1px var(--sp-3); margin: 0; }
.readout dt { color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.readout dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 500; }
.readout dd.missing { color: var(--muted); font-weight: 400; font-style: italic; }
@media (prefers-color-scheme: dark) {
    .readout { box-shadow: 0 4px 14px rgb(0 0 0 / 0.45); }
}

/* ------------------------------------- operations actions on a touch screen
   One «Действия» button per operation opens its three actions in place; a
   mouse never sees it. The row's kind select stays directly tappable, which
   an overlay like the transaction rows' would have covered. */
/* As specific as `td.actions button`, which would otherwise show it to a mouse. */
.ops-table td.actions .ops-toggle { display: none; }
@media (hover: none) {
    .ops-table td.actions .ops-toggle { display: block; }
    .ops-table td.actions:not(.open) > button:not(.ops-toggle) { display: none; }
}

/* Reference-led workspace: quiet canvas, clear cards, compact daily lists. */
.sidebar { background: var(--surface); padding-top: 28px; }
.brand { display: flex; align-items: center; gap: 9px; font-size: 16px; }
.brand::before { content: ""; width: 24px; height: 24px; border: 5px solid var(--accent); border-radius: 50%; box-shadow: inset -3px -3px 0 var(--income); flex: none; }
.place { font-size: var(--fs-sm); min-height: 38px; }
.main { padding: 28px; }
.page { max-width: 1440px; margin-inline: auto; }
.page.narrow { max-width: 760px; margin-inline: 0; }
.page-head { align-items: center; margin-bottom: 20px; }
h1 { font-size: 22px; letter-spacing: -.025em; }
h2 { font-size: 15px; }
.panel, section.block, .headline, .chart, .account-block, .transaction-panel, form.controls, .menu, .signin form {
    background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
    padding: 20px; box-shadow: 0 1px 3px rgb(20 25 20 / .035);
}
section.block, .account-block { margin-top: 16px; }
.chart { margin-top: 16px; }
.headline > .chart { border: 0; box-shadow: none; padding: 20px 0 0; border-top: 1px solid var(--line); border-radius: 0; }
.parts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.part { background: var(--bg); padding: 14px; border: 1px solid var(--line); border-radius: 8px; }
.part .value { margin-top: 4px; font-weight: 600; white-space: normal; overflow-wrap: anywhere; }
.stat-totals, .figures-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; border: 0; padding: 0; margin-bottom: 16px; }
.stat-totals > div, .figures-strip > div, .figures-strip > div + div { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; min-width: 0; }
.stat-totals .value { font-size: 24px; margin-top: 4px; white-space: normal; overflow-wrap: anywhere; }
.figures-strip .value { white-space: normal; overflow-wrap: anywhere; }
.toolbar { margin-bottom: 12px; }
.toolbar .search { max-width: none; }
.tx-layout { display: flex; flex-direction: column; gap: 16px; }
.tx-layout > * { width: 100%; }
.tx-summary { position: static; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; order: -1; }
.tx-summary .side { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.tx-summary .side + .side { margin: 0; }
.tx-summary .total { margin-top: 4px; font-weight: 600; }
.transaction-panel { padding: 16px 0 0; overflow: hidden; }
.transaction-panel > .toolbar, .transaction-panel > .tx-filters, .transaction-panel > .tx-count { margin-inline: 16px; }
.tx-filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.tx-filters select { width: auto; max-width: 100%; flex: 1 1 140px; font-size: 13px; }
.tx-count { font-size: var(--fs-xs); color: var(--muted); padding-bottom: 10px; }
.day-head, .day-group:first-child .day-head { background: var(--bg); padding: 7px 16px; font-size: 12px; border-block: 1px solid var(--line); }
.tx-list .rows { border-top: 0; }
.tx-row { padding: 10px 16px; font-size: 13px; }
.tx-row .meta { font-size: 12px; }
.tx-row .title { font-weight: 500; }
.tx-row:hover { background: var(--bg); }
.edit-slot { padding: 16px; }
.breakdown-layout { display: grid; grid-template-columns: 160px minmax(0, 1fr); align-items: start; gap: 24px; }
.donut { position: relative; width: 160px; aspect-ratio: 1; margin: 16px auto; }
.donut svg { display: block; width: 100%; height: 100%; transform: rotate(-90deg); }
.donut-center { position: absolute; inset: 26%; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; font-size: 12px; color: var(--muted); }
.donut-center .num { font-size: 17px; font-weight: 600; color: var(--ink); white-space: normal; overflow-wrap: anywhere; }
.category-dot { display: inline-block; width: 7px; height: 7px; border-radius: 2px; margin-right: 6px; background: var(--category-color); }
.breakdown-ranking .share-row { grid-template-columns: minmax(0, 1fr) auto; gap: 5px 12px; }
.breakdown-ranking .share { grid-column: 1 / -1; grid-row: 2; }
.breakdown-ranking .share svg { height: 4px; }
.breakdown-ranking .share .bar { fill: var(--category-color); }
.menu { padding-block: 4px; }
.menu li:last-child { border-bottom: 0; }
.signin form { padding: 28px; }
@media (max-width: 900px) { .breakdown-layout { grid-template-columns: minmax(0, 1fr); gap: 0; } }
@media (max-width: 720px) {
    .main { padding: 12px 12px calc(var(--tabbar) + 24px + env(safe-area-inset-bottom)); }
    .topbar { background: var(--bg); padding-inline: 16px; }
    .topbar .title { font-size: 17px; }
    .topbar .compact .button-label { font-size: 12px; }
    .page-head { margin-bottom: 12px; }
    .panel, section.block, .headline, .chart, .account-block, form.controls { padding: 16px; }
    .stat-totals, .figures-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
    .stat-totals > div, .figures-strip > div, .figures-strip > div + div { padding: 12px; border: 1px solid var(--line); }
    .stat-totals .value { font-size: 20px; }
    .tx-summary { gap: 8px; }
    .tx-summary .side { padding: 12px; min-width: 0; }
    .tx-summary .total { white-space: normal; overflow-wrap: anywhere; }
    .tx-row { padding: 10px 12px; min-height: 54px; }
    .tx-row .row-actions button { min-height: 44px; }
    .tx-filters { gap: 6px; }
    .tx-filters select { flex-basis: 40%; min-width: 0; }
    input, select, textarea { font-size: 16px; }
    button, .button, .segmented button { min-height: 44px; }
    .tab[aria-current="page"] svg { background: var(--accent-tint); box-shadow: 0 0 0 6px var(--accent-tint); border-radius: 4px; }
    dialog.add-dialog { padding-bottom: env(safe-area-inset-bottom); }
}

/* Classes preserve category colors under the self-only style CSP. */
.category-0 { --category-color: #327acc; }
.category-1 { --category-color: #e6a000; }
.category-2 { --category-color: #24a483; }
.category-3 { --category-color: #ce729e; }
.category-4 { --category-color: #8975bb; }
.category-5 { --category-color: #62a5ad; }
.category-6 { --category-color: #9b957f; }
.category-7 { --category-color: #748897; }

.tx-table-head, .tx-category, .tx-account, .tx-tags { display: none; }
@media (min-width: 1101px) {
    .tx-row, .tx-table-head { display: grid; grid-template-columns: minmax(160px, 2fr) minmax(100px, 1fr) minmax(120px, 1fr) 110px minmax(100px, auto); gap: 12px; }
    .tx-table-head { padding: 8px 16px; color: var(--muted); font-size: 12px; }
    .tx-category, .tx-account { display: block; min-width: 0; overflow-wrap: anywhere; font-size: 12px; color: var(--muted); }
    .tx-row .meta { display: none; }
    .tx-tags { display: block; color: var(--muted); font-size: 12px; }
}

.flow-scroll { overflow-x: auto; padding: 24px 0; }
.flow-scroll > svg { display: block; width: 100%; max-width: 960px; min-width: 760px; margin: auto; }
.flow-label { font: 12px var(--font); fill: var(--ink); }

.bulk-toolbar { padding: 0 16px 12px; }
.bulk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--accent-tint); }
.bulk-actions select { width: auto; max-width: 180px; }
.tx-selection { display: flex; align-items: center; gap: 10px; }
.tx-select { position: relative; z-index: 2; flex: none; }
@media (pointer: coarse) { .tx-select { width: 24px; height: 24px; } }

@media (max-width: 760px) {
    .pnl-panel > .figures-strip > div:first-child { grid-column: 1 / -1; }
}

/* Protocol positions use the same surface and type scale as the portfolio. */
.defi-card { border: 1px solid var(--line); border-radius: 12px; padding: 18px; margin: 16px 0; }
.defi-heading, .defi-position summary, .defi-leg, .defi-actions { display: flex; justify-content: space-between; gap: 16px; align-items: baseline; }
.defi-heading h3 { margin: 0 0 4px; }
.defi-address { overflow-wrap: anywhere; }
.defi-figure { display: flex; flex-direction: column; gap: 4px; }
.defi-position { border-top: 1px solid var(--line); padding: 12px 0; }
.defi-position summary { cursor: pointer; }
.defi-position summary::before { content: '+'; color: var(--muted, #777); }
.defi-position[open] summary::before { content: '−'; }
.defi-metrics { display: grid; grid-template-columns: repeat(auto-fit,minmax(120px,1fr)); gap: 16px; padding: 16px 0; }
.defi-leg { padding: 5px 0; }
.defi-form { display: grid; gap: 14px; padding-top: 18px; max-width: 600px; }
.defi-form label { display: grid; gap: 6px; }
.defi-actions { margin-top: 16px; }
@media(max-width:600px) { .defi-heading { flex-direction:column; gap:12px; } .defi-card { padding:12px; } .defi-position summary { flex-wrap:wrap; } }

.defi-card > label { display: flex; align-items: center; gap: 12px; justify-content: space-between; }
.defi-figure > .muted { font-size: 13px; }

.defi-position summary > span { margin-right: auto; }

/* Keep today's figures and recent activity beside bounded history. */
.overview-headline { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px 28px; align-items: start; }
.worth-summary { min-width: 0; }
.overview-headline .amount { margin: 6px 0 0; overflow-wrap: anywhere; }
.overview-headline > .overview-history { margin: 0; padding: 0 0 0 24px; border: 0; border-left: 1px solid var(--line); min-width: 0; }
.overview-headline > .fold { grid-column: 1 / -1; margin: 0; }
.overview-headline .parts { margin-top: 16px; gap: 8px; }
.overview-headline .part { padding: 8px 10px; }
.overview-month { margin-top: 20px; }
.month-heading { font-size: var(--fs-sm); font-weight: 500; }
.month-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 10px; }
.month-figures .name { font-size: var(--fs-sm); color: var(--muted); }
.month-figures .value { font-size: 20px; font-weight: 600; overflow-wrap: anywhere; margin-top: 3px; }
.pnl-panel .figures-strip { margin-top: 14px; }
.pnl-panel .figures-strip > div { border: 0; border-radius: 0; background: var(--bg); padding: 12px; }
.pnl-panel .figures-strip > div:first-child { border-left: 3px solid var(--accent); }
.portfolio-history, .secondary-chart { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 20px; }
.portfolio-history > summary, .secondary-chart > summary { font-weight: 500; }
.secondary-chart > .chart { padding: 0; box-shadow: none; border: 0; }
.flow-table { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.flow-table > p { grid-column: 1 / -1; }
.flow-table > section.block { padding: 0; border: 0; box-shadow: none; }
.flow-table .row { grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; }
.flow-table .row > :first-child { min-width: 0; overflow-wrap: anywhere; }
.flow-table .num { text-align: right; }
summary { min-height: 32px; padding-block: 6px; }
@media (max-width: 1100px) {
    .overview-headline { grid-template-columns: minmax(0, 1fr); }
    .overview-headline > .overview-history { padding: 12px 0 0; border-left: 0; border-top: 1px solid var(--line); }
    .flow-table { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 900px) {
    .breakdown-layout .donut { display: none; }
}
@media (max-width: 720px) {
    .overview-headline { gap: 16px; }
    .overview-headline .plot.short { height: 88px; }
    .overview-headline .chart-head .legend { display: none; }
    .overview-month { margin-top: 16px; }
    .month-figures .value { font-size: 18px; }
    .plot { height: 144px; }
    .chart-head h3 { font-size: 13px; }
    .stat-totals .value { font-size: 18px; }
    .breakdown-ranking .share-row { gap: 6px 10px; padding-block: 10px; }
    .breakdown-ranking .name { overflow-wrap: anywhere; }
    summary { min-height: 44px; }
}
/* Compact account groups have their own boundary and header; a row's
   original balance stays visually paired with its secondary conversion. */
.accounts-panel .block-head { margin-bottom: 12px; }
.account-groups { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.account-groups .group { min-width: 0; margin: 0; border: 1px solid var(--line-strong); border-radius: 8px; overflow: hidden; }
.account-groups .group .group-title { margin: 0; padding: 9px 12px; background: var(--bg); color: var(--ink); font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--line); }
.account-groups .rows { padding: 0 12px; }
.account-row { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center; min-height: 44px; padding: 6px 0; font-size: 13px; line-height: 1.35; }
.account-row:last-child { border-bottom: 0; }
.account-row .title { overflow-wrap: anywhere; }
.account-row .figures { text-align: right; font-weight: 500; }
.account-row .figures .secondary { font-size: 12px; font-weight: 400; }
.accounts-panel .foot-notes:empty { display: none; }
.more-categories { margin-top: 10px; }
@media (min-width: 1400px) { .account-groups { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 900px) { .account-groups { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 720px) {
    .account-row { gap: 12px; }
    .account-row .figures { max-width: 48vw; overflow-wrap: anywhere; }
    .figures-strip .value { white-space: normal; overflow-wrap: anywhere; }
}

.overview-history > summary { font-weight: 500; font-size: var(--fs-sm); }
.overview-history > .chart { border: 0; box-shadow: none; padding: 8px 0 0; margin: 0; }
.overview-history .chart-head { display: none; }
@media (max-width: 720px) {
    form.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
    form.controls .field { min-width: 0; max-width: none; }
    form.controls input, form.controls select { min-width: 0; width: 100%; }
    form.controls button { grid-column: 1 / -1; }
}

/* October reference redesign: mint header, warm canvas, readable daily cards.
   The desktop workspace and compact mobile navigation share the same controls. */
:root {
    --bg: #f8f8f3; --surface: #fff; --sunken: #f0f5f2; --ink: #3c4439;
    --muted: #758076; --line: #e3ebe5; --line-strong: #cddbd3;
    --accent: #26815f; --accent-ink: #fff; --accent-tint: #e7f3ec;
    --hero: #629e88; --hero-ink: #fff; --gold: #ffc62b;
    --income: #418e73; --expense: #3c4439; --expense-bar: #efb627;
    --radius: 10px; --radius-lg: 18px; --sidebar: 216px;
    --shadow: 0 12px 38px rgb(29 61 45 / .14);
}
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #151d19; --surface: #1e2923; --sunken: #25342c; --ink: #e6ede7;
        --muted: #a4b6a9; --line: #314339; --line-strong: #435b4c;
        --accent: #8acbb0; --accent-ink: #163528; --accent-tint: #2c493b;
        --hero: #335f4e; --hero-ink: #fff; --gold: #f5c744;
        --income: #89c5a9; --expense: #e6ede7; --expense-bar: #e8b94d;
    }
}
body { line-height: 1.45; }
button, .button { min-height: 38px; }
input, select { min-height: 42px; }
.sidebar { border: 0; box-shadow: 1px 0 0 var(--line); padding: 30px 16px 20px; }
.brand { color: var(--accent); font-size: 20px; gap: 10px; margin-bottom: 22px; }
.brand::before { width: 24px; height: 24px; border-width: 3px; box-shadow: inset 0 0 0 4px var(--surface), inset 0 0 0 6px var(--accent); }
.sidebar .add-button { background: var(--gold); border-color: var(--gold); color: #3d3b26; min-height: 44px; border-radius: 12px; }
.place { min-height: 44px; padding: 10px 12px; font-size: 14px; border-radius: 10px; }
.place[aria-current="page"] { background: var(--accent-tint); }
.places { gap: 5px; }
.main { padding: 24px 28px 48px; }
.page { max-width: 1256px; }
.page.narrow { max-width: 960px; margin-inline: auto; }
.page-head { background: var(--hero); color: var(--hero-ink); padding: 22px 26px; border-radius: 20px; margin-bottom: 22px; min-height: 78px; }
.page-head h1 { font-size: 23px; font-weight: 600; letter-spacing: -.025em; }
.page-head .sub, .page-head .crumbs, .page-head .crumbs a { color: #eef8f2; }
.page-head .button, .page-head button { background: rgb(255 255 255 / .14); color: #fff; border-color: rgb(255 255 255 / .28); }
.panel, section.block, .headline, .chart, .account-block, .transaction-panel, form.controls, .menu, .signin form {
    border-radius: 18px; border-color: transparent; box-shadow: 0 4px 18px rgb(36 62 46 / .055);
}
h2 { font-size: 16px; font-weight: 600; }
.row { border-color: var(--line); }
.row .title { font-weight: 500; }
.num .code { margin-left: .3em; }
.balance-hero { background: var(--hero); color: var(--hero-ink); border-radius: 22px 22px 0 0; padding: 18px 28px 0; text-align: center; }
.page-overview .page-head { margin-bottom: 0; border-radius: 20px 20px 0 0; min-height: 64px; padding-bottom: 12px; }
.page-overview .balance-hero { border-radius: 0; padding-top: 0; }
.balance-heading { display: flex; justify-content: center; position: relative; align-items: center; }
.balance-visibility { position: absolute; right: 0; }
.balance-hero button, .transaction-header button { color: var(--hero-ink); }
.balance-hero .code { color: #edf8f1; font-size: .5em; }
.account-selector { background: transparent; border: 0; color: inherit; font-size: 19px; min-height: 42px; gap: 10px; max-width: 100%; white-space: normal; }
.account-selector:hover { background: rgb(255 255 255 / .1); }
.account-selector > span:not(.chevron) { overflow-wrap: anywhere; }
.chevron { font-size: 19px; line-height: 1; }
.hero-amount { font-size: clamp(30px, 3vw, 40px); font-weight: 650; letter-spacing: -.025em; margin: 4px 0 2px; }
.hero-caption { font-size: 12px; color: #e4f2eb; margin-bottom: 14px; }
.activity-tabs { display: flex; justify-content: center; gap: 36px; padding-top: 6px; }
.activity-tabs button { background: none; border: 0; border-radius: 0; color: inherit; padding: 12px 16px; min-height: 48px; font-size: 15px; font-weight: 600; opacity: .7; border-bottom: 3px solid transparent; }
.activity-tabs button[aria-pressed="true"] { opacity: 1; border-bottom-color: currentColor; }
.activity-tabs button:hover { opacity: 1; }
.activity-panel { position: relative; background: var(--surface); border-radius: 20px; padding: 0 24px 22px; box-shadow: 0 6px 22px rgb(36 62 46 / .08); margin-top: -1px; }
.period-controls { position: relative; padding: 14px 0 10px; }
.period-tabs { display: flex; justify-content: center; gap: 10px; }
.period-tabs button { color: var(--muted); border: 0; background: none; border-radius: 0; min-height: 40px; padding: 8px 12px; font-size: 14px; border-bottom: 3px solid transparent; }
.period-tabs button[aria-pressed="true"] { color: var(--accent); border-bottom-color: var(--accent); font-weight: 650; }
.period-navigation { display: flex; align-items: center; justify-content: center; gap: 30px; margin: 10px auto 0; max-width: 480px; }
.period-navigation > .icon { color: var(--accent); flex: none; }
.period-current { border: 0; background: none; font-size: 16px; color: var(--muted); font-weight: 500; text-decoration: underline; text-underline-offset: 4px; white-space: normal; text-align: center; }
.period-current svg { flex: none; opacity: .65; }
.period-today { display: flex; margin: 2px auto 0; font-size: 12px; min-height: 28px; }
.activity-breakdown { display: grid; grid-template-columns: minmax(220px, .8fr) minmax(0, 1.4fr); gap: 20px 40px; align-items: center; }
.activity-chart { position: relative; padding: 10px 24px 16px; max-width: 340px; width: 100%; margin-inline: auto; }
.activity-ring { width: 100%; aspect-ratio: 1; position: relative; max-width: 268px; margin: auto; }
.activity-ring > svg { width: 100%; height: 100%; transform: rotate(-90deg); display: block; }
.ring-track { stroke: var(--line-strong); opacity: .75; }
.ring-inner { stroke: var(--line); }
.activity-ring-label { position: absolute; inset: 25%; display: flex; flex-direction: column; gap: 5px; justify-content: center; align-items: center; text-align: center; }
.activity-ring-label .num { text-align: center; font-size: clamp(16px, 1.6vw, 22px); font-weight: 550; white-space: normal; overflow-wrap: anywhere; }
.activity-ring-label .caption { color: var(--muted); font-size: 12px; }
.activity-ring-label .code { display: block; margin: 0; font-size: 12px; }
.ring-empty { font-size: 16px; line-height: 1.4; color: var(--muted); }
.round-add { width: 48px; height: 48px; border-radius: 50%; border: 0; padding: 0; background: var(--gold); color: #282c20; position: absolute; right: 4px; bottom: 14px; box-shadow: 0 4px 12px rgb(109 89 21 / .14); }
.category-list { min-width: 0; }
.category-list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.category-list-head h2 { font-size: 13px; color: var(--muted); }
.category-list-head button { font-size: 12px; }
.category-card { display: grid; grid-template-columns: 38px minmax(0, 1fr) 44px auto 16px; gap: 12px; width: 100%; padding: 12px 14px; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin-bottom: 8px; min-height: 62px; font-size: 14px; font-weight: 400; white-space: normal; }
.category-card:hover { background: var(--sunken); border-color: var(--line-strong); }
.category-card > svg { color: var(--line-strong); }
.category-name { min-width: 0; overflow-wrap: anywhere; }
.category-percent { text-align: right; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.category-card .num { font-size: 15px; font-weight: 550; }
.category-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--category-color, var(--hero)); color: #fff; }
.category-0 { --category-color: #589cce; } .category-1 { --category-color: #e7ac38; }
.category-2 { --category-color: #55aaa4; } .category-3 { --category-color: #dc6286; }
.category-4 { --category-color: #9277c7; } .category-5 { --category-color: #ed893f; }
.category-6 { --category-color: #91ad7c; } .category-7 { --category-color: #658ea7; }
.lifetime-panel > .chart { box-shadow: none; padding: 0; margin-top: 12px; }
.lifetime-panel .chart-head { display: none; }
.lifetime-panel .plot.short { height: 128px; }
.lifetime-panel > .small { margin-top: 8px; font-size: 11px; }
.workspace-fold { padding-block: 12px !important; }
.workspace-fold > summary { display: flex; gap: 6px; align-items: center; font-weight: 600; color: var(--ink); }
.workspace-fold > section.block { box-shadow: none; padding: 12px 0; }
.account-shortcuts { display: flex; justify-content: center; gap: 18px; margin: 22px 0; flex-wrap: wrap; }
.account-shortcuts button, .account-shortcuts a { border: 0; background: none; flex-direction: column; gap: 8px; font-size: 13px; color: var(--muted); }
.account-shortcuts svg { background: var(--hero); box-sizing: content-box; padding: 12px; color: #fff; border-radius: 16px; }
.account-shortcuts button:hover svg, .account-shortcuts a:hover svg { background: var(--accent); }
.account-groups { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.account-groups .group { border: 0; border-radius: 12px; background: var(--sunken); padding: 0 8px 8px; }
.account-groups .group .group-title { background: transparent; border: 0; font-size: 12px; letter-spacing: .03em; text-transform: uppercase; color: var(--muted); padding: 13px 8px 10px; }
.account-groups .rows { padding: 0; }
.account-row { border: 0; border-radius: 9px; background: var(--surface); padding: 12px; margin-bottom: 6px; min-height: 66px; font-size: 14px; gap: 10px; }
.account-row:last-child { margin-bottom: 0; }
.account-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.account-title .category-icon { width: 32px; height: 32px; }
.account-name { border: 0; padding: 0; min-height: 28px; text-align: left; background: none; white-space: normal; flex: 1; color: var(--ink); font-weight: 500; }
.account-name:hover { color: var(--accent); text-decoration: underline; }
.account-row .figures { font-size: 15px; }
.account-row .figures .secondary { font-size: 12px; margin-top: 3px; }
.workspace-accounts .headline { box-shadow: none; background: transparent; padding: 10px 20px; }
.workspace-accounts .caption { font-size: 14px; }
.workspace-accounts .worth-summary { align-self: center; text-align: center; }
.workspace-accounts .amount { font-size: 36px; }
.workspace-accounts .overview-history { border-left: 0; }
.transaction-header { background: var(--hero); border-radius: 20px 20px 0 0; color: #fff; text-align: center; padding: 14px 20px 0; }
.transaction-panel { padding: 0 24px 20px; border-radius: 18px; margin-top: -1px; overflow: visible; }
.transaction-panel > .toolbar { margin: 8px 0 12px; gap: 16px; align-items: flex-start; }
.transaction-panel .search { flex: 1; max-width: 420px; }
.transaction-panel .search input { background: var(--sunken); border-color: transparent; }
.transaction-filters { min-width: 94px; max-width: 450px; }
.transaction-filters > summary, .report-options > summary { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.transaction-filters[open] { flex: 1; }
.transaction-filters .tx-filters { margin-top: 8px; }
.transaction-filters .bulk-toolbar { padding: 0 0 10px; }
.transaction-list-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 16px 0 4px; }
.transaction-list-heading .tx-count { margin: 0; padding: 0; }
.transaction-totals { display: flex; gap: 24px; flex-wrap: wrap; }
.transaction-totals > div { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.transaction-totals .num { font-size: 17px; font-weight: 600; }
.day-head, .day-group:first-child .day-head { padding: 20px 2px 8px; border: 0; background: none; font-size: 13px; font-weight: 600; }
.tx-list .rows { padding: 0 14px; background: var(--sunken); border: 0; border-radius: 14px; }
.tx-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; padding: 12px 0; min-height: 72px; gap: 12px; font-size: 14px; }
.tx-row:last-child { border: 0; }
.tx-row .label { grid-column: 1; grid-row: 1; }
.tx-row .figures { grid-column: 3; grid-row: 1; align-self: start; padding-top: 6px; }
.tx-row .row-actions { grid-column: 2; grid-row: 1; }
.tx-category, .tx-account, .tx-tags, .tx-table-head { display: none !important; }
.tx-row .meta { display: block; font-size: 12px; padding-left: 48px; margin-top: -7px; }
.tx-selection { align-items: center; gap: 12px; }
.tx-selection .title { font-weight: 600; font-size: 14px; }
.tx-note { font-size: 13px; color: var(--muted); padding-left: 48px; margin-top: 6px; overflow-wrap: anywhere; }
.tx-select { width: 15px; position: absolute; left: -7px; top: 4px; opacity: 0; }
.tx-selection { position: relative; }
.tx-row:hover .tx-select, .tx-select:checked, .tx-select:focus-visible { opacity: 1; }
.tx-row .amount { font-size: 15px; font-weight: 600; }
.tx-row .secondary { font-size: 12px; margin-top: 4px; }
.tx-row:hover { background: transparent; }
.tx-row .row-actions button { font-size: 12px; padding-inline: 7px; }
.tx-row.selected { box-shadow: none; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state > svg { color: var(--hero); }
.report-tabs { background: var(--hero); color: #fff; border-radius: 18px 18px 0 0; }
.report-period { background: var(--surface); border-radius: 18px; padding: 0 20px 12px; margin-bottom: 18px; }
.report-options form.controls { box-shadow: none; padding: 12px 0 0; margin: 0; }
.report-options > summary { min-height: 30px; font-size: 12px; }
.stat-totals { gap: 12px; }
.stat-totals > div { border: 0; border-radius: 14px; box-shadow: 0 3px 14px rgb(36 62 46 / .045); }
.stat-totals .value { font-size: 22px; }
.reports-workspace .chart { padding: 22px; }
.reports-workspace .plot { height: 210px; }
.chart .bar.net { fill: #75b7e5; }
.swatch.net { color: #75b7e5; }
.report-breakdown > h2 { margin-bottom: 16px; }
.report-breakdown .round-add { display: none; }
.segmented, .workspace-tabs { display: flex; gap: 4px; border-radius: 12px; padding: 4px; background: var(--sunken); }
.segmented button, .workspace-tabs button { flex: 1; background: none; border: 0; min-height: 40px; color: var(--muted); }
.segmented button[aria-pressed="true"], .workspace-tabs button[aria-pressed="true"] { background: var(--surface); color: var(--accent); box-shadow: 0 2px 6px rgb(31 60 43 / .06); border-radius: 9px; }
.catalog-workspace > .small { margin-block: 16px 4px; }
.catalog-workspace > .block { margin-top: 12px; }
.catalog-workspace .row { min-height: 62px; }
.catalog-workspace .row-actions { opacity: 1; }
.catalog-workspace .block > h2 { margin-bottom: 12px; }
.subnav { border: 0; gap: 8px; margin-bottom: 16px; }
.subnav a { border-radius: 10px; border: 0; padding: 10px 16px; }
.subnav a[aria-current="page"] { background: var(--accent-tint); color: var(--accent); }
.section-intro { display: flex; align-items: center; gap: 16px; margin: 22px 4px; }
.section-intro > svg { color: var(--accent); }
.section-intro p { margin-top: 4px; font-size: 13px; }
.account-block > h2 { margin-bottom: 14px; }
.account-block .figures-strip > div { background: var(--sunken); border: 0; padding: 12px; }
.defi-card { border-color: var(--line); }
.portfolio-history { border: 0; }
.import-workspace { max-width: 780px; margin: 0 auto; }
.import-intro { text-align: center; padding: 28px 20px 20px; }
.import-intro > svg { color: var(--hero); margin-bottom: 12px; }
.import-intro h2 { font-size: 24px; margin-bottom: 10px; }
.import-intro p { max-width: 460px; margin: auto; }
.import-steps { list-style: none; display: flex; justify-content: center; gap: 12px; padding: 0; margin: 10px 0 24px; }
.import-steps li { font-size: 12px; color: var(--muted); padding: 8px 12px; border-radius: 20px; }
.import-steps .current { background: var(--accent-tint); color: var(--accent); }
.import-workspace form { padding: 28px; }
.import-workspace input[type="file"] { margin-top: 10px; padding: 22px; border-style: dashed; background: var(--sunken); }
.assistant-workspace { background: var(--surface); padding: 24px; border-radius: 20px; min-height: 60vh; display: flex; flex-direction: column; }
.assistant-welcome { display: flex; align-items: center; flex-direction: column; text-align: center; gap: 20px; padding: 36px 12px; }
.assistant-emblem { display: flex; align-items: center; justify-content: center; width: 64px; height: 64px; border-radius: 22px; background: var(--accent-tint); color: var(--accent); }
.assistant-welcome h2 { font-size: 26px; }
.assistant-prompts { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.assistant-prompts button { padding: 10px 14px; min-height: 44px; white-space: normal; font-weight: 400; }
.assistant-workspace .chat { flex: 1; }
.assistant-workspace .chat .intro { text-align: center; font-size: 13px; padding-bottom: 20px; }
.assistant-workspace .chat-input { background: var(--surface); padding-bottom: 0; border-top: 0; }
.assistant-workspace textarea { background: var(--sunken); border: 0; min-height: 54px; border-radius: 14px; }
.turn.user { background: var(--accent-tint); border-radius: 16px 16px 4px 16px; }
.menu { padding: 8px 20px; }
.menu a, .menu button { min-height: 62px; gap: 16px; }
.menu svg { background: var(--accent-tint); color: var(--accent); padding: 8px; box-sizing: content-box; border-radius: 10px; }
.signin { background: radial-gradient(ellipse at top, var(--accent-tint), var(--bg) 65%); }
.signin form { padding: 32px; border-top: 6px solid var(--hero); }
.signin .brand { margin-bottom: 22px; }
.signin button.primary { width: 100%; }
.workspace-dialog { width: min(480px, calc(100vw - 28px)); max-height: calc(100dvh - 40px); padding: 0; border: 0; border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.workspace-dialog::backdrop { background: rgb(18 38 29 / .58); }
.workspace-dialog .dialog-head { padding: 22px 22px 0; }
.workspace-dialog .dialog-head h2 { font-size: 20px; }
.workspace-dialog .dialog-body { padding: 18px 22px 22px; }
.dialog-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.account-picker { max-height: 58vh; overflow-y: auto; }
.account-option { display: flex; align-items: center; gap: 14px; padding: 12px 4px; cursor: pointer; }
.account-option input { flex: none; width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.account-option .label { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.account-option .title { font-size: 16px; overflow-wrap: anywhere; }
.account-option .meta { font-size: 13px; color: var(--muted); }
.account-option:has(input:checked) { background: var(--sunken); border-radius: 10px; }
dialog.add-dialog { border: 0; border-radius: 22px; }
dialog.add-dialog .dialog-head { background: var(--hero); color: #fff; padding: 20px; }
dialog.add-dialog .dialog-head button { color: #fff; }
dialog.add-dialog .dialog-body { padding: 22px; }
.amount-field input { background: var(--sunken); border-color: transparent; font-size: 30px; min-height: 64px; }
.floating-add { display: none; }
@media (max-width: 1100px) and (min-width: 721px) {
    :root { --sidebar: 188px; }
    .main { padding: 20px; }
    .activity-breakdown { grid-template-columns: minmax(180px, .75fr) minmax(0, 1.25fr); gap: 18px; }
    .category-card { grid-template-columns: 32px minmax(0, 1fr) auto; gap: 10px; padding: 10px; }
    .category-card > svg, .category-card .category-percent { display: none; }
    .account-groups { grid-template-columns: minmax(0, 1fr); }
    .tx-row .row-actions { flex-direction: column; }
}
@media (max-width: 720px) {
    .main { padding: 0 12px calc(var(--tabbar) + 96px + env(safe-area-inset-bottom)); }
    .topbar { background: var(--hero); border: 0; color: #fff; height: 58px; padding-inline: 20px; position: sticky; }
    .topbar-menu { color: #fff; padding: 10px; display: flex; border-radius: 50%; }
    .page-head { padding: 8px 12px 14px; margin: 0 -12px 16px; border-radius: 0 0 22px 22px; min-height: 0; }
    .page-head:not(:has(.crumbs, .tools, .sub)) { display: none; }
    .page-head .tools { width: 100%; justify-content: flex-end; }
    .page-head .sub { font-size: 12px; }
    .balance-hero { margin-inline: -12px; padding: 2px 20px 0; }
    .hero-amount { font-size: 34px; }
    .hero-caption { margin-bottom: 8px; }
    .account-selector { font-size: 18px; }
    .activity-tabs { gap: 24px; }
    .activity-tabs button { font-size: 14px; padding: 12px 10px; }
    .activity-panel { padding: 0 14px 16px; border-radius: 20px; }
    .period-tabs { gap: 0; width: 100%; }
    .period-tabs button { flex: 1; font-size: 12px; padding-inline: 5px; min-width: 0; white-space: normal; }
    .period-navigation { gap: 2px; justify-content: space-between; margin-top: 8px; }
    .period-current { font-size: 14px; padding-inline: 4px; }
    .period-current svg { display: none; }
    .period-controls { padding-top: 10px; }
    .activity-breakdown { grid-template-columns: minmax(0, 1fr); gap: 8px; }
    .activity-chart { max-width: 270px; padding: 4px 26px 8px; }
    .activity-ring { max-width: 212px; }
    .activity-ring-label .num { font-size: 18px; }
    .ring-empty { font-size: 14px; }
    .round-add { right: 0; bottom: 14px; width: 46px; height: 46px; min-height: 46px; }
    .category-list-head { margin-block: 10px; }
    .category-card { grid-template-columns: 34px minmax(0, 1fr) 30px auto; gap: 8px; padding: 10px; min-height: 61px; font-size: 13px; }
    .category-card > svg { display: none; }
    .category-card .num { font-size: 14px; }
    .category-percent { font-size: 11px; }
    .category-icon { width: 32px; height: 32px; }
    .lifetime-panel { padding: 16px; }
    .lifetime-panel .plot.short { height: 108px; }
    .lifetime-panel .block-head { gap: 8px; }
    .lifetime-panel h2 { font-size: 14px; }
    .lifetime-panel a { font-size: 12px; }
    .account-shortcuts { gap: 4px; flex-wrap: nowrap; justify-content: space-between; margin: 14px 0; }
    .account-shortcuts button, .account-shortcuts a { white-space: normal; text-align: center; font-size: 11px; padding-inline: 4px; flex: 1; }
    .account-shortcuts svg { padding: 10px; border-radius: 14px; }
    .account-groups { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .accounts-panel { padding: 12px !important; }
    .accounts-panel .block-head { padding-inline: 4px; }
    .account-row { font-size: 14px; padding: 11px 10px; min-height: 66px; }
    .account-name { font-size: 13px; }
    .account-title { flex-wrap: nowrap; gap: 8px; }
    .account-title .badge { display: none; }
    .account-row .figures { font-size: 14px; max-width: 44vw; }
    .workspace-accounts .headline { padding: 20px 4px 4px; gap: 10px; }
    .workspace-accounts .overview-history { padding-top: 8px; }
    .transaction-header { margin-inline: -12px; border-radius: 0; padding-top: 0; }
    .transaction-header .activity-tabs { gap: 6px; }
    .transaction-header .activity-tabs button { font-size: 12px; padding-inline: 9px; }
    .transaction-panel { padding: 0 12px 16px; }
    .transaction-panel > .toolbar { margin: 6px 0 10px; gap: 8px; flex-wrap: wrap; }
    .transaction-panel .search { min-width: 160px; }
    .transaction-filters { font-size: 12px; }
    .transaction-filters[open] { flex-basis: 100%; max-width: none; }
    .transaction-list-heading { flex-wrap: wrap; gap: 6px; }
    .transaction-totals { gap: 10px 18px; }
    .transaction-totals > div { font-size: 12px; }
    .transaction-totals .num { font-size: 15px; }
    .tx-list .rows { padding: 0 10px; }
    .tx-row { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; min-height: 78px; padding-block: 12px; }
    .tx-row .label { grid-column: 1; grid-row: 1 / span 2; }
    .tx-row .figures { grid-column: 2; grid-row: 1; padding-top: 1px; }
    .tx-row .row-actions { grid-column: 2; grid-row: 2; }
    .tx-selection { gap: 8px; }
    .tx-selection .category-icon { width: 30px; height: 30px; }
    .tx-selection .title { font-size: 13px; }
    .tx-row .meta { padding-left: 38px; font-size: 11px; margin-top: 1px; }
    .tx-note { padding-left: 0; margin-top: 7px; font-size: 12px; }
    .tx-row .amount { font-size: 14px; }
    .tx-row .secondary { font-size: 11px; max-width: 140px; }
    .tx-row .row-actions button { min-height: 32px; padding-inline: 6px; }
    .tx-select { opacity: 1; left: -8px; top: -4px; width: 14px; }
    .day-head, .day-group:first-child .day-head { font-size: 12px; padding-top: 17px; }
    .report-tabs { margin-inline: -12px; border-radius: 0; gap: 14px; padding-top: 0; }
    .report-period { padding: 0 12px 8px; }
    .report-options > summary { min-height: 32px; }
    .reports-workspace .stat-totals { gap: 8px; }
    .stat-totals .value { font-size: 18px; }
    .reports-workspace .chart { padding: 16px; }
    .reports-workspace .plot { height: 164px; }
    .report-breakdown .activity-chart { max-width: 220px; }
    .report-breakdown > h2 { margin-bottom: 8px; }
    .workspace-tabs button { padding-inline: 5px; font-size: 13px; }
    .catalog-workspace .row { grid-template-columns: minmax(0, 1fr) auto; }
    .catalog-workspace .row-actions { flex-direction: column; }
    .catalog-workspace .row-actions button { font-size: 11px; min-height: 34px; }
    .catalog-workspace .rename-form { grid-column: 1 / -1; }
    .subnav { margin-top: 12px; }
    .import-steps { gap: 4px; }
    .import-steps li { font-size: 10px; padding: 8px; }
    .import-workspace form { padding: 18px; }
    .import-intro { padding: 16px 8px; }
    .import-intro h2 { font-size: 21px; }
    .assistant-workspace { padding: 16px; margin-top: 12px; min-height: 65dvh; }
    .assistant-welcome { padding: 24px 0; gap: 16px; }
    .assistant-welcome h2 { font-size: 22px; }
    .assistant-prompts { flex-direction: column; }
    .assistant-workspace .chat-input { position: static; align-items: stretch; }
    .assistant-workspace .chat-input button { padding-inline: 10px; }
    .page-more .menu { margin-top: 12px; }
    .floating-add { display: flex; position: fixed; right: 20px; bottom: calc(var(--tabbar) + 18px + env(safe-area-inset-bottom)); z-index: 4; width: 52px; height: 52px; padding: 0; border: 0; border-radius: 50%; background: var(--gold) !important; color: #2e3525 !important; box-shadow: 0 5px 20px rgb(76 67 20 / .18); }
    .floating-add .button-label { font-size: 0; display: flex; }
    .floating-add svg { width: 26px; height: 26px; }
    .shell:has(.page-overview) > .floating-add { display: none; }
    .tabbar { border: 0; box-shadow: 0 -2px 18px rgb(29 61 45 / .07); }
    .tab { font-size: 10px; }
    .tab[aria-current="page"] svg { border-radius: 9px; }
    dialog.add-dialog { width: calc(100vw - 20px); max-width: 480px; height: auto; max-height: calc(100dvh - 24px); margin: auto; border-radius: 20px; }
    dialog.add-dialog .dialog-head { padding: 16px; }
    dialog.add-dialog .dialog-body { padding: 16px; }
    .workspace-dialog .dialog-body { padding: 16px; }
    .workspace-dialog .dialog-head { padding: 16px 16px 0; }
    .workspace-dialog .grid-2 { grid-template-columns: 1fr 1fr; gap: 10px; }
    .workspace-dialog input[type="date"] { min-width: 0; padding-inline: 8px; }
}
@media (prefers-reduced-motion: no-preference) {
    button, .button, .category-card { transition: background-color 120ms, border-color 120ms; }
}
/* Keep the chart beside the first categories even with a long history. */
.activity-breakdown { align-items: start; }
.activity-chart { margin-top: 22px; }
.activity-breakdown.is-empty { grid-template-columns: 1fr; }
.activity-breakdown.is-empty .category-list { display: none; }
.activity-breakdown.is-empty .activity-chart { margin-top: 0; }
.more-categories > summary { padding: 10px 4px; color: var(--accent); font-size: 13px; }
.more-categories[open] > summary { margin-bottom: 8px; }
.page-overview .page-head { min-height: 48px; padding-top: 16px; padding-bottom: 0; }
.balance-hero .activity-tabs { padding-top: 0; }
.balance-hero .activity-tabs button { min-height: 44px; padding-block: 10px; }
.hero-caption { margin-bottom: 8px; }
@media (max-width: 720px) { .activity-chart { margin-top: 0; } }
.account-name { justify-content: flex-start; }
.page-transactions .page-head, .page-stats .page-head { margin-bottom: 0; border-radius: 20px 20px 0 0; padding-bottom: 10px; min-height: 58px; }
.page-transactions .transaction-header, .page-stats .report-tabs { border-radius: 0; }
.catalog-workspace .fold { margin-block: 12px 18px; }
.show-more { display: flex; margin: 20px auto 0; }
.page-operations .figures-strip > div { border: 0; background: var(--surface); border-radius: 14px; padding: 18px; }
.page-operations .ops-table thead { background: var(--sunken); }
.page-operations .ops-table td { padding-block: 16px; }
@media (max-width: 720px) { .page-operations .ops-table td { padding-block: 4px; } }
@media (max-width: 720px) {
    .transaction-filters { max-width: 100%; }
    .tx-select { opacity: 0; pointer-events: none; }
    .transaction-panel:has(.transaction-filters[open]) .tx-select, .tx-select:checked, .tx-select:focus-visible { opacity: 1; pointer-events: auto; }
}
.balance-hero .mark-inline { color: #fff0c2; font-size: .6em; }
@media (max-width: 720px) { .page-accounts .page-head { display: none; } }
/* Independently valued history stays visible when another component is missing. */
.chart .line.partial-accounts { stroke: var(--accent); stroke-dasharray: 6 4; }
.chart .line.partial-positions { stroke: var(--muted); stroke-dasharray: 2 4; }
.swatch.total, .swatch.partial-accounts, .readout-dot.partial-accounts { color: var(--accent); }
.swatch.partial-accounts { border-top-style: dashed; }
.swatch.partial-positions, .readout-dot.partial-positions { color: var(--muted); }
.swatch.partial-positions { border-top-style: dotted; }
.chart .chart-point { fill: var(--accent); stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart .chart-point.cost, .chart .chart-point.partial-positions { fill: var(--muted); stroke: var(--muted); }
.chart .chart-point.gain { fill: var(--ink); stroke: var(--ink); }
.networth-history-chart .history-coverage { line-height: 1.5; }
.lifetime-panel .networth-history-chart > .chart { box-shadow: none; padding: 0; margin-top: 12px; }
.lifetime-panel .chart-head { display: flex; justify-content: flex-end; }
.lifetime-panel .chart-head h3 { display: none; }
