/* ============================================================
   Ledger — design system
   Swiss/Braun-clean, opinionated, typographic.
   No cards. No zebra. No SaaS blue. Hairlines and tabular numerals.
   ============================================================ */

/* ---------------- tokens: light ---------------- */
:root,
:root[data-theme="light"] {
    --surface:        oklch(0.985 0.004 75);    /* paper */
    --subsurface:     oklch(0.965 0.005 75);    /* inset wells */
    --inset:          oklch(0.945 0.006 75);    /* filter row, code */
    --ink:            oklch(0.18 0.012 250);    /* primary text */
    --ink-2:          oklch(0.34 0.010 250);    /* secondary text */
    --muted:          oklch(0.55 0.008 250);    /* captions, labels */
    --faint:          oklch(0.72 0.006 250);    /* placeholder */
    --hairline:       oklch(0.18 0.012 250 / 0.10);
    --hairline-2:     oklch(0.18 0.012 250 / 0.18);
    --hairline-3:     oklch(0.18 0.012 250 / 0.32);
    --pos:            oklch(0.52 0.13 150);     /* oxidized forest */
    --pos-soft:       oklch(0.52 0.13 150 / 0.10);
    --neg:            oklch(0.55 0.19 28);      /* oxide red */
    --neg-soft:       oklch(0.55 0.19 28 / 0.08);
    --select-bg:      oklch(0.18 0.012 250 / 0.05);
    --focus-ring:     oklch(0.18 0.012 250 / 0.55);
    --backdrop:       oklch(0.18 0.012 250 / 0.30);

    --shadow-flat:    none;
    --shadow-soft:    0 1px 0 0 oklch(0.18 0.012 250 / 0.06);

    --radius-1: 2px;
    --radius-2: 4px;

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', 'Menlo', monospace;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --t-fast: 140ms;
    --t-norm: 220ms;

    --sidebar-width: 232px;
    --sidebar-collapsed-width: 60px;
    --max-content: none;

    color-scheme: light;
}

/* ---------------- tokens: dark ---------------- */
:root[data-theme="dark"] {
    --surface:        oklch(0.155 0.008 250);   /* graphite */
    --subsurface:     oklch(0.195 0.008 250);
    --inset:          oklch(0.225 0.008 250);
    --ink:            oklch(0.94 0.006 75);     /* warm bone */
    --ink-2:          oklch(0.78 0.008 75);
    --muted:          oklch(0.62 0.01 250);
    --faint:          oklch(0.45 0.008 250);
    --hairline:       oklch(0.94 0.006 75 / 0.10);
    --hairline-2:     oklch(0.94 0.006 75 / 0.18);
    --hairline-3:     oklch(0.94 0.006 75 / 0.32);
    --pos:            oklch(0.74 0.14 150);
    --pos-soft:       oklch(0.74 0.14 150 / 0.12);
    --neg:            oklch(0.72 0.17 28);
    --neg-soft:       oklch(0.72 0.17 28 / 0.10);
    --select-bg:      oklch(0.94 0.006 75 / 0.06);
    --focus-ring:     oklch(0.94 0.006 75 / 0.55);
    --backdrop:       oklch(0.10 0.005 250 / 0.55);

    color-scheme: dark;
}

/* respect system preference when no explicit choice */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --surface:        oklch(0.155 0.008 250);
        --subsurface:     oklch(0.195 0.008 250);
        --inset:          oklch(0.225 0.008 250);
        --ink:            oklch(0.94 0.006 75);
        --ink-2:          oklch(0.78 0.008 75);
        --muted:          oklch(0.62 0.01 250);
        --faint:          oklch(0.45 0.008 250);
        --hairline:       oklch(0.94 0.006 75 / 0.10);
        --hairline-2:     oklch(0.94 0.006 75 / 0.18);
        --hairline-3:     oklch(0.94 0.006 75 / 0.32);
        --pos:            oklch(0.74 0.14 150);
        --pos-soft:       oklch(0.74 0.14 150 / 0.12);
        --neg:            oklch(0.72 0.17 28);
        --neg-soft:       oklch(0.72 0.17 28 / 0.10);
        --select-bg:      oklch(0.94 0.006 75 / 0.06);
        --focus-ring:     oklch(0.94 0.006 75 / 0.55);
        --backdrop:       oklch(0.10 0.005 250 / 0.55);
        color-scheme: dark;
    }
}

/* ---------------- reset ---------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    font-feature-settings: "ss01", "cv11";
}

body {
    font-family: var(--font-sans);
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--surface);
    font-feature-settings: "ss01", "cv11", "tnum" off;
    transition: background-color var(--t-norm) var(--ease), color var(--t-norm) var(--ease);
}

::selection { background: var(--select-bg); color: var(--ink); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ---------------- typography ---------------- */
h1, h2, h3, h4 { color: var(--ink); font-weight: 600; letter-spacing: -0.015em; line-height: 1.1; }

h1 {
    font-size: 44px;
    font-weight: 600;
    letter-spacing: -0.028em;
    margin-bottom: 28px;
    line-height: 1.0;
}

h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.018em;
    margin-bottom: 14px;
    line-height: 1.15;
}

h3 {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    font-family: var(--font-mono);
    margin-bottom: 14px;
}

h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--ink);
}

a { color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--hairline-2); transition: border-color var(--t-fast) var(--ease); }
a:hover { border-bottom-color: var(--ink); text-decoration: none; }

p { margin-bottom: 12px; color: var(--ink-2); }

small { font-size: 11px; color: var(--muted); font-family: var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; font-weight: 500; }

strong { font-weight: 600; color: var(--ink); }

code, kbd {
    font-family: var(--font-mono);
    font-size: 12px;
    background: var(--inset);
    padding: 1px 5px;
    border-radius: var(--radius-1);
    color: var(--ink);
}

kbd { border: 1px solid var(--hairline-2); }

/* ---------------- layout ---------------- */
#app, .app-shell {
    display: flex;
    min-height: 100vh;
    background: var(--surface);
    width: 100%;
}

.content {
    flex: 1;
    padding: 40px 56px 80px;
    overflow-y: auto;
    background: var(--surface);
    max-width: 100%;
}

.content > div {
    max-width: var(--max-content);
}

