:root {
    /* Modern Finance Tracker theme (shared with Daily Budget) */
    --ink: #0f1c1a;
    --muted: #5c6f6a;
    --bg0: #eef6f3;
    --bg1: #d9ebe4;
    --surface: rgba(255, 255, 255, 0.78);
    --surface-solid: #f7fbf9;
    --accent: #0d7a62;
    --accent-deep: #065f4c;
    --warn: #c2410c;
    --line: rgba(15, 28, 26, 0.1);
    --shadow: 0 18px 50px rgba(15, 40, 34, 0.12);
    --radius: 1.15rem;
    --font-display: Fraunces, Georgia, serif;
    --font-money: Outfit, "DM Sans", system-ui, sans-serif;

    /* Legacy aliases used across loan / spending CSS */
    --primary-color: var(--accent);
    --secondary-color: var(--accent-deep);
    --background-color: var(--bg0);
    --card-background: var(--surface-solid);
    --text-color: var(--ink);
    --border-color: var(--line);
    --success-color: var(--accent);
    --danger-color: var(--warn);

    /* Daily Budget aliases */
    --db-ink: var(--ink);
    --db-muted: var(--muted);
    --db-bg0: var(--bg0);
    --db-bg1: var(--bg1);
    --db-surface: var(--surface);
    --db-surface-solid: var(--surface-solid);
    --db-accent: var(--accent);
    --db-accent-deep: var(--accent-deep);
    --db-warn: var(--warn);
    --db-line: var(--line);
    --db-shadow: var(--shadow);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: "DM Sans", system-ui, sans-serif;
    background-color: var(--bg0);
    color: var(--ink);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

body.app-page::before,
body.db-page::before,
body.spending-page::before,
body.home-page::before,
body.login-page::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background:
        radial-gradient(900px 500px at 10% -10%, rgba(13, 122, 98, 0.28), transparent 55%),
        radial-gradient(700px 480px at 100% 0%, rgba(20, 80, 110, 0.18), transparent 50%),
        linear-gradient(165deg, var(--bg0), var(--bg1) 55%, #e7f0ec);
}

body.app-page > *,
body.db-page > *,
body.spending-page > *,
body.home-page > *,
body.login-page > * {
    position: relative;
    z-index: 1;
}

.container,
.app-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

header {
    margin-bottom: 1.5rem;
}

h1 {
    font-family: var(--font-display);
    color: var(--ink);
    font-size: 2.25rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 1rem;
}

.card {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15, 40, 34, 0.06);
    padding: 1.35rem 1.45rem;
    margin-bottom: 1.5rem;
}

h2 {
    font-family: var(--font-display);
    color: var(--ink);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
}

/* Shared chrome */
.app-brand {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    text-decoration: none;
}

.app-header {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15, 40, 34, 0.06);
}

.app-header-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem 1rem;
}

.app-header-left {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem 1.25rem;
}

.app-header-right {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}

.app-session {
    font-size: 0.85rem;
    color: var(--muted);
}

.app-nav {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.25rem;
    width: 100%;
    padding: 0.25rem;
    border-radius: 1.15rem;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid var(--line);
    backdrop-filter: blur(8px);
}

.app-nav a {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 0.35rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--muted);
    text-decoration: none;
    text-align: center;
    transition: background 0.15s ease, color 0.15s ease;
}

.app-nav a:hover {
    color: var(--ink);
}

.app-nav a.app-nav-active {
    background: var(--ink);
    color: #f4faf7;
}

@media (min-width: 768px) {
    .app-header {
        display: grid;
        grid-template-columns: auto 1fr auto;
        align-items: center;
        column-gap: 1.25rem;
        row-gap: 0.65rem;
    }

    .app-header-top {
        display: contents;
    }

    .app-brand {
        grid-column: 1;
        grid-row: 1;
    }

    .app-nav {
        display: inline-flex;
        flex-wrap: nowrap;
        width: auto;
        grid-column: 2;
        grid-row: 1;
        justify-self: start;
        gap: 0.2rem;
        padding: 0.2rem;
        border-radius: 999px;
    }

    .app-nav a {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
        min-height: 0;
        white-space: nowrap;
        flex: 0 0 auto;
    }

    .app-header-right {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
    }

    /* Loan detail: title + actions on row 1, nav full-width row 2 */
    .loan-detail-header {
        grid-template-columns: 1fr auto;
    }

    .loan-detail-header .loan-detail-title {
        grid-column: 1;
        grid-row: 1;
    }

    .loan-detail-header .loan-detail-actions {
        grid-column: 2;
        grid-row: 1;
    }

    .loan-detail-header .app-nav {
        grid-column: 1 / -1;
        grid-row: 2;
        justify-self: start;
    }
}

.app-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    font-size: 0.9rem;
    border-radius: 0.85rem;
    padding: 0.65rem 1rem;
    text-decoration: none;
    transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

.app-btn:active {
    transform: scale(0.98);
}

.app-btn--primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 10px 22px rgba(13, 122, 98, 0.25);
}

.app-btn--primary:hover {
    background: var(--accent-deep);
    color: #fff;
}

.app-btn--ghost {
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--line);
    color: var(--ink);
}

.app-btn--danger {
    background: var(--warn);
    color: #fff;
}

.app-btn--muted {
    background: rgba(15, 28, 26, 0.08);
    color: var(--ink);
}

/* Quantities: Outfit — clearer numerals than Fraunces, still expressive */
.money-hero-value,
.money-hero-value--prompt,
.money-hero-stat-value,
.glass-stat-value,
.home-spotlight-value,
.home-spotlight-value--prompt,
.home-spotlight-stat-value,
.db-hero-value,
.db-entry-currency,
.db-entry-amount,
.db-meta-value,
.db-goals-hero-value,
.spending-metric__value,
.balance-amount,
.stat-value,
body.app-page .balance-amount {
    font-family: var(--font-money);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

/* Shared money hero (Home / Daily / Monthly / Loans) */
.money-hero {
    display: block;
    text-decoration: none;
    color: #eef8f4;
    padding: 1.45rem 1.35rem 1.35rem;
    border-radius: 1.35rem;
    background:
        linear-gradient(145deg, rgba(15, 28, 26, 0.96), rgba(13, 70, 58, 0.92));
    box-shadow: 0 18px 40px rgba(15, 40, 34, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

a.money-hero:hover,
.home-spotlight-hero:hover {
    transform: translateY(-1px);
    box-shadow: 0 22px 48px rgba(15, 40, 34, 0.22);
    color: #eef8f4;
}

.money-hero--warn,
.home-spotlight-hero--over {
    background:
        linear-gradient(145deg, rgba(60, 20, 12, 0.96), rgba(120, 45, 20, 0.9));
}

.money-hero-kicker,
.home-spotlight-kicker {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #eef8f4;
    opacity: 0.72;
    margin-bottom: 0.35rem;
}

.money-hero-label,
.home-spotlight-label {
    font-size: 0.95rem;
    font-weight: 600;
    color: #eef8f4;
    opacity: 0.88;
    margin-bottom: 0.2rem;
}

.money-hero-value,
.home-spotlight-value {
    font-family: var(--font-money);
    font-size: clamp(2.35rem, 8vw, 3.25rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    color: #eef8f4;
}

.money-hero-value--prompt,
.home-spotlight-value--prompt {
    font-size: clamp(1.75rem, 6vw, 2.35rem);
}

.money-hero-meta,
.home-spotlight-meta {
    margin-top: 0.65rem;
    font-size: 0.88rem;
    color: #eef8f4;
    opacity: 0.78;
    line-height: 1.4;
}

.money-hero-delta {
    margin-top: 0.35rem;
    font-size: 0.85rem;
    color: #eef8f4;
    opacity: 0.85;
}

.money-hero-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 1.5rem;
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px solid rgba(238, 248, 244, 0.18);
}

.money-hero-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.money-hero-stat-label {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    opacity: 0.65;
}

.money-hero-stat-value {
    font-family: var(--font-money);
    font-size: 1.15rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

/* Glass stat tiles */
.glass-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    padding: 1rem 1.05rem;
    border-radius: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(15, 40, 34, 0.06);
    transition: border-color 0.15s ease, transform 0.12s ease;
}

a.glass-stat:hover {
    border-color: rgba(13, 122, 98, 0.45);
    transform: translateY(-1px);
    color: inherit;
}

.glass-stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.glass-stat-value {
    font-family: var(--font-money);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.glass-stat-value--muted {
    color: var(--muted);
}

.glass-stat-meta {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.35;
}

.app-section-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 0.35rem;
}

.app-section-lead {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 1rem;
    line-height: 1.45;
}

.app-control {
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface-solid);
    color: var(--ink);
    font-family: inherit;
    font-size: 0.95rem;
}

.app-control:focus {
    outline: 2px solid rgba(13, 122, 98, 0.35);
    outline-offset: 1px;
}

/* Home hub */
body.home-page {
    background: transparent;
    color: var(--ink);
}

.home-spotlight {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.home-spotlight-hero {
    display: block;
    text-decoration: none;
    color: #eef8f4;
    padding: 1.45rem 1.35rem 1.35rem;
    border-radius: 1.35rem;
    background:
        linear-gradient(145deg, rgba(15, 28, 26, 0.96), rgba(13, 70, 58, 0.92));
    box-shadow: 0 18px 40px rgba(15, 40, 34, 0.18);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.home-spotlight-hero:hover {
    transform: translateY(-1px);
    box-shadow: 0 22px 48px rgba(15, 40, 34, 0.22);
    color: #eef8f4;
}

.home-spotlight-hero--over {
    background:
        linear-gradient(145deg, rgba(60, 20, 12, 0.96), rgba(120, 45, 20, 0.9));
}

.home-spotlight-kicker {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.72;
    margin-bottom: 0.35rem;
}

.home-spotlight-label {
    font-size: 0.95rem;
    font-weight: 600;
    opacity: 0.88;
    margin-bottom: 0.2rem;
}

.home-spotlight-value {
    font-family: var(--font-money);
    font-size: clamp(2.35rem, 8vw, 3.25rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.home-spotlight-value--prompt {
    font-size: clamp(1.75rem, 6vw, 2.35rem);
}

.home-spotlight-meta {
    margin-top: 0.65rem;
    font-size: 0.88rem;
    opacity: 0.78;
    line-height: 1.4;
}

.home-spotlight-side {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.home-spotlight-stat {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    text-decoration: none;
    color: inherit;
    padding: 1rem 1.05rem;
    border-radius: 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    backdrop-filter: blur(10px);
    box-shadow: 0 10px 28px rgba(15, 40, 34, 0.06);
    transition: border-color 0.15s ease, transform 0.12s ease;
}

.home-spotlight-stat:hover {
    border-color: rgba(13, 122, 98, 0.45);
    transform: translateY(-1px);
    color: inherit;
}

.home-spotlight-stat-label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.home-spotlight-stat-value {
    font-family: var(--font-money);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
}

.home-spotlight-stat-value--muted {
    color: var(--muted);
}

.home-spotlight-stat-meta {
    font-size: 0.78rem;
    color: var(--muted);
    line-height: 1.35;
}

@media (min-width: 768px) {
    .home-spotlight {
        grid-template-columns: minmax(0, 1.35fr) minmax(0, 0.9fr);
        gap: 1rem;
        align-items: stretch;
    }

    .home-spotlight-hero {
        padding: 1.75rem 1.6rem 1.55rem;
        display: flex;
        flex-direction: column;
        justify-content: center;
        min-height: 100%;
    }

    .home-spotlight-side {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .home-spotlight-stat {
        flex: 1 1 auto;
        justify-content: center;
        padding: 1.15rem 1.25rem;
    }

    .home-spotlight-stat-value {
        font-size: 1.55rem;
    }
}

.home-section {
    margin-bottom: 1.5rem;
}

.home-section-h {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
}

.home-section-sub {
    font-size: 0.9rem;
    color: var(--muted);
    margin-bottom: 0;
}

.home-page .hidden {
    display: none !important;
}

.home-statements-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem 1.25rem;
    margin-bottom: 1rem;
}

.home-statements-head .home-section-h {
    margin-bottom: 0.25rem;
}

.home-statements-head .home-section-sub {
    margin-bottom: 0;
}

.home-statements-head .reconcile-btn {
    flex-shrink: 0;
    align-self: center;
}

.home-statements-callout {
    margin: 0 0 1rem;
    padding: 0.7rem 0.9rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(13, 122, 98, 0.28);
    background: rgba(13, 122, 98, 0.08);
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--ink);
}

.home-statements-callout a {
    color: var(--accent-deep);
    font-weight: 600;
}

.home-month-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.home-month {
    display: grid;
    grid-template-columns: 5.5rem minmax(0, auto) minmax(0, 1fr) 0.75rem;
    align-items: center;
    gap: 0.65rem 0.85rem;
    padding: 0.7rem 0.95rem;
    border-radius: 0.85rem;
    border: 1px solid var(--line);
    background: transparent;
    color: inherit;
    text-decoration: none;
}

.home-month:hover {
    border-color: rgba(13, 122, 98, 0.35);
    background: rgba(255, 255, 255, 0.55);
}

.home-month--current {
    background: rgba(13, 122, 98, 0.07);
    border-color: rgba(13, 122, 98, 0.22);
}

.home-month-label {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}

.home-month-pill {
    display: inline-flex;
    align-items: center;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    white-space: nowrap;
    background: rgba(15, 28, 26, 0.06);
    color: var(--muted);
}

.home-month-pill--imported {
    background: rgba(13, 122, 98, 0.12);
    color: var(--accent-deep);
}

.home-month-pill--imported_without_recon {
    background: rgba(15, 28, 26, 0.07);
    color: var(--ink);
}

.home-month-pill--in_progress {
    background: rgba(13, 122, 98, 0.16);
    color: var(--accent-deep);
}

.home-month-detail {
    font-size: 0.8125rem;
    color: var(--muted);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.home-month-chevron {
    width: 0.4rem;
    height: 0.4rem;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(-45deg);
    justify-self: end;
}

.home-months-toggle {
    margin-top: 0.75rem;
    background: none;
    border: 0;
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--accent-deep);
    cursor: pointer;
}

.home-months-toggle:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .home-month {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "label chevron"
            "pill pill"
            "detail detail";
        gap: 0.35rem 0.6rem;
        padding: 0.75rem 0.85rem;
    }
    .home-month-label { grid-area: label; }
    .home-month-pill { grid-area: pill; justify-self: start; }
    .home-month-detail { grid-area: detail; white-space: normal; }
    .home-month-chevron { grid-area: chevron; }
    .home-statements-head .reconcile-btn {
        width: 100%;
        justify-content: center;
    }
}

.home-import-next:not(.hidden) {
    margin-top: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(13, 122, 98, 0.3);
    background: rgba(13, 122, 98, 0.08);
    font-size: 0.9rem;
}

.home-import-next.hidden {
    display: none !important;
}

.home-import-next a {
    color: var(--accent-deep);
    font-weight: 600;
    margin-right: 0.85rem;
}

/* Statement import form (Home) */
.import-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.import-fields {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

.import-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.import-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--muted);
}

.import-field .spending-control,
.import-field .spending-control.import-file-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

/* Same box for month/date/text so the Source column lines up with period fields. */
.import-fields .import-field > input.spending-control,
.import-fields .import-field .source-combobox > input.spending-control {
    height: 2.75rem;
    min-height: 2.75rem;
    line-height: 1.25;
}

/* Custom Source combobox (replaces unreliable native <datalist>). */
.source-combobox {
    position: relative;
    width: 100%;
    min-width: 0;
}

.source-combobox__list {
    position: absolute;
    z-index: 40;
    left: 0;
    right: 0;
    top: calc(100% + 0.25rem);
    margin: 0;
    padding: 0.35rem;
    list-style: none;
    max-height: min(14rem, 45vh);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    background: var(--surface-solid);
    box-shadow: 0 10px 28px rgba(15, 40, 32, 0.12);
}

.source-combobox__list[hidden] {
    display: none !important;
}

.source-combobox__option {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.65rem 0.75rem;
    border: 0;
    border-radius: 0.65rem;
    background: transparent;
    color: var(--ink);
    font: inherit;
    font-size: 0.95rem;
    text-align: left;
    cursor: pointer;
    line-height: 1.3;
}

.source-combobox__option:hover,
.source-combobox__option[aria-selected="true"] {
    background: rgba(13, 122, 98, 0.12);
    color: var(--accent-deep);
}

.source-combobox__empty {
    margin: 0;
    padding: 0.65rem 0.75rem;
    color: var(--muted);
    font-size: 0.85rem;
    line-height: 1.35;
}

.import-reset {
    align-self: stretch;
    text-align: center;
}

.import-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
}

.import-actions .spending-btn {
    width: 100%;
    text-align: center;
    padding: 0.85rem 1rem;
}

@media (min-width: 640px) {
    .import-fields {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        /* Top-align so fields with different heights (e.g. Source + hint)
           keep labels/inputs on the same row as siblings. */
        align-items: start;
    }

    .import-reset {
        align-self: flex-start;
        width: auto;
    }

    .import-actions {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.65rem;
    }

    .import-actions .spending-btn {
        width: auto;
        padding: 0.55rem 1rem;
    }

    .import-field--file {
        max-width: 28rem;
    }
}

@media (min-width: 960px) {
    .import-fields {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Monthly insights toolbar */
.spending-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.spending-toolbar-controls {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.spending-toolbar-month .spending-control {
    width: 100%;
}

.spending-toolbar-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

.spending-toolbar-actions .spending-btn {
    width: 100%;
    text-align: center;
    padding: 0.75rem 0.85rem;
}

@media (min-width: 768px) {
    .spending-toolbar {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: flex-end;
        gap: 1rem;
    }

    .spending-toolbar-controls {
        flex-direction: row;
        flex-wrap: wrap;
        align-items: flex-end;
        gap: 0.65rem;
    }

    .spending-toolbar-month .spending-control {
        width: auto;
        min-width: 11rem;
    }

    .spending-toolbar-actions {
        display: flex;
        flex-wrap: wrap;
        width: auto;
    }

    .spending-toolbar-actions .spending-btn {
        width: auto;
        padding: 0.55rem 0.85rem;
    }
}


.app-surface {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15, 40, 34, 0.06);
    padding: 1.35rem 1.45rem;
}

.app-table {
    width: 100%;
    border-collapse: collapse;
}

.app-table th {
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: rgba(15, 28, 26, 0.03);
}

.app-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.app-table tr:last-child td {
    border-bottom: 0;
}

.app-table tbody tr {
    transition: background 0.12s ease;
}

.app-table tbody tr:hover {
    background: rgba(13, 122, 98, 0.06);
}

.app-badge {
    display: inline-block;
    margin-left: 0.4rem;
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    background: rgba(194, 65, 12, 0.12);
    color: var(--warn);
}

.app-modal-backdrop {
    background: rgba(15, 28, 26, 0.45);
    backdrop-filter: blur(4px);
}

.app-modal {
    background: var(--surface-solid);
    border: 1px solid var(--line);
    border-radius: 1.25rem;
    box-shadow: var(--shadow);
}

.summary-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    font-size: 1.1rem;
}

.summary-details p {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background-color: var(--background-color);
    border-radius: 0.25rem;
}

.form-group {
    margin-bottom: 1rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
}

input, select {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 1rem;
}

button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.2s;
}

button:hover {
    background-color: var(--secondary-color);
}

/* Monthly Spending: table header sort controls (override global primary button) */
button.insight-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    color: #374151;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    text-align: left;
    text-transform: none;
    letter-spacing: 0;
    cursor: pointer;
    transition: color 0.15s ease;
}

button.insight-sort-btn:hover {
    background: transparent;
    color: #1d4ed8;
}

button.insight-sort-btn .sort-ind {
    display: inline-block;
    min-width: 1em;
    font-weight: 500;
    font-size: 0.8125rem;
    line-height: 1;
    color: #2563eb;
}

button.insight-sort-btn:focus {
    outline: none;
}

button.insight-sort-btn:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--primary-color);
    border-radius: 2px;
}

