/* =========================================================================
   Budget Tucks — neon-punk design system
   Dark = neon signage. Light = photocopied zine flyer. Same personality,
   different medium: dark leans on soft glow, light on hard offset shadow.
   ========================================================================= */

:root {
    /* Dark theme (default) */
    --bg: #0a0118;
    --bg-grid: #120726;
    --surface: #150a2e;
    --surface-2: #1e1040;
    --border: #3a1f6b;
    --border-strong: #6b3fc7;
    --neon-cyan: #00f5ff;
    --neon-pink: #ff2ec4;
    --neon-lime: #c6ff00;
    --text: #f2eeff;
    --text-dim: #b3a3d9;
    --text-faint: #7a6ba3;
    --shadow-style: glow;
    --radius: 10px;
    --radius-lg: 16px;
}

[data-theme="light"] {
    --bg: #f3f0ff;
    --bg-grid: #ece4ff;
    --surface: #ffffff;
    --surface-2: #ece4ff;
    --border: #1a0630;
    --border-strong: #1a0630;
    --neon-cyan: #00a6b8;
    --neon-pink: #d4189a;
    --neon-lime: #6f9600;
    --text: #150524;
    --text-dim: #4a3968;
    --text-faint: #7a6a96;
    --shadow-style: hard;
}

* { box-sizing: border-box; }

html { scroll-padding-top: env(safe-area-inset-top, 0px); }

body {
    margin: 0;
    font-family: 'Poppins', system-ui, -apple-system, sans-serif;
    font-weight: 400;
    background:
        radial-gradient(circle at 15% 0%, color-mix(in srgb, var(--neon-pink) 10%, transparent), transparent 40%),
        radial-gradient(circle at 85% 15%, color-mix(in srgb, var(--neon-cyan) 8%, transparent), transparent 40%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    transition: background-color 0.2s ease, color 0.2s ease;
}

@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* --- Topbar --------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    padding-top: calc(0.9rem + env(safe-area-inset-top, 0px));
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    backdrop-filter: blur(10px);
    border-bottom: 2px solid var(--border);
}

.topbar-brand {
    font-weight: 900;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
    color: var(--text);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.topbar-brand::before {
    content: '';
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--neon-pink);
}

[data-theme="dark"] .topbar-brand::before,
:root:not([data-theme]) .topbar-brand::before {
    box-shadow: 0 0 10px 2px var(--neon-pink);
}

.theme-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: transform 0.15s ease, border-color 0.15s ease;
}

.theme-toggle:hover { border-color: var(--neon-cyan); transform: scale(1.06); }
.theme-toggle:focus-visible { outline: 3px solid var(--neon-cyan); outline-offset: 2px; }

.topbar-nav-pill {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: var(--surface-2);
    border: 2px solid var(--border-strong);
    border-radius: 999px;
    padding: 0.35rem 0.9rem;
    font-weight: 700;
    font-size: 0.85rem;
    white-space: nowrap;
}
.topbar-nav-pill a {
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0.1rem 0.2rem;
}
.topbar-nav-pill a:hover { color: var(--neon-cyan); }

@media (max-width: 560px) {
    .topbar-nav-label { display: none; }
    .topbar-nav-pill { padding: 0.35rem 0.6rem; gap: 0.5rem; }
}

.topbar-actions { display: flex; align-items: center; gap: 0.6rem; }

.hamburger-toggle {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--border-strong);
    background: var(--surface-2);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.hamburger-toggle:hover { border-color: var(--neon-cyan); transform: scale(1.06); }
.hamburger-toggle:focus-visible { outline: 3px solid var(--neon-cyan); outline-offset: 2px; }

.nav-menu-dialog { max-width: 300px; }
.nav-menu-links {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.nav-menu-links a {
    display: block;
    padding: 0.7rem 0.8rem;
    border-radius: 8px;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}
.nav-menu-links a:hover { background: var(--surface-2); color: var(--neon-cyan); }
.nav-menu-links hr { border: none; border-top: 1px solid var(--border); margin: 0.5rem 0; }

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

main.page {
    max-width: 1080px;
    margin: 0 auto;
    padding: clamp(1rem, 4vw, 2.5rem) clamp(1rem, 4vw, 1.5rem) 4rem;
}

.card {
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: clamp(1.25rem, 4vw, 2rem);
    max-width: 720px;
    margin: 0 auto;
}

.card.wide { max-width: 1080px; }
.card-medium { max-width: 960px; }

[data-theme="dark"] .card, :root:not([data-theme]) .card {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon-cyan) 15%, transparent),
                0 0 40px -10px color-mix(in srgb, var(--neon-cyan) 25%, transparent);
}

[data-theme="light"] .card {
    box-shadow: 6px 6px 0 var(--border);
}

/* --- Headings ---------------------------------------------------------- */

h1, h2, h3, h4 {
    font-family: 'Poppins', system-ui, sans-serif;
    font-weight: 900;
    letter-spacing: -0.02em;
    line-height: 1.08;
    margin: 0 0 0.6rem;
}

h1 {
    font-size: clamp(1.9rem, 5vw, 2.75rem);
    animation: heading-in 0.5s ease-out;
}

[data-theme="dark"] h1, :root:not([data-theme]) h1 {
    text-shadow: 0 0 18px color-mix(in srgb, var(--neon-pink) 55%, transparent),
                 0 0 42px color-mix(in srgb, var(--neon-pink) 25%, transparent);
}