/* ---------------- sidebar ---------------- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--hairline-2);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    transition: width var(--t-norm) var(--ease), min-width var(--t-norm) var(--ease);
}

.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    min-width: var(--sidebar-collapsed-width);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 22px 20px 22px;
    border-bottom: 1px solid var(--hairline);
    min-height: 64px;
}

.sidebar-logo {
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity var(--t-norm) var(--ease);
}
.sidebar-logo::before {
    content: 'Q/';
    display: inline-block;
    margin-right: 8px;
    color: var(--neg);
    font-weight: 700;
}

.sidebar-collapsed .sidebar-logo { opacity: 0; width: 0; }

.sidebar-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--t-fast) var(--ease);
}
.sidebar-toggle:hover { color: var(--ink); background: none; }

.sidebar-nav {
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 9px 20px;
    color: var(--muted);
    text-decoration: none;
    border-bottom: none;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
    white-space: nowrap;
    position: relative;
}

.nav-item:hover {
    background: transparent;
    color: var(--ink);
    text-decoration: none;
    border-bottom: none;
}

.nav-item.router-link-active {
    background: transparent;
    color: var(--ink);
    font-weight: 600;
}
.nav-item.router-link-active::after {
    content: '';
    position: absolute;
    left: 20px;
    right: 20px;
    bottom: 4px;
    height: 1px;
    background: var(--ink);
}
.sidebar-collapsed .nav-item.router-link-active::after { display: none; }

.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    stroke-width: 1.6;
}

.nav-label { transition: opacity var(--t-norm) var(--ease); }
.sidebar-collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }

.nav-spacer { flex: 1; min-height: 24px; }

/* theme toggle in sidebar bottom */
.theme-toggle {
    margin: 0 12px 14px;
    padding: 8px 8px;
    background: transparent;
    border: 1px solid var(--hairline-2);
    border-radius: 0;
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: calc(100% - 24px);
    transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.theme-toggle:hover { color: var(--ink); border-color: var(--hairline-3); background: transparent; }
.theme-toggle .theme-mode { color: var(--ink); }
.sidebar-collapsed .theme-toggle { display: none; }

/* ---------------- containers (no cards) ---------------- */
article {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin-bottom: 32px;
    box-shadow: none;
}

article > header {
    border-bottom: 1px solid var(--hairline-2);
    padding-bottom: 12px;
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
}

article > footer {
    border-top: 1px solid var(--hairline);
    padding-top: 14px;
    margin-top: 18px;
}

/* ---------------- tables ---------------- */
figure {
    margin: 0 0 24px;
    overflow-x: auto;
    border-top: 1px solid var(--hairline-2);
    border-bottom: 1px solid var(--hairline-2);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    font-variant-numeric: tabular-nums;
}

thead th {
    text-align: left;
    padding: 10px 12px;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    border-bottom: 1px solid var(--hairline-2);
    background: transparent;
    white-space: nowrap;
}

thead th:first-child { padding-left: 0; }
thead th:last-child { padding-right: 0; }

tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--hairline);
    color: var(--ink);
    vertical-align: middle;
}

tbody td:first-child { padding-left: 0; }
tbody td:last-child { padding-right: 0; }

tbody tr { transition: background-color var(--t-fast) var(--ease); }
tbody tr:last-child td { border-bottom: none; }

tbody tr:hover { background: var(--select-bg); }

/* zebra striping deleted on purpose */

/* ---------------- buttons ---------------- */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    border-radius: var(--radius-1);
    border: 1px solid var(--ink);
    cursor: pointer;
    transition: background-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
    background: var(--ink);
    color: var(--surface);
    text-decoration: none;
    line-height: 1;
    height: 30px;
    border-bottom-style: solid;
}

button:hover,
.btn:hover {
    background: var(--surface);
    color: var(--ink);
    border-color: var(--ink);
    text-decoration: none;
    border-bottom-color: var(--ink);
}

button:disabled,
.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

button.outline,
a.outline,
.btn.outline {
    background: transparent;
    border: 1px solid var(--hairline-3);
    color: var(--ink);
}

button.outline:hover,
a.outline:hover,
.btn.outline:hover {
    background: transparent;
    border-color: var(--ink);
    color: var(--ink);
}

button.secondary,
button.outline.secondary {
    color: var(--muted);
    border-color: var(--hairline-2);
}
button.secondary:hover,
button.outline.secondary:hover { color: var(--ink); border-color: var(--hairline-3); }

button.small,
a.small,
.btn.small {
    padding: 4px 10px;
    font-size: 10px;
    height: 24px;
}

button.danger { background: var(--neg); border-color: var(--neg); color: var(--surface); }
button.danger:hover { background: var(--surface); color: var(--neg); border-color: var(--neg); }

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.nav-item:focus-visible {
    outline: 1px solid var(--focus-ring);
    outline-offset: 2px;
    border-bottom-color: var(--ink);
}

/* ---------------- forms ---------------- */
input,
select,
textarea {
    width: 100%;
    padding: 8px 10px;
    font-family: var(--font-sans);
    font-size: 13px;
    border: 1px solid var(--hairline-2);
    border-radius: var(--radius-1);
    background: var(--surface);
    color: var(--ink);
    transition: border-color var(--t-fast) var(--ease);
    line-height: 1.4;
    height: 32px;
}

textarea { height: auto; min-height: 64px; }

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--ink);
    box-shadow: none;
}

input::placeholder { color: var(--faint); }

label {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.10em;
}

input[type="checkbox"] {
    width: auto;
    height: auto;
    accent-color: var(--ink);
}

input[type="color"] { padding: 2px; height: 32px; cursor: pointer; }

input[type="file"] {
    padding: 6px 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    height: auto;
}

input[type="date"] { font-family: var(--font-mono); }

select { appearance: auto; cursor: pointer; }

/* ---------------- details/summary ---------------- */
details {
    border: 1px solid var(--hairline-2);
    border-radius: 0;
    margin-bottom: 16px;
    overflow: hidden;
}

summary {
    padding: 10px 14px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--ink);
    cursor: pointer;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 10px;
    background: transparent;
}

summary:hover { background: var(--select-bg); }

summary::marker, summary::-webkit-details-marker { display: none; }

summary::before {
    content: '+';
    font-size: 14px;
    font-weight: 500;
    width: 12px;
    color: var(--muted);
    transition: transform var(--t-fast) var(--ease);
}

details[open] > summary { border-bottom: 1px solid var(--hairline); }
details[open] > summary::before { content: '−'; }

details > :not(summary) { padding: 14px; }

/* ---------------- dialog ---------------- */
dialog {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: var(--backdrop);
    backdrop-filter: none;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border: none;
    padding: 0;
    color: var(--ink);
}