button.secondary {
    background-color: var(--background-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    margin-top: 1rem;
}

button.secondary:hover {
    background-color: var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
}

th, td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    background-color: var(--background-color);
    font-weight: 600;
}

tr:hover {
    background-color: var(--background-color);
}

.negative {
    color: var(--danger-color);
}

@media (max-width: 768px) {
    .container,
    .app-shell {
        padding: 1rem;
    }
    
    .summary-details {
        grid-template-columns: 1fr;
    }
    
    table {
        display: block;
        overflow-x: auto;
    }
}

.interest-day-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.interest-day-input {
    width: 60px !important;
    text-align: center;
    padding: 0.25rem !important;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 1rem;
}

.interest-day-container small {
    color: var(--text-color);
    opacity: 0.8;
}

.icon-button {
    background-color: transparent;
    color: var(--accent-deep);
    border: 1px solid var(--line);
    padding: 0.35rem 0.75rem;
    border-radius: 0.65rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    transition: all 0.2s;
}

.icon-button:hover {
    background-color: var(--accent);
    border-color: var(--accent);
    color: white;
}

.interest-day-input:disabled {
    background-color: var(--background-color);
    cursor: not-allowed;
    opacity: 0.7;
}

.interest-day-input:not(:disabled) {
    background-color: white;
    border-color: var(--primary-color);
}

.interest-rate-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.interest-rate-input {
    width: 70px !important;
    text-align: right;
    padding: 0.25rem !important;
    border: 1px solid var(--border-color);
    border-radius: 0.25rem;
    font-size: 1rem;
}

.current-balance-container {
    text-align: center;
    padding: 1.5rem;
    background-color: var(--background-color);
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

.current-balance-container p {
    font-size: 1.2rem;
    color: var(--text-color);
    margin-bottom: 0.5rem;
}

.balance-amount {
    font-size: 2.5rem;
    color: var(--primary-color);
    font-weight: bold;
}

.settings-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    font-size: 1.1rem;
}

.settings-details p {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--background-color);
    border-radius: 0.25rem;
}

.interest-settings {
    margin-bottom: 2rem;
}

@media (max-width: 768px) {
    .settings-details {
        grid-template-columns: 1fr;
    }
    
    .balance-amount {
        font-size: 2rem;
    }
}

.balance-details {
    display: flex;
    justify-content: space-around;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.balance-stat {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 0.9rem;
    color: var(--text-color);
    opacity: 0.8;
    margin-bottom: 0.25rem;
}

.stat-value {
    display: block;
    font-size: 1.1rem;
    color: var(--text-color);
    font-weight: 500;
}

@media (max-width: 768px) {
    .balance-details {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .balance-stat {
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .stat-label {
        margin-bottom: 0;
    }
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    justify-content: space-between;
}

.back-button {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.back-button:hover {
    text-decoration: underline;
}

.loans-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.loan-row {
    cursor: pointer;
    transition: background-color 0.2s;
}

.loan-row:hover {
    background-color: var(--background-color);
}

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--card-background);
    padding: 2rem;
    border-radius: 0.5rem;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
    margin: 0 auto;
    transform: translateY(50%);
    max-height: 90vh;
    overflow-y: auto;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1.5rem;
}

button.primary {
    background-color: var(--primary-color);
    color: white;
}

button.primary:hover {
    background-color: var(--secondary-color);
}

@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        text-align: center;
    }
    
    .back-button {
        margin-bottom: 0.5rem;
    }
    
    .loans-header {
        flex-direction: column;
        gap: 1rem;
    }
    
    .modal-content {
        margin: 1rem;
        padding: 1.5rem;
        max-width: calc(100% - 2rem);
        max-height: calc(100vh - 2rem);
        transform: translateY(-50%);
    }
}

.loan-name-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.edit-name-button {
    background-color: transparent;
    border: none;
    padding: 0.25rem;
    cursor: pointer;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.edit-name-button:hover {
    color: var(--secondary-color);
}

.loan-name-edit {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
    width: auto;
    background-color: transparent;
    padding: 0;
    box-shadow: none;
    z-index: 10;
}

.loan-name-input {
    flex-grow: 1;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--primary-color);
    border-radius: 0.25rem;
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-color);
    background-color: var(--card-background);
    min-width: 200px;
}

.save-button, .cancel-button {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .loan-name-container {
        flex-direction: row;
        align-items: center;
        justify-content: center;
    }
    
    .edit-name-button {
        margin-top: 0;
    }
    
    .loan-name-edit {
        flex-direction: row;
        width: auto;
    }
    
    .loan-name-input {
        width: auto;
        min-width: 150px;
        font-size: 2rem;
    }
}

/* Baseline table row delete: avoid global blue button + red text clash */
button.baseline-saved-delete {
    background-color: transparent;
    color: #b91c1c;
    border: 1px solid #fecaca;
    padding: 0.35rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
}

button.baseline-saved-delete:hover {
    background-color: #fef2f2;
    color: #991b1b;
}

/* Custom style for the delete loan button */
#deleteLoanBtn {
    background-color: var(--danger-color) !important;
    color: #fff !important;
}
#deleteLoanBtn:hover {
    background-color: #b91c1c !important;
}

.deleted-badge {
    display: inline-block;
    background-color: #dc2626;
    color: #fff;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 0.25rem;
    padding: 0.15em 0.6em;
    margin-left: 0.75em;
    vertical-align: middle;
    letter-spacing: 0.5px;
}

/* Monthly spending: preview rows flagged as duplicate of ledger or same upload */
tr.spending-preview-row-duplicate td {
    background-color: #fffbeb;
}
span.preview-duplicate-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #92400e;
    background: #fde68a;
    border: 1px solid #fbbf24;
    border-radius: 0.25rem;
    padding: 0.15rem 0.4rem;
    white-space: nowrap;
}
span.preview-duplicate-pill[data-reason="ledger"] {
    color: #1e3a5f;
    background: #dbeafe;
    border-color: #93c5fd;
}
span.preview-duplicate-pill[data-reason="manual"] {
    color: #14532d;
    background: #dcfce7;
    border-color: #86efac;
}

/* Statement outgoing not found in manual list — review these */
tr.spending-preview-row-missed:not(.spending-preview-row-duplicate) td {
    background-color: #fef2f2;
}
span.preview-review-pill {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-radius: 0.25rem;
    padding: 0.15rem 0.4rem;
    white-space: nowrap;
}
span.preview-review-pill[data-reason="missed"] {
    color: #7f1d1d;
    background: #fecaca;
    border: 1px solid #f87171;
}
span.preview-review-pill[data-reason="expected_bill"] {
    color: #334155;
    background: #e2e8f0;
    border: 1px solid #94a3b8;
}

/* User matched a missed row to a suggested manual (exclude from import) */
tr.spending-preview-row-manual-dismissed:not(.spending-preview-row-duplicate) td {
    background-color: #f0fdf4;
}
.preview-manual-suggest-stack {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.3rem;
    max-width: 15rem;
}
select.preview-manual-suggest-select {
    width: 100%;
    max-width: 15rem;
    font-size: 0.7rem;
    line-height: 1.3;
    padding: 0.2rem 0.35rem;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    background: #fff;
    color: #334155;
    cursor: pointer;
}
select.preview-manual-suggest-select:focus {
    outline: none;
    border-color: #86efac;
    box-shadow: 0 0 0 2px rgba(134, 239, 172, 0.35);
}
tr.spending-preview-row-manual-dismissed select.preview-manual-suggest-select {
    border-color: #86efac;
    background: #f0fdf4;
}

/* Started outside period, completed/settled date inside (e.g. Revolut) */
tr.spending-preview-row-boundary:not(.spending-preview-row-duplicate):not(.spending-preview-row-missed) td {
    background-color: #f0fdfa;
}
.preview-date-stack {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: flex-start;
}
.preview-date-primary {
    white-space: nowrap;
}
span.preview-boundary-pill {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #115e59;
    background: #ccfbf1;
    border: 1px solid #5eead4;
    border-radius: 0.25rem;
    padding: 0.12rem 0.35rem;
    white-space: nowrap;
    max-width: 14rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Home import preview chrome (desktop defaults; mobile cards in @media below) */
.import-preview-wrap:not(.hidden) {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.preview-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.preview-toolbar-include {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--ink, #0f2822);
    -webkit-tap-highlight-color: transparent;
}

.preview-toolbar-include input {
    width: 1.1rem;
    height: 1.1rem;
}

.preview-expand-hint {
    display: none;
    margin: 0;
    font-size: 0.78rem;
    color: var(--muted, #5b6b66);
}

.import-preview-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    min-width: 0;
}

.import-preview-body {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    align-items: stretch;
}

.import-unclaimed-manuals {
    border: 1px solid var(--line, rgba(15, 40, 34, 0.12));
    border-radius: 0.65rem;
    background: rgba(255, 255, 255, 0.9);
    padding: 0.55rem 0.7rem 0.7rem;
}

.import-unclaimed-manuals.hidden {
    display: none !important;
}

.import-unclaimed-manuals-details {
    margin: 0;
}

.import-unclaimed-manuals-summary {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    cursor: pointer;
    list-style: none;
    font-weight: 650;
    color: var(--ink, #0f2822);
}

.import-unclaimed-manuals-summary::-webkit-details-marker {
    display: none;
}

.import-unclaimed-manuals-title {
    font-size: 0.88rem;
}

.import-unclaimed-manuals-count {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--muted, #5b6b66);
    letter-spacing: 0.02em;
}

.import-unclaimed-manuals-hint {
    margin: 0.35rem 0 0.55rem;
    font-size: 0.72rem;
    line-height: 1.35;
    color: var(--muted, #5b6b66);
}

.import-unclaimed-manuals-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 14rem;
    overflow-y: auto;
}

.import-unclaimed-manuals-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas:
        "amt desc"
        "date desc";
    column-gap: 0.45rem;
    row-gap: 0.05rem;
    padding: 0.4rem 0.45rem;
    border-radius: 0.45rem;
    border: 1px solid transparent;
    background: rgba(15, 40, 34, 0.03);
    font-size: 0.75rem;
    line-height: 1.3;
    transition: background 0.12s ease, border-color 0.12s ease, opacity 0.12s ease;
}

.import-unclaimed-manuals-item[data-direction="incoming"] {
    background: rgba(59, 130, 246, 0.06);
}

.import-unclaimed-manuals-amt {
    grid-area: amt;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ink, #0f2822);
    white-space: nowrap;
}

.import-unclaimed-manuals-date {
    grid-area: date;
    font-size: 0.68rem;
    color: var(--muted, #5b6b66);
    white-space: nowrap;
}

.import-unclaimed-manuals-desc {
    grid-area: desc;
    color: var(--ink, #0f2822);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.import-unclaimed-manuals-item.is-preview-linked {
    opacity: 0.55;
    background: #f0fdf4;
    border-color: #bbf7d0;
}

.import-unclaimed-manuals-item.is-preview-linked .import-unclaimed-manuals-desc {
    text-decoration: line-through;
    text-decoration-color: rgba(15, 40, 34, 0.35);
}

.import-unclaimed-manuals-item.is-row-suggest {
    border-color: #fca5a5;
    background: #fef2f2;
    box-shadow: 0 0 0 1px rgba(248, 113, 113, 0.25);
}

.import-unclaimed-manuals-empty {
    margin: 0.35rem 0 0;
    font-size: 0.75rem;
    color: var(--muted, #5b6b66);
}

.import-unclaimed-manuals-empty.hidden {
    display: none;
}

/*
 * Wide desktops: float in the right viewport gutter beside the centered
 * .app-shell (max 1120px) so the preview table keeps full content width.
 * Needs ~15.5rem + gap in the right gutter → ≈1640px viewport.
 */
@media (min-width: 1640px) {
    .import-unclaimed-manuals:not(.hidden) {
        position: fixed;
        /* top/max-height set in JS to track .import-preview-scroll */
        top: 0;
        left: calc(50% + 560px + 0.75rem);
        width: 15.5rem;
        max-width: calc(50vw - 560px - 1.5rem);
        max-height: calc(100vh - 2rem);
        margin: 0;
        z-index: 30;
        overflow: hidden;
        display: flex;
        flex-direction: column;
        box-shadow: 0 12px 32px rgba(15, 40, 34, 0.12);
        backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.94);
    }

    .import-unclaimed-manuals--offscreen {
        visibility: hidden;
        pointer-events: none;
    }

    .import-unclaimed-manuals-details {
        display: flex;
        flex-direction: column;
        min-height: 0;
        max-height: inherit;
        overflow: hidden;
    }

    .import-unclaimed-manuals-details[open] {
        flex: 1 1 auto;
    }

    .import-unclaimed-manuals-list {
        max-height: none;
        flex: 1 1 auto;
        overflow-y: auto;
        padding-right: 0.15rem;
    }

    .import-unclaimed-manuals-summary {
        cursor: default;
        pointer-events: none;
    }
}

.preview-tx-date-short,
.preview-tx-toggle,
.preview-tx-toggle-th {
    display: none;
}

.preview-summary {
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.preview-summary-totals {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.4rem;
}

.preview-summary-stat {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.45rem 0.55rem;
    border: 1px solid var(--line, rgba(15, 40, 34, 0.12));
    border-radius: 0.55rem;
    background: rgba(255, 255, 255, 0.72);
}

.preview-summary-stat-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted, #5b6b66);
}

.preview-summary-stat-value {
    font-size: 0.92rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ink, #0f2822);
    line-height: 1.2;
}

.preview-summary-meta {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--muted, #5b6b66);
}

.preview-summary-flags {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.preview-summary-flag {
    margin: 0;
    padding: 0.4rem 0.55rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    line-height: 1.35;
    border: 1px solid transparent;
}

.preview-summary-flag--dup {
    color: #92400e;
    background: #fffbeb;
    border-color: #fde68a;
}

.preview-summary-flag--missed {
    color: #7f1d1d;
    background: #fef2f2;
    border-color: #fecaca;
}

.preview-summary-flag--bill {
    color: #334155;
    background: #f8fafc;
    border-color: #e2e8f0;
}

#insight-transactions-tbody tr.spending-insight-tx-muted {
    color: #6b7280;
    background: #f3f4f6;
}
#insight-transactions-tbody tr.spending-insight-tx-muted .spending-insight-tx-amount {
    color: #6b7280;
}
button.insight-tx-exclude-btn {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.45rem;
    border-radius: 0.25rem;
    border: 1px solid #d1d5db;
    background: #fff;
    color: #374151;
    white-space: nowrap;
}
button.insight-tx-exclude-btn:hover {
    background: #f9fafb;
    border-color: #9ca3af;
}
button.insight-tx-exclude-btn[data-want-exclude="true"] {
    color: #7c2d12;
    border-color: #fdba74;
    background: #fff7ed;
}

/* Regular bills: expand / collapse (overrides global `button` padding + solid blue) */
#subscription-signals-toggle-wrap {
    text-align: left;
}
button.spending-subscription-toggle,
button#subscription-signals-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    width: auto;
    max-width: 100%;
    margin: 0;
    padding: 0.5rem 0.95rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0;
    text-transform: none;
    text-decoration: none;
    color: #1d4ed8;
    background: #f8fafc;
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}
button.spending-subscription-toggle:hover,
button#subscription-signals-toggle-btn:hover {
    background: #eff6ff;
    background-color: #eff6ff;
    color: #1e3a8a;
    border-color: #93c5fd;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}
button.spending-subscription-toggle:focus,
button#subscription-signals-toggle-btn:focus {
    outline: none;
}
button.spending-subscription-toggle:focus-visible,
button#subscription-signals-toggle-btn:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #3b82f6;
    border-color: #60a5fa;
}
button.spending-subscription-toggle[aria-expanded="true"],
button#subscription-signals-toggle-btn[aria-expanded="true"] {
    color: #334155;
    background: #f1f5f9;
    background-color: #f1f5f9;
    border-color: #cbd5e1;
}
button.spending-subscription-toggle[aria-expanded="true"]:hover,
button#subscription-signals-toggle-btn[aria-expanded="true"]:hover {
    background: #e2e8f0;
    background-color: #e2e8f0;
    color: #1e293b;
    border-color: #94a3b8;
}