[data-theme="light"] h1 {
    display: inline-block;
    position: relative;
}
[data-theme="light"] h1::after {
    content: '';
    position: absolute;
    left: 2px; right: 2px; bottom: 2px;
    height: 0.32em;
    background: var(--neon-lime);
    z-index: -1;
    opacity: 0.55;
}

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

h2 { font-size: clamp(1.3rem, 3.2vw, 1.7rem); font-weight: 800; color: var(--text); }
h3 { font-size: 1.15rem; font-weight: 700; color: var(--text); margin-top: 0; }
h4 { font-size: 1rem; font-weight: 700; color: var(--text-dim); text-transform: none; }

p { color: var(--text-dim); line-height: 1.55; }
small { color: var(--text-faint); }
code { background: var(--surface-2); padding: 0.1rem 0.4rem; border-radius: 4px; font-size: 0.85em; }
a { color: var(--neon-cyan); text-decoration: none; font-weight: 500; }
a:hover { text-decoration: underline; }
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
    outline: 3px solid var(--neon-cyan);
    outline-offset: 2px;
}

/* --- Layout helpers ---------------------------------------------------- */

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}
.header-row > div { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: clamp(1rem, 3vw, 1.5rem);
}
@media (max-width: 720px) {
    .grid { grid-template-columns: 1fr; }
}

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

section { margin-top: clamp(1.5rem, 4vw, 2.5rem); }

/* Section dividers — every module's repeated-item block (mortgage,
   member, holding, account, pot, asset, trip) shares this rhythm. */
.mortgage-block, .member-block, .holding-block, .account-block,
.pot-block, .asset-block, .trip-block {
    border-top: 2px solid var(--border);
    padding-top: 1.5rem;
    margin-top: 1.75rem;
}

.year-block { margin-top: 1.25rem; }
.year-block h4 { margin-bottom: 0.3rem; }

/* --- Tables -------------------------------------------------------------- */

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

th, td {
    text-align: left;
    padding: 0.6rem 0.5rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.92rem;
}
th { color: var(--text-faint); font-weight: 600; font-size: 0.8rem; }

tr.inactive td { color: var(--text-faint); }
tr.active td { font-weight: 700; color: var(--neon-lime); }

.actions a, .actions button { margin-right: 0.5rem; }
.actions form { display: inline; }

/* --- Forms ----------------------------------------------------------------- */

label {
    display: block;
    margin-bottom: 0.7rem;
    font-size: 0.88rem;
    color: var(--text-dim);
    font-weight: 500;
}

input, select, textarea {
    font-family: inherit;
    padding: 0.55rem 0.7rem;
    width: 100%;
    box-sizing: border-box;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    color: var(--text);
    font-size: 0.95rem;
    margin-top: 0.3rem;
    transition: border-color 0.15s ease;
}
input:hover, select:hover { border-color: var(--border-strong); }
input:focus, select:focus { border-color: var(--neon-cyan); }

input[type="checkbox"] { width: auto; margin-top: 0; vertical-align: middle; }

fieldset {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-top: 1rem;
    padding: 1rem 1.1rem 1.2rem;
}
legend {
    font-weight: 700;
    padding: 0 0.5rem;
    color: var(--neon-cyan);
    font-size: 0.9rem;
}

button, .button, .button-chunky {
    font-family: inherit;
    padding: 0.65rem 1.4rem;
    border: none;
    border-radius: 8px;
    background: var(--neon-pink);
    color: #10001a;
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
button:hover, .button-chunky:hover { transform: translateY(-1px); }
[data-theme="dark"] button:hover, :root:not([data-theme]) button:hover,
[data-theme="dark"] .button-chunky:hover, :root:not([data-theme]) .button-chunky:hover {
    box-shadow: 0 0 20px -2px var(--neon-pink);
}
[data-theme="light"] button:hover, [data-theme="light"] .button-chunky:hover { box-shadow: 3px 3px 0 var(--border); }
button:active, .button-chunky:active { transform: translateY(0); }

.checks { display: flex; gap: 0.5rem; flex-wrap: wrap; font-size: 0.8rem; margin-top: 0.3rem; }
.checks label { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; }
.checks input { width: auto; margin: 0; }

/* --- Callouts / badges / stats -------------------------------------------- */

.flash {
    background: color-mix(in srgb, var(--neon-cyan) 14%, var(--surface));
    border: 1px solid var(--neon-cyan);
    padding: 0.7rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.92rem;
}
.err { color: var(--neon-pink); font-weight: 600; }
.ok  { color: var(--neon-lime); font-weight: 600; }

.allowance-note, .estimate-note {
    background: var(--surface-2);
    border-left: 3px solid var(--neon-lime);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin: 0.9rem 0;
    font-size: 0.88rem;
    color: var(--text-dim);
}

.totals { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1rem 0; }
.totals[hidden] { display: none; }
.totals div {
    background: var(--surface-2);
    border: 1px solid var(--border);
    padding: 0.7rem 1.1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--text-faint);
}
.totals strong { display: block; font-size: 1.15rem; color: var(--text); margin-top: 0.15rem; font-weight: 700; }