dialog:not([open]) { display: none; }

dialog > article {
    background: var(--surface);
    border: 1px solid var(--hairline-3);
    border-radius: var(--radius-2);
    box-shadow: 0 24px 56px -12px oklch(0 0 0 / 0.18), 0 4px 16px -4px oklch(0 0 0 / 0.10);
    padding: 28px 32px 24px;
    max-width: 640px;
    width: 92%;
    max-height: 86vh;
    overflow-y: auto;
    margin: 0;
    animation: dialog-in 220ms var(--ease);
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.dialog-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--muted);
    width: 28px;
    height: 28px;
    padding: 0;
    border-radius: var(--radius-1);
}
.dialog-close:hover { color: var(--ink); background: var(--inset); border-color: transparent; }

/* ---------------- amount typography ---------------- */
.amount-positive,
.amount-negative {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-weight: 500;
    letter-spacing: 0;
}

.amount-positive { color: var(--pos); }
.amount-negative { color: var(--neg); }

/* mono numerals everywhere amounts appear */
td.amount-positive,
td.amount-negative,
.tx-table td:nth-child(4),
.ledger-table td[style*="text-align:right"] {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
}

/* ---------------- utilities ---------------- */
.nowrap { white-space: nowrap; }

.muted, .muted p {
    color: var(--muted);
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
}

.error-msg {
    color: var(--neg);
    background: var(--neg-soft);
    border: 1px solid var(--neg);
    border-left-width: 1px;
    padding: 10px 14px;
    margin-bottom: 16px;
    font-family: var(--font-mono);
    font-size: 12px;
    border-radius: var(--radius-1);
}

.loading-text {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

.loading-text::before {
    content: '';
    display: inline-block;
    width: 10px;
    height: 10px;
    border: 1px solid var(--hairline-2);
    border-top-color: var(--ink);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.button-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 4px;
}
.button-row.compact { gap: 6px; }
.button-row button { margin-bottom: 0; width: auto; }

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px 24px;
    margin-bottom: 16px;
}

hr {
    border: none;
    border-top: 1px solid var(--hairline);
    margin: 24px 0;
}

/* ---------------- steps bar ---------------- */
.steps-bar {
    display: flex;
    gap: 32px;
    margin-bottom: 32px;
    padding: 16px 0;
    border-bottom: 1px solid var(--hairline-2);
}

.steps-bar span {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    position: relative;
}

.steps-bar span.active {
    color: var(--ink);
    font-weight: 600;
}
.steps-bar span.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -17px;
    height: 1px;
    background: var(--ink);
}

.steps-bar span.done {
    color: var(--ink-2);
}

/* ---------------- duplicate row ---------------- */
.row-duplicate {
    color: var(--faint);
}
.row-duplicate td { text-decoration: line-through; }

/* ---------------- color swatch ---------------- */
.color-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 0;
    vertical-align: middle;
    border: 1px solid var(--hairline-2);
}

/* ---------------- category group ---------------- */
.category-group,
.account-group {
    margin-bottom: 32px;
}

.category-group h3,
.account-group h3 {
    margin-bottom: 8px;
    text-transform: uppercase;
}

/* ---------------- account name w/ icons ---------------- */
.account-name {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
}
.account-name .bank-logo {
    width: 18px;
    height: 18px;
    object-fit: contain;
    border-radius: 3px;
    flex-shrink: 0;
    background: var(--inset);
    padding: 1px;
}
.account-name .card-icon {
    width: 14px;
    height: 14px;
    color: var(--muted);
    flex-shrink: 0;
}

/* ---------------- transaction table ---------------- */
.tx-table {
    font-size: 12.5px;
}

/* ---------------- inline controls ---------------- */
.inline-select,
.inline-input {
    padding: 4px 6px;
    margin: 0;
    font-size: 12px;
    height: 26px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-1);
}
.inline-select:hover,
.inline-input:hover { border-color: var(--hairline-2); background: var(--surface); }
.inline-select:focus,
.inline-input:focus { border-color: var(--ink); background: var(--surface); }

.inline-select { min-width: 110px; }
.inline-input { width: 100%; }

/* ---------------- category cell ---------------- */
.cat-cell {
    white-space: nowrap;
}
.cat-cell .cat-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 8px;
    vertical-align: middle;
    border: 1px solid var(--hairline-2);
    background: transparent;
    flex-shrink: 0;
}
.cat-cell .cat-select {
    vertical-align: middle;
    min-width: 130px;
}

/* ---------------- notes cell ---------------- */
/* The notes cell wraps its child in a fixed-width <div>. Browsers ignore
   max-width on <td> in auto table layouts, so we constrain the inner div
   instead — the td shrinks to fit the div, regardless of note length. */
.tx-table td.notes-td { padding: 4px; }
.tx-table td.notes-td > .notes-wrap {
    width: 180px;
    max-width: 180px;
    overflow: hidden;
}
/* Generic notes-cell styling — used both as a <td> in the ledger view and as a
   <span> inside .notes-wrap on the transactions table. The block/ellipsis rules
   are scoped to the transactions table to avoid breaking ledger <td> layout. */
.notes-cell {
    cursor: pointer;
    color: var(--faint);
    font-size: 12px;
    padding: 2px 4px;
    border-radius: var(--radius-1);
    transition: color var(--t-fast) var(--ease);
}
.notes-cell:hover { color: var(--ink); }

.tx-table .notes-wrap > .notes-cell {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.tx-table .notes-td .inline-input {
    width: 100%;
    box-sizing: border-box;
}

/* ---------------- account cell with bank logo ---------------- */
/* Keep `display: flex` off the <td> so the cell's baseline still aligns with
   sibling td cells. Use an inline-flex chip for the icon + label group. */
.account-cell { vertical-align: middle; }
.account-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}
.bank-logo-sm {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 3px;
    display: block;
}
.account-card-icon {
    color: var(--muted);
    flex-shrink: 0;
    display: block;
}
.account-name { display: inline-block; }

/* ---------------- split indicator ---------------- */
.split-icon-btn { position: relative; }
.split-icon-btn.has-splits { color: var(--accent, var(--ink)); }
.split-count-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: var(--ink);
    color: var(--surface);
    border-radius: 999px;
    min-width: 14px;
    height: 14px;
    padding: 0 4px;
    font-size: 9px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ---------------- excluded transaction row ---------------- */