/* Month transactions: column header filters (override global `input` / `button` in table) */
#spending-insight-transactions-table tr.spending-tx-filters th {
    vertical-align: top;
    background: #f9fafb;
}
#spending-insight-transactions-table tr.spending-tx-filters th:not(:last-child) {
    min-width: 0;
}
#spending-insight-transactions-table input.spending-tx-header-filter,
#spending-insight-transactions-table select.spending-tx-header-filter {
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    margin: 0;
    padding: 0.2rem 0.4rem;
    font-size: 0.75rem;
    line-height: 1.3;
    border: 1px solid #d1d5db;
    border-radius: 0.25rem;
    background: #fff;
    color: #374151;
    box-sizing: border-box;
    box-shadow: none;
}
#spending-insight-transactions-table input.spending-tx-header-filter::placeholder {
    color: #9ca3af;
    font-size: 0.7rem;
}
#spending-insight-transactions-table input.spending-tx-header-filter:focus,
#spending-insight-transactions-table select.spending-tx-header-filter:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px #3b82f6;
}
button.spending-tx-filter-clear {
    display: block;
    width: 100%;
    margin: 0;
    padding: 0.2rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: 0.02em;
    text-transform: none;
    color: #4b5563;
    background: #fff;
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 0.25rem;
    cursor: pointer;
    box-shadow: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}
button.spending-tx-filter-clear:hover {
    background: #f3f4f6;
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #1f2937;
}
button.spending-tx-filter-clear:focus {
    outline: none;
}
button.spending-tx-filter-clear:focus-visible {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #3b82f6;
    border-color: #60a5fa;
}

/* Screen-reader-only labels in spending (if Tailwind `sr-only` is unavailable) */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Live sums under Amount (£) header (visible / filtered rows) */
p.insight-tx-amount-rollup,
#insight-tx-filter-rollup {
    font-variant-numeric: tabular-nums;
    margin: 0;
    padding: 0;
    font-weight: 500;
    width: 100%;
    max-width: 14rem;
}
p.insight-tx-amount-rollup:not(.hidden):empty,
#insight-tx-filter-rollup:not(.hidden):empty {
    min-height: 0;
}

/* --- Monthly spending page (aligned with :root tokens) --- */
html:has(body.spending-page),
body.spending-page {
    overflow-x: hidden;
}
body.spending-page {
    background-color: transparent;
    color: var(--ink);
}
.spending-shell {
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}
.spending-header,
.spending-section.card,
.spending-chart-card {
    background: var(--surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15, 40, 34, 0.06);
    padding: 1.25rem 1.45rem;
}
.spending-header-inner {
    width: 100%;
}
.spending-top-nav {
    /* legacy class kept; prefer .app-nav */
    background: transparent;
    border: 0;
    padding: 0;
}
.spending-nav-active {
    background: var(--ink) !important;
    color: #f4faf7 !important;
    font-weight: 600;
    box-shadow: none;
}
.spending-h2 {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 0.25rem;
}
.spending-h3 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 0.35rem;
}
.spending-sub,
.spending-muted {
    color: var(--muted);
    opacity: 1;
}
.spending-hint {
    color: var(--muted);
    opacity: 1;
}
.spending-skip {
    text-decoration: none;
    color: var(--accent-deep) !important;
    font-weight: 600;
}
.spending-skip:hover {
    text-decoration: underline;
}
.spending-control {
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    padding: 0.55rem 0.75rem;
    background: var(--surface-solid);
    color: var(--ink);
}
.spending-btn {
    display: inline-block;
    font-weight: 700;
    border-radius: 0.85rem;
    padding: 0.55rem 1rem;
    text-decoration: none;
    border: 1px solid transparent;
    cursor: pointer;
    line-height: 1.3;
    transition: background 0.15s, color 0.15s, border-color 0.15s, transform 0.12s;
}
.spending-btn:active {
    transform: scale(0.98);
}
.spending-btn--primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.spending-btn--primary:hover {
    background: var(--accent-deep);
    border-color: var(--accent-deep);
    color: #fff;
}
.spending-btn--ok {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.spending-btn--ok:hover {
    background: var(--accent-deep);
    color: #fff;
}
.spending-btn--muted {
    background: rgba(15, 28, 26, 0.08);
    color: var(--ink);
    border-color: var(--line);
}
.spending-btn--muted:hover {
    background: rgba(15, 28, 26, 0.12);
}
.spending-btn--teal {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.spending-btn--teal:hover {
    background: var(--accent-deep);
    color: #fff;
}
.spending-btn--danger {
    background: var(--warn);
    color: #fff;
    border-color: var(--warn);
}
.spending-btn--danger:hover {
    filter: brightness(0.95);
    color: #fff;
}
.spending-btn--indigo {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
.spending-btn--indigo:hover {
    background: var(--accent-deep);
    color: #fff;
}
.spending-kpi-grid {
    display: grid;
    grid-template-columns: repeat(1, minmax(0, 1fr));
    gap: 0.75rem;
}
@media (min-width: 640px) {
    .spending-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
@media (min-width: 1024px) {
    .spending-kpi-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.spending-spotlight .home-spotlight-side {
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .spending-spotlight .home-spotlight-side {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 768px) {
    .spending-spotlight {
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
    }

    .spending-spotlight .home-spotlight-side {
        grid-template-columns: 1fr;
    }
}

.spending-metric__label {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}
.spending-metric__value {
    font-family: var(--font-money);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    font-variant-numeric: tabular-nums;
}
.spending-metric--income .glass-stat-value,
.spending-metric--income .spending-metric__value { color: var(--accent-deep); }
.spending-metric--outgoing .glass-stat-value,
.spending-metric--outgoing .spending-metric__value { color: var(--warn); }
.spending-metric--net .spending-metric__value { color: var(--accent); }
.spending-metric--savings .glass-stat-value,
.spending-metric--savings .spending-metric__value { color: var(--accent-deep); }
.spending-metric__delta {
    font-size: 0.78rem;
    margin-top: 0.15rem;
}
.spending-metric__delta--up { color: #b91c1c; }
.spending-metric__delta--down { color: var(--accent-deep); }
.spending-metric__delta--neutral { opacity: 0.75; }
.spending-metric__sub { margin-top: 0.15rem; opacity: 0.85; }
.spending-budget-actions {
    background: rgba(13, 122, 98, 0.07);
    border: 1px solid rgba(13, 122, 98, 0.18);
    border-radius: 1.1rem;
    padding: 1rem 1.1rem;
}
.spending-budget-actions-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.spending-budget-actions-list li {
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--line);
}
.spending-budget-actions-list li:last-child {
    border-bottom: 0;
}

.money-hero .balance-amount,
.loan-money-hero .balance-amount {
    color: #eef8f4 !important;
}

.loans-add-tile {
    cursor: pointer;
    font: inherit;
    text-align: left;
    width: 100%;
    border-style: dashed;
    border-color: rgba(13, 122, 98, 0.35);
    background: rgba(13, 122, 98, 0.05);
}

.loans-add-tile:hover {
    border-color: var(--accent);
    background: rgba(13, 122, 98, 0.1);
}

.text-warn {
    color: var(--warn) !important;
}

.loan-panel {
    margin-bottom: 1.5rem;
}

.loan-thead th {
    background: rgba(15, 28, 26, 0.04);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.loan-detail-page .app-section-title {
    margin-bottom: 0.75rem;
}

.spending-budget-item-title { font-weight: 600; color: var(--text-color); }
.spending-budget-item-detail { margin-top: 0.2rem; opacity: 0.88; font-size: 0.9rem; }

/* Savings coach (AI) */
.spending-savings-coach .savings-coach-status { color: var(--text-color); }
.spending-savings-coach .savings-coach-status[aria-busy="true"] { opacity: 0.9; }
.spending-savings-coach .savings-coach-priority { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; padding: 0.1rem 0.45rem; border-radius: 0.25rem; margin-right: 0.35rem; }
.spending-savings-coach .savings-coach-priority--1 { background: rgba(13, 122, 98, 0.18); color: var(--accent-deep); }
.spending-savings-coach .savings-coach-priority--2 { background: rgba(13, 122, 98, 0.1); color: var(--accent); }
.spending-savings-coach .savings-coach-priority--3 { background: rgba(100, 116, 139, 0.2); color: #334155; }
.spending-savings-coach .spending-budget-item-detail--evidence { margin-top: 0.35rem; font-size: 0.8rem; opacity: 0.75; }
.spending-link-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 500;
    padding: 0;
    text-decoration: underline;
    font: inherit;
}
.spending-link-btn:hover {
    color: var(--secondary-color);
}
.spending-chart-card {
    padding: 0.75rem 1rem;
}
.spending-cb input {
    accent-color: var(--primary-color);
}
.spending-bar-list li {
    list-style: none;
}
#top-merchants-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
#top-categories-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
#anomalies-list,
#recurring-list {
    list-style: disc;
    padding-left: 1.1rem;
}
/* Wide month table: scroll inside this shell, never the whole page. */
.spending-tx-scroll {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}
.spending-tx-table {
    border-collapse: collapse;
    width: 100%;
}
@media (max-width: 768px) {
    /* Global `table { display: block }` lets thead/tbody expand the document.
       Keep a real table inside the scroll shell so only the shell scrolls. */
    .spending-tx-scroll > table.spending-tx-table {
        display: table;
        overflow: visible;
        width: max-content;
        min-width: 100%;
    }
}
.spending-tx-tbody tr:nth-child(even) {
    background: rgba(241, 245, 249, 0.5);
}
.spending-tx-tbody tr:hover {
    background: rgba(219, 234, 254, 0.35);
}
.spending-tx-thead th {
    border-bottom: 1px solid var(--border-color);
}
.spending-section--insights {
    order: 1;
}
.spending-mom-line { color: var(--text-color); }
.spending-trailing { border-left: 3px solid var(--primary-color); padding-left: 0.6rem; }

/* Monthly net hero: keep light type on the dark panel (mom/delta rules otherwise force ink) */
.spending-money-hero,
.spending-money-hero .money-hero-kicker,
.spending-money-hero .money-hero-label,
.spending-money-hero .money-hero-value,
.spending-money-hero .money-hero-meta,
.spending-money-hero .money-hero-delta,
.spending-money-hero .spending-mom-line,
.spending-money-hero .spending-trailing {
    color: #eef8f4 !important;
}

.spending-money-hero .spending-metric__delta--up {
    color: #fdba74 !important;
}

.spending-money-hero .spending-metric__delta--down {
    color: #a7f3d0 !important;
}

.spending-money-hero .spending-metric__delta--neutral {
    color: rgba(238, 248, 244, 0.75) !important;
}

.spending-money-hero .spending-trailing {
    border-left-color: rgba(167, 243, 208, 0.55);
}

/* Category stack chart: custom legend (checkboxes) */
button.spending-legend-ctrl {
    background: none;
    border: none;
    color: var(--primary-color);
    font-weight: 500;
    cursor: pointer;
    padding: 0.2rem 0.35rem;
    border-radius: 0.25rem;
    font: inherit;
    min-height: 2rem;
    min-width: 2.75rem;
    text-decoration: underline;
    text-underline-offset: 2px;
}
button.spending-legend-ctrl:hover {
    color: var(--secondary-color);
    background: rgba(37, 99, 235, 0.08);
    text-decoration: none;
}
button.spending-legend-ctrl:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}
.spending-category-legend-cbs {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.25rem 0.4rem;
}
label.spending-category-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    min-height: 0;
    min-width: 0;
    padding: 0.2rem 0.45rem 0.2rem 0.35rem;
    border-radius: 0.3rem;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1.2;
    color: var(--text-color);
    border: 1px solid transparent;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
label.spending-category-legend-item:hover {
    background: var(--background-color);
    border-color: var(--border-color);
}
input.category-stack-legend-cb {
    width: 1rem;
    height: 1rem;
    min-width: 1rem;
    min-height: 1rem;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--primary-color);
}
span.spending-category-legend-swatch {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 0.1rem;
    flex-shrink: 0;
    background: var(--swatch, #64748b);
    border: 1px solid rgba(0, 0, 0, 0.12);
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.4) inset;
}
label.spending-category-legend-item > span:last-of-type {
    word-break: break-word;
    max-width: 12rem;
}
/* ===== Daily Budget (responsive; touch-friendly on small screens) ===== */
body.db-page {
    background: transparent;
    color: var(--ink);
    overflow-x: hidden;
}

.db-shell {
    position: relative;
    z-index: 1;
    max-width: 1120px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 3rem;
}

.db-header {
    margin-bottom: 1.25rem;
}

.db-link-quiet {
    color: var(--accent-deep);
    font-weight: 600;
    text-decoration: none;
}

.db-panel-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem;
    margin-bottom: 1rem;
    max-width: 28rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid var(--line);
    backdrop-filter: blur(8px);
}

.db-panel-tab {
    border: 0;
    background: transparent;
    color: var(--db-muted);
    font-family: inherit;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.65rem 0.5rem;
    border-radius: 999px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.db-panel-tab--active {
    background: var(--db-ink);
    color: #f4faf7;
    border-color: transparent;
    transform: none;
}

.db-flash {
    margin-bottom: 0.85rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.9rem;
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid var(--db-line);
}

.db-flash--error {
    border-color: rgba(194, 65, 12, 0.35);
    color: var(--db-warn);
}

.db-flash--ok {
    border-color: rgba(13, 122, 98, 0.35);
    color: var(--db-accent-deep);
}

.db-overspend-prompt {
    margin: 0 0 1rem;
    padding: 1rem 1.1rem;
    border-radius: 1.1rem;
    border: 1px solid rgba(194, 65, 12, 0.28);
    background: linear-gradient(135deg, rgba(194, 65, 12, 0.1), rgba(255, 255, 255, 0.75));
}

.db-overspend-prompt-title {
    margin: 0 0 0.35rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--db-ink);
}

.db-overspend-prompt-body {
    margin: 0 0 0.85rem;
    font-size: 0.92rem;
    color: var(--db-muted);
    line-height: 1.45;
}

.db-overspend-prompt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.55rem;
}

.db-debt-note {
    margin: 0 0 1rem;
    padding: 0.65rem 0.85rem;
    border-radius: 0.85rem;
    font-size: 0.88rem;
    color: var(--db-ink);
    background: rgba(15, 28, 26, 0.06);
    border: 1px solid var(--db-line);
}

.db-debt-card {
    margin: 0 0 1.1rem;
    padding: 1rem 1.1rem;
    border-radius: 1.1rem;
    border: 1px solid rgba(194, 65, 12, 0.22);
    background: linear-gradient(135deg, rgba(194, 65, 12, 0.08), rgba(15, 28, 26, 0.04));
}

.db-debt-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.45rem;
}

.db-debt-card-label {
    margin: 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--db-muted);
    font-weight: 600;
}

.db-debt-card-value {
    margin: 0.15rem 0 0;
    font-family: var(--font-money);
    font-size: 1.65rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--db-warn);
}

.db-debt-card-meta {
    margin: 0 0 0.65rem;
    font-size: 0.85rem;
    color: var(--db-muted);
}

.db-goal-bar-fill--debt {
    background: linear-gradient(90deg, #c2410c, #ea580c);
}

.db-hero {
    position: relative;
    padding: 1.5rem 1.35rem 1.25rem;
    border-radius: 1.5rem;
    background:
        linear-gradient(145deg, rgba(15, 28, 26, 0.96), rgba(13, 70, 58, 0.92));
    color: #eef8f4;
    box-shadow: var(--db-shadow);
    margin-bottom: 1.1rem;
    overflow: hidden;
    animation: db-hero-in 0.55s ease both;
}

.db-hero::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    right: -60px;
    top: -70px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(94, 214, 180, 0.35), transparent 70%);
    pointer-events: none;
}

@keyframes db-hero-in {
    from { opacity: 0; transform: translateY(12px) scale(0.98); }
    to { opacity: 1; transform: none; }
}

.db-hero-kicker {
    font-size: 0.78rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    opacity: 0.72;
    margin-bottom: 0.35rem;
}