.default-badge, .member-chip {
    display: inline-block;
    background: var(--surface-2);
    border: 1px solid var(--neon-lime);
    color: var(--neon-lime);
    border-radius: 999px;
    padding: 0.2rem 0.8rem;
    font-size: 0.78rem;
    font-weight: 600;
    margin: 0.2rem 0.3rem 0.2rem 0;
}

.pl-positive, .net-positive { color: var(--neon-lime) !important; font-weight: 700; }
.pl-negative, .net-negative { color: var(--neon-pink) !important; font-weight: 700; }

.history { font-size: 0.82rem; color: var(--text-faint); margin-top: 0.4rem; line-height: 1.7; }

/* --- Collapsible month groups (day-rate calendar) ------------------------- */

details.month-group {
    border: 2px solid var(--border);
    border-radius: var(--radius);
    margin-top: 0.75rem;
    padding: 0 1rem 0.25rem;
}
details.month-group summary {
    cursor: pointer;
    padding: 1rem 0;
    font-weight: 700;
    font-size: 0.95rem;
    list-style: none;
    position: relative;
    padding-left: 1.5rem;
    min-height: 24px;
    display: flex;
    align-items: center;
}
details.month-group summary::-webkit-details-marker { display: none; }
details.month-group summary::before {
    content: '▸';
    position: absolute;
    left: 0;
    font-size: 1.1rem;
    color: var(--neon-cyan);
    transition: transform 0.15s ease;
}
details.month-group[open] summary::before { transform: rotate(90deg); }
details.month-group[open] summary { border-bottom: 1px solid var(--border); margin-bottom: 0.5rem; }
details.month-group table { margin-top: 0; }

.month-group table th:first-child, .month-group table td:first-child { width: 2.2rem; text-align: center; }
.month-group table input[type="checkbox"] { margin: 0; width: 1.15rem; height: 1.15rem; cursor: pointer; }
.month-group table th input[type="checkbox"] { width: 1.3rem; height: 1.3rem; }

/* --- Projection page: year-by-year growth, each year expandable to its own month breakdown --- */

.growth-year-list { margin-top: 0.75rem; border: 2px solid var(--border); border-radius: var(--radius); padding: 0 1rem; }
.growth-year-row { display: flex; align-items: center; padding: 0.5rem 0; border-bottom: 1px solid var(--border); font-size: 0.88rem; }
.growth-year-list > *:last-child, .growth-year-list > details:last-child summary { border-bottom: none; }
.growth-year-row > span { flex: 1; }
.growth-year-row > span:first-child { flex: 0.6; }
.growth-year-header { font-weight: 700; color: var(--text-faint); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; }
.growth-year-detail summary {
    cursor: pointer;
    list-style: none;
    position: relative;
    padding-left: 1.4rem;
}
.growth-year-detail summary::-webkit-details-marker { display: none; }
.growth-year-detail summary::before {
    content: '▸';
    position: absolute;
    left: 0;
    font-size: 1rem;
    color: var(--neon-cyan);
    transition: transform 0.15s ease;
}
.growth-year-detail[open] summary::before { transform: rotate(90deg); }
.growth-year-detail[open] summary { margin-bottom: 0.3rem; }
.growth-month-table { margin: 0 0 0.6rem 1.4rem; font-size: 0.82rem; width: calc(100% - 1.4rem); }

.button-danger, .button-success {
    box-shadow: 0 0 0 1px var(--neon-pink) inset;
}
.button-success { box-shadow: 0 0 0 1px var(--neon-lime) inset; background: var(--neon-lime); }

/* Under 640px, the day list drops the table grid entirely and becomes a
   stack of cards — no horizontal scrolling needed, and every tap target
   (checkbox, confirm link) gets genuinely bigger rather than shrinking
   text to fit a cramped table. */
@media (max-width: 640px) {
    details.month-group summary {
        font-size: 1rem;
        padding: 1.1rem 0 1.1rem 1.6rem;
    }
    details.month-group summary::before { font-size: 1.2rem; }

    .month-group table, .month-group table thead, .month-group table tbody,
    .month-group table tr, .month-group table th, .month-group table td {
        display: block;
        width: 100%;
        white-space: normal;
    }
    .month-group table { overflow-x: visible; }
    .month-group table thead { display: none; }
    .month-group table tr {
        position: relative;
        border: 2px solid var(--border);
        border-radius: var(--radius);
        padding: 0.9rem 3rem 0.9rem 1rem;
        margin-bottom: 0.7rem;
    }
    .month-group table td { border: none; padding: 0.15rem 0; font-size: 0.95rem; }
    .month-group table td:first-child {
        position: absolute;
        top: 0.9rem;
        right: 0.9rem;
        width: auto;
    }
    .month-group table td:first-child input[type="checkbox"] { width: 1.5rem; height: 1.5rem; }
    .month-group table td:nth-child(2) { font-weight: 800; font-size: 1.05rem; padding-right: 2.5rem; }
    .month-group table td:nth-child(3)::before { content: 'Amount: '; color: var(--text-faint); font-weight: 500; }
    .month-group table td:nth-child(4)::before { content: 'Status: '; color: var(--text-faint); font-weight: 500; }
    .month-group table td:nth-child(5)::before { content: 'Paid: '; color: var(--text-faint); font-weight: 500; }
    .month-group table td:nth-child(6):not(:empty)::before { content: 'Note: '; color: var(--text-faint); font-weight: 500; }
    .month-group table td:last-child:not(:empty) { margin-top: 0.4rem; }
    .month-group table td:last-child .confirm-btn {
        display: inline-block;
        width: auto;
        padding: 0.5rem 1rem;
        background: var(--surface-2);
        border: 2px solid var(--neon-lime);
        color: var(--neon-lime);
        border-radius: 8px;
        font-weight: 600;
    }

    .button-danger.button-top, .button-success.button-top { margin-bottom: 0.75rem; }

    /* Invoices/payments tables get the same stacked-card treatment. */
    .stack-mobile table, .stack-mobile table thead, .stack-mobile table tbody,
    .stack-mobile table tr, .stack-mobile table th, .stack-mobile table td {
        display: block; width: 100%; white-space: normal;
    }
    .stack-mobile table { overflow-x: visible; }
    .stack-mobile table thead { display: none; }
    .stack-mobile table tr {
        border: 2px solid var(--border);
        border-radius: var(--radius);
        padding: 0.9rem 1rem;
        margin-bottom: 0.7rem;
    }
    .stack-mobile table td { border: none; padding: 0.2rem 0; font-size: 0.95rem; }
    .stack-mobile table td:first-child { font-weight: 800; font-size: 1.05rem; }
    .stack-mobile table td[data-label]::before { content: attr(data-label) ': '; color: var(--text-faint); font-weight: 500; }
}