.tx-table tr.excluded-row { opacity: 0.45; }
.tx-table tr.excluded-row td { font-style: italic; }
.tx-table tr.excluded-row:hover { opacity: 0.7; }

/* ---------------- pill button group (contact / split-type pickers) ---------------- */
.pill-group {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}
.pill-btn {
    padding: 6px 14px;
    border: 1px solid var(--hairline-2);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.pill-btn:hover { border-color: var(--ink); }
.pill-btn.is-active {
    background: var(--ink);
    color: var(--surface);
    border-color: var(--ink);
}
.pill-btn-new {
    color: var(--muted);
    border-style: dashed;
}
.pill-btn-new.is-active {
    background: var(--ink);
    color: var(--surface);
    border-style: solid;
}

/* Backwards-compat aliases — keep so old class refs in other places still work. */
.contact-picker { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.contact-btn,
.segmented-btn { /* re-skinned to the pill style */
    padding: 6px 14px;
    border: 1px solid var(--hairline-2);
    border-radius: 999px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.contact-btn:hover,
.segmented-btn:hover { border-color: var(--ink); }
.contact-btn.is-active,
.segmented-btn.is-active {
    background: var(--ink);
    color: var(--surface);
    border-color: var(--ink);
}
.segmented { display: flex; flex-wrap: wrap; gap: 6px; border: none; border-radius: 0; overflow: visible; }

/* ---------------- inline filter checkbox row ---------------- */
.filter-toggles { margin-top: 8px; display: flex; gap: 16px; flex-wrap: wrap; }
.checkbox-inline {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
}
.checkbox-inline input[type="checkbox"] { margin: 0; }

/* ---------------- transactions filter bar (redesigned) ---------------- */
.tx-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.filter-search-row {
    display: flex;
    align-items: center;
    gap: 12px;
}
.search-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}
.search-wrap .search-icon {
    position: absolute;
    left: 10px;
    color: var(--muted);
    pointer-events: none;
}
.search-wrap input[type="search"] {
    width: 100%;
    padding: 8px 12px 8px 32px;
    margin: 0;
    border: 1px solid var(--hairline-2);
    border-radius: var(--radius-1);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}
.search-wrap input[type="search"]:focus {
    outline: none;
    border-color: var(--ink);
}
.clear-filters-btn { white-space: nowrap; }

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.filter-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    margin: 0;
    border: 1px solid var(--hairline-2);
    border-radius: 999px;
    background: var(--surface);
    font-size: 11px;
    line-height: 1;
}
.filter-pill-label {
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-size: 10px;
}
.filter-pill select,
.filter-pill input {
    padding: 0;
    margin: 0;
    border: none;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 12px;
    height: 22px;
    cursor: pointer;
}
.filter-pill select:focus,
.filter-pill input:focus { outline: none; }
.filter-amount-input {
    width: 70px;
    -moz-appearance: textfield;
    appearance: textfield;
}
.filter-amount-input::-webkit-outer-spin-button,
.filter-amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.filter-presets {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
}
.filter-presets-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-right: 4px;
}

.filter-toggle-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border: 1px solid var(--hairline-2);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font: inherit;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.filter-toggle-pill:hover { color: var(--ink); }
.filter-toggle-pill.is-active {
    background: var(--ink);
    color: var(--surface);
    border-color: var(--ink);
}

/* Subtotal row — only visible when filters are active */
.filter-subtotal {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 8px 12px;
    background: color-mix(in oklab, var(--ink) 4%, transparent);
    border-radius: var(--radius-1);
    font-size: 11px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    color: var(--muted);
    align-items: baseline;
}
.filter-subtotal-count { color: var(--ink); font-weight: 600; }
.filter-subtotal-in { color: var(--pos); }
.filter-subtotal-out { color: var(--neg); }
.filter-subtotal-split { color: var(--faint); }
.filter-subtotal-net {
    margin-left: auto;
    color: var(--ink);
    font-weight: 600;
    font-size: 12px;
}
.filter-subtotal-net.is-negative { color: var(--neg); }

/* ---------------- sortable table headers ---------------- */
th.sortable {
    cursor: pointer;
    user-select: none;
}
th.sortable:hover { color: var(--ink); }
.sort-indicator { font-size: 10px; margin-left: 2px; opacity: 0.6; }

/* ---------------- non-applicable category placeholder ---------------- */
.cat-na { color: var(--faint); padding: 0 4px; }

/* ---------------- contact management (repayments) ---------------- */
.contact-mgmt { margin-top: 32px; }
.contact-mgmt-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
.contact-mgmt-head h3 { margin: 0; font-size: 14px; }
.contact-add-form {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    align-items: center;
}
.contact-add-form input {
    flex: 1;
    max-width: 280px;
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--hairline-2);
    border-radius: var(--radius-1);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}
.contact-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--hairline);
    max-width: 480px;
}
.contact-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 4px;
    border-bottom: 1px solid var(--hairline);
    font-size: 13px;
}
.contact-name-wrap { flex: 1; min-width: 0; }
.contact-name {
    cursor: pointer;
    color: var(--ink);
    padding: 2px 4px;
    border-radius: var(--radius-1);
    transition: background var(--t-fast) var(--ease);
}
.contact-name:hover { background: var(--hairline); }
.contact-name-input {
    width: 100%;
    margin: 0;
    padding: 4px 6px;
    border: 1px solid var(--hairline-2);
    border-radius: var(--radius-1);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}
.contact-meta {
    color: var(--muted);
    font-size: 11px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    white-space: nowrap;
}
.icon-btn-danger:hover { color: var(--neg); background: color-mix(in oklab, var(--neg) 12%, transparent); }

/* ---------------- compact notes cell (repayments) ---------------- */
.notes-mini {
    font-size: 11px;
    color: var(--faint);
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------- split dialog redesign ---------------- */
.split-dialog .split-article {
    max-width: 560px;
    width: 100%;
    padding: 24px 28px;
    position: relative;
}
.split-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: none;
    padding: 0;
    margin: 0 0 16px 0;
    font-family: var(--font-sans);
    font-size: inherit;
    letter-spacing: normal;
    text-transform: none;
}
.split-header h2 { margin: 0; font-size: 18px; }
.split-body { display: flex; flex-direction: column; gap: 18px; }