.db-hero-label {
    font-size: 0.95rem;
    opacity: 0.85;
}

.db-hero-value {
    font-family: var(--font-money);
    font-size: clamp(2.8rem, 12vw, 3.6rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    line-height: 1.05;
    margin: 0.15rem 0 0.85rem;
}

.db-hero-value--over {
    color: #fdba74;
}

.db-hero-bar {
    height: 0.45rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.15);
    overflow: hidden;
    margin-bottom: 1rem;
}

.db-hero-bar-fill {
    height: 100%;
    width: 0;
    border-radius: inherit;
    background: linear-gradient(90deg, #5ed6b4, #a7f3d0);
    transition: width 0.35s ease;
}

.db-hero-bar-fill--over {
    background: linear-gradient(90deg, #fb923c, #fdba74);
}

.db-hero-meta {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}

.db-meta-label {
    display: block;
    font-size: 0.7rem;
    opacity: 0.65;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.db-meta-value {
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.db-lead--tight {
    margin-bottom: 0.65rem;
}

.db-limit-math-note {
    margin: 0.55rem 0 0;
    font-size: 0.82rem;
    line-height: 1.35;
    color: var(--db-muted);
}

.db-entry {
    background: var(--db-surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--db-line);
    border-radius: 1.35rem;
    padding: 1.1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 10px 30px rgba(15, 40, 34, 0.06);
    animation: db-rise 0.5s ease 0.08s both;
}

@keyframes db-rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.db-entry-amount-wrap {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
    margin-bottom: 0.85rem;
    padding: 0.35rem 0.2rem 0.6rem;
    border-bottom: 2px solid var(--db-ink);
}

.db-entry-currency {
    font-family: var(--font-money);
    font-size: 2rem;
    font-weight: 600;
    color: var(--db-muted);
}

.db-entry-amount {
    flex: 1;
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    font-family: var(--font-money);
    font-size: 2.6rem;
    font-weight: 600;
    letter-spacing: -0.03em;
    color: var(--db-ink);
    padding: 0 !important;
    width: 100%;
    outline: none;
}

.db-field {
    display: block;
    margin-bottom: 0.85rem;
}

.db-field--compact {
    margin-bottom: 0;
    min-width: 0;
}

.db-field > span,
.db-field > label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--db-muted);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.db-title-input-wrap {
    position: relative;
}

.db-title-input-wrap input {
    padding-right: 3.5rem;
}

.db-title-clear {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0.3rem;
    width: 2.5rem;
    height: 2.5rem;
    min-width: 2.5rem;
    min-height: 2.5rem;
    margin: auto 0;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--db-muted);
    font-family: inherit;
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s ease, opacity 0.15s ease;
}

body.db-page button.db-title-clear {
    padding: 0;
    background: transparent;
    color: var(--db-muted);
}

.db-title-clear:hover,
.db-title-clear:focus-visible {
    background: transparent;
    color: var(--db-ink);
}

.db-title-clear:active {
    background: transparent;
    color: var(--db-ink);
    opacity: 0.65;
}

body.db-page button.db-title-clear:hover,
body.db-page button.db-title-clear:focus-visible,
body.db-page button.db-title-clear:active {
    background: transparent;
    color: var(--db-ink);
}

.db-title-clear.hidden {
    display: none;
}

.db-title-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.db-title-suggestions.hidden {
    display: none;
}

.db-title-chip {
    border: 1px solid var(--db-line);
    background: rgba(255, 255, 255, 0.7);
    border-radius: 0.75rem;
    padding: 0.45rem 0.7rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--db-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.db-title-chip:active {
    transform: scale(0.98);
}

.db-title-chip--selected {
    background: var(--db-ink);
    border-color: var(--db-ink);
    color: #f4faf7;
}

body.db-page button.db-title-chip {
    padding: 0.45rem 0.7rem;
    background: rgba(255, 255, 255, 0.7);
    color: var(--db-muted);
}

body.db-page button.db-title-chip--selected {
    background: var(--db-ink);
    border-color: var(--db-ink);
    color: #f4faf7;
}

.db-usual {
    background: var(--db-surface);
    border: 1px solid var(--db-line);
    border-radius: 1.35rem;
    padding: 0.95rem 1rem 0.85rem;
    margin-bottom: 0.85rem;
    box-shadow: 0 10px 30px rgba(15, 40, 34, 0.06);
}

.db-usual-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.db-usual-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--db-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.db-usual-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.db-usual-chip {
    border: 1px solid var(--db-line);
    background: rgba(255, 255, 255, 0.85);
    border-radius: 0.75rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--db-ink);
    text-align: left;
    line-height: 1.2;
    cursor: pointer;
}

.db-usual-chip small {
    display: block;
    margin-top: 0.1rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--db-muted);
}

.db-usual-chip--add {
    border-style: dashed;
    color: var(--db-accent);
    background: transparent;
}

.db-usual-x {
    margin-left: 0.35rem;
    color: var(--db-warn);
}

.db-usual-sheet {
    margin-top: 0.65rem;
    padding: 0.7rem;
    border-radius: 0.9rem;
    background: var(--db-surface-solid);
    border: 1px solid var(--db-line);
}

.db-usual-sheet > .db-usual-label {
    display: block;
    margin-bottom: 0.4rem;
}

.db-usual-suggests {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.45rem;
}

.db-usual-suggest {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    width: 100%;
    border: 1px solid var(--db-line);
    background: #fff;
    border-radius: 0.75rem;
    padding: 0.55rem 0.7rem;
    text-align: left;
    cursor: pointer;
    color: var(--db-ink);
}

.db-usual-suggest > span:first-child {
    min-width: 0;
}

.db-usual-suggest strong {
    display: block;
    font-size: 0.9rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.db-usual-suggest small {
    color: var(--db-muted);
    font-weight: 600;
    font-size: 0.7rem;
}

.db-usual-suggest-amt {
    font-family: var(--font-money);
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: -0.02em;
    white-space: nowrap;
}

.db-usual-manual-toggle {
    margin-bottom: 0.55rem;
}

.db-usual-manual input,
.db-usual-manual select {
    width: 100%;
    border: 1px solid var(--db-line);
    background: var(--db-surface-solid);
    border-radius: 0.85rem;
    padding: 0.7rem 0.8rem;
    font: inherit;
    font-size: 0.95rem;
    color: var(--db-ink);
    margin-bottom: 0.55rem;
    min-height: 2.75rem;
}

.db-usual-manual .db-cta {
    margin-top: 0.1rem;
    padding: 0.8rem 1rem;
    font-size: 0.95rem;
}

.db-usual-note {
    margin: 0.55rem 0 0;
    font-size: 0.78rem;
    color: var(--db-muted);
    line-height: 1.4;
}

.db-usual-toast {
    margin-top: 0.55rem;
    background: var(--db-ink);
    color: #f4faf7;
    border-radius: 0.85rem;
    padding: 0.55rem 0.7rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.82rem;
}

body.db-page button.db-usual-edit {
    background: transparent;
    color: var(--db-accent);
    border: 0;
    padding: 0.2rem 0;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 0;
}

body.db-page button.db-usual-edit:hover,
body.db-page button.db-usual-edit:focus-visible {
    background: transparent;
    color: var(--db-accent-deep);
}

body.db-page button.db-usual-chip {
    background: rgba(255, 255, 255, 0.85);
    color: var(--db-ink);
    padding: 0.55rem 0.7rem;
}

body.db-page button.db-usual-chip:hover,
body.db-page button.db-usual-chip:focus-visible {
    background: #fff;
    color: var(--db-ink);
}

body.db-page button.db-usual-chip--add,
body.db-page button.db-usual-chip--add:hover,
body.db-page button.db-usual-chip--add:focus-visible {
    background: transparent;
    color: var(--db-accent);
}

body.db-page button.db-usual-suggest,
body.db-page button.db-usual-suggest:hover,
body.db-page button.db-usual-suggest:focus-visible {
    background: #fff;
    color: var(--db-ink);
    padding: 0.55rem 0.7rem;
}

body.db-page button.db-usual-undo,
body.db-page button.db-usual-undo:hover,
body.db-page button.db-usual-undo:focus-visible {
    background: transparent;
    color: #a7f3d0;
    border: 0;
    padding: 0.2rem 0.15rem;
    font-size: 0.82rem;
    font-weight: 700;
}

.db-field input,
.db-select,
.db-bill-add input {
    width: 100%;
    border: 1px solid var(--db-line);
    background: var(--db-surface-solid);
    border-radius: 0.85rem;
    padding: 0.85rem 0.95rem;
    font-size: 1.05rem;
    color: var(--db-ink);
    min-height: 3rem;
    appearance: none;
}

.db-select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%235c6f6a' d='M1.4.6 6 5.2 10.6.6 12 2 6 8 0 2z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    padding-right: 2.25rem;
}

.db-dates {
    border: 0;
    margin: 0 0 1rem;
    padding: 0;
}

.db-dates--view {
    margin: 0 0 0.85rem;
}

.db-dates legend,
.db-cats legend {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--db-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.45rem;
}

.db-date-chip-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
    margin-bottom: 0.55rem;
}

.db-date-chip {
    border: 1px solid var(--db-line);
    background: rgba(255, 255, 255, 0.7);
    border-radius: 0.75rem;
    padding: 0.7rem 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--db-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, transform 0.12s ease;
}

.db-date-chip:active {
    transform: scale(0.98);
}

.db-date-chip--selected {
    background: var(--db-ink);
    border-color: var(--db-ink);
    color: #f4faf7;
}

.db-date-other {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0;
}

.db-date-other-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--db-muted);
    white-space: nowrap;
}

.db-date-other input[type="date"] {
    flex: 1;
    min-width: 0;
    max-width: 11.5rem;
    margin-left: auto;
    border: 1px solid var(--db-line);
    background: var(--db-surface-solid);
    border-radius: 0.75rem;
    padding: 0.55rem 0.7rem;
    font-size: 0.92rem;
    color: var(--db-ink);
    min-height: 2.5rem;
}

.db-cats {
    border: 0;
    margin: 0 0 1rem;
    padding: 0;
}

.db-cat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.45rem;
}

.db-cat {
    border: 1px solid var(--db-line);
    background: rgba(255, 255, 255, 0.7);
    border-radius: 0.75rem;
    padding: 0.7rem 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: capitalize;
    color: var(--db-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.db-cat--selected {
    background: var(--db-accent);
    border-color: var(--db-accent);
    color: #fff;
}

.db-cta,
.db-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    font-weight: 700;
    border-radius: 1rem;
    transition: transform 0.12s ease, background 0.15s ease, opacity 0.15s ease;
}

.db-cta:active,
.db-btn:active {
    transform: scale(0.98);
}

.db-panel-tab,
.db-cat,
.db-date-chip,
.db-today-del,
.db-title-clear {
    font-family: inherit;
}

body.db-page button.db-btn--ghost {
    background: rgba(255, 255, 255, 0.7);
    color: var(--db-ink);
    border: 1px solid var(--db-line);
}

body.db-page button.db-btn--ghost:hover {
    background: rgba(255, 255, 255, 0.95);
    color: var(--db-ink);
}

body.db-page button.db-btn--solid {
    background: var(--db-ink);
    color: #f4faf7;
}

body.db-page button.db-btn--solid:hover {
    background: #1a2e2a;
    color: #f4faf7;
}

body.db-page button.db-cta {
    background: var(--db-accent);
    color: #fff;
}

body.db-page button.db-cta:hover {
    background: var(--db-accent-deep);
    color: #fff;
}

body.db-page button.db-panel-tab {
    background: transparent;
    color: var(--db-muted);
}

body.db-page button.db-panel-tab--active {
    background: var(--db-ink);
    color: #f4faf7;
}

body.db-page button.db-cat {
    background: rgba(255, 255, 255, 0.7);
    color: var(--db-muted);
}

body.db-page button.db-cat--selected {
    background: var(--db-accent);
    color: #fff;
    border-color: var(--db-accent);
}

body.db-page button.db-date-chip {
    background: rgba(255, 255, 255, 0.7);
    color: var(--db-muted);
}

body.db-page button.db-date-chip--selected {
    background: var(--db-ink);
    color: #f4faf7;
    border-color: var(--db-ink);
}

.db-cta {
    width: 100%;
    padding: 1.05rem 1rem;
    font-size: 1.1rem;
    background: var(--db-accent);
    color: #fff;
    box-shadow: 0 12px 28px rgba(13, 122, 98, 0.28);
}

.db-cta:hover {
    background: var(--db-accent-deep);
}

.db-cta:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.db-btn--ghost {
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--db-line);
    color: var(--db-ink);
    font-size: 0.9rem;
    min-height: 3rem;
    white-space: nowrap;
}

.db-btn--solid {
    padding: 0.75rem 1rem;
    background: var(--db-ink);
    color: #f4faf7;
    font-size: 0.95rem;
    min-height: 3rem;
}

.db-section-title {
    font-family: var(--font-display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 0.35rem;
    color: var(--db-ink);
}

.db-subsection-title {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    margin: 1.35rem 0 0.45rem;
    color: var(--db-ink);
}

.db-subsection-title--flush {
    margin-top: 0;
}

.db-lead {
    color: var(--db-muted);
    font-size: 0.95rem;
    margin-bottom: 1.1rem;
    line-height: 1.45;
}

.db-hint {
    font-size: 0.82rem;
    color: var(--db-muted);
    margin: 0 0 0.85rem;
    line-height: 1.4;
}

.db-field-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.78rem;
    color: var(--db-muted);
    line-height: 1.35;
    font-weight: 400;
}

.db-field-grid > .db-field:has(#plan-tracking-from),
.db-field-grid > .db-field:has(#plan-pay-day) {
    grid-column: 1 / -1;
}

.db-empty {
    color: var(--db-muted);
    font-size: 0.92rem;
    margin: 0.35rem 0 0.85rem;
}

.db-today-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin: 0.75rem 0 0;
}

.db-today-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.55rem;
    align-items: center;
    padding: 0.85rem 0.95rem;
    border-radius: 1rem;
    background: var(--db-surface);
    border: 1px solid var(--db-line);
}

.db-today-item-main strong {
    display: block;
    font-size: 0.98rem;
}

.db-today-cat {
    font-size: 0.75rem;
    color: var(--db-muted);
    text-transform: capitalize;
}

.db-today-item-amt {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.db-today-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    min-width: 2rem;
    min-height: 2rem;
    padding: 0;
    border-radius: 999px;
    border: 1px solid var(--db-line);
    background: rgba(255, 255, 255, 0.8);
    color: var(--db-muted);
    font-family: inherit;
    font-size: 1.15rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
}

body.db-page button.db-today-del {
    padding: 0;
    background: rgba(255, 255, 255, 0.8);
    color: var(--db-muted);
    border: 1px solid var(--db-line);
}

body.db-page button.db-today-del:hover {
    background: rgba(15, 28, 26, 0.06);
    color: var(--db-ink);
}

.db-card {
    background: var(--db-surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--db-line);
    border-radius: 1.35rem;
    padding: 1.2rem;
    box-shadow: 0 10px 30px rgba(15, 40, 34, 0.06);
    animation: db-rise 0.45s ease both;
}

.db-field-grid {
    display: grid;
    gap: 0.75rem;
}

@media (min-width: 480px) {
    .db-field-grid {
        grid-template-columns: 1fr 1fr;
    }
}

.db-plan-math {
    margin: 0.85rem 0 1rem;
    padding: 0.85rem 0.95rem;
    border-radius: 1rem;
    background: rgba(13, 122, 98, 0.08);
    border: 1px solid rgba(13, 122, 98, 0.15);
    transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

.db-plan-math--saved {
    background: rgba(13, 122, 98, 0.16);
    border-color: rgba(13, 122, 98, 0.35);
    box-shadow: 0 0 0 3px rgba(13, 122, 98, 0.12);
}

.db-plan-math-title {
    margin: 0 0 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--accent-deep);
}

.db-plan-feedback {
    margin: 0 0 0.55rem;
    padding: 0.75rem 0.9rem;
    border-radius: 0.85rem;
    font-size: 0.92rem;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
}

.db-plan-feedback--ok {
    border-color: rgba(13, 122, 98, 0.35);
    color: var(--accent-deep);
    background: rgba(13, 122, 98, 0.1);
}

.db-plan-feedback--error {
    border-color: rgba(194, 65, 12, 0.35);
    color: var(--warn);
    background: rgba(194, 65, 12, 0.08);
}

.db-plan-last-saved {
    margin: 0 0 0.65rem;
    font-size: 0.82rem;
    color: var(--muted);
    text-align: center;
}

.db-cta--success {
    background: var(--accent-deep) !important;
    box-shadow: 0 12px 28px rgba(13, 122, 98, 0.35) !important;
}

.db-plan-math-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    font-size: 0.92rem;
    padding: 0.28rem 0;
}

.db-plan-math-row span {
    color: var(--db-muted);
}