/* --- Worked-vs-paid badges and markers -------------------------------------- */

.invoice-badge, .se-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    border-radius: 999px;
    padding: 0.1rem 0.55rem;
}
.invoice-badge-unpaid { color: var(--neon-pink); border: 1px solid var(--neon-pink); }
.invoice-badge-part { color: #ffa500; border: 1px solid #ffa500; }
.invoice-badge-paid { color: var(--neon-lime); border: 1px solid var(--neon-lime); }

.se-badge { margin-left: 0.4rem; vertical-align: middle; }
.se-badge-received { color: var(--neon-lime); border: 1px solid var(--neon-lime); }
.se-badge-worked { color: var(--text-faint); border: 1px solid var(--border-strong); }

.cal-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal-grid th { font-size: 0.75rem; color: var(--text-faint); padding: 0.3rem; text-align: center; }
.cal-grid td.cal-cell { border: 1px solid var(--border); padding: 0; height: 72px; vertical-align: top; }
.cal-day-btn {
    width: 100%; height: 100%; min-height: 72px; background: none; border: none; cursor: pointer;
    display: flex; flex-direction: column; align-items: flex-start; justify-content: flex-start;
    padding: 0.3rem; gap: 0.15rem; font-family: inherit; color: inherit;
}
.cal-day-btn:hover { background: var(--surface-2); }
.cal-day-num { font-size: 0.85rem; font-weight: 700; }
.cal-day-num-outside { display: block; padding: 0.3rem; font-size: 0.8rem; color: var(--text-faint); opacity: 0.4; }
.cal-cell-outside { background: var(--surface); opacity: 0.55; }
.cal-cell-today { outline: 2px solid var(--neon-cyan); outline-offset: -2px; }
.cal-day-amount { font-size: 0.7rem; font-weight: 600; }
.cal-status-projected .cal-day-num { color: #ffa500; }
.cal-status-confirmed .cal-day-num { color: var(--neon-lime); }
.cal-status-projected { background: rgba(255,165,0,0.08); }
.cal-status-confirmed { background: rgba(0,255,150,0.08); }
.cal-invoice-badge {
    font-size: 0.62rem; font-weight: 700; padding: 0.1rem 0.35rem; border-radius: 999px;
    display: inline-block; margin-top: 0.1rem;
}
.cal-half-toggle {
    font-size: 0.6rem; color: var(--text-faint); border-bottom: 1px dotted var(--text-faint);
    margin-top: 0.1rem; cursor: pointer;
}
.cal-half-toggle:hover { color: var(--neon-cyan); border-color: var(--neon-cyan); }
.cal-invoice-badge-unpaid { background: var(--neon-pink); color: #000; cursor: pointer; }
.cal-invoice-badge-paid { background: var(--neon-lime); color: #000; }
.cal-legend-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 0.2rem 0 0.6rem; vertical-align: middle; }
.cal-dot-projected { background: #ffa500; }
.cal-dot-confirmed { background: var(--neon-lime); }
.cal-dot-invoiced { background: var(--neon-pink); }
.cal-dot-paid { background: var(--neon-lime); border: 1px solid #000; }

.year-view-dialog { max-width: 900px; width: 95vw; }
.year-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}
.year-grid-month {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.5rem;
}
.year-grid-month-label { font-size: 0.75rem; font-weight: 700; text-align: center; margin-bottom: 0.35rem; }
.year-grid-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
}
.year-day { display: block; width: 100%; aspect-ratio: 1; border-radius: 2px; }
.year-day-none { background: #fff; border: 1px solid var(--border); }
.year-day-confirmed { background: var(--neon-lime); }
.year-day-projected { background: #ffa500; }
.year-day-outside { background: transparent; }

@media (max-width: 640px) {
    .year-grid { grid-template-columns: repeat(2, 1fr); }
}

.month-subheading-row td {
    background: var(--surface-2);
    font-weight: 700;
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-top: 2px solid var(--border-strong);
}

.day-marker { font-size: 1rem; }
.day-marker-not-invoiced { color: var(--text-faint); }
.day-marker-unpaid { color: var(--neon-pink); }
.day-marker-part { color: #ffa500; }
.day-marker-paid { color: var(--neon-lime); }

/* --- Modals (native <dialog>) ---------------------------------------------- */

dialog {
    border: 2px solid var(--border-strong);
    border-radius: var(--radius-lg);
    background: var(--surface);
    color: var(--text);
    padding: 1.5rem;
    max-width: 480px;
    width: 92vw;
    max-height: 85vh;
    overflow-y: auto;
}

[data-theme="dark"] dialog, :root:not([data-theme]) dialog {
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--neon-cyan) 20%, transparent),
                0 0 60px -10px color-mix(in srgb, var(--neon-cyan) 35%, transparent);
}
[data-theme="light"] dialog { box-shadow: 8px 8px 0 var(--border); }

dialog::backdrop {
    background: rgba(5, 0, 15, 0.65);
    backdrop-filter: blur(2px);
}

dialog fieldset { margin-top: 0.5rem; }

.modal-close-row { display: flex; justify-content: flex-end; margin: -0.5rem -0.5rem 0 0; }
.modal-close-row button {
    background: none;
    border: none;
    box-shadow: none;
    color: var(--text-faint);
    font-size: 1.3rem;
    line-height: 1;
    padding: 0.3rem 0.6rem;
    cursor: pointer;
}
.modal-close-row button:hover { color: var(--neon-pink); }

/* --- Chunky action buttons + tucked-away secondary links -------------------- */

.button-chunky {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.75rem;
    font-size: 1.05rem;
    font-weight: 800;
    border-radius: var(--radius-lg);
    margin-top: 0.75rem;
}

.action-row { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; margin-top: 0.75rem; }

.link-subtle {
    font-size: 0.82rem;
    color: var(--text-faint);
    text-decoration: underline;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.link-subtle:hover { color: var(--neon-cyan); }

/* --- Month navigation -------------------------------------------------------- */

.nav-month { align-items: center; }
.button-nav { margin-top: 0; padding: 0.75rem 1.25rem; font-size: 0.95rem; }
.month-jump-trigger {
    background: none;
    border: none;
    box-shadow: none;
    color: var(--text);
    font-family: 'Poppins', sans-serif;
    font-weight: 800;
    font-size: clamp(1.1rem, 3vw, 1.4rem);
    cursor: pointer;
    padding: 0.3rem 0.6rem;
    border-radius: 6px;
}
.month-jump-trigger:hover { background: var(--surface-2); color: var(--neon-cyan); }

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

.charts-row {
    display: flex;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}
.charts-row > div { flex: 1 1 260px; }
.pie-chart-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.pie-legend { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.82rem; color: var(--text-dim); }
.pie-legend-item { display: flex; align-items: center; gap: 0.5rem; }
.pie-swatch { width: 12px; height: 12px; border-radius: 3px; flex-shrink: 0; display: inline-block; }

/* --- Unified transactions table ----------------------------------------------- */

.txn-filters { display: flex; gap: 0.5rem; margin: 1rem 0 0.5rem; }
.filter-btn {
    background: var(--surface-2);
    border: 2px solid var(--border);
    color: var(--text-dim);
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}
.filter-btn.active { border-color: var(--neon-cyan); color: var(--neon-cyan); }

.txn-table { width: 100%; }
.txn-table td, .txn-table th { padding: 0.65rem 0.6rem; }
[data-theme="dark"] .txn-table tr.txn-in, :root:not([data-theme]) .txn-table tr.txn-in {
    background: color-mix(in srgb, var(--neon-lime) 7%, transparent);
}
[data-theme="dark"] .txn-table tr.txn-out, :root:not([data-theme]) .txn-table tr.txn-out {
    background: color-mix(in srgb, var(--neon-pink) 6%, transparent);
}
[data-theme="light"] .txn-table tr.txn-in { background: color-mix(in srgb, var(--neon-lime) 12%, white); }
[data-theme="light"] .txn-table tr.txn-out { background: color-mix(in srgb, var(--neon-pink) 10%, white); }

/* Future-dated rows: no colour yet, since nothing's actually happened there. */
.txn-table tr.txn-future { background: transparent !important; }

.txn-live-totals {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 2px dashed var(--border);
    font-size: 0.85rem;
}
.txn-live-totals > div { flex: 1; }
.txn-live-totals strong { display: block; font-size: 1.1rem; margin-top: 0.15rem; }

.txn-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface-2);
    border: 1px solid var(--border);
    font-size: 0.95rem;
    flex-shrink: 0;
}
.txn-avatar-large {
    width: 48px;
    height: 48px;
    font-size: 1.4rem;
    font-weight: 800;
    vertical-align: middle;
    margin-right: 0.3rem;
}
.txn-avatar img { width: 100%; height: 100%; object-fit: cover; }
.txn-avatar-generic { color: var(--text-faint); }

/* --- Projected / forecast income indicators ---------------------------------- */

.projected-figure { color: var(--neon-cyan) !important; }

.net-subnote {
    font-size: 0.72rem;
    color: var(--text-faint);
    font-weight: 500;
    margin-top: 0.2rem;
}

.projected-badge {
    display: inline-block;
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--neon-cyan);
    border: 1px solid var(--neon-cyan);
    border-radius: 999px;
    padding: 0.05rem 0.5rem;
    margin-left: 0.4rem;
    vertical-align: middle;
}

.txn-table tr.txn-projected {
    background: transparent !important;
    border-left: 3px dashed var(--neon-cyan);
}
.txn-table tr.txn-projected td { opacity: 0.85; }

/* --- Budget summary panel (net cash, in/out, projected toggle, SE, member income) --- */

.summary-panel {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.3rem 1.5rem;
    margin: 1.1rem 0 1.5rem;
}

.summary-net-block { text-align: center; }
.summary-net-label { font-size: 0.85rem; color: var(--text-faint); font-weight: 600; }
.summary-net-value { font-size: 2.3rem; font-weight: 800; line-height: 1.15; margin: 0.15rem 0; }

.summary-inout-row {
    display: flex;
    justify-content: center;
    gap: 2.5rem;
    margin: 0.75rem 0 0.25rem;
}
.summary-inout-item { text-align: center; font-size: 0.82rem; color: var(--text-faint); font-weight: 600; }
.summary-inout-item strong { display: block; font-size: 1.1rem; margin-top: 0.15rem; }

.toggle-projected-btn {
    display: block;
    margin: 0.6rem auto 0;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
}

.summary-subsection {
    margin-top: 1.25rem;
    padding-top: 1.1rem;
    border-top: 1px dashed var(--border);
}
.summary-subsection h4 { margin-bottom: 0.5rem; }

.member-income-row { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 0.4rem; }
.member-income-chip {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0.35rem 1rem 0.35rem 0.35rem;
    font-size: 0.85rem;
}
.member-income-chip .txn-avatar { width: 30px; height: 30px; }
.member-income-name { color: var(--text-dim); }
.member-income-chip strong { color: var(--text); }

@media (max-width: 560px) {
    .summary-net-value { font-size: 1.9rem; }
    .summary-inout-row { gap: 1.5rem; }
}

/* --- Breakdown modal (full pie + group filters, Budget + Year Overview) ----- */

.breakdown-modal { max-width: 640px; }
.breakdown-chart-view { display: flex; justify-content: center; margin-top: 0.75rem; }
.breakdown-chart-view[hidden] { display: none; }
.breakdown-chart-view .pie-chart-wrap { justify-content: center; }

/* --- Bar charts (Projection page) ------------------------------------------- */

.bar-chart-wrap { overflow-x: auto; margin: 0.5rem 0; }
.bar-chart-wrap svg { display: block; max-width: 100%; }
.bar-rect.bar-positive { fill: var(--neon-lime); }
.bar-rect.bar-negative { fill: var(--neon-pink); }
.bar-zero-line { stroke: var(--border); stroke-width: 1; }
.bar-value-label { fill: var(--text-dim); font-size: 11px; font-weight: 600; }
.bar-axis-label { fill: var(--text-faint); font-size: 11px; }

/* --- "What's in these figures?" toggle modal (Projection page) ------------- */

.toggle-modal { max-width: 560px; }

.whatif-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    margin: 0.75rem 0 1rem;
}
.whatif-row { display: flex; gap: 1.5rem; }
.whatif-row > div { flex: 1; font-size: 0.8rem; color: var(--text-faint); font-weight: 600; }
.whatif-row strong { display: block; font-size: 1.25rem; margin-top: 0.15rem; }
.whatif-milestones {
    display: flex;
    gap: 0.9rem;
    flex-wrap: wrap;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border);
}
.whatif-milestones > div { font-size: 0.78rem; color: var(--text-faint); font-weight: 600; min-width: 64px; }
.whatif-milestones strong { display: block; font-size: 0.95rem; margin-top: 0.1rem; }