/* Transaction summary card */
.split-tx-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-1);
    background: color-mix(in oklab, var(--ink) 3%, transparent);
}
.split-tx-meta { flex: 1; min-width: 0; }
.split-tx-desc {
    font-weight: 600;
    font-size: 14px;
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.split-tx-date {
    font-size: 11px;
    color: var(--muted);
    margin-top: 2px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
}
.split-tx-amount {
    font-size: 20px;
    font-weight: 600;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    flex-shrink: 0;
}
.split-tx-amount.is-positive { color: var(--pos); }
.split-tx-amount.is-negative { color: var(--neg); }

/* Allocation bar */
.split-alloc { display: flex; flex-direction: column; gap: 6px; }
.split-alloc-bar {
    display: flex;
    height: 6px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--hairline-2);
}
.split-alloc-fill { height: 100%; transition: width var(--t-fast) var(--ease); }
.split-alloc-fill.split-alloc-yours { background: var(--ink); }
.split-alloc-fill.split-alloc-others { background: var(--neg); opacity: 0.55; }
.split-alloc-legend {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    font-size: 11px;
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    color: var(--muted);
}
.split-alloc-item { display: inline-flex; align-items: center; gap: 6px; }
.split-alloc-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}
.split-alloc-dot.is-yours { background: var(--ink); }
.split-alloc-dot.is-others { background: var(--neg); opacity: 0.55; }
.split-alloc-amount { color: var(--ink); font-weight: 600; }

/* Sections */
.split-section { display: flex; flex-direction: column; gap: 10px; }
.split-section-title {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

/* Existing splits list */
.split-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.split-list-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-1);
    font-size: 13px;
}
.split-contact-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--neg);
    opacity: 0.55;
    flex-shrink: 0;
}
.split-contact-name { flex: 1; color: var(--ink); }
.split-pill {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.split-pill.is-repaid { background: color-mix(in oklab, var(--pos) 15%, transparent); color: var(--pos); }
.split-pill.is-owed   { background: color-mix(in oklab, var(--neg) 15%, transparent); color: var(--neg); }
.split-list-amount { font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 13px; color: var(--ink); }

/* Add-split form */
.split-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-1);
}
.split-form-divider {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-top: 1px dashed var(--hairline-2);
    padding-top: 12px;
    margin-top: -2px;
}
.split-field { display: flex; flex-direction: column; gap: 4px; }
.split-field-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}
.split-name-input {
    margin-top: 8px;
    padding: 6px 10px;
    border: 1px solid var(--hairline-2);
    border-radius: var(--radius-1);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
}
.split-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 4px;
}
.split-amount-input {
    flex: 0 1 160px;
    padding: 6px 10px;
    border: 1px solid var(--hairline-2);
    border-radius: var(--radius-1);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 13px;
    margin: 0;
}
.split-input-aside { color: var(--muted); font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 12px; }
.split-full-note {
    margin-top: 4px;
    padding: 8px 10px;
    background: color-mix(in oklab, var(--ink) 4%, transparent);
    border-radius: var(--radius-1);
    font-size: 12px;
    color: var(--muted);
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--muted);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 3px;
}
.link-btn:hover:not(:disabled) { color: var(--ink); }
.link-btn:disabled { color: var(--faint); cursor: not-allowed; }
.add-another-btn { align-self: flex-start; margin-top: 4px; }

.icon-btn {
    width: 22px;
    height: 22px;
    padding: 0;
    flex: 0 0 auto;
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    border-radius: var(--radius-1);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.icon-btn:hover { background: var(--hairline); color: var(--ink); }

.split-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid var(--hairline);
}

/* ---------------- per-category trend grid ---------------- */
.cat-trend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}
.cat-trend-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border: 1px solid var(--hairline);
    border-radius: var(--radius-1);
    background: var(--surface);
}
.cat-trend-head {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
}
.cat-trend-swatch {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.cat-trend-name {
    font-weight: 600;
    color: var(--ink);
    flex: 1;
}
.cat-trend-avg {
    color: var(--muted);
    font-family: 'JetBrains Mono', ui-monospace, monospace;
    font-size: 10px;
}
/* Chart.js responsive mode reads the parent's bounding box, so the wrapper
   needs an explicit height. The canvas fills it. */
.cat-trend-canvas-wrap {
    position: relative;
    width: 100%;
    height: 110px;
}
.cat-trend-canvas-wrap > canvas {
    width: 100% !important;
    height: 100% !important;
}

/* ---------------- filter bar ---------------- */
.filter-bar {
    margin-bottom: 24px;
    padding: 16px 0;
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
}
.filter-bar .grid { margin-bottom: 8px; }
.filter-bar .grid:last-child { margin-bottom: 0; }
.filter-bar label { margin-bottom: 6px; }

/* ---------------- bulk bar ---------------- */
.bulk-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    padding: 10px 16px;
    background: var(--inset);
    border: 1px solid var(--hairline-2);
    border-radius: var(--radius-1);
    margin-bottom: 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
}
.bulk-bar > span {
    color: var(--ink);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.10em;
}
.bulk-bar select {
    margin: 0;
    padding: 4px 8px;
    font-size: 11px;
    width: auto;
    height: 26px;
}

.selected-row { background: var(--select-bg); }
.selected-row td:first-child { box-shadow: inset 2px 0 0 var(--ink); }

/* ---------------- pagination ---------------- */
.pagination {
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--hairline);
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.06em;
}

/* ---------------- ledger ---------------- */
.ledger-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
    gap: 24px;
}
.ledger-header h1 { margin-bottom: 8px; }
.ledger-header .muted {
    color: var(--muted);
    margin: 0;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
}

.ledger-table { font-size: 12.5px; }
.ledger-table .desc-cell { max-width: 360px; overflow: hidden; }
.ledger-table .desc-truncate {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sortable-header {
    cursor: pointer;
    user-select: none;
    transition: color var(--t-fast) var(--ease);
}
.sortable-header:hover { color: var(--ink); }

.sort-indicator {
    font-size: 8px;
    margin-left: 4px;
    opacity: 0.6;
}

.split-icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--faint);
    height: 24px;
    width: 24px;
    border-radius: var(--radius-1);
    transition: color var(--t-fast) var(--ease), background-color var(--t-fast) var(--ease);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.split-icon-btn:hover { color: var(--ink); background: var(--inset); }
.split-icon-btn svg { width: 14px; height: 14px; vertical-align: middle; }