.db-plan-math-row strong {
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.db-plan-math-op {
    display: inline-block;
    min-width: 0.85em;
    margin-right: 0.2rem;
    font-weight: 700;
    color: var(--accent-deep);
}

.db-plan-math-row--income {
    padding-bottom: 0.4rem;
    margin-bottom: 0.15rem;
    border-bottom: 1px dashed rgba(13, 122, 98, 0.22);
}

.db-plan-math-row--income span {
    color: var(--ink);
    font-weight: 600;
}

.db-plan-math-row--income strong {
    font-size: 1.05rem;
    color: var(--accent-deep);
}

.db-plan-math-row--sub {
    padding-left: 0.1rem;
}

.db-plan-math-row--result {
    margin-top: 0.35rem;
    padding-top: 0.55rem;
    border-top: 1px solid rgba(13, 122, 98, 0.28);
}

.db-plan-math-row--result span {
    color: var(--ink);
    font-weight: 600;
}

.db-plan-math-row--result strong {
    font-size: 1.08rem;
    color: var(--accent-deep);
}

.db-plan-math-row--note {
    padding-top: 0.15rem;
    font-size: 0.86rem;
}

.db-plan-math-row--note strong {
    font-weight: 600;
    color: var(--ink);
}

.db-mode-fieldset {
    border: 0;
    padding: 0;
    margin: 0 0 1.25rem;
}

.db-mode-fieldset legend {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--db-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.db-mode-grid {
    display: grid;
    gap: 0.5rem;
}

.db-mode {
    display: block;
    cursor: pointer;
}

.db-mode input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.db-mode-card {
    display: block;
    padding: 0.85rem 0.95rem;
    border-radius: 1rem;
    border: 1px solid var(--db-line);
    background: rgba(255, 255, 255, 0.65);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.db-mode-card strong {
    display: block;
    font-size: 0.98rem;
    margin-bottom: 0.2rem;
}

.db-mode-card small {
    color: var(--db-muted);
    font-size: 0.8rem;
    line-height: 1.35;
}

.db-mode input:checked + .db-mode-card {
    border-color: var(--db-accent);
    background: rgba(13, 122, 98, 0.1);
    box-shadow: inset 0 0 0 1px rgba(13, 122, 98, 0.2);
}

.db-pull {
    margin-top: 0.25rem;
    padding-top: 1.15rem;
    border-top: 1px solid var(--db-line);
}

.db-pull-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
    margin-bottom: 0.95rem;
    align-items: end;
}

@media (min-width: 420px) {
    .db-pull-toolbar {
        grid-template-columns: minmax(0, 1fr) auto;
    }
}

.db-pull-btn {
    width: 100%;
}

@media (min-width: 420px) {
    .db-pull-btn {
        width: auto;
        min-width: 11.5rem;
    }
}

.db-bill-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    margin: 0 0 0.75rem;
    min-height: 0;
}

.db-bill-list:empty {
    display: none;
}

.db-bill-diff-summary {
    margin: 0 0 0.65rem;
    padding: 0.65rem 0.8rem;
    border-radius: 0.75rem;
    background: rgba(15, 28, 26, 0.05);
    border: 1px solid var(--db-line);
    color: var(--db-ink);
    font-size: 0.84rem;
    line-height: 1.35;
}

.db-hint--tight {
    margin-top: 0.15rem;
    margin-bottom: 0.55rem;
}

.db-bill-item {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto auto;
    gap: 0.55rem;
    align-items: center;
    padding: 0.75rem 0.85rem;
    border-radius: 0.9rem;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid var(--db-line);
}

.db-bill-item--new {
    border-color: rgba(30, 120, 80, 0.45);
    background: rgba(40, 140, 95, 0.1);
    box-shadow: inset 3px 0 0 rgba(30, 120, 80, 0.75);
}

.db-bill-item--changed {
    border-color: rgba(170, 110, 20, 0.45);
    background: rgba(210, 140, 40, 0.12);
    box-shadow: inset 3px 0 0 rgba(170, 110, 20, 0.8);
}

.db-bill-item--same {
    opacity: 0.92;
}

.db-bill-item--removed {
    grid-template-columns: minmax(0, 1fr) auto auto;
    background: rgba(15, 28, 26, 0.04);
    border-style: dashed;
    opacity: 0.9;
}

.db-bill-title-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.db-bill-title-row strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.db-bill-badge {
    flex-shrink: 0;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    padding: 0.12rem 0.4rem;
    border-radius: 0.35rem;
    line-height: 1.2;
}

.db-bill-badge--new {
    color: #0f5c3a;
    background: rgba(40, 140, 95, 0.22);
}

.db-bill-badge--changed {
    color: #7a4a08;
    background: rgba(210, 140, 40, 0.28);
}

.db-bill-amt-old {
    text-decoration: line-through;
    color: var(--db-muted);
    font-weight: 600;
}

.db-bill-amt-arrow {
    color: var(--db-muted);
    font-weight: 600;
}

.db-bill-amt-new {
    font-weight: 700;
}

.db-bill-removed-wrap {
    margin: 0.35rem 0 0.85rem;
    padding: 0.75rem 0.85rem 0.85rem;
    border-radius: 1rem;
    border: 1px dashed var(--db-line);
    background: rgba(15, 28, 26, 0.03);
}

.db-bill-removed-title {
    margin: 0;
    font-size: 0.86rem;
    font-weight: 700;
}

.db-bill-list--removed {
    margin-bottom: 0;
}

.db-bill-restore {
    padding: 0.35rem 0.65rem;
    font-size: 0.78rem;
    white-space: nowrap;
}

.db-bill-item input[type="checkbox"] {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    accent-color: var(--db-accent);
    flex-shrink: 0;
}

.db-bill-body {
    min-width: 0;
}

.db-bill-body strong {
    display: block;
    font-size: 0.92rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.db-bill-title-row strong {
    display: block;
}

.db-bill-body small {
    color: var(--db-muted);
    font-size: 0.72rem;
    text-transform: capitalize;
}

.db-bill-amt {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.db-bill-add {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
    margin: 0.85rem 0 0;
    padding: 0.85rem;
    border-radius: 1rem;
    background: rgba(15, 28, 26, 0.03);
    border: 1px dashed var(--db-line);
    align-items: end;
}

@media (min-width: 420px) {
    .db-bill-add {
        grid-template-columns: minmax(0, 1fr) 6.5rem auto;
    }
}

.db-bill-add-btn {
    width: 100%;
}

@media (min-width: 420px) {
    .db-bill-add-btn {
        width: auto;
        min-width: 4.5rem;
    }
}

.db-plan-footer {
    margin-top: 1.35rem;
    padding-top: 1.15rem;
    border-top: 1px solid var(--db-line);
}

.db-goals-hero {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    padding: 1rem 1.1rem;
    border-radius: 1.1rem;
    background: linear-gradient(135deg, rgba(13, 122, 98, 0.14), rgba(15, 28, 26, 0.06));
    margin-bottom: 1.1rem;
}

.db-goals-hero-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--db-muted);
    font-weight: 600;
}

.db-goals-hero-value {
    font-family: var(--font-money);
    font-size: 2.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--db-accent-deep);
}

.db-goals-hero-value--over {
    color: var(--db-warn);
}

.db-cycle-picker {
    margin: 0 0 1rem;
}

.db-cycle-picker-label {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--db-muted);
    font-weight: 600;
}

.db-cycle-chip-row {
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 0.15rem;
    -webkit-overflow-scrolling: touch;
}

.db-cycle-more {
    margin-top: 0.55rem;
}

.db-alloc {
    margin-bottom: 1rem;
}

.db-alloc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 0.75rem;
    margin-bottom: 0.55rem;
}

.db-alloc-kicker {
    margin: 0;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--db-muted);
    font-weight: 600;
}

.db-alloc-income {
    margin: 0.1rem 0 0;
    font-family: var(--font-money);
    font-size: 1.45rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--db-ink);
}

.db-alloc-used {
    margin: 0;
    font-size: 0.85rem;
    color: var(--db-muted);
}

.db-alloc-bar {
    display: flex;
    height: 0.62rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 28, 26, 0.08);
}

.db-alloc-seg {
    display: flex;
    min-width: 0;
    height: 100%;
}

.db-alloc-fill {
    min-width: 0;
    height: 100%;
}

.db-alloc-fill--disc {
    background: var(--db-accent);
}

.db-alloc-fill--sav {
    background: #1d8f82;
}

.db-alloc-fill--exp {
    background: rgba(15, 28, 26, 0.38);
}

.db-alloc-fill--warn {
    background: var(--db-warn);
}

.db-alloc-fill--used {
    opacity: 0.34;
}

.db-alloc-fill--warn.db-alloc-fill--used {
    opacity: 1;
}

.db-alloc-rows {
    list-style: none;
    margin: 0.85rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.db-alloc-row-top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.3rem;
}

.db-alloc-row-label {
    font-weight: 600;
    color: var(--db-ink);
}

.db-alloc-row-detail {
    display: block;
    font-size: 0.78rem;
    color: var(--db-muted);
    font-weight: 400;
}

.db-alloc-row-amt {
    font-family: var(--font-money);
    font-size: 0.92rem;
    font-weight: 600;
    white-space: nowrap;
    color: var(--db-ink);
}

.db-alloc-row-amt span {
    font-weight: 400;
    color: var(--db-muted);
}

.db-alloc-meter {
    display: flex;
    height: 0.38rem;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(15, 28, 26, 0.08);
}

.db-goal-form {
    display: grid;
    gap: 0.65rem;
    margin-bottom: 1rem;
    align-items: end;
}

@media (min-width: 480px) {
    .db-goal-form {
        grid-template-columns: minmax(0, 1fr) 7rem auto;
    }

    .db-goal-form .db-btn--solid {
        width: auto;
    }
}

.db-goal-form .db-btn--solid {
    width: 100%;
}

.db-goals-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.db-goal-card {
    padding: 0.9rem 1rem;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--db-line);
}

.db-goal-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.45rem;
}

.db-goal-targets {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--db-muted);
    margin-bottom: 0.4rem;
}

.db-goal-bar {
    height: 0.4rem;
    border-radius: 999px;
    background: rgba(15, 28, 26, 0.08);
    overflow: hidden;
}

.db-goal-bar-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--db-accent), #34d399);
    border-radius: inherit;
    transition: width 0.35s ease;
}

.db-day-insight {
    margin: -0.15rem 0 0.75rem;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--db-ink);
}

.db-day-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.45rem;
    margin-bottom: 0.85rem;
}

@media (min-width: 480px) {
    .db-day-stats {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.db-day-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.55rem 0.6rem;
    border-radius: 0.75rem;
    background: rgba(15, 28, 26, 0.04);
    border: 1px solid transparent;
}

.db-day-stat-label {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--db-muted);
    font-weight: 600;
}

.db-day-stat-value {
    font-family: var(--font-money);
    font-size: 0.98rem;
    font-weight: 600;
    color: var(--db-ink);
    letter-spacing: -0.01em;
}

.db-day-linewrap {
    margin: 0.15rem -0.85rem 0;
}

.db-day-chart-frame {
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: 0.35rem 0 0.15rem;
}

.db-day-yaxis {
    flex: 0 0 2.5rem;
    width: 2.5rem;
    height: 11.75rem;
    display: block;
    overflow: visible;
    margin-left: 0.35rem;
    pointer-events: none;
}

.db-day-chart-scroll {
    flex: 1 1 auto;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x;
    overscroll-behavior-x: none;
    padding: 0 0.85rem 0 0;
    scrollbar-width: thin;
}

.db-day-linechart {
    width: auto;
    height: 11.75rem;
    display: block;
    overflow: visible;
}

.db-day-grid {
    stroke: rgba(15, 28, 26, 0.08);
    stroke-width: 1;
}

.db-day-axis {
    fill: var(--db-muted);
    font-size: 10px;
    font-family: "DM Sans", system-ui, sans-serif;
}

.db-day-axis--x {
    font-size: 9px;
    font-weight: 500;
}

.db-day-axis--today {
    fill: var(--db-accent-deep);
    font-weight: 700;
}

.db-day-limit-line {
    stroke: rgba(13, 122, 98, 0.45);
    stroke-width: 2;
    stroke-dasharray: 5 4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.db-day-spend-line {
    stroke: var(--db-accent);
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.db-day-dot {
    cursor: pointer;
    outline: none;
}

.db-day-dot-hit {
    fill: transparent;
}

.db-day-dot-mark {
    fill: var(--db-accent);
    stroke: #fff;
    stroke-width: 2;
    transform-box: fill-box;
    transform-origin: center;
    transition: transform 0.18s ease, fill 0.18s ease;
}

.db-day-dot--over .db-day-dot-mark {
    fill: var(--db-warn);
}

.db-day-dot--today .db-day-dot-mark {
    stroke: var(--db-accent-deep);
    stroke-width: 2.5;
}

.db-day-dot--selected .db-day-dot-mark,
.db-day-dot:focus-visible .db-day-dot-mark,
.db-day-dot:hover .db-day-dot-mark {
    transform: scale(1.3);
}

.db-day-dot--selected .db-day-dot-mark {
    fill: var(--db-accent-deep);
}

.db-day-dot--selected.db-day-dot--over .db-day-dot-mark {
    fill: var(--db-warn);
}

.db-day-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem 1rem;
    margin-top: 0.45rem;
    padding: 0 0.85rem;
    font-size: 0.75rem;
    color: var(--db-muted);
}

.db-day-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.db-day-swatch {
    width: 0.7rem;
    height: 0.2rem;
    border-radius: 999px;
    display: inline-block;
}

.db-day-swatch--spend {
    background: var(--db-accent);
    height: 0.28rem;
}

.db-day-swatch--limit {
    background: transparent;
    border-top: 2px dashed rgba(13, 122, 98, 0.55);
    height: 0;
    width: 0.85rem;
}

.db-day-swatch--over {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--db-warn);
}

.db-day-hint {
    margin: 0.45rem 0.85rem 0;
    font-size: 0.78rem;
    color: var(--db-muted);
}

.db-day-tooltip-box {
    fill: rgba(15, 28, 26, 0.94);
    stroke: rgba(255, 255, 255, 0.14);
    stroke-width: 1;
    filter: drop-shadow(0 6px 14px rgba(15, 28, 26, 0.22));
}

.db-day-tooltip-title {
    fill: rgba(255, 255, 255, 0.72);
    font-size: 9px;
    font-weight: 600;
    font-family: "DM Sans", system-ui, sans-serif;
}

.db-day-tooltip-amounts {
    fill: #fff;
    font-size: 11px;
    font-weight: 700;
    font-family: Outfit, "DM Sans", system-ui, sans-serif;
}

.db-day-tooltip-delta {
    font-size: 9px;
    font-weight: 600;
    font-family: "DM Sans", system-ui, sans-serif;
}

.db-day-tooltip-delta--under,
.db-day-tooltip-delta--exact {
    fill: #9ee4d2;
}

.db-day-tooltip-delta--clear {
    fill: rgba(255, 255, 255, 0.62);
}

.db-day-tooltip-delta--over {
    fill: #ffb38a;
}

.db-page .hidden {
    display: none !important;
}

@media (min-width: 768px) {
    .db-panel-tabs {
        max-width: 22rem;
    }

    #panel-today.db-panel:not([hidden]):not(.hidden) {
        display: grid;
        grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
        gap: 1.25rem 1.5rem;
        align-items: start;
    }

    #panel-today .db-hero {
        margin-bottom: 0;
    }

    #panel-today .db-entry {
        margin-bottom: 0;
    }

    #panel-today .db-today-compose {
        display: flex;
        flex-direction: column;
        gap: 0.85rem;
        min-width: 0;
    }

    #panel-today .db-today-compose .db-usual {
        margin-bottom: 0;
    }

    #panel-today .db-today-list-wrap {
        grid-column: 1 / -1;
    }

    #panel-plan .db-card,
    #panel-goals .db-card {
        max-width: 42rem;
    }
}

/* ===== App-wide loan / Tailwind bridge ===== */
body.app-page {
    background: transparent;
}

body.app-page .bg-white,
body.app-page .bg-white.rounded,
body.app-page .bg-white.shadow,
body.app-page .bg-white.rounded.shadow {
    background: var(--surface) !important;
    backdrop-filter: blur(10px);
    border: 1px solid var(--line);
    border-radius: var(--radius) !important;
    box-shadow: 0 10px 30px rgba(15, 40, 34, 0.06) !important;
}

body.app-page header.bg-white.shadow,
body.app-page .bg-white.shadow.mb-8 {
    background: var(--surface) !important;
}

body.app-page .text-gray-900,
body.app-page .text-gray-800 {
    color: var(--ink) !important;
}

body.app-page .text-gray-700,
body.app-page .text-gray-600,
body.app-page .text-gray-500 {
    color: var(--muted) !important;
}

body.app-page .bg-gray-100,
body.app-page .bg-gray-50 {
    background: rgba(15, 28, 26, 0.04) !important;
}

body.app-page .divide-gray-200 > :not([hidden]) ~ :not([hidden]),
body.app-page .divide-y {
    border-color: var(--line) !important;
}

body.app-page .border-gray-200,
body.app-page .border-gray-300 {
    border-color: var(--line) !important;
}

body.app-page .bg-blue-500,
body.app-page .bg-blue-600,
body.app-page .bg-indigo-500,
body.app-page .bg-indigo-600,
body.app-page .hover\:bg-blue-700:hover,
body.app-page .hover\:bg-indigo-700:hover {
    background: var(--accent) !important;
}

body.app-page .hover\:bg-blue-700:hover,
body.app-page .hover\:bg-indigo-700:hover,
body.app-page .bg-blue-500:hover,
body.app-page .bg-indigo-500:hover {
    background: var(--accent-deep) !important;
}

body.app-page .bg-green-600,
body.app-page .hover\:bg-green-700:hover {
    background: var(--accent) !important;
}