.toggle-list-wrap h4 { margin: 0.9rem 0 0.3rem; }
.toggle-group { margin-bottom: 0.6rem; }
.toggle-group-heading {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--text-dim);
    margin-bottom: 0.3rem;
}
.toggle-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.35rem 0;
    font-size: 0.85rem;
}
.toggle-item-main { display: flex; align-items: center; gap: 0.6rem; flex: 1; cursor: pointer; min-width: 0; }
.toggle-item input[type="checkbox"] { flex-shrink: 0; }
.toggle-item .txn-avatar { width: 22px; height: 22px; font-size: 0.75rem; flex-shrink: 0; }
.toggle-item-label {
    flex: 1;
    color: var(--text-dim);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Plain, table-like figure column — a clickable span, never a <button>,
   so it never inherits a browser's native button chrome. */
.toggle-amount-edit {
    display: inline-block;
    flex-shrink: 0;
    min-width: 92px;
    text-align: right;
    padding: 0.1rem 0.3rem;
    margin: -0.1rem -0.3rem;
    border-radius: 4px;
    cursor: text;
    color: var(--text);
    font-size: 0.85rem;
    font-weight: 600;
}
.toggle-amount-edit:hover, .toggle-amount-edit:focus-visible {
    background: var(--surface-hover, rgba(128, 128, 128, 0.12));
    outline: none;
}
.toggle-amount-edit.overridden .toggle-amount-display {
    text-decoration: underline dotted;
    text-decoration-color: var(--text-faint);
}
.toggle-amount-edit input[type="number"] {
    width: 90px;
    text-align: right;
    font-size: 0.85rem;
    padding: 2px 4px;
}

/* --- Self-employment real-vs-average indicator (month-by-month chart) --- */

.se-basis-legend {
    font-size: 0.75rem;
    color: var(--text-faint);
    margin: 0.3rem 0 0;
}
.se-basis-actual { color: var(--neon-cyan); }
.se-basis-mixed { color: var(--text-dim); }
.se-basis-assumed { color: var(--text-faint); }

@media (max-width: 560px) {
    .whatif-row { flex-direction: column; gap: 0.5rem; }
}

/* --- Responsive ------------------------------------------------------------ */

@media (max-width: 560px) {
    .card { border-radius: var(--radius); }
    .totals { flex-direction: column; }
    .totals div { width: 100%; }
    button, .button { width: 100%; }
    .header-row > div { width: 100%; justify-content: space-between; }
    .button-chunky { width: 100%; justify-content: center; }
    dialog { padding: 1.1rem; }
    .button-nav { width: auto; padding: 0.6rem 0.9rem; font-size: 0.85rem; }
    .nav-month { flex-wrap: nowrap; gap: 0.4rem; }
    .charts-row { flex-direction: column; }
    .pie-chart-wrap { flex-direction: column; align-items: flex-start; }
}

/* --- Employment: member card grid ------------------------------------------- */

.member-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.1rem;
    margin: 1rem 0;
}