/* ---------------- rule suggestion ---------------- */
.rule-suggestion {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 14px;
    background: transparent;
    border: 1px solid var(--hairline-3);
    border-radius: var(--radius-1);
    margin-bottom: 16px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    color: var(--ink);
}
.rule-suggestion span:first-child {
    text-transform: none;
    letter-spacing: 0.02em;
}
.rule-suggestion strong { color: var(--ink); font-weight: 600; }
.rule-suggestion button { margin: 0; }
.rule-suggestion .inline-input {
    border: 1px solid var(--hairline-2);
    background: var(--surface);
    height: 26px;
}

/* ---------------- credit card credit row ---------------- */
.cc-credit {
    background: var(--pos-soft);
}

.cc-credit-label {
    color: var(--pos);
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 10px;
    letter-spacing: 0.14em;
    margin-right: 4px;
    padding: 1px 4px;
    border: 1px solid var(--pos);
    border-radius: var(--radius-1);
}

/* ---------------- splits ---------------- */
.split-row {
    border: 1px solid var(--hairline-2);
    border-radius: var(--radius-1);
    padding: 12px 14px;
    margin-bottom: 8px;
    background: transparent;
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.split-summary {
    margin-top: 16px;
    padding: 12px 14px;
    background: var(--inset);
    border-radius: var(--radius-1);
    font-family: var(--font-mono);
    font-size: 12px;
}

/* ---------------- tabs ---------------- */
.tab-nav {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--hairline-2);
    padding-bottom: 0;
}

.tab-nav button {
    background: none;
    border: none;
    color: var(--muted);
    padding: 10px 16px 10px 0;
    cursor: pointer;
    border-bottom: 1px solid transparent;
    margin-right: 24px;
    margin-bottom: -1px;
    font-family: var(--font-mono);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    height: auto;
    border-radius: 0;
    transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.tab-nav button.active {
    color: var(--ink);
    border-bottom-color: var(--ink);
    font-weight: 600;
}

.tab-nav button:hover {
    color: var(--ink);
    background: none;
    border-color: transparent;
}

.tab-nav button.active:hover { border-bottom-color: var(--ink); }

/* ---------------- balance cards (now: typographic stat blocks) ---------------- */
.balance-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0;
    border-top: 1px solid var(--hairline-2);
    border-bottom: 1px solid var(--hairline-2);
    margin-bottom: 32px;
}

.balance-card {
    cursor: pointer;
    padding: 18px 20px 18px 0;
    border: none;
    border-right: 1px solid var(--hairline);
    background: transparent;
    transition: background-color var(--t-fast) var(--ease);
    margin: 0;
}
.balance-card:last-child { border-right: none; }
.balance-card:hover { background: var(--select-bg); }

.balance-card header {
    border: none;
    padding: 0;
    margin: 0 0 10px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
}
.balance-card p {
    margin: 6px 0 0;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    font-weight: 500;
}

.balance-card footer {
    border-top: 1px solid var(--hairline);
    margin-top: 14px;
    padding-top: 10px;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.04em;
    color: var(--muted);
}
.balance-card footer small {
    text-transform: none;
    letter-spacing: 0.04em;
    font-size: 10px;
}

.balance-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 26px;
    font-weight: 500;
    text-align: left;
    margin: 0;
    color: var(--ink);
    letter-spacing: -0.015em;
    line-height: 1.1;
}
.balance-amount.amount-positive { color: var(--pos); }
.balance-amount.amount-negative { color: var(--neg); }

/* ---------------- dashboard: typographic header ---------------- */
.dash-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    border-bottom: 1px solid var(--hairline-2);
    padding-bottom: 24px;
    margin-bottom: 32px;
    gap: 24px;
}
.dash-header h1 { margin: 0; }
.dash-month {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--ink);
}
.dash-month .month-label {
    min-width: 110px;
    text-align: center;
}
.dash-month button {
    width: 26px;
    height: 26px;
    padding: 0;
    font-size: 14px;
    line-height: 1;
}

/* hero block — replaces the 5-card grid */
.dash-hero {
    padding: 28px 0 36px;
    border-bottom: 1px solid var(--hairline-2);
    margin-bottom: 0;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 48px;
    align-items: end;
}

.dash-hero-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 80px;
    font-weight: 400;
    letter-spacing: -0.04em;
    color: var(--ink);
    line-height: 1;
    margin-bottom: 6px;
    display: block;
}
.dash-hero-amount .currency {
    font-size: 0.42em;
    color: var(--muted);
    letter-spacing: 0.06em;
    margin-right: 0.16em;
    vertical-align: 0.65em;
    font-weight: 500;
}
.dash-hero-amount.is-negative { color: var(--neg); }

.dash-hero-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
}

.dash-hero-meta {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-end;
    text-align: right;
}
.dash-hero-meta .income-line {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    font-size: 13px;
}
.dash-hero-meta .income-line .label {
    color: var(--muted);
    font-size: 10px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    margin-right: 8px;
}

/* secondary stats row */
.dash-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    border-bottom: 1px solid var(--hairline-2);
    margin-bottom: 36px;
}

.dash-stat {
    padding: 22px 24px 22px 0;
    border-right: 1px solid var(--hairline);
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.dash-stat:last-child { border-right: none; }

.dash-stat-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 24px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--ink);
    line-height: 1.1;
}

.dash-stat-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
}

.dash-stat .delta {
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.04em;
}

/* legacy summary-cards retained but re-skinned to a clean strip */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0;
    margin-bottom: 32px;
    border-top: 1px solid var(--hairline-2);
    border-bottom: 1px solid var(--hairline-2);
}

.summary-card {
    text-align: left;
    padding: 18px 22px 18px 0;
    margin: 0;
    background: transparent;
    border: none;
    border-right: 1px solid var(--hairline);
    border-radius: 0;
    box-shadow: none;
}
.summary-card:last-child { border-right: none; padding-right: 0; }

.summary-card small {
    display: block;
    margin-bottom: 6px;
    text-transform: uppercase;
    font-size: 10px;
    letter-spacing: 0.12em;
    color: var(--muted);
    font-family: var(--font-mono);
    font-weight: 500;
}

.summary-card strong {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 22px;
    font-weight: 500;
    letter-spacing: -0.01em;
    color: var(--ink);
}

/* deliberately remove the colored side-stripe accents */
.summary-card.income,
.summary-card.expenses,
.summary-card.savings,
.summary-card.investments,
.summary-card.remaining {
    border-top: none;
}

/* ---------------- month selector (legacy) ---------------- */
.month-selector {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}
.month-selector h2 {
    margin: 0;
    min-width: 180px;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 12px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

/* ---------------- chart sections ---------------- */
.chart-section {
    margin-bottom: 40px;
    padding-top: 8px;
}

.chart-section h3 {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--muted);
    font-weight: 500;
    margin-bottom: 16px;
}