body.app-page .hover\:bg-green-700:hover {
    background: var(--accent-deep) !important;
}

body.app-page .bg-red-600,
body.app-page .hover\:bg-red-700:hover {
    background: var(--warn) !important;
}

body.app-page .bg-gray-500,
body.app-page .hover\:bg-gray-700:hover,
body.app-page .bg-gray-300,
body.app-page .hover\:bg-gray-400:hover {
    background: rgba(15, 28, 26, 0.1) !important;
    color: var(--ink) !important;
}

body.app-page .hover\:bg-gray-700:hover,
body.app-page .hover\:bg-gray-400:hover {
    background: rgba(15, 28, 26, 0.16) !important;
}

body.app-page .text-blue-700,
body.app-page .text-indigo-900 {
    color: var(--accent-deep) !important;
}

body.app-page .bg-indigo-50,
body.app-page .hover\:bg-indigo-100:hover {
    background: rgba(13, 122, 98, 0.1) !important;
}

body.app-page .border-indigo-200 {
    border-color: rgba(13, 122, 98, 0.25) !important;
}

body.app-page .bg-amber-50,
body.app-page .border-amber-300 {
    background: rgba(194, 65, 12, 0.08) !important;
    border-color: rgba(194, 65, 12, 0.28) !important;
}

body.app-page .text-amber-800,
body.app-page .text-amber-900 {
    color: var(--warn) !important;
}

body.app-page .rounded,
body.app-page .rounded-lg {
    border-radius: 0.85rem !important;
}

body.app-page input[type="text"],
body.app-page input[type="number"],
body.app-page input[type="email"],
body.app-page input[type="file"],
body.app-page select,
body.app-page textarea {
    border-radius: 0.85rem !important;
    border-color: var(--line) !important;
    background: var(--surface-solid) !important;
    color: var(--ink) !important;
}

body.app-page .loan-row {
    cursor: pointer;
}

body.app-page .balance-amount {
    font-family: var(--font-money);
    letter-spacing: -0.02em;
}

body.app-page .text-3xl.font-bold {
    font-family: var(--font-display);
    letter-spacing: -0.02em;
}

/* Login */
body.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 1.5rem;
    background: transparent;
}

.login-card {
    width: 100%;
    max-width: 26rem;
    padding: 2rem 1.75rem;
    background: var(--surface);
    backdrop-filter: blur(12px);
    border: 1px solid var(--line);
    border-radius: 1.4rem;
    box-shadow: var(--shadow);
}

.login-card h1 {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-card label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
}

.login-card input {
    width: 100%;
    margin-top: 0.35rem;
    margin-bottom: 1rem;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    background: var(--surface-solid);
    font-size: 1.05rem;
    color: var(--ink);
}

.login-card button[type="submit"] {
    width: 100%;
    margin-top: 0.35rem;
    padding: 0.95rem 1rem;
    border: 0;
    border-radius: 1rem;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
    font-size: 1.05rem;
    cursor: pointer;
    box-shadow: 0 12px 28px rgba(13, 122, 98, 0.28);
}

.login-card button[type="submit"]:hover {
    background: var(--accent-deep);
}

.login-error {
    margin-top: 1rem;
    padding: 0.75rem 0.9rem;
    border-radius: 0.85rem;
    border: 1px solid rgba(194, 65, 12, 0.35);
    color: var(--warn);
    background: rgba(194, 65, 12, 0.08);
    font-size: 0.9rem;
}

.spending-metric.glass-stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
}

.spending-metric--savings .glass-stat-value,
.spending-metric--savings .spending-metric__value {
    color: var(--accent-deep) !important;
}

/* Loan detail header pieces */
.loan-detail-title {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.75rem;
    min-width: 0;
    flex: 1 1 auto;
}

.loan-back {
    color: var(--muted);
    display: inline-flex;
    flex-shrink: 0;
}

.loan-back:hover {
    color: var(--ink);
}

.loan-detail-name {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    line-height: 1.2;
    min-width: 0;
    word-break: break-word;
}

.loan-detail-actions {
    flex-shrink: 0;
}

/* ===== Mobile layout overhaul ===== */
@media (max-width: 767px) {
    .container,
    .app-shell,
    .spending-shell,
    .db-shell {
        padding: 0.75rem 0.85rem 2.75rem;
    }

    .app-header {
        padding: 0.85rem 0.9rem;
        margin-bottom: 1rem;
        gap: 0.75rem;
        border-radius: 1rem;
    }

    .app-brand {
        font-size: 1.15rem;
    }

    .app-session {
        display: none;
    }

    .app-btn--logout {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    .app-nav a {
        min-height: 2.5rem;
        font-size: 0.72rem;
        padding: 0.45rem 0.2rem;
    }

    .card,
    .spending-section.card,
    .spending-chart-card,
    .app-surface {
        padding: 1rem 0.95rem;
        border-radius: 1rem;
    }

    /* Glance: Daily hero + compact Monthly/Loans — no scroll strip */
    .home-spotlight {
        margin-bottom: 1.15rem;
    }

    .home-spotlight-hero {
        padding: 1.25rem 1.15rem 1.15rem;
    }

    .home-spotlight-side {
        gap: 0.65rem;
    }

    .home-spotlight-stat {
        padding: 0.85rem 0.9rem;
    }

    .home-spotlight-stat-value {
        font-size: 1.2rem;
    }

    .home-section-h {
        font-size: 1.2rem;
    }

    .home-section-sub {
        font-size: 0.85rem;
        margin-bottom: 0.75rem;
    }

    .home-import-hint {
        margin-bottom: 0.85rem !important;
    }

    .home-import-next:not(.hidden) {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }

    .home-import-next a {
        margin-right: 0;
        display: inline-block;
    }

    .home-statements li {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.2rem;
    }

    /* Daily */
    .db-panel-tabs {
        max-width: none;
        width: 100%;
    }

    .db-hero {
        padding: 1.25rem 1.1rem 1.1rem;
    }

    .db-hero-value {
        font-size: clamp(2rem, 10vw, 2.6rem);
    }

    .db-title-clear {
        width: 3.25rem;
        height: 3.25rem;
        min-width: 3.25rem;
        min-height: 3.25rem;
        right: 0.15rem;
        font-size: 1.35rem;
    }

    .db-title-input-wrap input {
        padding-right: 3.85rem;
    }

    /* Monthly KPIs: 2-up on phone */
    .spending-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 0.65rem;
    }

    .spending-h2 {
        font-size: 1.2rem;
    }

    /* Loan detail */
    .loan-detail-name {
        font-size: 1.25rem;
    }

    .loan-detail-actions {
        width: 100%;
        justify-content: stretch;
    }

    .loan-detail-actions .app-btn {
        flex: 1 1 auto;
        padding: 0.55rem 0.65rem;
        font-size: 0.8rem;
    }

    .app-shell.container.mx-auto.py-8 {
        padding-top: 0.75rem !important;
        padding-bottom: 2.75rem !important;
    }
}

/* --- Global transaction search --- */
html:has(body.search-page),
body.search-page {
    overflow-x: hidden;
}

.search-form {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.search-q-wrap {
    display: block;
    width: 100%;
}

.search-q-input {
    width: 100%;
    box-sizing: border-box;
    font-family: var(--font-body, inherit);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--ink);
    background: rgba(255, 255, 255, 0.72);
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    padding: 0.85rem 1rem;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-q-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(13, 122, 98, 0.18);
}

.search-q-input::placeholder {
    color: var(--muted);
    font-weight: 400;
}

.search-filters {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
    gap: 0.65rem 0.75rem;
}

.search-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.search-filter-field--min {
    grid-column: auto;
}

.search-filter-field--max {
    grid-column: auto;
}

.search-filter-field .spending-control {
    width: 100%;
    min-width: 0;
}

.search-form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.search-pager {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.65rem;
}

.search-pager.hidden {
    display: none;
}

.search-muted-section {
    padding-top: 0.35rem;
    border-top: 1px dashed rgba(15, 40, 34, 0.14);
}

.search-muted-section.hidden {
    display: none;
}

.search-muted-heading {
    margin: 0;
    font-family: var(--font-display, inherit);
    font-size: 0.95rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    color: #6b7280;
}

/* Desktop: muted/excluded rows are clearly grayed */
body.search-page .search-tx-table--muted {
    opacity: 0.92;
}

body.search-page .search-tx-table--muted tr.search-tx-row--muted,
body.search-page #tx-search-muted-tbody tr.search-tx-row--muted {
    color: #6b7280;
    background: #f3f4f6;
}

body.search-page .search-tx-table--muted tr.search-tx-row--muted .spending-insight-tx-amount,
body.search-page #tx-search-muted-tbody tr.search-tx-row--muted .spending-insight-tx-amount {
    color: #6b7280;
}

body.search-page .search-tx-muted-badge {
    display: inline-block;
    margin-left: 0.45rem;
    padding: 0.08rem 0.4rem;
    border-radius: 0.3rem;
    border: 1px solid #d1d5db;
    background: #e5e7eb;
    color: #4b5563;
    font-size: 0.65rem;
    font-weight: 650;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    vertical-align: middle;
    white-space: nowrap;
}

/* Desktop: short mobile date chip stays hidden; toggle column too */
.search-tx-toggle,
.search-tx-toggle-col,
.search-tx-date-short {
    display: none;
}

.search-expand-hint {
    display: none;
}

/* Mobile: compact rows that expand for details */
@media (max-width: 640px) {
    .search-q-input {
        font-size: 1rem;
        padding: 0.75rem 0.9rem;
    }

    .search-filters {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.85rem;
    }

    .search-filter-field .import-label {
        font-size: 0.72rem;
    }

    .search-expand-hint:not(.hidden) {
        display: block;
    }

    body.search-page .search-tx-scroll {
        overflow-x: visible;
        margin-left: -0.15rem;
        margin-right: -0.15rem;
    }

    body.search-page .search-tx-scroll > table.search-tx-table {
        display: block;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    body.search-page .search-tx-thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    body.search-page .search-tx-tbody {
        display: flex;
        flex-direction: column;
        gap: 0.28rem;
    }

    body.search-page .search-tx-tbody tr.search-tx-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        grid-template-areas: "desc amount toggle";
        column-gap: 0.4rem;
        row-gap: 0;
        align-items: center;
        margin: 0;
        padding: 0.42rem 0.55rem;
        border: 1px solid var(--line) !important;
        border-radius: 0.65rem;
        background: rgba(255, 255, 255, 0.84);
        box-shadow: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.15s ease, box-shadow 0.15s ease;
    }

    body.search-page .search-tx-tbody tr.search-tx-row:nth-child(even) {
        background: rgba(255, 255, 255, 0.94);
    }

    body.search-page .search-tx-tbody tr.search-tx-row:hover,
    body.search-page .search-tx-tbody tr.search-tx-row:focus-visible {
        background: rgba(255, 255, 255, 0.98);
        outline: none;
        box-shadow: 0 0 0 2px rgba(13, 122, 98, 0.22);
    }

    body.search-page .search-tx-tbody tr.search-tx-row--muted {
        opacity: 0.78;
        color: #6b7280;
        background: #f3f4f6 !important;
    }

    body.search-page .search-tx-tbody tr.search-tx-row--muted .search-tx-amount,
    body.search-page .search-tx-tbody tr.search-tx-row--muted .search-tx-ref,
    body.search-page .search-tx-tbody tr.search-tx-row--muted .search-tx-date-short {
        color: #6b7280;
    }

    body.search-page .search-tx-tbody tr.search-tx-row--muted:hover,
    body.search-page .search-tx-tbody tr.search-tx-row--muted:focus-visible {
        background: #e5e7eb !important;
    }

    body.search-page .search-tx-muted-badge {
        display: none;
    }

    body.search-page .search-tx-row--open .search-tx-muted-badge {
        display: inline-block;
        margin: 0.35rem 0 0;
    }

    body.search-page .search-muted-section {
        margin-top: 1.15rem;
        padding-top: 0.85rem;
    }

    body.search-page .search-tx-tbody tr.search-tx-row--open {
        grid-template-areas:
            "desc amount toggle"
            "date date date"
            "dir dir dir"
            "cat cat cat"
            "source source source"
            "month month month";
        row-gap: 0.28rem;
        padding: 0.5rem 0.6rem 0.65rem;
        box-shadow: 0 6px 16px rgba(15, 40, 34, 0.05);
    }

    body.search-page .search-tx-tbody td {
        border: 0;
        padding: 0;
        min-width: 0;
        white-space: normal;
        font-size: 0.88rem;
        line-height: 1.2;
        color: var(--ink);
    }

    body.search-page .search-tx-desc {
        grid-area: desc;
        font-size: 0.9rem;
        font-weight: 600;
        letter-spacing: -0.01em;
        line-height: 1.25;
        padding-right: 0.15rem;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.search-page .search-tx-ref {
        font-weight: 600;
    }

    body.search-page .search-tx-date-short {
        display: inline;
        font-weight: 500;
        font-size: 0.78rem;
        color: var(--muted);
        white-space: nowrap;
    }

    body.search-page .search-tx-amount {
        grid-area: amount;
        justify-self: end;
        text-align: right;
        font-size: 0.9rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
        line-height: 1.25;
    }

    body.search-page .search-tx-amount::before {
        content: "£";
        font-weight: 600;
        margin-right: 0.04rem;
        color: var(--muted);
    }

    /* Full ISO date is a detail field on mobile until the row is expanded. */
    body.search-page .search-tx-date {
        display: none;
        grid-area: date;
        color: var(--muted);
        font-size: 0.72rem;
        font-variant-numeric: tabular-nums;
        line-height: 1.15;
    }

    body.search-page .search-tx-row--open .search-tx-date {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.75rem;
        width: 100%;
        margin-top: 0.15rem;
        padding-top: 0.4rem;
        border-top: 1px solid rgba(15, 40, 34, 0.08);
        font-size: 0.88rem;
        color: var(--ink);
    }

    body.search-page .search-tx-row--open .search-tx-date::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--muted);
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    body.search-page .search-tx-row--open .search-tx-date-short {
        display: none;
    }

    body.search-page .search-tx-toggle {
        display: flex;
        grid-area: toggle;
        align-items: center;
        justify-content: center;
        width: 1.2rem;
        height: 1.2rem;
        border-radius: 999px;
        background: rgba(15, 40, 34, 0.05);
        color: var(--muted);
    }

    body.search-page .search-tx-chevron {
        display: block;
        width: 0.45rem;
        height: 0.45rem;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        translate: 0 -0.1rem;
        transition: transform 0.15s ease;
    }

    body.search-page .search-tx-row--open .search-tx-chevron {
        transform: rotate(225deg);
        translate: 0 0.12rem;
    }

    body.search-page .search-tx-detail {
        display: none;
    }

    body.search-page .search-tx-row--open .search-tx-detail {
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        gap: 0.75rem;
        width: 100%;
        padding: 0.45rem 0 0;
        border-top: 1px solid rgba(15, 40, 34, 0.08);
        font-size: 0.88rem;
        color: var(--ink);
    }

    body.search-page .search-tx-row--open .search-tx-dir {
        grid-area: dir;
        text-transform: capitalize;
        margin-top: 0;
        border-top: 0;
        padding-top: 0.22rem;
    }

    body.search-page .search-tx-row--open .search-tx-cat {
        grid-area: cat;
        text-transform: capitalize;
        border-top: 0;
        padding-top: 0.22rem;
    }

    body.search-page .search-tx-row--open .search-tx-source {
        grid-area: source;
        border-top: 0;
        padding-top: 0.22rem;
    }

    body.search-page .search-tx-row--open .search-tx-month {
        grid-area: month;
        border-top: 0;
        padding-top: 0.22rem;
    }

    body.search-page .search-tx-row--open .search-tx-detail::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--muted);
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    body.search-page .search-tx-month-link {
        font-weight: 600;
    }

    .search-filter-field--source {
        grid-column: 1 / -1;
    }

    .search-filter-field .spending-control {
        min-height: 2.5rem;
        padding-top: 0.45rem;
        padding-bottom: 0.45rem;
    }
}

/* --- Home + loan statement import: native expandable cards on phone --- */
html:has(body.home-page),
body.home-page {
    overflow-x: hidden;
}