.member-card {
    display: block;
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.member-card:hover { transform: translateY(-2px); border-color: var(--neon-cyan); }
[data-theme="dark"] .member-card:hover, :root:not([data-theme]) .member-card:hover {
    box-shadow: 0 0 24px -6px var(--neon-cyan);
}
[data-theme="light"] .member-card:hover { box-shadow: 5px 5px 0 var(--border); }

.member-card-head {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    margin-bottom: 0.75rem;
}
.member-card-head h3 { margin: 0 0 0.25rem; font-size: 1.15rem; }

.member-card-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    font-size: 1.5rem;
    font-weight: 800;
    flex-shrink: 0;
}
.member-card-avatar img { width: 100%; height: 100%; object-fit: cover; }
.member-card-avatar-generic { color: var(--text-faint); }

.member-card-badges { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.member-card-stats {
    display: flex;
    gap: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
    font-size: 0.85rem;
}
.member-card-stats > div { flex: 1; }
.member-card-stats strong { display: block; font-size: 1rem; margin-top: 0.1rem; }

@media (max-width: 560px) {
    .member-card-grid { grid-template-columns: 1fr; }
}

/* --- Stats groups (all-time vs this-year separation) ------------------------ */

.stats-group {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem 0.4rem;
    margin: 0.75rem 0;
}
.stats-group h5 {
    margin: 0 0 0.4rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}
.stats-group .totals { margin: 0; }
.stats-group-year {
    border-color: var(--neon-cyan);
    border-width: 2px;
}
.stats-group-year h5 { color: var(--neon-cyan); }

/* --- Compact pill button (quick inline actions like Mark paid) -------------- */

.pill-success {
    display: inline-block;
    background: var(--neon-lime);
    color: #0a1a00;
    border: none;
    border-radius: 999px;
    padding: 0.3rem 0.9rem;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: none;
    transition: transform 0.12s ease;
}
.pill-success:hover { transform: translateY(-1px); }

.inline-paid-form {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}
.inline-paid-form input[type="date"] {
    width: auto;
    padding: 0.25rem 0.4rem;
    font-size: 0.78rem;
    border-radius: 6px;
}

.txn-edit-icon {
    display: inline-block;
    background: none;
    border: none;
    box-shadow: none;
    padding: 0.2rem 0.4rem;
    font-size: 0.95rem;
    cursor: pointer;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.12s ease;
}
.txn-edit-icon:hover { opacity: 1; }

.tooltip-trigger {
    position: relative;
    border-bottom: 1px dotted var(--text-faint);
    cursor: help;
}
.tooltip-bubble {
    position: absolute;
    left: 0;
    bottom: calc(100% + 8px);
    background: var(--surface-2);
    border: 2px solid var(--neon-cyan);
    border-radius: 8px;
    padding: 0.45rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0,0,0,0.25);
    opacity: 0;
    visibility: hidden;
    transform: translateY(4px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    z-index: 20;
}
.tooltip-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 14px;
    border: 6px solid transparent;
    border-top-color: var(--neon-cyan);
}
.tooltip-trigger:hover .tooltip-bubble,
.tooltip-trigger:focus .tooltip-bubble {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* --- Dashboard ------------------------------------------------------- */

.member-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.dash-hero {
    text-align: center;
    padding: 2rem 1rem 1.75rem;
    margin: 0.5rem 0 1.5rem;
    border-radius: var(--radius);
    background: linear-gradient(145deg, color-mix(in srgb, var(--neon-cyan) 10%, var(--surface-2)), color-mix(in srgb, var(--neon-pink) 8%, var(--surface-2)));
    border: 2px solid var(--border-strong);
}
.dash-hero-label {
    font-size: 0.95rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-faint);
    margin-bottom: 0.4rem;
}
.dash-hero-number {
    font-family: 'Poppins', sans-serif;
    font-size: clamp(2.8rem, 10vw, 4.5rem);
    font-weight: 800;
    line-height: 1;
    text-shadow: 0 0 24px color-mix(in srgb, currentColor 40%, transparent);
}
.dash-hero-sub {
    margin-top: 0.6rem;
    font-size: 0.85rem;
    color: var(--text-faint);
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
}