.chart-grid {
    display: grid;
    grid-template-columns: minmax(220px, 360px) 1fr;
    gap: 40px;
    align-items: center;
}

/* doughnut + center label */
.chart-pie-wrap { position: relative; max-width: 360px; }
.pie-center {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
}
.pie-center-amount {
    font-size: 22px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}
.pie-center-label {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    margin-top: 4px;
}

/* category legend list */
.cat-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cat-legend li {
    display: grid;
    grid-template-columns: 14px 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--hairline);
    font-size: 13px;
}
.cat-legend li:last-child { border-bottom: none; }
.cat-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
    flex-shrink: 0;
}
.cat-legend .cat-name { color: var(--ink); }
.cat-legend .cat-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    font-weight: 500;
}
.cat-legend .cat-pct {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    min-width: 48px;
    text-align: right;
}
.cat-swatch-deduction {
    background: transparent;
    border: 1px dashed var(--pos);
    box-sizing: border-box;
}

/* top vendors */
.vendor-list {
    list-style: none;
    margin: 0;
    padding: 0;
    counter-reset: vendor;
}
.vendor-list li {
    display: grid;
    grid-template-columns: 24px minmax(120px, 1fr) auto minmax(120px, 2fr) auto;
    gap: 16px;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--hairline);
    font-size: 13px;
}
.vendor-rank {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--faint);
    text-align: right;
}
.vendor-name {
    color: var(--ink);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.vendor-count {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
}
.vendor-bar {
    display: block;
    height: 6px;
    background: var(--hairline);
    border-radius: 3px;
    overflow: hidden;
}
.vendor-bar-fill {
    display: block;
    height: 100%;
    background: var(--ink);
    transition: width var(--t-norm) var(--ease);
}
.vendor-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    font-weight: 500;
    text-align: right;
}

/* account balance cards */
.balance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
.balance-card {
    padding: 16px 18px;
    border: 1px solid var(--hairline-2);
    background: var(--subsurface);
    display: flex;
    flex-direction: column;
    gap: 6px;
    border-radius: var(--radius-1);
    transition: border-color var(--t-fast) var(--ease);
}
.balance-card:hover { border-color: var(--hairline-3); }
.balance-card.balance-credit_card { border-left: 3px solid var(--neg); }
.balance-card.balance-bank { border-left: 3px solid var(--pos); }
.balance-card.balance-savings { border-left: 3px solid var(--ink); }
.balance-card.balance-investment { border-left: 3px solid var(--muted); }
.balance-inst {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
}
.balance-name {
    font-size: 13px;
    color: var(--ink);
    font-weight: 500;
}
.balance-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    font-size: 18px;
    color: var(--ink);
    font-weight: 600;
    margin-top: 4px;
}
.balance-amount.is-negative { color: var(--neg); }
.balance-amount .currency {
    font-size: 11px;
    margin-right: 4px;
    color: var(--muted);
    font-weight: 500;
}

.waterfall-chart {
    width: 100%;
    min-height: 320px;
}

.waterfall-chart svg text {
    font-family: var(--font-mono);
    font-size: 10px;
    fill: var(--muted);
    letter-spacing: 0.04em;
}
.waterfall-chart svg .domain,
.waterfall-chart svg .tick line {
    stroke: var(--hairline-2);
    shape-rendering: crispEdges;
}
.waterfall-chart svg .tick text { fill: var(--muted); }

/* ---------------- budget tracker ---------------- */
.budget-item { margin-bottom: 16px; }

.budget-label {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 11px;
    margin-bottom: 6px;
    letter-spacing: 0.04em;
}

.budget-bar-bg {
    height: 4px;
    background: var(--hairline);
    border-radius: 0;
    overflow: hidden;
    position: relative;
}

.budget-bar-fill {
    height: 100%;
    border-radius: 0;
    transition: width 0.6s var(--ease);
    background: var(--ink);
}

.budget-alert {
    background: var(--neg-soft);
    border: 1px solid var(--neg);
    color: var(--neg);
    padding: 12px 16px;
    border-radius: var(--radius-1);
    margin-bottom: 24px;
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.06em;
    font-weight: 500;
    text-transform: uppercase;
}

/* ---------------- statement drift ---------------- */
.drift-warning {
    background: var(--neg-soft);
    border-left: 3px solid var(--neg);
    color: var(--ink);
    padding: 12px 16px;
    margin: 0 0 20px;
    font-size: 12.5px;
    line-height: 1.5;
}
.drift-warning strong {
    color: var(--neg);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    margin-right: 8px;
}
.drift-warning .muted {
    display: block;
    margin-top: 4px;
    color: var(--muted);
    font-size: 11px;
    font-family: var(--font-mono);
}

/* ---------------- responsive ---------------- */
@media (max-width: 960px) {
    .content { padding: 28px 32px 60px; }
    h1 { font-size: 36px; }
    .dash-hero { grid-template-columns: 1fr; gap: 24px; }
    .dash-hero-meta { align-items: flex-start; text-align: left; }
    .dash-hero-amount { font-size: 56px; }
    .dash-stats { grid-template-columns: repeat(2, 1fr); }
    .dash-stat:nth-child(2) { border-right: none; }
    .dash-stat:nth-child(odd) { border-right: 1px solid var(--hairline); }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .summary-card:nth-child(2) { border-right: none; }
    .chart-grid { grid-template-columns: 1fr; }
    .grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
    :root { --sidebar-width: var(--sidebar-collapsed-width); }
    .sidebar-logo { display: none; }
    .nav-label { opacity: 0; width: 0; overflow: hidden; }
    .summary-cards { grid-template-columns: 1fr; }
    .summary-card { border-right: none; border-bottom: 1px solid var(--hairline); }
    .dash-stats { grid-template-columns: 1fr; }
    .dash-stat { border-right: none; border-bottom: 1px solid var(--hairline); }
    .dash-stat:last-child { border-bottom: none; }
    .balance-cards { grid-template-columns: 1fr; }
    .balance-card { border-right: none; border-bottom: 1px solid var(--hairline); }
    .balance-card:last-child { border-bottom: none; }
}