@media (max-width: 640px) {
    body.home-page .import-fields .import-field > input.spending-control,
    body.home-page .import-fields .import-field .source-combobox > input.spending-control,
    body.home-page .import-field--file .import-file-input {
        font-size: 1rem;
        min-height: 2.85rem;
    }

    body.home-page .source-combobox__option {
        padding: 0.75rem 0.85rem;
        font-size: 1rem;
        min-height: 2.75rem;
    }

    body.home-page .import-actions .spending-btn {
        min-height: 2.85rem;
        font-size: 0.95rem;
    }

    body.home-page .preview-summary-totals {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.45rem;
    }

    body.home-page .preview-summary-stat {
        padding: 0.55rem 0.65rem;
        border-radius: 0.65rem;
    }

    body.home-page .preview-summary-stat-value {
        font-size: 1rem;
    }

    body.home-page .preview-toolbar {
        padding: 0.15rem 0.1rem 0.35rem;
        position: sticky;
        top: 0;
        z-index: 2;
        background: linear-gradient(
            to bottom,
            rgba(247, 250, 248, 0.96) 70%,
            rgba(247, 250, 248, 0)
        );
    }

    body.home-page .preview-expand-hint {
        display: block;
        width: 100%;
        order: 2;
    }

    body.home-page .preview-toolbar-include {
        order: 1;
        min-height: 2.5rem;
        padding: 0.35rem 0;
        font-size: 0.95rem;
    }

    body.home-page .preview-toolbar-include input {
        width: 1.25rem;
        height: 1.25rem;
    }

    body.home-page .import-preview-scroll {
        overflow-x: visible;
        margin-left: -0.15rem;
        margin-right: -0.15rem;
    }

    body.home-page .import-preview-scroll > table.preview-tx-table {
        display: block;
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }

    body.home-page .preview-tx-thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    body.home-page .preview-tx-tbody {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    body.home-page .preview-tx-tbody tr.preview-tx-row {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        grid-template-areas:
            "include desc amount toggle"
            "include match match match";
        column-gap: 0.45rem;
        row-gap: 0.2rem;
        align-items: center;
        margin: 0;
        padding: 0.55rem 0.65rem;
        border: 1px solid var(--line, rgba(15, 40, 34, 0.12)) !important;
        border-radius: 0.75rem;
        background: rgba(255, 255, 255, 0.9);
        box-shadow: none;
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
        transition: background 0.15s ease, box-shadow 0.15s ease;
    }

    body.home-page .preview-tx-tbody tr.preview-tx-row:hover,
    body.home-page .preview-tx-tbody tr.preview-tx-row:focus-visible {
        background: rgba(255, 255, 255, 0.98);
        outline: none;
        box-shadow: 0 0 0 2px rgba(13, 122, 98, 0.22);
    }

    body.home-page .preview-tx-tbody tr.spending-preview-row-duplicate {
        background: #fffbeb !important;
    }

    body.home-page .preview-tx-tbody tr.spending-preview-row-missed:not(.spending-preview-row-duplicate) {
        background: #fef2f2 !important;
    }

    body.home-page .preview-tx-tbody tr.spending-preview-row-boundary:not(.spending-preview-row-duplicate):not(.spending-preview-row-missed) {
        background: #f0fdfa !important;
    }

    body.home-page .preview-tx-tbody tr.preview-tx-row--open {
        grid-template-areas:
            "include desc amount toggle"
            "include match match match"
            "date date date date"
            "dir dir dir dir"
            "cat cat cat cat"
            "transfer transfer transfer transfer";
        row-gap: 0.28rem;
        padding: 0.6rem 0.7rem 0.75rem;
        box-shadow: 0 6px 16px rgba(15, 40, 34, 0.05);
    }

    body.home-page .preview-tx-tbody td {
        border: 0 !important;
        padding: 0 !important;
        min-width: 0;
        white-space: normal;
        font-size: 0.88rem;
        line-height: 1.25;
        color: var(--ink, #0f2822);
        background: transparent !important;
    }

    body.home-page .preview-tx-include {
        grid-area: include;
        align-self: start;
        padding-top: 0.15rem !important;
    }

    body.home-page .preview-tx-include .preview-include {
        width: 1.25rem;
        height: 1.25rem;
    }

    body.home-page .preview-tx-desc {
        grid-area: desc;
        font-size: 0.92rem;
        font-weight: 600;
        letter-spacing: -0.01em;
        line-height: 1.25;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.home-page .preview-tx-ref {
        font-weight: 600;
    }

    body.home-page .preview-tx-date-short {
        display: inline;
        font-weight: 500;
        font-size: 0.78rem;
        color: var(--muted, #5b6b66);
        white-space: nowrap;
    }

    body.home-page .preview-tx-amount {
        grid-area: amount;
        justify-self: end;
        text-align: right;
        font-size: 0.95rem;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
        line-height: 1.25;
    }

    body.home-page .preview-tx-amount::before {
        content: "£";
        font-weight: 600;
        margin-right: 0.04rem;
        color: var(--muted, #5b6b66);
    }

    body.home-page .preview-tx-match {
        grid-area: match;
        min-height: 1.1rem;
    }

    body.home-page .preview-tx-match .preview-match-empty {
        display: none;
    }

    body.home-page .preview-duplicate-pill,
    body.home-page .preview-review-pill {
        font-size: 0.72rem;
        padding: 0.22rem 0.5rem;
        border-radius: 0.55rem;
        letter-spacing: 0.03em;
    }

    body.home-page .preview-tx-toggle {
        display: flex;
        grid-area: toggle;
        align-items: center;
        justify-content: center;
        width: 1.35rem;
        height: 1.35rem;
        border-radius: 999px;
        background: rgba(15, 40, 34, 0.05);
        color: var(--muted, #5b6b66);
    }

    body.home-page .preview-tx-chevron {
        display: block;
        width: 0.45rem;
        height: 0.45rem;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        translate: 0 -0.1rem;
        transition: transform 0.15s ease;
    }

    body.home-page .preview-tx-row--open .preview-tx-chevron {
        transform: rotate(225deg);
        translate: 0 0.12rem;
    }

    body.home-page .preview-tx-detail {
        display: none;
    }

    body.home-page .preview-tx-row--open .preview-tx-detail {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        width: 100%;
        padding: 0.45rem 0 0 !important;
        border-top: 1px solid rgba(15, 40, 34, 0.08);
        font-size: 0.88rem;
        color: var(--ink, #0f2822);
    }

    body.home-page .preview-tx-row--open .preview-tx-date {
        grid-area: date;
        margin-top: 0.2rem;
    }

    body.home-page .preview-tx-row--open .preview-tx-date-short {
        display: none;
    }

    body.home-page .preview-tx-row--open .preview-tx-dir {
        grid-area: dir;
        border-top: 0;
        padding-top: 0.22rem !important;
    }

    body.home-page .preview-tx-row--open .preview-tx-cat {
        grid-area: cat;
        border-top: 0;
        padding-top: 0.22rem !important;
    }

    body.home-page .preview-tx-row--open .preview-tx-transfer {
        grid-area: transfer;
        border-top: 0;
        padding-top: 0.22rem !important;
        align-items: flex-start;
    }

    body.home-page .preview-tx-row--open .preview-tx-detail::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--muted, #5b6b66);
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    body.home-page .preview-tx-row--open .preview-direction,
    body.home-page .preview-tx-row--open .preview-category {
        min-height: 2.4rem;
        min-width: 8.5rem;
        font-size: 0.95rem;
        padding: 0.35rem 0.55rem;
        border-radius: 0.55rem;
    }

    /* Loan statement import cards */
    #statement-import-results .loan-import-toolbar {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: space-between;
        gap: 0.45rem 0.85rem;
        margin-bottom: 0.55rem;
    }

    #statement-import-results .loan-import-expand-hint {
        display: block;
        margin: 0;
        width: 100%;
        font-size: 0.78rem;
        color: var(--muted, #5b6b66);
    }

    #statement-import-results .loan-import-scroll {
        overflow-x: visible;
    }

    #statement-import-results table.loan-import-table {
        display: block;
        width: 100%;
        min-width: 0;
    }

    #statement-import-results .loan-import-thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    #statement-import-results .loan-import-tbody {
        display: flex;
        flex-direction: column;
        gap: 0.35rem;
    }

    #statement-import-results tr.loan-import-row {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto auto;
        grid-template-areas:
            "include desc bank toggle"
            "include badge badge badge";
        column-gap: 0.45rem;
        row-gap: 0.2rem;
        align-items: center;
        padding: 0.55rem 0.65rem;
        border: 1px solid var(--line, rgba(15, 40, 34, 0.12));
        border-radius: 0.75rem;
        background: rgba(255, 255, 255, 0.9);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    #statement-import-results tr.loan-import-row.bg-amber-50 {
        background: #fffbeb !important;
    }

    #statement-import-results tr.loan-import-row--open {
        grid-template-areas:
            "include desc bank toggle"
            "include badge badge badge"
            "date date date date"
            "share share share share";
        row-gap: 0.28rem;
        padding-bottom: 0.75rem;
        box-shadow: 0 6px 16px rgba(15, 40, 34, 0.05);
    }

    #statement-import-results tr.loan-import-row td {
        border: 0;
        padding: 0;
        min-width: 0;
        background: transparent !important;
    }

    #statement-import-results .loan-import-include {
        grid-area: include;
        align-self: start;
    }

    #statement-import-results .loan-import-include .statement-row-check {
        width: 1.25rem;
        height: 1.25rem;
    }

    #statement-import-results .loan-import-desc {
        grid-area: desc;
        font-weight: 600;
        font-size: 0.92rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #statement-import-results .loan-import-bank {
        grid-area: bank;
        justify-self: end;
        font-weight: 700;
        font-variant-numeric: tabular-nums;
        white-space: nowrap;
    }

    #statement-import-results .loan-import-bank::before {
        content: "£";
        color: var(--muted, #5b6b66);
        font-weight: 600;
        margin-right: 0.04rem;
    }

    #statement-import-results .loan-import-badge {
        grid-area: badge;
        font-size: 0.72rem;
        font-weight: 600;
        color: #92400e;
    }

    #statement-import-results .loan-import-toggle {
        display: flex;
        grid-area: toggle;
        align-items: center;
        justify-content: center;
        width: 1.35rem;
        height: 1.35rem;
        border-radius: 999px;
        background: rgba(15, 40, 34, 0.05);
        color: var(--muted, #5b6b66);
    }

    #statement-import-results .loan-import-chevron {
        display: block;
        width: 0.45rem;
        height: 0.45rem;
        border-right: 2px solid currentColor;
        border-bottom: 2px solid currentColor;
        transform: rotate(45deg);
        translate: 0 -0.1rem;
        transition: transform 0.15s ease;
    }

    #statement-import-results tr.loan-import-row--open .loan-import-chevron {
        transform: rotate(225deg);
        translate: 0 0.12rem;
    }

    #statement-import-results .loan-import-detail {
        display: none;
    }

    #statement-import-results tr.loan-import-row--open .loan-import-detail {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 0.75rem;
        width: 100%;
        padding-top: 0.45rem;
        border-top: 1px solid rgba(15, 40, 34, 0.08);
        font-size: 0.88rem;
    }

    #statement-import-results tr.loan-import-row--open .loan-import-date {
        grid-area: date;
        margin-top: 0.2rem;
    }

    #statement-import-results tr.loan-import-row--open .loan-import-share {
        grid-area: share;
        border-top: 0;
        padding-top: 0.22rem;
    }

    #statement-import-results tr.loan-import-row--open .loan-import-detail::before {
        content: attr(data-label);
        flex: 0 0 auto;
        color: var(--muted, #5b6b66);
        font-size: 0.68rem;
        font-weight: 600;
        letter-spacing: 0.03em;
        text-transform: uppercase;
    }

    #statement-import-results .statement-row-amount {
        min-height: 2.4rem;
        width: 100%;
        max-width: 10rem;
        font-size: 0.95rem;
        border-radius: 0.55rem;
    }

    #statement-import-results .loan-import-actions {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0.55rem;
        margin-top: 0.75rem;
    }

    #statement-import-results .loan-import-actions .app-btn {
        width: 100%;
        margin: 0 !important;
        min-height: 2.85rem;
    }
}

@media (min-width: 641px) {
    #statement-import-results .loan-import-toolbar,
    #statement-import-results .loan-import-expand-hint,
    #statement-import-results .loan-import-toggle,
    #statement-import-results .loan-import-toggle-th,
    #statement-import-results .loan-import-badge {
        display: none;
    }
}

@media (max-width: 640px) {
    #statement-import-results .loan-import-inline-badge {
        display: none;
    }
}

/* --- Reconcile page --- */
/* .hidden must win over display:flex / inline-flex on this page. */
.reconcile-page .hidden {
    display: none !important;
}

.reconcile-page .reconcile-section {
    padding: 1.35rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.reconcile-steps {
    display: flex;
    align-items: center;
    gap: 0;
    list-style: none;
    margin: 0 0 1.35rem;
    padding: 0 0 1.15rem;
    border-bottom: 1px solid var(--line);
}

.reconcile-steps-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0;
    padding: 0;
    border: 0;
    background: none;
    font: inherit;
    color: var(--muted);
    cursor: pointer;
}

.reconcile-steps-item + .reconcile-steps-item::before {
    content: "";
    width: 1.6rem;
    height: 1px;
    margin: 0 0.7rem 0 0.35rem;
    background: var(--line);
}

.reconcile-steps-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.35rem;
    height: 1.35rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    font-size: 0.6875rem;
    font-weight: 700;
    line-height: 1;
}

.reconcile-steps-label {
    font-size: 0.8125rem;
    font-weight: 600;
}

.reconcile-steps-item.is-current {
    color: var(--ink);
}

.reconcile-steps-item.is-current .reconcile-steps-num {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.reconcile-steps-item.is-done {
    color: var(--accent-deep);
}

.reconcile-steps-item.is-done .reconcile-steps-num {
    background: rgba(13, 122, 98, 0.12);
    border-color: rgba(13, 122, 98, 0.2);
    color: var(--accent-deep);
}

.reconcile-step {
    display: flex;
    flex-direction: column;
}

.reconcile-step-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    margin: 0 0 0.85rem;
}

.reconcile-step-foot {
    display: flex;
    justify-content: flex-end;
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.reconcile-step-foot--split {
    justify-content: space-between;
    gap: 0.75rem;
}

.reconcile-step-foot-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
}

.reconcile-recap {
    margin: 0 0 1rem;
    padding: 0.95rem 1.05rem;
    border: 1px solid var(--line);
    border-radius: 0.95rem;
    background: rgba(13, 122, 98, 0.05);
}

.reconcile-recap-hero {
    margin: 0;
    font-size: 1.05rem;
    line-height: 1.4;
    color: var(--ink);
}

.reconcile-recap-hero strong {
    font-weight: 700;
}

.reconcile-recap-note {
    margin: 0.35rem 0 0;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--muted);
}

.reconcile-recap-note--warn {
    color: #b45309;
}

.reconcile-summary-list {
    list-style: none;
    margin: 0.85rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    font-size: 0.9375rem;
    line-height: 1.5;
    color: var(--ink);
}

.reconcile-unclaimed-item.is-ignored {
    opacity: 0.62;
}

.reconcile-top {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.85rem 1.25rem;
    padding-bottom: 0.35rem;
}

.reconcile-top-copy {
    min-width: 0;
    flex: 1 1 16rem;
}

.reconcile-page .reconcile-top .spending-h2 {
    margin: 0;
}

.reconcile-lead {
    margin: 0.3rem 0 0;
    max-width: 38rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--muted);
}

.reconcile-top-meta {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    flex: 0 0 auto;
}

.reconcile-month-wrap {
    display: block;
    margin: 0;
}

.reconcile-month {
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    padding: 0 0.7rem;
    background: #fff;
    color: var(--ink);
    font-size: 0.875rem;
    font-family: inherit;
}

.reconcile-month:focus {
    outline: none;
    border-color: rgba(13, 122, 98, 0.35);
    box-shadow: 0 0 0 3px rgba(13, 122, 98, 0.1);
}

.reconcile-status-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 2.5rem;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 0 0.85rem;
    border-radius: 999px;
    background: rgba(15, 28, 26, 0.05);
    border: 1px solid var(--line);
    color: var(--muted);
    white-space: nowrap;
}

.reconcile-status-chip[data-status="matched"],
.reconcile-status-chip[data-status="imported"] {
    background: rgba(13, 122, 98, 0.1);
    border-color: rgba(13, 122, 98, 0.18);
    color: var(--accent-deep);
}

.reconcile-stage {
    padding: 1.15rem 0 0;
    border-top: 1px solid var(--line);
}

.reconcile-stage-head {
    margin: 0 0 0.85rem;
}

.reconcile-stage-title,
.reconcile-panel-title {
    margin: 0;
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.reconcile-panel-title {
    margin-bottom: 0.35rem;
}

.reconcile-panel-desc {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--muted);
}

.reconcile-composer {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem 0.85rem;
    align-items: end;
}

.reconcile-field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.reconcile-field.reconcile-field--action {
    display: block;
    gap: 0;
    line-height: 0;
    font-size: 0;
    align-self: start;
}

.reconcile-field.reconcile-field--action .reconcile-btn {
    display: flex;
    font-size: 0.875rem;
}

.reconcile-field-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
    line-height: 1;
}

.reconcile-field-optional {
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    opacity: 0.8;
}