.dash-hero-number-small {
    font-family: 'Poppins', sans-serif;
    font-size: 2rem;
    font-weight: 800;
    line-height: 1;
    margin: 0.2rem 0 0.75rem;
}

.dash-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
}
.dash-card {
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
}
.dash-card h3 { margin-top: 0; }
.dash-card-wide { grid-column: 1 / -1; }

/* Debts page's "Card view" toggle (vs its table view) — auto-fit so it
   already behaves as a real grid at any width, not just on desktop. */
.client-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}
.client-card {
    background: var(--surface-2);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
}
.client-card-head { display: flex; align-items: center; gap: 0.75rem; }

.dash-stat-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin: 0.75rem 0;
}
.dash-stat { flex: 1; min-width: 110px; }
.dash-stat-label {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
}
.dash-stat-number {
    font-family: 'Poppins', sans-serif;
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.2;
}
.dash-stat-sub { font-size: 0.8rem; margin-top: 0.1rem; }

.dash-progress { margin-top: 0.9rem; }
.dash-progress-label { font-size: 0.8rem; color: var(--text-faint); margin-bottom: 0.25rem; }
.dash-progress-track {
    height: 10px;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
    overflow: hidden;
}
.dash-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--neon-cyan), var(--neon-pink));
    border-radius: 999px;
}