@media (max-width: 480px) {
    .sidebar {
        position: fixed;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform var(--t-norm) var(--ease);
    }
    .app-shell:not(.sidebar-collapsed) .sidebar { transform: translateX(0); }
    .sidebar-collapsed .sidebar { transform: translateX(-100%); }
    .content { padding: 20px 18px 60px; }
    h1 { font-size: 28px; margin-bottom: 18px; }
    .dash-hero-amount { font-size: 44px; }
}

/* ---------------- dashboard section labels ---------------- */
.dash-section-label {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: var(--muted);
    border-top: 1px solid var(--hairline);
    padding-top: 12px;
    margin: 32px 0 20px;
}

/* ---------------- income breakdown ---------------- */
.income-breakdown {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.income-bar {
    display: flex;
    width: 100%;
    height: 10px;
    border-radius: 2px;
    overflow: hidden;
    background: var(--hairline);
}
.income-bar-segment {
    height: 100%;
    cursor: pointer;
    transition: opacity 120ms var(--ease);
}
.income-bar-segment:hover { opacity: 0.85; }
.income-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.income-legend-row {
    display: grid;
    grid-template-columns: 14px 1fr auto auto;
    align-items: center;
    gap: 12px;
    padding: 6px 8px;
    margin: 0 -8px;
    font-size: 13px;
    cursor: pointer;
    border-radius: 3px;
    transition: background 120ms var(--ease);
}
.income-legend-row:hover { background: var(--inset); }
.income-legend-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}
.income-legend-name { color: var(--ink); }
.income-legend-amount {
    font-family: var(--font-mono);
    font-variant-numeric: tabular-nums;
    color: var(--ink);
    font-weight: 500;
}
.income-legend-pct {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    min-width: 48px;
    text-align: right;
}
.income-empty {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    margin: 0;
}

/* ---------------- category detail page ---------------- */
.cat-detail-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.cat-back {
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    text-decoration: none;
    padding: 4px 0;
}
.cat-back:hover { color: var(--ink); }
.cat-detail-title {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 200px;
}
.cat-detail-title h1 { margin: 0; }
.cat-detail-swatch {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    flex-shrink: 0;
}
.cat-detail-type {
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.10em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 2px 8px;
    border: 1px solid var(--hairline-2);
    border-radius: 3px;
}

.cat-detail-summary {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 24px;
    padding: 20px 0;
    border-top: 1px solid var(--hairline);
    border-bottom: 1px solid var(--hairline);
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.cat-summary-stats {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cat-summary-amount {
    font-size: 36px;
    font-weight: 600;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.cat-summary-amount .currency {
    font-size: 18px;
    color: var(--muted);
    margin-right: 4px;
    font-weight: 500;
}
.cat-summary-meta {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    display: flex;
    gap: 16px;
    margin-top: 4px;
}
.cat-anomaly-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-width: 60%;
}
.cat-anomaly-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--hairline-2);
    border-radius: 3px;
    font-size: 12px;
    background: var(--surface);
}
.cat-anomaly-tag.tone-warn { border-color: var(--neg); color: var(--neg); background: var(--neg-soft, transparent); }
.cat-anomaly-tag.tone-ok   { border-color: var(--pos); color: var(--pos); background: var(--pos-soft, transparent); }
.cat-anomaly-tag.tone-info { border-color: var(--hairline-2); color: var(--ink); }
.cat-anomaly-icon { font-size: 13px; }
.cat-anomaly-label { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.04em; }
.cat-anomaly-empty {
    color: var(--muted);
    font-family: var(--font-mono);
    font-size: 11px;
    letter-spacing: 0.04em;
    margin: 0;
}

.cat-trend-foot {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.04em;
}

.cat-detail-trend-wrap {
    position: relative;
    width: 100%;
    height: 220px;
}
.cat-detail-trend-wrap > canvas {
    width: 100% !important;
    height: 100% !important;
}

.split-amount-note {
    display: block;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--muted);
    font-weight: 400;
    margin-top: 2px;
}

/* clickable category entry points on the dashboard */
.cat-legend-row {
    cursor: pointer;
    transition: background 120ms var(--ease);
}
.cat-legend-row:hover { background: var(--inset); }
.cat-legend-row-uncat .cat-name { color: var(--muted); font-style: italic; }
.cat-legend-row-deduction { cursor: default; }
.cat-legend-row-deduction:hover { background: transparent; }
.cat-legend-row-deduction .cat-name { color: var(--muted); }
.cat-legend-row-deduction .cat-amount { color: var(--pos); }

.cat-trend-card {
    cursor: pointer;
    transition: border-color 120ms var(--ease), background 120ms var(--ease);
}
.cat-trend-card:hover {
    border-color: var(--ink);
    background: var(--inset);
}

.budget-item-clickable {
    cursor: pointer;
    padding: 8px;
    margin: 0 -8px 8px -8px;
    border-radius: 3px;
    transition: background 120ms var(--ease);
}
.budget-item-clickable:hover { background: var(--inset); }

/* ---------------- print ---------------- */
@media print {
    .sidebar, .sidebar-toggle, .filter-bar, .bulk-bar, .pagination, .button-row { display: none !important; }
    .content { padding: 0; }
    body { background: white; color: black; }
}

/* ===== Backup reminder toast ===== */
.backup-reminder-toast {
    position: fixed;
    bottom: 1.25rem;
    right: 1.25rem;
    z-index: 1000;
    max-width: 320px;
    padding: 0.875rem 1rem;
    background: var(--surface);
    color: var(--ink);
    border: 1px solid var(--hairline-2);
    border-radius: 8px;
    box-shadow: 0 8px 24px oklch(0 0 0 / 0.18);
    font-size: 13px;
    line-height: 1.4;
    animation: backup-reminder-slide-in 200ms ease-out;
}

@keyframes backup-reminder-slide-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.backup-reminder-text {
    margin-bottom: 0.625rem;
    font-weight: 500;
}

.backup-reminder-actions {
    display: flex;
    gap: 0.5rem;
}

.backup-reminder-primary,
.backup-reminder-ghost {
    padding: 0.375rem 0.75rem;
    font-size: 12px;
    font-weight: 500;
    border-radius: 4px;
    cursor: pointer;
    border: 1px solid var(--hairline-2);
}

.backup-reminder-primary {
    background: var(--ink);
    color: var(--surface);
    border-color: var(--ink);
}

.backup-reminder-primary:hover {
    opacity: 0.85;
}

.backup-reminder-ghost {
    background: transparent;
    color: var(--muted);
}

.backup-reminder-ghost:hover {
    color: var(--ink);
    border-color: var(--ink);
}