.reconcile-input {
    width: 100%;
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    padding: 0 0.85rem;
    background: #fff;
    color: var(--ink);
    font-size: 0.9375rem;
    line-height: 1.35;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.reconcile-input:focus {
    outline: none;
    border-color: rgba(13, 122, 98, 0.35);
    box-shadow: 0 0 0 3px rgba(13, 122, 98, 0.1);
}

.reconcile-file-control {
    position: relative;
    display: block;
    height: 2.5rem;
}

.reconcile-page .reconcile-file-input {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    margin: 0;
    padding: 0;
    border: 0 !important;
    background: transparent !important;
    border-radius: 0 !important;
}

.reconcile-file-fake {
    display: flex;
    align-items: stretch;
    height: 2.5rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #fff;
    overflow: hidden;
}

.reconcile-file-choose {
    display: inline-flex;
    align-items: center;
    padding: 0 0.9rem;
    background: rgba(15, 28, 26, 0.045);
    border-right: 1px solid var(--line);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
}

.reconcile-file-name {
    display: flex;
    align-items: center;
    min-width: 0;
    padding: 0 0.85rem;
    font-size: 0.8125rem;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reconcile-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    height: 2.5rem;
    padding: 0 1.05rem;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.12s;
}

.reconcile-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.reconcile-btn:disabled {
    opacity: 0.42;
    cursor: not-allowed;
}

.reconcile-btn--ghost {
    background: #fff;
    color: var(--ink);
    border-color: var(--line);
}

.reconcile-btn--ghost:hover:not(:disabled) {
    background: rgba(15, 28, 26, 0.03);
    border-color: rgba(15, 28, 26, 0.18);
}

.reconcile-btn--soft {
    background: rgba(13, 122, 98, 0.1);
    color: var(--accent-deep);
    border-color: rgba(13, 122, 98, 0.18);
}

.reconcile-btn--soft:hover:not(:disabled) {
    background: rgba(13, 122, 98, 0.16);
    border-color: rgba(13, 122, 98, 0.28);
}

.reconcile-btn--primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.reconcile-btn--primary:hover:not(:disabled) {
    background: var(--accent-deep);
    border-color: var(--accent-deep);
}

.reconcile-btn--danger {
    background: #fff;
    color: #b45309;
    border-color: rgba(194, 65, 12, 0.22);
}

.reconcile-btn--danger:hover:not(:disabled) {
    background: rgba(194, 65, 12, 0.06);
}

.reconcile-field--action .reconcile-btn {
    width: 100%;
}

.reconcile-upload-list {
    list-style: none;
    margin: 0.85rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 0.85rem;
    overflow: hidden;
    background: #fff;
}

.reconcile-upload-list--empty {
    border: 0;
    background: transparent;
}

.reconcile-upload-empty {
    margin: 0;
    padding: 0.7rem 0.95rem;
    color: var(--muted);
    font-size: 0.875rem;
    background: transparent;
}

.reconcile-upload-list--empty .reconcile-upload-empty {
    padding: 0.15rem 0 0;
}

.reconcile-upload-item {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
    padding: 0.65rem 0.95rem;
    font-size: 0.875rem;
    line-height: 1.4;
    border-top: 1px solid var(--line);
}

.reconcile-upload-meta {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reconcile-upload-item:first-child,
.reconcile-upload-empty:first-child {
    border-top: 0;
}

.reconcile-upload-meta strong {
    font-weight: 600;
    color: var(--ink);
}

.reconcile-upload-remove {
    height: 2rem;
    font-size: 0.8125rem;
    padding: 0 0.75rem;
    flex-shrink: 0;
}

.reconcile-status {
    margin: 0.75rem 0 0;
    padding: 0.55rem 0.85rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.45;
    background: rgba(13, 122, 98, 0.08);
    color: var(--accent-deep);
}

.reconcile-status.is-error {
    background: rgba(194, 65, 12, 0.08);
    color: #9a3412;
}

.reconcile-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.reconcile-toolbar-start {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.55rem;
}

.reconcile-tally {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.85rem 1.25rem;
    align-items: center;
    margin-top: 1.15rem;
    padding: 1rem 0 0;
    border-top: 1px solid var(--line);
}

.reconcile-stat {
    min-width: 0;
}

.reconcile-stat-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin-bottom: 0.2rem;
}

.reconcile-stat-line {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    margin-bottom: 0.45rem;
}

.reconcile-stat-value {
    font-family: var(--font-money);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.reconcile-stat-count {
    font-size: 0.8125rem;
    color: var(--muted);
}

.reconcile-tally-bar {
    height: 5px;
    background: rgba(15, 28, 26, 0.08);
    border-radius: 999px;
    overflow: hidden;
    margin-bottom: 0.4rem;
}

.reconcile-tally-bar span {
    display: block;
    height: 100%;
    background: rgba(13, 122, 98, 0.55);
    border-radius: 999px;
}

.reconcile-tally-bar--manual span {
    background: rgba(37, 99, 235, 0.45);
}

.reconcile-tally-sub {
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--muted);
}

.reconcile-tally-mid {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.reconcile-tally-align {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.reconcile-tally-align--ok {
    background: rgba(13, 122, 98, 0.1);
    color: var(--accent-deep);
}

.reconcile-tally-align--warn {
    background: rgba(217, 119, 6, 0.1);
    color: #b45309;
}

.reconcile-work {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.reconcile-work-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 0.85rem;
}

.reconcile-queue-progress {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--muted);
}

.reconcile-alert {
    margin: 0;
}

.reconcile-alert-chip {
    border: none;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    transition: opacity 0.15s;
}

.reconcile-alert-chip:hover {
    opacity: 0.88;
}

.reconcile-alert-chip--warn {
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
}

.reconcile-alert-chip--ok {
    background: rgba(13, 122, 98, 0.12);
    color: var(--accent-deep);
}

.reconcile-allrows {
    margin-left: auto;
}

.reconcile-text-btn {
    border: 0;
    background: none;
    padding: 0.25rem 0;
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-deep);
    cursor: pointer;
    text-decoration: none;
}

.reconcile-text-btn:hover {
    text-decoration: underline;
}

.reconcile-triage,
.reconcile-panel--manuals,
.reconcile-panel--summary {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--line);
    border-radius: 0.95rem;
    background: #fff;
    overflow: hidden;
}

.reconcile-panel--manuals,
.reconcile-panel--summary {
    padding: 1.1rem 1.2rem 1.15rem;
}

.reconcile-focus {
    padding: 1.05rem 1.15rem 0.85rem;
}

.reconcile-focus-title {
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin: 0 0 0.75rem;
    color: var(--muted);
}

.reconcile-focus-title--matched {
    color: var(--accent-deep);
}

.reconcile-tx {
    display: grid;
    grid-template-columns: 4.4rem minmax(0, 1fr) auto;
    gap: 0.2rem 0.75rem;
    align-items: baseline;
    padding: 0.4rem 0;
}

.reconcile-tx + .reconcile-tx {
    border-top: 1px dashed var(--line);
}

.reconcile-tx-role {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
}

.reconcile-tx-name {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--ink);
    min-width: 0;
    overflow-wrap: anywhere;
}

.reconcile-tx--manual .reconcile-tx-name {
    font-weight: 500;
    color: var(--muted);
}

.reconcile-tx-meta {
    display: flex;
    align-items: baseline;
    justify-content: flex-end;
    gap: 0.7rem;
    font-variant-numeric: tabular-nums;
}

.reconcile-tx-amt {
    min-width: 5.4rem;
    text-align: right;
    font-family: var(--font-money);
    font-weight: 600;
    color: var(--ink);
}

.reconcile-tx-date {
    min-width: 6.6rem;
    text-align: right;
    font-size: 0.8125rem;
    color: var(--muted);
}

.reconcile-source-pill {
    display: inline-flex;
    align-items: center;
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.1);
    color: #1d4ed8;
    min-width: 4.25rem;
    justify-content: center;
}

.reconcile-source-pill--empty {
    visibility: hidden;
}

.reconcile-leg-join {
    display: none;
}

.reconcile-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    padding: 0 1.15rem 0.85rem;
}

.reconcile-suggestions:empty {
    display: none;
}

.reconcile-suggest-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    margin: 0.15rem 0 0;
}

.reconcile-suggest-empty {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.45;
    color: var(--muted);
}

.reconcile-suggest-card {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.7rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #f7fbf9;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1.4;
    color: var(--ink);
    transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}

.reconcile-suggest-card:hover {
    border-color: rgba(13, 122, 98, 0.25);
    background: rgba(13, 122, 98, 0.04);
}

.reconcile-suggest-card--selected {
    border-color: rgba(13, 122, 98, 0.4);
    background: rgba(13, 122, 98, 0.07);
    box-shadow: 0 0 0 3px rgba(13, 122, 98, 0.08);
}

.reconcile-triage-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.55rem 0.85rem;
    padding: 0.75rem 1.15rem;
    border-top: 1px solid var(--line);
    background: rgba(15, 28, 26, 0.025);
}

.reconcile-triage--idle .reconcile-triage-foot,
.reconcile-triage--idle .reconcile-suggestions {
    display: none;
}

.reconcile-triage--idle .reconcile-focus {
    padding-bottom: 1.05rem;
}

.reconcile-actions,
.reconcile-queue-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.reconcile-queue-nav .reconcile-queue-progress {
    margin-right: 0.25rem;
}

.reconcile-panel-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-top: 1.15rem;
    padding-top: 1rem;
    border-top: 1px solid var(--line);
}

.reconcile-unclaimed-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.reconcile-unclaimed-item {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 0.65rem 1rem;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #f7fbf9;
    font-size: 0.875rem;
    line-height: 1.4;
}

.reconcile-unclaimed-copy {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.reconcile-unclaimed-copy strong {
    font-weight: 600;
    color: var(--ink);
}

.reconcile-unclaimed-meta {
    font-size: 0.8125rem;
    color: var(--muted);
}

.reconcile-unclaimed-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.reconcile-unclaimed-empty {
    margin: 0;
    color: var(--muted);
    font-size: 0.875rem;
}

.reconcile-review-check {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    margin: 1.1rem 0 0;
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--ink);
}

.reconcile-summary-body {
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--ink);
}

.reconcile-summary-body p {
    margin: 0 0 0.4rem;
}

.reconcile-summary-body p:last-child {
    margin-bottom: 0;
}

.reconcile-summary-block {
    margin-top: 1.35rem;
    padding-top: 1.15rem;
    border-top: 1px solid var(--line);
}

.reconcile-summary-block h4 {
    margin: 0;
    font-size: 0.9375rem;
    font-weight: 650;
    color: var(--ink);
}

.reconcile-summary-block-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 1rem;
}

.reconcile-bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.reconcile-summary-block .reconcile-panel-desc {
    margin: 0.25rem 0 0.75rem;
}

.reconcile-bill-compare {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

@media (min-width: 720px) {
    .reconcile-bill-compare {
        grid-template-columns: 1fr 1fr;
    }
}

.reconcile-bill-col h5 {
    margin: 0 0 0.45rem;
    font-size: 0.75rem;
    font-weight: 650;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.reconcile-unaccounted-filter {
    display: block;
    margin: 0 0 0.75rem;
}

.reconcile-unaccounted-filter .reconcile-input {
    width: 100%;
}

.reconcile-choice-btn.is-selected {
    background: #ecf6f1;
    border-color: #9ec9b6;
    color: var(--ink);
}

.reconcile-unclaimed-item.is-matching {
    border-color: rgba(13, 122, 98, 0.35);
    box-shadow: 0 0 0 1px rgba(13, 122, 98, 0.12);
}

.reconcile-manual-match-picker {
    flex: 1 1 100%;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-top: 0.15rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--line);
}

.reconcile-manual-match-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    max-height: 16rem;
    overflow: auto;
}

.reconcile-manual-match-list .reconcile-suggest-card {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    background: #fff;
}

.reconcile-manual-match-list .reconcile-suggest-card strong {
    font-weight: 600;
}

.reconcile-manual-match-list .reconcile-suggest-card span {
    font-size: 0.8125rem;
    color: var(--muted);
}

.reconcile-amt-diff {
    color: #b45309;
    font-weight: 600;
}

.reconcile-unclaimed-item.is-keep {
    background: #f7fbf9;
}

.reconcile-matched-more {
    margin-top: 0.65rem;
}

.reconcile-matched-more summary {
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--muted);
    list-style: none;
}

.reconcile-matched-more summary::-webkit-details-marker {
    display: none;
}

.reconcile-matched-more summary::after {
    content: ' ▾';
    font-weight: 400;
}

.reconcile-matched-more[open] summary::after {
    content: ' ▴';
}

.reconcile-matched-more .reconcile-unclaimed-list {
    margin-top: 0.55rem;
}

.reconcile-match-pair {
    display: flex;
    flex-direction: column;
    padding: 0.55rem 0.85rem;
    border: 1px solid var(--line);
    border-radius: 0.75rem;
    background: #f7fbf9;
}

.reconcile-match-pair .reconcile-tx {
    padding: 0.4rem 0;
}

.reconcile-tx-amt--diff,
.reconcile-tx-date--diff {
    color: #b45309;
    font-weight: 650;
}

.reconcile-empty {
    margin: 0;
    color: var(--muted);
    font-size: 0.9375rem;
    line-height: 1.5;
}

.home-reconcile-cta {
    margin-bottom: 1.25rem;
    padding: 1.35rem 1.5rem;
}

.home-reconcile-cta .home-section-sub {
    margin-bottom: 0;
}

.home-reconcile-cta .reconcile-btn {
    margin-top: 1rem;
}

.reconcile-range-toggle {
    margin: 0.65rem 0 0;
}

.reconcile-range {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem 0.85rem;
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--line);
}

.reconcile-readonly-note {
    margin: 0.65rem 0 0;
    font-size: 0.875rem;
    color: var(--muted);
}

body.reconcile-readonly .reconcile-composer,
body.reconcile-readonly .reconcile-step-foot,
body.reconcile-readonly .reconcile-range-toggle,
body.reconcile-readonly .reconcile-range,
body.reconcile-readonly .reconcile-triage,
body.reconcile-readonly #reconcile-back-to-files,
body.reconcile-readonly #reconcile-restart-match,
body.reconcile-readonly #reconcile-restart-match-confirm {
    display: none !important;
}

@media (min-width: 720px) {
    .reconcile-range {
        grid-template-columns: minmax(8.5rem, 13rem) minmax(8.5rem, 13rem) auto;
        align-items: end;
    }
}

.reconcile-view-all-panel {
    width: 100%;
    padding: 0.75rem 0;
    overflow-x: auto;
}

.reconcile-rows-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
}

.reconcile-rows-table th,
.reconcile-rows-table td {
    text-align: left;
    padding: 0.45rem 0.6rem;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
}

.reconcile-rows-table th {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--muted);
}

.reconcile-rows-table td.reconcile-tx-amt {
    min-width: 4.5rem;
}

@media (min-width: 720px) {
    .reconcile-composer {
        grid-template-columns: minmax(8.5rem, 13rem) minmax(0, 1fr) auto;
    }

    .reconcile-field--action {
        padding-top: calc(0.6875rem + 0.35rem);
    }

    .reconcile-field--action .reconcile-btn {
        width: auto;
        min-width: 9.25rem;
    }
}

@media (max-width: 768px) {
    .reconcile-page .reconcile-section {
        padding: 1rem 0.9rem 1.15rem;
    }

    .reconcile-top {
        flex-direction: column;
        align-items: stretch;
    }

    .reconcile-top-copy,
    .reconcile-top-meta {
        flex: 1 1 auto;
        width: 100%;
    }

    .reconcile-month-wrap {
        flex: 1 1 auto;
        min-width: 0;
    }

    .reconcile-month {
        width: 100%;
    }

    .reconcile-btn {
        height: 2.75rem;
        padding: 0 0.9rem;
    }

    .reconcile-tally {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .reconcile-tally-mid {
        order: -1;
        justify-content: flex-start;
    }

    .reconcile-tx {
        grid-template-columns: auto minmax(0, 1fr);
        gap: 0.15rem 0.55rem;
    }

    .reconcile-tx-role {
        padding-right: 0.35rem;
    }

    .reconcile-tx-meta {
        grid-column: 2;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 0.3rem 0.65rem;
    }

    .reconcile-tx-amt,
    .reconcile-tx-date {
        min-width: 0;
        text-align: left;
    }

    .reconcile-source-pill {
        min-width: 0;
    }

    .reconcile-source-pill--empty {
        display: none;
    }

    .reconcile-triage-foot {
        flex-direction: column;
        align-items: stretch;
        gap: 0.7rem;
    }

    .reconcile-actions,
    .reconcile-queue-nav {
        width: 100%;
    }

    .reconcile-actions .reconcile-btn {
        flex: 1 1 calc(50% - 0.3rem);
        min-width: calc(50% - 0.3rem);
    }

    .reconcile-actions .reconcile-btn--primary {
        flex-basis: 100%;
    }

    .reconcile-queue-nav {
        justify-content: space-between;
    }

    .reconcile-queue-nav .reconcile-btn {
        flex: 0 1 auto;
        min-width: 0;
        padding: 0 0.75rem;
    }

    .reconcile-unclaimed-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.6rem;
    }

    .reconcile-unclaimed-actions,
    .reconcile-bulk-actions {
        width: 100%;
    }

    .reconcile-unclaimed-actions .reconcile-btn,
    .reconcile-bulk-actions .reconcile-btn {
        flex: 1 1 0;
        min-width: 0;
    }

    .reconcile-summary-block-head {
        flex-direction: column;
        align-items: stretch;
        gap: 0.65rem;
    }

    .reconcile-step-foot .reconcile-btn--primary,
    .reconcile-panel-footer .reconcile-btn--primary,
    .reconcile-field--action .reconcile-btn {
        width: 100%;
    }

    .reconcile-step-foot-actions {
        width: 100%;
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .reconcile-step-foot--split,
    .reconcile-panel-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .reconcile-steps {
        gap: 0.1rem;
        justify-content: space-between;
    }

    .reconcile-steps-label {
        white-space: nowrap;
    }

    .reconcile-steps-item + .reconcile-steps-item::before {
        width: 0.55rem;
        margin: 0 0.3rem 0 0.1rem;
        flex-shrink: 0;
    }

    .reconcile-allrows {
        margin-left: 0;
        margin-top: 0.85rem;
    }

    .reconcile-upload-item {
        align-items: flex-start;
        gap: 0.5rem;
    }

    .reconcile-upload-meta {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
    }

    .reconcile-upload-item .reconcile-tally-sub {
        display: block;
        margin-top: 0.15rem;
    }
}