.dash-deadline-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.dash-deadline-list li {
    display: flex;
    gap: 0.9rem;
    align-items: baseline;
    padding: 0.55rem 0;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}
.dash-deadline-list li:last-child { border-bottom: none; }
.balance-update-box {
    background: var(--surface);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    margin: 0.75rem 0;
}
.balance-update-box label { display: block; font-size: 0.8rem; color: var(--text-faint); margin-bottom: 0.4rem; }
.balance-update-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.balance-update-row input[type="number"] { width: 140px; margin: 0; }
.balance-update-row .muted { font-size: 0.85rem; }

.dash-deadline-date {
    font-weight: 700;
    color: var(--neon-cyan);
    white-space: nowrap;
    min-width: 85px;
}

/* =========================================================================
   Desktop widescreen layout (>=1440px)
   Everything above this point is the existing, already-tested layout and
   stays exactly as it is below 1440px wide (tablets, small laptops, phones
   all keep today's look). This block only runs on a big screen, and only
   widens containers / adds columns — no new colors, fonts or effects.
   ========================================================================= */
@media (min-width: 1440px) {
    main.page { max-width: 1680px; }
    .card { max-width: 860px; }
    .card-medium { max-width: 1200px; }
    .card.wide { max-width: 1600px; }

    /* Dashboard's card grid already auto-fits — just give it more room to
       settle into 3-4 columns instead of 2. */
    .dash-grid { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.5rem; }

    .charts-row { gap: 2rem; }
    .charts-row > div { flex: 1 1 380px; }

    /* Reusable desktop-only grid wrappers — applied around groups of
       same-shaped sections/cards that otherwise just stack one under the
       other however wide the screen is. Each page below opts specific
       wrappers into these; nothing structural changes under 1440px. */
    /* auto-fit rather than a fixed column count: a page with only one item
       (one mortgage, one pension pot) still gets the full row instead of
       sitting in a half-width column with dead space beside it; two or
       more settle into even columns on their own. */
    .desktop-cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(480px, 1fr)); gap: 1.75rem; align-items: start; }
    .desktop-cols-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1.5rem; align-items: start; }
    .desktop-cols-2 > section, .desktop-cols-3 > section,
    .desktop-cols-2 > .card, .desktop-cols-3 > .card { margin-top: 0; }

    /* The repeated-item "-block" family (holdings, mortgages, pension pots,
       assets, trips) normally separates with just a top rule, stacked full
       width. Inside a desktop-cols wrapper they become self-contained cards
       instead, so a 2-up/3-up grid of them actually reads as a grid. */
    .desktop-cols-2 > .mortgage-block, .desktop-cols-2 > .member-block, .desktop-cols-2 > .holding-block,
    .desktop-cols-2 > .account-block, .desktop-cols-2 > .pot-block, .desktop-cols-2 > .asset-block,
    .desktop-cols-2 > .trip-block,
    .desktop-cols-3 > .mortgage-block, .desktop-cols-3 > .member-block, .desktop-cols-3 > .holding-block,
    .desktop-cols-3 > .account-block, .desktop-cols-3 > .pot-block, .desktop-cols-3 > .asset-block,
    .desktop-cols-3 > .trip-block {
        border-top: none;
        border: 2px solid var(--border);
        border-radius: var(--radius-lg);
        padding: 1.25rem 1.5rem;
        margin-top: 0;
        background: var(--surface-2);
    }

    /* Collapsible "-card"/"month-group" rows (savings accounts, debts
       cards, etc.) already carry their own full border — just stop them
       stretching to 100% width when sat in a grid column. */
    .desktop-cols-2 > details.month-group, .desktop-cols-3 > details.month-group {
        margin-top: 0;
    }
}
