/*
 * assets/css/main.css
 * HomeBase — global stylesheet
 * No framework. Custom CSS only.
 *
 * Table of contents:
 *   1. Reset & base (CSS custom properties, dark mode)
 *   2. Typography
 *   3. Layout utilities
 *   4. Navigation bar
 *   5. Auth forms (login / register)
 *   6. Form controls
 *   7. Buttons
 *   8. Error & validation states
 *   9. Dashboard
 *  10. Budget & account pages
 *  11. Footer
 *  12. Theme toggle
 *  13. Responsive
 *  14. Tooltip
 */

/* ── 1. Reset & base ─────────────────────────────────────────────────────────── */

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

:root {
    /* Brand palette */
    --color-brand:             #1f6feb;
    --color-brand-hover:       #1558c9;
    --color-brand-active:      #0e429e;
    --color-brand-dark:        #0d2a4e;
    --color-brand-bg-subtle:   rgba(31, 111, 235, 0.07);
    --color-brand-ring:        rgba(31, 111, 235, 0.18);
    /* Brand FILL tokens: backgrounds that carry --color-text-on-brand text. Same as brand in light;
       darker in dark mode so white text passes 4.5:1 (B-54). --color-brand stays for text/borders/icons. */
    --color-brand-fill:        #1f6feb;
    --color-brand-fill-hover:  #1558c9;
    --color-brand-fill-active: #0e429e;

    /* Neutrals */
    --color-bg:                #f2f4f8;
    --color-surface:           #ffffff;
    --color-border:            #d0d7de;
    --color-text:              #1a1a2e;
    --color-text-muted:        #6b7280;
    --color-text-on-brand:     #ffffff;
    --color-text-on-brand-soft:  rgba(255, 255, 255, 0.85);
    --color-text-on-brand-muted: rgba(255, 255, 255, 0.75);

    /* Feedback */
    --color-error:             #c0392b;
    --color-error-bg:          #fdf0ef;
    --color-error-border:      #e74c3c;
    --color-error-hover:       #a93226;
    --color-error-ring:        rgba(192, 57, 43, 0.18);
    --color-danger:            #c0392b;
    --color-success:           #16a34a;
    --color-success-bg:        #eafaf0;

    /* Nav */
    --color-nav-bg:            #0d2a4e;
    --color-nav-text:          #d0e8ff;
    --color-nav-text-hover:    #ffffff;
    --color-nav-avatar-bg:     rgba(255, 255, 255, 0.15);
    --color-nav-avatar-border: #aacff5;

    /* Surface variations */
    --color-row-hover:         rgba(31, 111, 235, 0.09);
    --color-row-hover-active:  rgba(31, 111, 235, 0.14);
    --color-badge-bg:          #eef2f7;
    --color-bg-secondary:      #eef2f7;
    --color-surface-alt:       #eef2f7;
    --color-input-bg:          #ffffff;

    /* Undo banner */
    --color-warning-bg:        #fef3cd;
    --color-warning-border:    #ffc107;
    --color-warning-text:      #664d03;
    --color-warning:           #664d03;

    /* Shadows */
    --color-shadow-hover:  rgba(0, 0, 0, 0.13);
    --shadow-nav:          rgba(0, 0, 0, 0.25);
    --shadow-knob:         rgba(0, 0, 0, 0.2);
    --color-hairline:      rgba(0, 0, 0, 0.05);   /* faint row divider on any surface */
    --scrim-edge:          rgba(0, 0, 0, 0.08);   /* scroll-hint edge fade */

    /* Elevation (full box-shadow values; dark overrides below where they differ) */
    --shadow-hairline:     0 1px 2px rgba(0, 0, 0, 0.08);                          /* active segmented pill */
    --shadow-tip:          0 2px 8px rgba(0, 0, 0, 0.18);                          /* tooltips */
    --shadow-pop:          0 4px 16px rgba(0, 0, 0, 0.12);                         /* small popovers, drag-lift */
    --shadow-menu:         0 8px 20px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.1); /* combobox / autocomplete lists */
    --shadow-bar:          0 -4px 10px rgba(0, 0, 0, 0.08);                        /* sticky save bar, batch bar */
    --shadow-bar-dark:     0 -4px 10px rgba(0, 0, 0, 0.35);                        /* constant; used by the OS-dark media rules */
    --shadow-bar-lg:       0 -4px 14px rgba(0, 0, 0, 0.10);                        /* reconcile suggest / group bar */

    /* Text and fills that sit on a solid brand / danger / success / nav fill (same in both themes) */
    --color-on-solid:          #ffffff;
    --color-on-solid-soft:     rgba(255, 255, 255, 0.85);
    --color-on-solid-muted:    rgba(255, 255, 255, 0.75);
    --color-on-solid-glass:    rgba(255, 255, 255, 0.15);
    --color-on-solid-glass-strong: rgba(255, 255, 255, 0.25);

    /* Stronger brand tint (spending / bottom-line rows) */
    --color-brand-bg-strong:   rgba(31, 111, 235, 0.13);

    /* Income block colour steps (overview period card, glossary "Income Block
       Colour Steps"). Shade = block tint 10/20/30/40% brand over surface; stripe =
       4px left stripe 35/55/75/100% brand over surface. color-mix() of the
       tokens above, so these follow [data-theme="dark"] on their own (they
       re-resolve on the same root element); only the on-tint text is a literal. */
    --income-shade-1:          color-mix(in srgb, var(--color-brand) 10%, var(--color-surface));
    --income-shade-2:          color-mix(in srgb, var(--color-brand) 20%, var(--color-surface));
    --income-shade-3:          color-mix(in srgb, var(--color-brand) 30%, var(--color-surface));
    --income-shade-4:          color-mix(in srgb, var(--color-brand) 40%, var(--color-surface));
    --income-stripe-1:         color-mix(in srgb, var(--color-brand) 35%, var(--color-surface));
    --income-stripe-2:         color-mix(in srgb, var(--color-brand) 55%, var(--color-surface));
    --income-stripe-3:         color-mix(in srgb, var(--color-brand) 75%, var(--color-surface));
    --income-stripe-4:         var(--color-brand);
    /* Secondary text on the stronger tints: plain --color-text-muted drops under 4.5:1 there */
    --color-text-muted-on-tint: #3d4455;

    /* Amber "negative" tint (summary stat card) */
    --color-warn-tint:         rgba(245, 158, 11, 0.06);
    --color-warn-tint-border:  rgba(245, 158, 11, 0.25);
    --color-warn-tint-dark:        rgba(245, 158, 11, 0.08);   /* constants for the OS-dark media rule */
    --color-warn-tint-border-dark: rgba(245, 158, 11, 0.2);

    /* Spacing scale (glossary Spacing entry; adopted in the .gl-/.sg- sections only) */
    --space-1:             4px;
    --space-2:             8px;
    --space-3:             12px;
    --space-4:             16px;
    --space-5:             24px;

    /* Type: families and a small size scale (rem) */
    --font-sans:           -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-mono:           ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
    --font-size-2xs:       0.6875rem;
    --font-size-xs:        0.75rem;
    --font-size-sm:        0.8125rem;
    --font-size-md:        0.875rem;
    --font-size-base:      0.9375rem;

    /* Sizing */
    --radius:              8px;
    --radius-sm:           4px;
    --radius-lg:           12px;
    --shadow-card:         0 2px 12px rgba(0, 0, 0, 0.09);
    --shadow-modal:        0 8px 32px rgba(0, 0, 0, 0.2);
    --color-backdrop:      rgba(0, 0, 0, 0.5);
    --transition:          0.18s ease;
    --nav-height:          56px;
    --container-max:       480px;
    --container-wide:      960px;
}

/* ── Dark mode ───────────────────────────────────────────────────────────────── */

[data-theme="dark"] {
    --color-brand:             #4a9eff;
    --color-brand-hover:       #6db3ff;
    --color-brand-active:      #3a8ae6;
    --color-brand-dark:        #0a1929;
    --color-brand-bg-subtle:   rgba(74, 158, 255, 0.1);
    --color-brand-ring:        rgba(74, 158, 255, 0.25);
    /* Fill tokens (B-54): white on #2a6fdb = 4.78:1 (white on #4a9eff was 2.75:1). Hover/active go darker, as in light. */
    --color-brand-fill:        #2a6fdb;
    --color-brand-fill-hover:  #1f5fc4;
    --color-brand-fill-active: #1a52ad;

    --color-bg:                #121218;
    --color-surface:           #1e1e2e;
    --color-border:            #2e2e3e;
    --color-text:              #e0e0e0;
    --color-text-muted:        #888899;
    --color-text-on-brand:     #ffffff;
    --color-text-on-brand-soft:  rgba(255, 255, 255, 0.85);
    --color-text-on-brand-muted: rgba(255, 255, 255, 0.75);

    --color-error:             #e06050;
    --color-error-bg:          #2a1a18;
    --color-error-border:      #c04040;
    --color-error-hover:       #c04040;
    --color-error-ring:        rgba(224, 96, 80, 0.25);
    --color-danger:            #e06050;
    --color-success:           #34d058;
    --color-success-bg:        #1a2a1e;

    --color-nav-bg:            #0a1929;
    --color-nav-text:          #8fadc8;
    --color-nav-text-hover:    #d0e8ff;
    --color-nav-avatar-bg:     rgba(255, 255, 255, 0.08);
    --color-nav-avatar-border: #4a6a8a;

    --color-row-hover:         rgba(74, 158, 255, 0.14);
    --color-row-hover-active:  rgba(74, 158, 255, 0.20);
    --color-badge-bg:          #252535;
    --color-bg-secondary:      #2a2d35;
    --color-surface-alt:       #2a2d35;
    --color-input-bg:          #2a2a3a;

    --color-warning-bg:        #332b00;
    --color-warning-border:    #665200;
    --color-warning-text:      #e6c200;
    --color-warning:           #e6c200;

    --shadow-card:             0 2px 12px rgba(0, 0, 0, 0.3);
    --shadow-modal:            0 8px 32px rgba(0, 0, 0, 0.45);
    --color-backdrop:          rgba(0, 0, 0, 0.65);
    --color-shadow-hover:      rgba(0, 0, 0, 0.35);
    --shadow-nav:              rgba(0, 0, 0, 0.4);
    --shadow-knob:             rgba(0, 0, 0, 0.35);
    --scrim-edge:              rgba(0, 0, 0, 0.25);
    --shadow-bar:              var(--shadow-bar-dark);
    --shadow-bar-lg:           0 -4px 14px rgba(0, 0, 0, 0.35);
    --color-brand-bg-strong:   rgba(74, 158, 255, 0.13);
    --color-text-muted-on-tint: #d0d4de;   /* income block tints (--income-shade-*) recompute from the dark brand/surface above */
    /* Re-declared here (same formulas as :root) so they re-resolve against the dark
       brand/surface on ANY [data-theme="dark"] scope, e.g. Style Guide preview panels;
       a var() on :root is substituted at :root and would inherit the light result. */
    --income-shade-1:          color-mix(in srgb, var(--color-brand) 10%, var(--color-surface));
    --income-shade-2:          color-mix(in srgb, var(--color-brand) 20%, var(--color-surface));
    --income-shade-3:          color-mix(in srgb, var(--color-brand) 30%, var(--color-surface));
    --income-shade-4:          color-mix(in srgb, var(--color-brand) 40%, var(--color-surface));
    --income-stripe-1:         color-mix(in srgb, var(--color-brand) 35%, var(--color-surface));
    --income-stripe-2:         color-mix(in srgb, var(--color-brand) 55%, var(--color-surface));
    --income-stripe-3:         color-mix(in srgb, var(--color-brand) 75%, var(--color-surface));
    --income-stripe-4:         var(--color-brand);
    --color-warn-tint:         var(--color-warn-tint-dark);
    --color-warn-tint-border:  var(--color-warn-tint-border-dark);
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--font-sans);
    background-color: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ── 2. Typography ───────────────────────────────────────────────────────────── */

h1, h2, h3, h4 {
    font-weight: 700;
    line-height: 1.25;
    color: var(--color-text);
}

h1, h2, h3 {
    text-wrap: balance;
}

a {
    color: var(--color-brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ── 3. Layout utilities ─────────────────────────────────────────────────────── */

.main-content {
    flex: 1;
    padding: 40px 16px 60px;
}

.container {
    max-width: var(--container-wide);
    margin: 0 auto;
}

/* ── 4. Navigation bar ───────────────────────────────────────────────────────── */

.navbar {
    background-color: var(--color-nav-bg);
    height: var(--nav-height);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 4px var(--shadow-nav);
}

.navbar-inner {
    max-width: var(--container-wide);
    height: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
}

.navbar-brand {
    grid-column: 1;
    justify-self: start;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--color-on-solid);
    letter-spacing: 0.02em;
    text-decoration: none;
}

.navbar-brand-icon {
    width: 28px;
    height: 28px;
    display: none;
    flex-shrink: 0;
}

.navbar-brand-text {
    display: inline;
}

.navbar-inner:not(:has(.navbar-user)) .navbar-brand {
    grid-column: 2;
    justify-self: center;
}

.navbar-brand:hover {
    color: var(--color-nav-text);
    text-decoration: none;
}

.navbar-user {
    grid-column: 3;
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-greeting {
    color: var(--color-nav-text);
    font-size: 0.9rem;
}

.navbar-link {
    font-size: 0.875rem;
    color: var(--color-nav-text);
    text-decoration: none;
    white-space: nowrap;
}

.navbar-link:hover {
    color: var(--color-nav-text-hover);
    text-decoration: underline;
}

.navbar-link.tab-active {
    color: var(--color-nav-text-hover);
    font-weight: 600;
    text-decoration: none;
    border-bottom: 2px solid var(--color-nav-text-hover);
    padding-bottom: 2px;
}

.navbar-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: var(--color-nav-avatar-bg);
    border: 1.5px solid var(--color-nav-avatar-border);
    transition: background-color var(--transition), border-color var(--transition);
    text-decoration: none;
    flex-shrink: 0;
}

.navbar-avatar:hover {
    background-color: var(--color-on-solid-glass-strong);
    border-color: var(--color-nav-text-hover);
    text-decoration: none;
}

.avatar-icon {
    width: 20px;
    height: 20px;
    color: var(--color-nav-text);
}

.navbar-avatar:hover .avatar-icon {
    color: var(--color-nav-text-hover);
}

/* ── Profile page (sectioned cards) ─────────────────────────────────────────── */

.profile-page {
    max-width: 560px;
    margin: 0 auto;
    padding: 32px 16px 48px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.profile-card {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 28px 28px;
}

.profile-card-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.profile-avatar-large {
    width: 72px;
    height: 72px;
    margin-bottom: 16px;
    border-radius: 50%;
    background-color: var(--color-brand-bg-subtle);
    border: 2px solid var(--color-brand);
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-avatar-large svg {
    width: 36px;
    height: 36px;
    color: var(--color-brand);
}

.profile-display-name {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
    line-height: 1.3;
}

.profile-display-meta {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 2px;
    line-height: 1.5;
}

.profile-display-meta a {
    color: var(--color-text-muted);
}

.profile-member-since {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 8px;
}

/* Quick links */
.profile-quick-links {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.profile-quick-link {
    flex: 1;
    min-width: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 16px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-brand);
    background-color: var(--color-brand-bg-subtle);
    border: 1px solid transparent;
    border-radius: var(--radius);
    text-decoration: none;
    transition: background-color var(--transition), color var(--transition), transform 160ms ease-out;
}


.profile-quick-link:hover {
    background-color: var(--color-brand-fill);
    color: var(--color-text-on-brand);
    text-decoration: none;
}

.profile-quick-link:active {
    transform: scale(0.97);
}

.profile-quick-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

/* My Budgets card */
.profile-budget-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 16px;
}

.profile-budget-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-radius: var(--radius);
    background-color: var(--color-bg-secondary);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: background-color var(--transition), color var(--transition);
    gap: 12px;
}

.profile-budget-item:hover {
    background-color: var(--color-brand-bg-subtle);
    color: var(--color-brand);
    text-decoration: none;
}

.profile-budget-name {
    font-weight: 600;
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-budget-household {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.profile-budget-footer {
    display: grid;
    gap: 10px;
}

/* Account settings card */
.profile-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 20px;
}

.profile-settings-section {
    margin-bottom: 20px;
}

.profile-settings-section:last-child {
    margin-bottom: 0;
}

.profile-section-heading {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin-bottom: 8px;
}

.profile-inline-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.profile-inline-form .form-group {
    flex: 1;
    margin-bottom: 0;
}

.profile-inline-form .btn {
    flex-shrink: 0;
    align-self: flex-end;
}

/* Password disclosure */
.profile-password-disclosure {
    border: none;
    padding: 0;
    margin: 0;
}

.profile-password-disclosure summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-brand);
    cursor: pointer;
    padding: 8px 0;
    list-style: none;
    transition: color var(--transition);
}

.profile-password-disclosure summary::-webkit-details-marker {
    display: none;
}

.profile-password-disclosure summary::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(-45deg);
    transition: transform var(--transition);
}

.profile-password-disclosure[open] summary::before {
    transform: rotate(45deg);
}

.profile-password-disclosure summary:hover {
    color: var(--color-brand-hover);
}

.profile-password-disclosure .profile-password-body {
    padding-top: 12px;
}

/* Budget allocation disclosure (collapsible section) */
.budget-disclosure {
    border: none;
    padding: 0;
    margin: 0;
}

.budget-disclosure summary {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
    padding: 8px 0;
    list-style: none;
    user-select: none;
}

.budget-disclosure summary::-webkit-details-marker {
    display: none;
}

.budget-disclosure summary::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--color-brand);
    border-bottom: 2px solid var(--color-brand);
    transform: rotate(-45deg);
    transition: transform var(--transition);
    flex-shrink: 0;
}

.budget-disclosure[open] summary::before {
    transform: rotate(45deg);
}

.budget-disclosure summary:hover {
    color: var(--color-brand);
}

.budget-disclosure-body {
    padding-top: 8px;
}

/* Preferences: setting row — converged onto the shared .bills-archived-toggle-wrap
   / .bills-archived-toggle-label classes (bills/index.php, register/index.php)
   per the UI consistency audit item #20, both being a "text label +
   .theme-toggle-profile" composition. The shared class is a compact inline
   pairing elsewhere (label + toggle sit right next to a filter pill), but this
   card is a full-width settings row, so space-between is restored here without
   touching the shared class's base (compact) behavior used on those pages. */
.profile-card .bills-archived-toggle-wrap {
    justify-content: space-between;
    padding: 4px 0;
}

.profile-card .bills-archived-toggle-label {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: normal;
}

/* Actions card */
.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-back-link {
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.profile-back-link a {
    color: var(--color-brand);
    font-weight: 600;
}

.theme-toggle-profile {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
}

.toggle-track {
    position: relative;
    width: 44px;
    height: 24px;
    background-color: var(--color-border);
    border-radius: 99px;
    transition: background-color var(--transition);
}

.toggle-track.toggle-on {
    background-color: var(--color-brand);
}

.toggle-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background-color: var(--color-surface);
    border-radius: 50%;
    transition: transform var(--transition);
    box-shadow: 0 1px 3px var(--shadow-knob);
}

.toggle-track.toggle-on .toggle-knob {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    min-width: 24px;
}

/* Switch standard (B-64 item 6): .toggle-track and .form-status-switch share one look
   (44x24, 99px, brand when on) and one label style (600, body colour). Phones get a
   44px-tall row. Behaviour split: .form-status-switch = a form field saved with the
   page's Save; .toggle-track = an instant action (button / link). */
@media (max-width: 640px) {
    .bills-archived-toggle-wrap,
    .theme-toggle-profile {
        min-height: 44px;
    }
}


/* ── 5. Auth forms (login / register) ────────────────────────────────────────── */

.auth-container {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding-top: 48px;
}

.auth-card {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 40px 36px;
    width: 100%;
    max-width: var(--container-max);
}

.auth-title {
    font-size: 1.6rem;
    margin-bottom: 28px;
    text-align: center;
    color: var(--color-brand-dark);
}

[data-theme="dark"] .auth-title {
    color: var(--color-brand);
}

.auth-footer-link {
    margin-top: 24px;
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text-muted);
}

.auth-footer-link a {
    color: var(--color-brand);
    font-weight: 600;
}

.auth-inline-link {
    align-self: flex-end;
    font-size: 0.825rem;
    color: var(--color-text-muted);
}

/* ── 6. Form controls ────────────────────────────────────────────────────────── */

.form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* 2-column form grid — desktop only */
.form-grid-2col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 16px;
}
.form-grid-span {
    grid-column: 1 / -1;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.form-group--inline {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.label-hint {
    font-weight: 400;
    color: var(--color-text-muted);
}

textarea,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="month"],
select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    color: var(--color-text);
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    -webkit-appearance: none;
}

textarea {
    resize: vertical;
}

textarea:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="month"]:focus,
select:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-ring);
}

input:disabled,
select:disabled,
textarea:disabled {
    background-color: var(--color-surface-alt);
    color: var(--color-text-muted);
    border-color: var(--color-border);
    cursor: not-allowed;
    opacity: 0.65;
}

/* ── Grouped Account Picker (glossary: "Grouped Account Picker") ────────────────
   Native <select> + <optgroup>s (assets/js/account-picker.js, PHP helper
   render_account_picker_options()). Rendering of the OPEN list is the OS/browser's
   own; we only make sure it stays readable in dark mode where the engine honors
   option/optgroup colors (Chromium/Firefox desktop) — no custom widget, and no
   effect on iOS/Android native pickers. Group headers keep the browser's bold,
   non-selectable look. */
select option,
select optgroup {
    background-color: var(--color-input-bg);
    color: var(--color-text);
}
select optgroup {
    font-weight: 600;
    font-style: normal;
}
select option:disabled {
    color: var(--color-text-muted);
}

/* "in <group>" line under a closed select[data-account-picker] — a closed native
   select shows only the option text, so "Unallocated" alone doesn't say which one.
   Inserted/updated by account-picker.js; `hidden` (no line at all) for the
   placeholder/empty value. Sits inside the existing .form-group, so it adds one
   short line and nothing else (no fixed width, wraps on a phone).
   min-height reserves that line for any select that has optgroups (approved
   preview slide 117: .mock-acct-hint min-height) so choosing the first option
   doesn't push the form down; a select with no optgroups is `hidden` (no space).
   .form-group is a column flexbox with gap: 5px, so as its child the hint takes
   the gap instead of an extra margin-top (B-23). */
.account-picker-hint {
    margin-top: 4px;
    min-height: 1.3em;
    font-size: 0.72rem;
    line-height: 1.3;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
}
.form-group > .account-picker-hint {
    margin-top: 0;
}
.account-picker-hint[hidden] {
    display: none;
}

/* ── Password show/hide toggle ──────────────────────────────────────────────── */
.input-password-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-password-wrap input[type="password"],
.input-password-wrap input[type="text"] {
    padding-right: 42px;
}

.password-toggle {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--color-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
    min-width: 36px;
    min-height: 36px;
}

.password-toggle:hover {
    color: var(--color-text);
}

.password-toggle:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-brand);
    cursor: pointer;
    flex-shrink: 0;
}

/* Checkbox row standard (B-64 item 7): body-colour label (muted text is for hints and
   reads as disabled), --font-size-md, 32px row on desktop / 44px on phones. Explanations
   longer than a few words go in a .field-hint line below the label, not in the label.
   Labels name the state ("Cleared"), never an action verb (No Mark verbiage). */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-height: 32px;
    font-size: var(--font-size-md);
    font-weight: 400;
    cursor: pointer;
    color: var(--color-text);
}

@media (max-width: 640px) {
    .checkbox-label {
        min-height: 44px;
    }
    .tx-modal-cleared {
        min-height: 0;
    }
}

/* Stacked checkbox lists (e.g. attach-accounts list on budgets/create.php) */
.checkbox-label--stacked {
    margin-bottom: 6px;
}

/* ── Compact checklist (carry-forward #26, slide 46 Variant A) ─────────────────
   Tight rows for a cluster of related checkboxes that previously each had a
   full hint paragraph underneath (e.g. budgets/edit.php Budget Behavior).
   Row itself reuses .checkbox-label as-is; only the list container + info-dot
   are new. First use of data-tooltip on a standalone element (not the
   interactive control itself) — see .info-dot touch handling in app.js. */
.checklist-compact {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0 14px;
}

.checklist-compact .checkbox-label {
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text);
}

.checklist-compact .checkbox-label:last-child {
    border-bottom: none;
}

.info-dot {
    margin-left: auto;
    width: 16px;
    height: 16px;
    min-width: 16px;
    border-radius: 50%;
    border: 1px solid var(--color-text-muted);
    color: var(--color-text-muted);
    font-size: 10px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: help;
    flex-shrink: 0;
    transition: border-color var(--transition), color var(--transition);
}

.info-dot:hover,
.info-dot.is-active {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

/* ── 7. Buttons ──────────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: var(--font-size-base);
    font-family: inherit;
    font-weight: 600;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: background-color var(--transition), border-color var(--transition),
                color var(--transition), box-shadow var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

/* Global mobile touch-target floor (UI consistency audit item #2). Most
   container-scoped rules already hit 44px explicitly; this is the catch-all
   for buttons that don't have one yet (admin/index.php header actions,
   budgets/index.php "New Budget", households/index.php header, etc.).
   More specific existing rules (e.g. .filter-group-actions .btn at 38px,
   the .bills-mobile-filter-row .bills-seg-btn / .period-mode-btn 36px→44px
   split at ~7129) still win the cascade regardless of source order since
   they carry higher specificity than this bare .btn selector. */
@media (max-width: 640px) {
    .btn {
        min-height: 44px;
    }
}

/* ── Remove / dismiss icon buttons (B-64 item 9, Daniel adopted Rec 2026-09-30) ──
   Two classes, one size, colour by meaning:
     .remove-row  - takes an item out of a form list or clears a picked file;
                    hover = error tint. (.btn-remove-sub-bill, .btn-remove-sub-acct,
                    .import-file-clear stay on the element as JS/markup hooks.)
     .icon-close  - dismisses a panel or modal without changing data; hover =
                    neutral. (.quick-transfer-close, .tx-modal-close stay as hooks.)
   32px hit area desktop, 44px on phones, glyph 1.25rem. */
.remove-row,
.icon-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    min-width: 32px;
    min-height: 32px;
    padding: 0 var(--space-2);
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-family: inherit;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: color var(--transition), background var(--transition);
}

.remove-row:hover {
    color: var(--color-error);
    background: var(--color-error-bg);
}

.icon-close:hover {
    color: var(--color-text);
    background: var(--color-bg-secondary);
}

@media (max-width: 640px) {
    .remove-row,
    .icon-close {
        min-width: 44px;
        min-height: 44px;
    }
}

/* Icon + text buttons (Edit / Add actions app-wide) — icon never squishes
   when button width gets tight. Standard (glossary "Icon + Text Button"):
   icon BEFORE the label, 16px in a default .btn, 14px in a .btn-sm, 6px gap
   (the .btn gap above). Stroke icons drawn on a 24 viewBox (the pencil) are
   thickened so their on-screen line weight matches the 14-viewBox plus (1.8px):
   stroke-width = 1.8 * 24 / rendered size. */
.btn > svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.btn-sm > svg {
    width: 14px;
    height: 14px;
}

.btn > svg[viewBox="0 0 24 24"][stroke] {
    stroke-width: 2.7;
}

.btn-sm > svg[viewBox="0 0 24 24"][stroke] {
    stroke-width: 3.1;
}

.btn-primary {
    background-color: var(--color-brand-fill);
    color: var(--color-text-on-brand);
    border-color: var(--color-brand-fill);
}

.btn-primary:hover {
    background-color: var(--color-brand-fill-hover);
    border-color: var(--color-brand-fill-hover);
    text-decoration: none;
    color: var(--color-text-on-brand);
}

.btn-primary:active {
    background-color: var(--color-brand-fill-active);
}

.btn-secondary {
    background-color: transparent;
    color: var(--color-brand);
    border-color: var(--color-brand);
}

.btn-secondary:hover {
    background-color: var(--color-brand-bg-subtle);
    text-decoration: none;
}

.btn-secondary:active {
    background-color: color-mix(in srgb, var(--color-brand) 15%, transparent);
}

/* Full-width button: the DEFAULT size stretched to its container. Carries no
   margin of its own — the container/layout supplies spacing (.sticky-save-bar,
   a flex gap, or a .mt-2 utility on the auth forms). */
.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 14px;
    font-size: var(--font-size-sm);
}

.btn-danger {
    background-color: var(--color-error);
    color: var(--color-on-solid);
    border-color: var(--color-error);
}

.btn-danger:hover {
    background-color: var(--color-error-hover);
    border-color: var(--color-error-hover);
    text-decoration: none;
    color: var(--color-on-solid);
}

/* Base disabled state (B-60). Same 0.5 / not-allowed values as the specific
   confirm-button disabled rules. Placed after the variant :hover rules so it
   wins the equal-specificity tie; this rule only dims and changes the cursor,
   it does not restate the hover colours. */
.btn:disabled,
.btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Loading (glossary "Button Loading vs Disabled"): an in-flight async submit.
   Spinner + the caller's text swap ("Saving...") + aria-busy="true", at 0.7
   so it reads as "working", not "unavailable" (disabled is 0.5). Clicks are
   blocked while it runs. The caller also sets `disabled`, so the selector
   is doubled with :disabled to win over the 0.5 rule above. */
.btn.btn-loading,
.btn.btn-loading:disabled {
    opacity: 0.7;
    cursor: progress;
    pointer-events: none;
}

.btn.btn-loading::before {
    content: "";
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    box-sizing: border-box;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
}

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

/* Full-width form action buttons (add/edit transaction) */
.form-actions-row {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 8px;
}

.form-actions-row .btn {
    flex: 1;
}

/* Delete section separator on edit pages */
.form-delete-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

/* Edit page sub-section pattern (sub-accounts, attached accounts, etc.) */
.edit-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--color-border); }
.edit-section-title { font-size: 1rem; margin-bottom: 8px; }
.edit-section-title-mt { margin-top: 16px; }
.edit-section-desc { font-size: 0.875rem; margin-bottom: 12px; }
.edit-section-note { font-size: 0.85em; margin-top: 8px; }

/* Desktop: sections stack far less densely than they need to once the card
   is wide enough to pair some of them side by side (see .form-card--wide
   and the Sinking Funds / Pay Schedule pairing on budgets/edit.php), so trim
   the per-section top gap. Mobile keeps the roomier default spacing. */
@media (min-width: 641px) {
    .edit-section { margin-top: 16px; padding-top: 14px; }
}
.edit-row-list { display: flex; flex-direction: column; gap: 8px; }
.edit-row-list-mb { margin-bottom: 12px; }
.edit-row-item { display: flex; justify-content: space-between; align-items: center; padding: 8px 12px; background: var(--color-bg); border-radius: 6px; }
.edit-row-add { margin-top: 12px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* Reparent-as-sub-account (2026-09-04): source-side "Move to Another Account"
   section renders disabled with an inline reason when the account is
   ineligible (already a parent, or a budget's Bill Sync account) — see
   get_account_reparent_ineligibility_reason() in budget_helpers.php. */
.edit-section-blocked { opacity: 0.6; }
.edit-section-blocked .edit-section-title { color: var(--color-text-muted); }
.edit-section-block-reason {
    display: flex; align-items: flex-start; gap: 6px; font-size: 0.78rem; color: var(--color-error);
    background: var(--color-error-bg); border: 1px solid var(--color-error-border); border-radius: var(--radius-sm);
    padding: 8px 10px; margin-top: 8px;
}
.edit-section-block-reason svg { flex-shrink: 0; margin-top: 1px; }

/* Target-side "Add Existing Account as Sub-Account" picker, alongside the
   existing "Add Sub-Account" button in .edit-row-add. */
.existing-account-picker {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px;
    padding: 10px 12px; border: 1px dashed var(--color-border); border-radius: var(--radius-sm); background: var(--color-bg);
}
.form-inline-row { margin: 0; }
.hint-text { font-size: 0.85em; }
.account-code-meta { text-align: center; margin-bottom: 20px; }

/* ── 7b. Focus-visible ──────────────────────────────────────────────────────── */

.btn:focus-visible,
a:focus-visible,
.navbar-link:focus-visible,
.navbar-avatar:focus-visible,
.navbar-brand:focus-visible,
.register-back-link:focus-visible,
.cleared-btn:focus-visible,
.drag-handle:focus-visible,
.edit-icon-btn:focus-visible,
.account-picker-card:focus-visible,
.profile-quick-link:focus-visible,
.profile-password-disclosure summary:focus-visible,
.theme-toggle-profile:focus-visible,
.undo-btn:focus-visible,
.period-jump-btn:focus-visible,
.tx-clickable:focus-visible,
.tab-item:focus-visible,
.tx-modal-close:focus-visible,
.filter-toggle-btn:focus-visible,
.widget-visibility-toggle:focus-visible,
.overflow-menu-item:focus-visible,
.category-combobox-toggle:focus-visible,
.btn-unmark-confirm:focus-visible,
.btn-sync-confirm:focus-visible,
.btn-override-confirm:focus-visible,
.btn-mark-paid:focus-visible,
.btn-tithe-mark:focus-visible,
.btn-paycheck-mark:focus-visible,
.btn-tithe-confirm-cleared:focus-visible,
.btn-tithe-cancel-cleared:focus-visible,
.btn-paycheck-confirm-cleared:focus-visible,
.btn-paycheck-cancel-cleared:focus-visible,
.btn-sinkfund-pay:focus-visible,
.btn-tithe-unmark-confirm:focus-visible,
.btn-tithe-unmark-cancel:focus-visible,
.btn-paycheck-unmark-confirm:focus-visible,
.btn-paycheck-unmark-cancel:focus-visible,
.btn-sinkfund-unmark-confirm:focus-visible,
.btn-sinkfund-unmark-cancel:focus-visible,
.btn-fund-save-mark:focus-visible,
.btn-fund-save-confirm:focus-visible,
.btn-fund-save-cancel:focus-visible,
.btn-fund-save-unmark-confirm:focus-visible,
.btn-fund-save-unmark-cancel:focus-visible,
.btn-fund-spending-mark:focus-visible,
.btn-pc-fund:focus-visible,
.btn-pc-fund-confirm:focus-visible,
.btn-pc-fund-cancel:focus-visible,
.btn-pc-unfund-confirm:focus-visible,
.btn-pc-unfund-cancel:focus-visible,
.btn-fund-spending-confirm:focus-visible,
.btn-fund-spending-cancel:focus-visible,
.btn-fund-spending-unmark-confirm:focus-visible,
.btn-fund-spending-unmark-cancel:focus-visible,
.quick-transfer-close:focus-visible,
.bill-period-row-check:focus-visible,
.bills-archived-header:focus-visible,
.mp-tx-row:focus-visible,
.recon-line:focus-visible,
.recon-accuracy-stat:focus-visible,
.recon-line-remove-btn:focus-visible,
.recon-line-unlink-btn:focus-visible,
.recon-sugg-main:focus-visible,
.recon-group:focus-visible,
.recon-removed-toggle:focus-visible,
.bs-move-btn:focus-visible,
.bs-income-toggle-btn:focus-visible,
.gl-nav-section-summary:focus-visible,
.gl-entry-summary:focus-visible,
.gl-demo button:focus-visible,
.gl-demo [tabindex]:focus-visible,
.gl-view-tabs .bills-seg-btn:focus-visible,
.sg-theme .bills-seg-btn:focus-visible,
.sg-jump-link:focus-visible,
.sg-jump-arrow:focus-visible,
.sg-token:focus-visible,
.sg-glossary-link:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

/* ── 8. Error & validation states ────────────────────────────────────────────── */

.form-error-banner,
.import-error-banner {
    background-color: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    border-radius: var(--radius-sm);
    color: var(--color-error);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 14px;
    margin-bottom: 20px;
}

.form-success-banner {
    background-color: var(--color-success-bg);
    border: 1px solid var(--color-success);
    border-radius: var(--radius-sm);
    color: var(--color-success);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 14px;
    margin-bottom: 20px;
}

/* Compact inline variant of .form-success-banner for short one-line status
   text swapped into an existing small confirm block (e.g. the Save/Fund
   one-click "Saved. Reloading…" message in assets/js/bills.js — replaces
   .unmark-error in place, so it keeps the same font-size/no-margin footprint
   rather than the full block-level banner's padding/border/margin). */
.form-success-banner-inline {
    color: var(--color-success);
    font-size: 0.75rem;
    font-weight: 600;
}

.form-info-banner {
    background-color: var(--color-brand-bg-subtle);
    border: 1px solid var(--color-brand-ring);
    border-radius: var(--radius-sm);
    color: var(--color-brand);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 14px;
    margin-bottom: 20px;
}

.form-warning-banner {
    background-color: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius-sm);
    color: var(--color-warning-text);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 10px 14px;
    margin-bottom: 20px;
}

.field-error {
    display: block;
    color: var(--color-error);
    font-size: 0.8rem;
    font-weight: 500;
    margin-top: 2px;
}

input.input-error,
select.input-error,
textarea.input-error {
    border-color: var(--color-error-border);
}

input.input-error:focus,
select.input-error:focus,
textarea.input-error:focus {
    box-shadow: 0 0 0 3px var(--color-error-ring);
}

/* ── 9. Dashboard ────────────────────────────────────────────────────────────── */

.dashboard-container {
    max-width: var(--container-wide);
    margin: 0 auto;
    padding: 32px 0;
}

.dashboard-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 6px;
}

.dashboard-header h1 {
    font-size: 1.8rem;
    overflow-wrap: break-word;
    word-break: break-word;
    min-width: 0;
}

.dashboard-switch-link {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.dashboard-budget-name {
    font-size: 1rem;
    color: var(--color-text-muted);
    margin-bottom: 28px;
}

.text-muted {
    color: var(--color-text-muted);
}

.budget-create-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background-color: var(--color-surface);
    border: 2px solid var(--color-brand);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-top: 28px;
    box-shadow: var(--shadow-card);
}

.budget-create-banner-text strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: var(--color-text);
}

.budget-create-banner-text p {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
}

.widget-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 8px;
}

.widget {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-card);
}

.widget-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.widget-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.widget-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.8rem;
    color: var(--color-brand);
}

.widget-link svg {
    flex-shrink: 0;
}

/* Wraps a switch_budget POST form (security fix — CSRF token moved out of
   the query string) so it lays out identically to the plain <a class="widget-link">
   it replaced inside the flex .widget-header-controls row, and resets the
   submit button's default chrome so .widget-link's own styling applies. */
.widget-link-form {
    display: contents;
}

.widget-link-btn {
    background: none;
    border: none;
    padding: 0;
    margin: 0;
    font: inherit;
    cursor: pointer;
}

.widget-empty {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

.widget-hint {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 8px;
}

.account-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.account-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.account-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.account-row-name {
    font-size: 0.9375rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Badge: one base + tones (B-64 items 10-28, 2026-09-30) ─────────────────
   Every badge/label pill in the app is `.badge` + one tone (+ optional caps /
   outline / dashed). Family classes (.account-type-badge, .recon-tag, ...) are
   kept in markup only as JS/CSS hooks and carry layout bits (margin, alignment)
   at most — never their own size, padding, radius or colours. Must stay above
   .u-hidden so a hidden badge still hides. Tokens only; no dark overrides. */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    flex-shrink: 0;
    font-size: var(--font-size-2xs);
    font-weight: 700;
    line-height: 1.4;
    padding: 2px var(--space-2);
    border: 1px solid transparent;
    border-radius: 99px;
    white-space: nowrap;
    background: var(--color-badge-bg);
    color: var(--color-text-muted);
}
.badge--caps { text-transform: uppercase; letter-spacing: 0.04em; }
.badge--solid { background: var(--color-brand-fill); color: var(--color-text-on-brand); }
.badge--brand { background: var(--color-brand-bg-subtle); color: var(--color-brand); }
.badge--neutral { background: var(--color-badge-bg); color: var(--color-text-muted); border-color: var(--color-border); }
.badge--success { background: var(--color-success-bg); color: color-mix(in srgb, var(--color-success) 70%, var(--color-text)); }
.badge--warning { background: var(--color-warning-bg); color: var(--color-warning-text); border-color: var(--color-warning-border); }
.badge--danger { background: var(--color-error-bg); color: var(--color-error); border-color: var(--color-error-border); }
.badge--outline { background: var(--color-surface); }
.badge--outline.badge--brand { border-color: var(--color-brand); }
.badge--outline.badge--success { border-color: var(--color-success); }
.badge--dashed { border-style: dashed; }

/* .account-type-badge: hook only (badge badge--neutral badge--caps) — look lives on .badge. */

.account-row-balance {
    font-size: 0.9375rem;
    font-weight: 600;
    white-space: nowrap;
    flex-shrink: 0;
}

.balance-positive { color: var(--color-success); }
.balance-negative { color: var(--color-error); }

.account-row-sub {
    padding-left: 24px;
    font-size: 0.875rem;
    opacity: 0.85;
    border-bottom-color: transparent;
}

.account-row-sub .account-row-name {
    font-weight: 400;
}

.balance-total {
    font-size: 2rem;
    font-weight: 700;
    margin: 8px 0;
}

.budget-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-bg);
    font-size: 0.9375rem;
}

.budget-summary-row:last-child {
    border-bottom: none;
}

.budget-summary-label {
    color: var(--color-text-muted);
    font-size: 0.875rem;
}

.budget-summary-total {
    font-weight: 600;
    margin-top: 4px;
}

/* ── 10. Budget & account pages ──────────────────────────────────────────────── */

.page-container {
    max-width: var(--container-wide);
    margin: 0 auto;
    padding: 32px 0;
}

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
}

.page-header h1 {
    font-size: 1.7rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

/* Title row: budget name + (mobile) overflow trigger + (desktop) view toggle */
.page-header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    flex-wrap: wrap;
}

.page-header-title h1 {
    margin: 0;
}

.page-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* ── Overflow menu ── */
.overflow-menu-wrap {
    position: relative;
}

.overflow-menu {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    min-width: 190px;
    max-width: calc(100vw - 16px);
    z-index: 100;
    padding: 4px 0;
}

.overflow-menu.open {
    display: block;
}

.overflow-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text);
    text-decoration: none;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    transition: background var(--transition);
}

.overflow-menu-item:hover {
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
}

.overflow-menu-item svg {
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.budget-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.budget-card {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-card);
    transition: background-color var(--transition);
}

.budget-card-active {
    background-color: var(--color-brand-bg-subtle);
}

.budget-card-body {
    flex: 1;
    min-width: 0;
}

.budget-card-name {
    font-size: 1.05rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.budget-card-meta {
    font-size: 0.85rem;
    color: var(--color-text-muted);
}

.budget-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* .active-badge: hook only (badge badge--solid badge--caps) — look lives on .badge. */

/* Default household/budget star (preview slide 69) — filled-star "Default"
   read-only label on the current default row; outline-star pill button on
   other rows. Reused as-is on pages/households/index.php and
   pages/budgets/index.php. */
.default-star-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--color-brand);
    font-weight: 600;
    font-size: 0.8125rem;
    white-space: nowrap;
}

.default-star-badge .star-icon {
    font-size: 1.125rem;
    line-height: 1;
}

.btn-set-default {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    cursor: pointer;
    white-space: nowrap;
}

.btn-set-default:hover {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

.btn-set-default .star-icon {
    font-size: 1rem;
    line-height: 1;
}

.col-right {
    text-align: right;
}

.col-actions {
    text-align: right;
    white-space: nowrap;
    display: flex;
    gap: 6px;
    justify-content: flex-end;
    align-items: center;
}

.account-code {
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

.form-page {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    /* .main-content already contributes 40px of top padding — this used to
       add another 48px on top of that (88px total before the card, ~128px
       before the card's own heading), reading as a large dead gap under the
       navbar. Trimmed to restore parity with other page types. */
    padding-top: 8px;
}

.form-card {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 40px 36px;
    width: 100%;
    max-width: var(--container-max);
}

/* Modifier: pages with enough content/columns to justify a wider desktop
   card than the standard auth-width form (e.g. budgets/edit.php, which has
   a 2-col field grid plus paired Sinking Funds / Pay Schedule sections).
   Mobile is untouched — .form-card's mobile override (max-width: 640px,
   full-bleed) already wins there regardless of this modifier. */
@media (min-width: 641px) {
    .form-card--wide {
        max-width: 680px;
    }
}

/* Same modifier as .form-card--wide above, but for .auth-card-based pages
   (e.g. admin/add_user.php, admin/edit_user.php) whose 2-col field grid
   (.form-grid-2col) is cramped at the standard auth-width. Mobile is
   untouched — .auth-card's mobile override already wins there regardless
   of this modifier. */
@media (min-width: 641px) {
    .auth-card--wide {
        max-width: 680px;
    }
}

.form-card .register-back-link {
    margin-bottom: 16px;
}

.form-card-title {
    margin-bottom: 4px;
}

/* Title row with an inline control (e.g. bills/edit.php's "Active" checkbox next
   to the page heading). Wraps below the title on narrow viewports rather than
   forcing the checkbox label to truncate. */
.form-card-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}

.form-card-title-row .form-card-title {
    margin-bottom: 0;
}

.form-card-title-checkbox {
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.form-card-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 24px;
}

/* ── Sticky save bar (reusable pattern) ──────────────────────────────────────
   Opt-in wrapper for an edit/save form's primary submit button. Wrap the
   button in <div class="sticky-save-bar"> anywhere in the form (position in
   the DOM doesn't matter). Below 641px (mobile) it renders fixed to the
   bottom of the viewport for thumb-reach; at 641px+ (desktop) it overrides
   back to `position: static` so it sits in normal document flow right after
   the last field — see the min-width: 641px block below. On mobile, fixed
   is required because pages that use this pattern have multiple independent
   <form> elements below the save button's own form (e.g. Accounts, Delete),
   so `position: sticky` cannot work here — sticky's stick-range is bounded
   by its own containing block (the button's <form>), so it would "unstick"
   and scroll away as soon as the user scrolls past that form's bottom edge,
   long before reaching the rest of the page. `position: fixed` has no such
   containing-block limit, so it stays pinned for the entire page scroll
   regardless of how many sections follow. Centered/sized to match
   .form-card's width via left:50% + translateX(-50%) since .form-page
   centers .form-card the same way. Because fixed removes the bar from
   document flow, .form-card must reserve bottom space on mobile (see
   padding-bottom below) so content like the Delete Budget button isn't
   hidden underneath it — not needed on desktop since the bar is back in
   flow there. Also reused on .auth-card (login/register/admin user forms)
   — .auth-card shares the same max-width: var(--container-max) and
   full-bleed mobile behavior as .form-card, so the centering math and
   :has() padding reservation apply unchanged; see
   .auth-card:has(.sticky-save-bar) below. */
.sticky-save-bar {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--container-max);
    box-sizing: border-box;
    z-index: 20;
    padding: 12px 36px;
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    box-shadow: var(--shadow-bar);
}

/* Reserve room at the bottom of the form card so fixed-positioned
   .sticky-save-bar never overlaps trailing content (e.g. Delete Budget). */
.form-card:has(.sticky-save-bar),
.auth-card:has(.sticky-save-bar) {
    padding-bottom: 96px;
}

/* profile.php: the bar is JS-driven (hidden by default via the `hidden`
   attribute, shown only while a field inside the Account Settings accordion
   has focus — see assets/js/profile.js). Only reserve the padding while it's
   actually visible, since most of the time no bar is on screen at all. */
.profile-page:has(.sticky-save-bar:not([hidden])) {
    padding-bottom: 96px;
}

@media (prefers-color-scheme: dark) {
    .sticky-save-bar { box-shadow: var(--shadow-bar-dark); }
}

/* Desktop: the save bar sits in normal document flow right after the last
   field, directly inside the card, instead of pinning to the viewport
   bottom. Fixed positioning on desktop left a large detached gap between
   the card and a button floating at the bottom of the browser window (only
   useful for mobile thumb-reach). A top border still reads as a divider
   between the fields and the action row. Card padding-bottom reservations
   are no longer needed since the bar is back in flow. */
@media (min-width: 641px) {
    .sticky-save-bar {
        position: static;
        left: auto;
        bottom: auto;
        transform: none;
        width: auto;
        max-width: none;
        margin-top: 24px;
        padding: 24px 0 0;
        box-shadow: none;
    }

    .form-card:has(.sticky-save-bar),
    .auth-card:has(.sticky-save-bar) {
        padding-bottom: 40px;
    }

    .profile-page:has(.sticky-save-bar:not([hidden])) {
        padding-bottom: 0;
    }
}

@media (min-width: 641px) and (prefers-color-scheme: dark) {
    .sticky-save-bar { box-shadow: none; }
}
@media (min-width: 641px) {
    :root[data-theme="dark"] .sticky-save-bar { box-shadow: none; }
}

.navbar-budget-name {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--color-text-on-brand);
    background: var(--color-brand-fill);
    padding: 3px 10px;
    border-radius: var(--radius-lg);
    max-width: 180px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Household label + budget select: identical pill treatment (same colors,
   shape, padding, border-radius) at every breakpoint — these two controls
   sit side by side in the navbar and previously diverged (solid brand-blue
   select vs. translucent outline household label on desktop, and a
   different translucent/bordered look for both on mobile). */
.navbar-household-label,
.navbar-budget-select {
    display: inline-flex;
    align-items: center;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--color-on-solid);
    background: var(--color-on-solid-glass);
    border: 1px solid var(--color-on-solid-glass-strong);
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    flex-shrink: 0;
}

.navbar-budget-select {
    padding: 4px 20px 4px 8px;
    cursor: pointer;
    width: auto;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='white'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
}

.navbar-budget-select option,
.navbar-budget-select optgroup {
    background: var(--color-surface);
    color: var(--color-text);
    text-transform: none;
    font-weight: 400;
}

/* Household badge (contextual label on pages) */
.household-badge {
    margin-left: 8px; /* layout only; look = badge badge--brand */
}

/* Budget selector dropdown (dashboard, register index) — pill style matching navbar */
.budget-selector {
    width: auto;
    min-width: 160px;
    max-width: 280px;
    padding: 5px 28px 5px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-family: inherit;
    color: var(--color-text-on-brand);
    background-color: var(--color-brand-fill);
    border: none;
    border-radius: 16px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='white'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    transition: background-color var(--transition), box-shadow var(--transition);
}

.budget-selector:hover {
    background-color: var(--color-brand-fill-hover);
}

.budget-selector:focus {
    outline: none;
    box-shadow: 0 0 0 3px var(--color-brand-ring);
}

.budget-selector option {
    background: var(--color-surface);
    color: var(--color-text);
    text-transform: none;
    font-weight: 400;
}

.budget-selector-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* ── 10b. Register ───────────────────────────────────────────────────────────── */

/* .register-header now wraps a single child (.register-header-left) —
   the balance card that used to be its second child was moved out into
   .register-summary-bar below. justify-content: space-between is a no-op
   with only one flex item (nothing to space against), so it's dropped here;
   align-items/gap/margin still apply and are kept. The matching ≤640px
   flex-direction: column override (below, in the mobile section) is dead
   for the same reason and dropped there too. */
.register-header {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 20px;
}

.register-header h1 {
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    overflow-wrap: break-word;
    word-break: break-word;
}

.register-header-left {
    min-width: 0;
}

/* Filter toggle button */
.filter-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    margin-bottom: 12px;
    transition: all var(--transition);
}

.filter-toggle-btn:hover {
    color: var(--color-brand);
    border-color: var(--color-brand);
}

.filter-toggle-btn.filter-open {
    color: var(--color-brand);
    border-color: var(--color-brand);
}

.register-filter-bar.filter-collapsed {
    display: none;
}

.register-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 16px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.filter-group input[type="month"],
.filter-group input[type="text"],
.filter-group select {
    width: auto;
    min-width: 140px;
}

.filter-group-actions {
    flex-direction: row;
    align-items: flex-end;
    gap: 8px;
}

.filter-group-actions .btn {
    padding-top: 7px;
    padding-bottom: 7px;
    min-height: 38px;
    line-height: 1.4;
    font-size: 0.875rem;
}

.register-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

/* Bulk category action bar */
.bulk-action-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--color-surface-alt);
    border-radius: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
    border: 1px solid var(--color-border);
}

.bulk-action-bar.hidden {
    display: none;
}

.bulk-selected-count {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    margin-right: 4px;
}

/* Labelled field group inside the bulk bar */
.bulk-action-group {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.bulk-action-label {
    font-size: 0.7rem;
    color: var(--color-text-muted);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* Thin vertical divider between the field selects and action buttons */
.bulk-action-divider {
    width: 1px;
    height: 32px;
    background: var(--color-border);
    margin: 0 4px;
    align-self: center;
    flex-shrink: 0;
}

/* Compact select variant used inside the bulk bar */
.form-select-sm {
    width: auto;
    min-width: 120px;
    padding: 4px 24px 4px 8px;
    font-size: 0.8rem;
    height: 32px;
    font-family: inherit;
    color: var(--color-text);
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
}

.form-select-sm:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-ring);
}

.bulk-action-bar #bulkActionError {
    font-size: 0.85rem;
    flex-basis: 100%;
}

.bulk-action-bar #bulkActionError.hidden {
    display: none;
}

/* Select-all across pages banner */
.select-all-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--color-badge-bg);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-bottom: 0.5rem;
}
.select-all-banner.hidden { display: none; }
.select-all-banner-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-brand);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
}
.select-all-banner-btn:hover { opacity: 0.8; }

/* Checkbox column in register grid */
.rg-col-checkbox,
.rg-cell-checkbox {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.tx-checkbox {
    width: 16px;
    height: 16px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Register grid layout */
.register-grid-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
}

.register-grid-wrapper.is-loading {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity var(--transition);
}

.register-grid {
    display: grid;
    grid-template-columns: 20px 40px 1fr 1fr 100px 100px 32px;
    gap: 0;
    font-size: 0.9rem;
    background-color: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    min-width: 480px;
}

.register-grid-header {
    display: contents;
}

.register-grid-header .rg-col {
    background-color: transparent;
    color: var(--color-text-muted);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

.register-grid-header .rg-col-cleared {
    text-align: center;
}

.register-grid-header .rg-col-amount {
    text-align: right;
}

.register-grid-row {
    display: contents;
}

.register-grid-row .rg-cell {
    padding: 10px 12px;
    border-bottom: 1px solid var(--color-bg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
}

.register-grid-row:last-child .rg-cell {
    border-bottom: none;
}

.register-grid-row:hover .rg-cell {
    background-color: var(--color-row-hover);
}

.rg-cell-cleared {
    justify-content: center;
}

.rg-cell-amount {
    justify-content: flex-end;
    font-variant-numeric: tabular-nums;
}

.rg-cell-date {
    font-variant-numeric: tabular-nums;
}

/* Undo delete banner */
.undo-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background-color: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--color-warning-text);
}

.undo-banner form {
    display: inline;
}

.undo-btn {
    background: none;
    border: 1px solid var(--color-warning-text);
    color: var(--color-warning-text);
    font-weight: 600;
    font-size: 0.85rem;
    padding: 4px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition);
}

.undo-btn:hover {
    background-color: var(--color-warning-text);
    color: var(--color-warning-bg);
}

.undo-dismiss-btn {
    background: none;
    border: none;
    color: var(--color-warning-text);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    margin-left: auto;
    opacity: 0.6;
    transition: opacity var(--transition);
}

.undo-dismiss-btn:hover {
    opacity: 1;
}

/* Amount color coding */
.amount-credit {
    color: var(--color-success);
    font-weight: 600;
}

.amount-debit {
    color: var(--color-error);
    font-weight: 600;
}

.cleared-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-sm);
    line-height: 1;
    transition: color var(--transition), opacity var(--transition);
}

.cleared-btn svg {
    display: block;
}

.cleared-on {
    color: var(--color-success);
    opacity: 1;
}

.cleared-on:hover {
    opacity: 0.7;
}

/* Off state: full muted colour (no opacity fade - a 40% muted glyph is very
   likely below 3:1 non-text contrast); hover lifts it to brand. B-64 item 8. */
.cleared-off {
    color: var(--color-text-muted);
    opacity: 1;
}

.cleared-off:hover {
    color: var(--color-brand);
}

.tx-transfer .rg-cell {
    color: var(--color-text-muted);
    font-style: italic;
}

.account-picker-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Divider between top-level rows/groups — flat list style (no gaps, no
   shadow bubbles), consistent at every breakpoint. */
.account-picker-grid > * + * {
    border-top: 1px solid var(--color-border);
}

.account-picker-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background-color: var(--color-surface);
    padding: 16px 20px;
    min-height: 56px;
    cursor: pointer;
    text-decoration: none;
    color: var(--color-text);
    transition: box-shadow var(--transition), background-color var(--transition);
}

.account-picker-card:hover {
    background-color: var(--color-brand-bg-subtle);
    box-shadow: 0 4px 20px var(--color-shadow-hover);
    transform: translateX(2px);
    text-decoration: none;
    color: var(--color-text);
}

.account-picker-card::after {
    content: '\203A';
    font-size: 1.4rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
    transition: transform var(--transition);
}

.account-picker-card:hover::after {
    transform: translateX(3px);
    color: var(--color-brand);
}

.account-picker-card-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.account-picker-card-name {
    font-size: 1rem;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-picker-card-balance {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: right;
    margin-left: auto;
    min-width: 110px;
    font-variant-numeric: tabular-nums;
}

/* Background lives on the row (not just the card) so the drag-handle
   gutter on the left is solid white too — matching the divider above,
   which sits on this row's full-width box (`.account-picker-grid > * + *`).
   Without this, the gutter showed the page background instead of white,
   and the hover tint (below) looked like it "bled" past the divider's
   inset since the divider only ever spanned the card, not the gutter. */
.account-picker-row {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: var(--color-surface);
}

.account-picker-row:hover {
    background-color: var(--color-brand-bg-subtle);
}

.account-picker-row .account-picker-card {
    flex: 1;
    min-width: 0;
}

/* Drag handle for sortable accounts */
.drag-handle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 40px;
    flex-shrink: 0;
    cursor: grab;
    color: var(--color-text-muted);
    opacity: 0.4;
    transition: color var(--transition), opacity var(--transition);
    touch-action: none;
}

.drag-handle:hover {
    color: var(--color-brand);
    opacity: 1;
}

.drag-handle:active {
    cursor: grabbing;
}

.drag-handle-sub {
    width: 24px;
    height: 36px;
}

.drag-handle svg {
    flex-shrink: 0;
}

/* Desktop: only show drag handles on row hover (or while reorder mode is
   active) instead of at all times — matches mobile's reorder-gated
   visibility instead of cluttering every row with a persistent grip icon. */
@media (min-width: 641px) {
    .drag-handle {
        opacity: 0;
    }

    .account-picker-row:hover .drag-handle,
    .account-group-row:hover .drag-handle,
    .account-sub-row-with-edit:hover .drag-handle,
    .budget-card:hover .drag-handle,
    .reorder-mode-active .drag-handle {
        opacity: 0.4;
    }

    .account-picker-row:hover .drag-handle:hover,
    .account-group-row:hover .drag-handle:hover,
    .account-sub-row-with-edit:hover .drag-handle:hover,
    .budget-card:hover .drag-handle:hover {
        opacity: 1;
    }

    /* Right-side breathing room for the trailing edit button. The card's own
       padding (16px 20px, see .account-picker-card) gives its content a
       20px inset from the row's left AND right edge, but the edit button
       sits *after* the card as its own flex sibling — with no padding of
       its own, it was flush against the row's right edge, i.e. the grid's
       own edge, with 0px past it (unlike mobile, where the grid
       intentionally bleeds edge-to-edge to the real device edge, so
       "flush" reads as normal there). On desktop the grid is an inset card
       floating in whitespace, not a true edge, so the same 20px the card
       gives its content on the left is added here to match.
       (.account-sub-row-with-edit gets the same treatment further down,
       declared again after its own unconditional `padding: 0` rule so it
       isn't overridden by later cascade order — see that rule's comment.) */
    .account-picker-row,
    .account-group-row {
        padding-right: 20px;
    }
}

/* SortableJS drag states */
.sortable-ghost {
    opacity: 0.3;
    border: 2px dashed var(--color-brand) !important;
    border-radius: var(--radius);
    background: var(--color-brand-bg-subtle) !important;
}

.sortable-chosen {
    box-shadow: var(--shadow-pop);
    transform: scale(1.01);
    z-index: 10;
    position: relative;
}

.sortable-drag {
    opacity: 1 !important;
}

.account-picker-total {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 16px 20px;
    margin-top: 6px;
    border-top: 2px solid var(--color-border);
}

.account-picker-total-label {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.account-picker-total-balance {
    font-size: 1.1rem;
    font-weight: 700;
    white-space: nowrap;
    min-width: 110px;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Account groups (envelope sub-accounts) */
.account-group {
    margin-bottom: 0;
    /* Same reasoning as .account-picker-row: background on the full-width
       direct-child box (the one the divider border-top sits on), not just
       the inner header card, so the drag-handle gutter matches. */
    background-color: var(--color-surface);
}

/* Wrapper: group header + edit button side-by-side (matches .account-picker-row layout) */
.account-group-row {
    display: flex;
    align-items: center;
    gap: 6px;
    /* Left accent border groups the parent account row with its sub-account
       rows below (same technique as .bill-card--parent / .bill-card--child).
       Placed on this outer wrapper — not .account-group-header — because
       the "remove AI-tell side stripe" rule further down (search
       ".account-picker-card, .account-group-header { border-left: none; }")
       unconditionally strips border-left from .account-group-header at
       equal specificity later in the cascade; it does not touch this
       selector. No padding compensation needed: this wrapper has no
       left padding of its own (the drag handle is its first flex child). */
    border-left: 3px solid var(--color-brand);
}

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

.account-group-row > .account-group-header {
    flex: 1;
    min-width: 0;
}

.account-group-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
    min-height: 56px;
    background: var(--color-surface);
    cursor: pointer;
    user-select: none;
    color: var(--color-text);
    transition: box-shadow var(--transition), background-color var(--transition);
}

.account-group-header:hover {
    background-color: var(--color-brand-bg-subtle);
    box-shadow: 0 4px 20px var(--color-shadow-hover);
}

.account-group-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.account-group-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    transition: transform var(--transition);
    flex-shrink: 0;
    transform: rotate(90deg);
}

.account-group.collapsed .account-group-toggle {
    transform: rotate(0deg);
}

.account-group.collapsed .account-group-children {
    display: none;
}

.account-group-children {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0 0 0 16px;
    /* Divider between the group header row and its first sub-account row —
       without this, `.account-picker-grid > * + *` (which only separates
       *top-level* siblings) never fires here because the sub-rows live one
       level deeper, inside this wrapper, leaving the boundary right after
       the parent row with no line while every other row transition has one.
       Naturally disappears when the group is collapsed (`display: none` on
       this element in that state removes the border along with everything
       else), so collapsed groups never show a stray line before nothing. */
    border-top: 1px solid var(--color-border);
}

/* Thin divider between sub-account rows */
.account-group-children > .account-sub-row + .account-sub-row {
    border-top: 1px solid var(--color-border);
}

.account-sub-row {
    padding: 0;
}

.account-sub-row .account-picker-card {
    border-radius: 0;
    background-color: var(--color-surface);
    box-shadow: none;
    padding: 10px 16px;
    min-height: 44px;
    border-left: none;
}

.account-sub-row:last-of-type .account-picker-card {
    /* No special treatment — same as other sub-account cards */
}

.account-picker-card-sub {
    font-size: 0.95rem;
}

/* Icon-only edit button (per-record edit link) — reused app-wide */
.edit-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    flex-shrink: 0;
    text-decoration: none;
    transition: color var(--transition), background-color var(--transition),
                border-color var(--transition), box-shadow var(--transition);
}

.edit-icon-btn:hover {
    color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
    border-color: var(--color-brand);
    text-decoration: none;
}

.edit-icon-btn:active {
    background: var(--color-brand-fill);
    color: var(--color-text-on-brand);
    border-color: var(--color-brand-fill);
    transform: scale(0.96);
}

.edit-icon-btn svg {
    width: 16px;
    height: 16px;
}

/* Right side of group header (edit icon + balance) */
.account-group-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* Account delete button (register page) */
.account-delete-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.account-delete-btn:hover {
    color: var(--color-error);
    border-color: var(--color-error);
    background: var(--color-error-bg);
}
.account-delete-btn:active {
    transform: scale(0.96);
}

/* Sub-account rows with edit link */
.account-sub-row-with-edit {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    /* Continues the parent .account-group-row's left accent border down
       through every sub-account row (mirrors .bill-card--child). Placed on
       this outer wrapper, not .account-picker-card, for the same reason as
       .account-group-row above — .account-picker-card has its own
       border-left: none override later in the file. No padding
       compensation needed (padding is already 0; the drag handle is the
       first flex child). The .account-group-children wrapper's existing
       16px left padding is what nests this border under the parent's,
       same 16px indent already accepted on the Bills version
       (.bill-card--children padding-left: 16px). */
    border-left: 3px solid var(--color-brand);
}
.account-sub-row-with-edit .account-picker-card {
    flex: 1;
    min-width: 0;
}

.account-sub-row-with-edit:hover {
    background-color: var(--color-row-hover);
}

/* The inner .account-picker-card's own :hover (brand-tinted background +
   shadow + translateX shift, meant for the top-level clickable account
   list) would otherwise fire at the same time as the row hover above
   (hovering the card also satisfies :hover on this wrapper, since the
   card is its descendant), producing two different background colors
   plus a shift in the same row. Suppressed here so a sub-account row
   gets exactly one hover treatment — full-row highlight, same as
   .account-group-row:hover on the parent row above. */
.account-sub-row-with-edit .account-picker-card:hover {
    background-color: transparent;
    box-shadow: none;
    transform: none;
}

/* Desktop-only right breathing room for the trailing edit button — see the
   matching rule (and full rationale) in the `@media (min-width: 641px)`
   block above with `.account-picker-row`/`.account-group-row`. Declared
   again here, after the unconditional `padding: 0` above, because that
   later same-specificity rule would otherwise beat the earlier media-query
   version regardless of viewport width. */
@media (min-width: 641px) {
    .account-sub-row-with-edit {
        padding-right: 20px;
    }
}

.account-sub-row-add {
    display: flex;
    gap: 8px;
    padding: 4px 0 0 0;
}

/* Summary stats bar (account register) */
.register-summary-bar {
    display: grid;
    /* auto-fit instead of a hard repeat(4, 1fr): between the ≤640px stack
       breakpoint and full desktop width (~iPad portrait, 641-820px) a fixed
       4-up grid squeezed the 1.15rem tabular-figure amounts too tight; each
       card now wraps to its own row once it can't fit at >=150px. */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.summary-stat {
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

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

.summary-stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Back link (breadcrumb-style) above register header — same blue-outline,
   full-width treatment at every breakpoint (was a plain gray full-width
   button on mobile and a smaller blue-outline pill on desktop; unified per
   Daniel's request to look identical everywhere). */
.register-back-link {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    width: 100%;
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-brand);
    text-decoration: none;
    margin-bottom: 16px;
    padding: 10px 16px;
    border: 1px solid var(--color-brand);
    border-radius: var(--radius-sm);
    transition: background-color var(--transition), color var(--transition);
}

.register-back-link:hover {
    background-color: var(--color-brand-fill);
    color: var(--color-text-on-brand);
    text-decoration: none;
}

.register-back-link svg,
.period-nav-btn svg {
    flex-shrink: 0;
}

/* Payment method badge (shown inline with payee in register table) */
.payment-method-badge {
    margin-left: 6px; /* layout only; look = badge badge--neutral badge--caps */
    vertical-align: middle;
}

/* Clickable transaction rows */
.tx-clickable .rg-cell-payee,
.tx-clickable .rg-cell-category,
.tx-clickable .rg-cell-amount,
.tx-clickable .rg-cell-date,
.tx-clickable .rg-cell-arrow {
    cursor: pointer;
}

.rg-cell-arrow {
    justify-content: center;
}

.row-chevron {
    color: var(--color-text-muted);
    font-size: 1.2rem;
    transition: transform var(--transition);
}

.tx-clickable:hover .row-chevron {
    transform: translateX(3px);
    color: var(--color-text);
}

.tx-clickable:hover .rg-cell {
    background-color: var(--color-row-hover-active);
}

/* Transaction view modal */
.tx-modal-backdrop {
    position: fixed;
    inset: 0;
    background-color: var(--color-backdrop);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.tx-modal {
    background-color: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 24px;
}

.tx-modal-header {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    margin-bottom: 4px;
}

.tx-modal-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-text);
}

.tx-modal-cleared {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* .tx-modal-close: visual styling comes from the shared .icon-close (B-64 item 9);
   the class stays as the JS/mobile-order hook. */

.tx-modal-subtitle {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 20px;
}

.tx-modal-details {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.tx-modal-detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    border-bottom: 1px solid var(--color-bg);
    font-size: 0.9rem;
}

.tx-modal-detail-row:last-child {
    border-bottom: none;
}

.tx-modal-detail-label {
    color: var(--color-text-muted);
    font-weight: 500;
}

.tx-modal-detail-value {
    font-weight: 600;
    color: var(--color-text);
    text-align: right;
    max-width: 60%;
    word-break: break-word;
}

.tx-modal-form {
    padding: 0;
    margin-bottom: 20px;
}

.tx-modal-form .form-group {
    margin-bottom: 14px;
}

.tx-modal-form .form-group:last-child {
    margin-bottom: 0;
}

.tx-modal-form .form-group label {
    font-size: 0.85rem;
}

.tx-modal-form .form-error-banner {
    margin-bottom: 14px;
    font-size: 0.85rem;
}

.tx-modal-actions {
    display: flex;
    gap: 10px;
}

.tx-modal-actions .btn {
    flex: 1;
}

/* Radio-in-a-box choice group (glossary: "Bordered Radio Choice Group"). The
   .radio-pill-group / .radio-group aliases and their .radio-pill / .radio-option
   children (pay_schedules/create.php + edit.php tithe controls) previously had NO
   CSS at all — bare native radios with tight text wrapping (B-32). They now share
   this one component instead of a parallel copy. */
.type-toggle,
.radio-pill-group,
.radio-group {
    display: flex;
    gap: 12px;
}

/* Wraps two fields side by side on mobile (tx-modal); plain block on desktop */
.tx-modal-row {
    display: block;
}

.type-option,
.radio-pill,
.radio-option {
    display: flex;
    flex: 1;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 0.9rem;
    font-weight: 400;
    cursor: pointer;
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 8px;
}

.type-option input[type="radio"],
.radio-pill input[type="radio"],
.radio-option input[type="radio"] {
    accent-color: var(--color-brand);
    cursor: pointer;
}

/* The app never sets color-scheme, so a native radio's unchecked ring renders
   light-styled on the dark surface. Opt just these radios into the dark control
   palette (accent-color above still supplies the checked colour). Same
   theme-selector trio as the rest of the file: system preference unless the manual
   toggle says light, plus the explicit dark toggle. */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .type-option input[type="radio"],
    :root:not([data-theme="light"]) .radio-pill input[type="radio"],
    :root:not([data-theme="light"]) .radio-option input[type="radio"] {
        color-scheme: dark;
    }
}
:root[data-theme="dark"] .type-option input[type="radio"],
:root[data-theme="dark"] .radio-pill input[type="radio"],
:root[data-theme="dark"] .radio-option input[type="radio"] {
    color-scheme: dark;
}

/* Disabled choice (e.g. pay schedule "Of Gross / Of Net" while tithe is Fixed $). */
.type-option:has(input:disabled),
.radio-pill:has(input:disabled),
.radio-option:has(input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}

.type-option input[type="radio"]:disabled,
.radio-pill input[type="radio"]:disabled,
.radio-option input[type="radio"]:disabled {
    cursor: not-allowed;
}

/* Pay schedule choice groups only (not the Debit/Credit or wizard instances):
   44px tap target, and .radio-group (2-3 longer labels such as "Round down
   (floor)") stacks one option per row on a phone, mirroring the
   .import-amount-mode precedent below. .radio-pill-group (% / Fixed $) is two
   short labels and stays side by side. */
@media (max-width: 640px) {
    .radio-pill,
    .radio-option {
        min-height: 44px;
    }

    .radio-group {
        flex-direction: column;
        gap: 8px;
    }

    .radio-group .radio-option {
        flex: 1 1 auto;
        justify-content: flex-start;
        min-width: 0;
    }
}

/* Stack the Amount Mode toggle (CSV import wizard + Bank Reconciliation
   wizard, both wrapped in .import-amount-mode) vertically on mobile instead
   of squeezing two flex:1 labels to ~170-190px each, which wrapped their
   text awkwardly across 2-3 lines. Scoped to .import-amount-mode so this
   does NOT reach the unrelated Debit/Credit .type-toggle instances
   (register/account.php's tx modal, register/add.php, register/edit.php),
   which keep their own deliberate mobile layouts (see e.g. the compact
   segmented toggle override around line 4134). */
@media (max-width: 640px) {
    .import-amount-mode .type-toggle {
        flex-direction: column;
    }

    .import-amount-mode .type-option {
        flex: 1 1 auto;
        justify-content: flex-start;
        min-width: 0;
    }
}

/* Utility: truncate text */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Utility: visually hidden (for hidden forms managed by JS) */
.u-hidden {
    display: none;
}

/* Utility: visually hidden but announced by screen readers */
.u-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Spacing utilities */
.mt-0  { margin-top: 0; }
.mt-2  { margin-top: 0.5rem; }
.mt-3  { margin-top: 0.75rem; }
.mt-4  { margin-top: 1rem; }
.mb-2  { margin-bottom: 0.5rem; }
.mb-3  { margin-bottom: 0.75rem; }
.mb-4  { margin-bottom: 1rem; }
.mb-6  { margin-bottom: 1.5rem; }

/* Text size utility */
.text-sm { font-size: 0.875rem; }

/* Disabled overlay state */
.disabled-overlay { opacity: 0.45; pointer-events: none; }

/* Bill sync / toggle section hint paragraph */
.bill-sync-hint { margin: 10px 0 14px; font-size: 0.875rem; color: var(--color-text-muted); }

/* Inline note on toggle headers (e.g. "No other bills") */
.toggle-note { font-size: 0.8rem; font-weight: 400; color: var(--color-text-muted); }

/* ── 12. Theme toggle ────────────────────────────────────────────────────────── */

.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background-color: var(--color-nav-avatar-bg);
    border: 1.5px solid var(--color-nav-avatar-border);
    cursor: pointer;
    transition: background-color var(--transition), border-color var(--transition);
    flex-shrink: 0;
    padding: 0;
}

.theme-toggle:hover {
    background-color: var(--color-on-solid-glass-strong);
    border-color: var(--color-nav-text-hover);
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    color: var(--color-nav-text);
    transition: color var(--transition);
}

.theme-toggle:hover svg {
    color: var(--color-nav-text-hover);
}

/* Show sun in dark mode, moon in light mode */
.icon-sun {
    display: none;
}

.icon-moon {
    display: block;
}

[data-theme="dark"] .icon-sun {
    display: block;
}

[data-theme="dark"] .icon-moon {
    display: none;
}

/* ── 10c. Modal polish ───────────────────────────────────────────────────── */

.widget-cta {
    margin-top: 10px;
    display: inline-flex;
}

/* Onboarding card */
.onboarding-card {
    background-color: var(--color-surface);
    border: 2px dashed var(--color-brand);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 24px;
}

.onboarding-card h3 {
    font-size: 1.1rem;
    margin-bottom: 14px;
}

.onboarding-steps {
    list-style: decimal;
    padding-left: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 0.9375rem;
}

.onboarding-steps a {
    font-weight: 600;
}

/* Section heading for account groups (e.g. "Unbudgeted Accounts") */
.account-section-heading {
    margin-top: 32px;
    margin-bottom: 12px;
    font-size: 1.1rem;
    color: var(--color-text-muted);
}

/* System sub-account label (kept for reference, label text removed from UI) */

/* ── 14b. Polish overrides ──────────────────────────────────────────────────── */

/* Remove AI-tell side stripe from account picker cards and group headers */
.account-picker-card,
.account-group-header {
    border-left: none;
}

.account-picker-card:hover {
    transform: none;
}

/* Keep chevron but remove its translateX hover animation */
.account-picker-card:hover::after {
    transform: none;
}

/* Fix eyebrow proliferation — remove uppercase from non-label elements */
.widget-title {
    text-transform: none;
    letter-spacing: normal;
    font-size: 0.875rem;
}

.register-grid-header .rg-col {
    text-transform: none;
    letter-spacing: normal;
    font-weight: 600;
}

/* Unified budget selector base (non-navbar instances) */
.budget-selector {
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--color-text-on-brand);
    background-color: var(--color-brand-fill);
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='white'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 6px center;
    padding: 4px 20px 4px 8px;
}

/* ── 14. Tooltip ─────────────────────────────────────────────────────────────── */

#tooltip {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    display: none;
    background: var(--color-text);
    color: var(--color-bg);
    font-size: 0.72rem;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: normal;
    word-break: break-word;
    box-shadow: var(--shadow-tip);
    max-width: 200px;
}

@media (hover: none) {
    #tooltip { display: none !important; }
}

/* Reorder button: desktop-only hidden — only useful on mobile where drag handles are hidden */
#reorderModeBtn {
    display: none;
}

/* ── 13a. Mobile bottom tab bar ──────────────────────────────────────────────── */

.mobile-tab-bar {
    display: none;
}

/* ── 13. Responsive ──────────────────────────────────────────────────────────── */

/* Tablet and below */
/* ── 13a. Mid-width navbar: prevent dropdowns from squeezing brand ─────────── */
@media (max-width: 900px) {
    /* Constrain household and budget selectors so "HomeBase" brand stays visible */
    .navbar-household-label {
        flex-shrink: 1;
        min-width: 0;
        max-width: clamp(60px, 18vw, 130px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .navbar-budget-select {
        flex-shrink: 1;
        min-width: 0;
        max-width: clamp(70px, 22vw, 150px);
    }

    /* Prevent navbar-user flex row from overflowing its grid cell */
    .navbar-user {
        max-width: 100%;
        overflow: hidden;
    }

    /* Brand link: never shrink, always visible */
    .navbar-brand {
        white-space: nowrap;
    }
}

@media (max-width: 640px) {
    .auth-card {
        padding: 28px 20px;
        border-left: none;
        border-right: none;
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
    }

    .auth-container {
        padding-top: 0;
        align-items: stretch;
    }

    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }

    .auth-title {
        font-size: 1.4rem;
    }

    .navbar-inner {
        padding: 0 12px;
        grid-template-columns: 1fr;
    }

    .navbar-brand {
        display: none;
    }

    .main-content {
        padding: 24px 0 48px;
    }

    .dashboard-container {
        padding: 12px 16px;
    }

    .widget-grid {
        grid-template-columns: 1fr;
    }

    .budget-create-banner {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .page-container {
        padding: 12px 16px 24px;
    }

    .page-header {
        flex-direction: column;
        gap: 12px;
        margin-bottom: 20px;
    }

    .page-header-title {
        width: 100%;
    }

    .page-header-actions {
        width: 100%;
        flex-direction: column;
    }

    .page-header-actions .btn {
        width: 100%;
        min-height: 44px;
    }

    /* Register — Accounts: Edit + Add Account share one row on mobile
       instead of stacking full-width on separate lines. */
    .register-index-actions {
        flex-direction: row;
        gap: 8px;
    }

    .register-index-actions .btn {
        flex: 1 1 0;
        width: auto;
    }

    .budget-card {
        flex-wrap: wrap;
        gap: 8px 12px;
    }

    .budget-card .budget-card-actions {
        width: 100%;
    }

    /* H3: budget card action buttons — 44px touch target */
    .budget-card-actions .btn {
        min-height: 44px;
    }

    .form-page {
        padding: 0;
        min-height: 100vh;
        align-items: stretch;
    }

    .form-card {
        padding: 20px 16px;
        border-left: none;
        border-right: none;
        border-radius: 0;
        box-shadow: none;
        width: 100%;
        max-width: 100%;
        min-height: 100vh;
    }

    /* Full viewport width (matches .form-card going edge-to-edge on mobile)
       and clears the mobile bottom tab bar so the save bar doesn't hide
       behind it. */
    .sticky-save-bar {
        left: 0;
        transform: none;
        width: 100%;
        max-width: 100%;
        padding: 12px 16px;
        bottom: calc(56px + env(safe-area-inset-bottom, 0));
    }

    .form-card:has(.sticky-save-bar),
    .auth-card:has(.sticky-save-bar) {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 96px);
    }

    .profile-page:has(.sticky-save-bar:not([hidden])) {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 96px);
    }

    .register-filter-bar {
        flex-direction: column;
        gap: 10px;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group input[type="month"],
    .filter-group input[type="text"],
    .filter-group input[type="date"],
    .filter-group select {
        width: 100%;
        min-width: 0;
        font-size: 16px; /* prevent iOS auto-zoom on focus */
    }

    .filter-group-actions {
        width: 100%;
        flex-direction: column;
    }

    .filter-group-actions .btn {
        width: 100%;
    }

    /* Register grid: stacked card layout on mobile */
    .register-grid {
        display: flex;
        flex-direction: column;
        gap: 8px;
        min-width: 0;
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: transparent;
    }

    /* Column headings on mobile — match the 5-column card layout (44px | 44px | 1fr | auto | 20px).
       Category and date live in row 2 of each card, so their header cells are hidden. */
    .register-grid-header {
        display: grid;
        grid-template-columns: 44px 44px 1fr 88px 20px;
        padding: 4px 16px;
        border-bottom: 1px solid var(--color-border);
    }

    .register-grid-header .rg-col {
        padding: 0;
        border-bottom: none;
    }

    /* Category and date are in row 2 of the card — hide from the single-row header */
    .register-grid-header .rg-col-category,
    .register-grid-header .rg-col-date {
        display: none;
    }

    /* Checkbox column on mobile: 44px column meets touch-target guideline, spans both rows */
    .rg-cell-checkbox {
        display: flex;
        align-items: center;
        justify-content: center;
        grid-row: 1 / 3;
        grid-column: 1;
        padding: 0;
        min-height: 44px;
    }

    /* Bulk action bar visible on mobile with wrapping layout */
    .bulk-action-bar {
        display: flex;
    }

    .register-grid-row {
        display: grid;
        grid-template-columns: 44px 44px 1fr 88px 20px;
        grid-template-rows: auto auto;
        gap: 2px 8px;
        padding: 12px 16px;
        background-color: var(--color-surface);
        border-radius: var(--radius);
        box-shadow: var(--shadow-card);
        align-items: center;
    }

    .register-grid-row .rg-cell {
        border-bottom: none;
        padding: 0;
        white-space: normal;
        overflow: visible;
    }

    /* Row 1: [chk col1] [clr col2] [payee col3] [amount col4] [arrow col5] */
    .rg-cell-cleared { grid-row: 1; grid-column: 2; }
    .rg-cell-payee {
        grid-row: 1;
        grid-column: 3;
        font-weight: 600;
        font-size: 0.95rem;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    .rg-cell-amount {
        grid-row: 1;
        grid-column: 4;
        font-size: 0.9rem;
        justify-self: end;
    }

    /* Row 2: [chk spans] [___ col2] [category col3] [date col4] [arrow spans] */
    .rg-cell-category {
        grid-row: 2;
        grid-column: 3;
        font-size: 0.8rem;
        color: var(--color-text-muted);
    }
    .rg-cell-date {
        grid-row: 2;
        grid-column: 4;
        font-size: 0.8rem;
        color: var(--color-text-muted);
        justify-self: end;
    }

    .rg-cell-arrow {
        grid-row: 1 / 3;
        grid-column: 5;
        align-self: center;
    }

    .register-grid-row:hover .rg-cell {
        background-color: transparent;
    }

    .account-picker-card {
        flex-direction: row;
    }


    /* Hide desktop nav links on mobile (keep budget/household selectors visible) */
    .navbar-user .navbar-link,
    .navbar-user .navbar-avatar,
    .navbar-user .navbar-budget-name {
        display: none;
    }

    /* Mobile: same pill (color/background/border/radius inherited from the
       shared .navbar-household-label, .navbar-budget-select rule) — only
       size/touch-target tweaks differ here. */
    .navbar-user .navbar-budget-select,
    .navbar-user .navbar-household-label {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        padding: 6px 10px;
        min-height: 44px;
        justify-content: center;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        text-transform: none;
        font-size: 13px;
    }

    .navbar-user .navbar-budget-select {
        padding: 6px 26px 6px 10px;
        background-position: right 8px center;
    }

    .navbar-user {
        grid-column: 1;
        gap: 6px;
        flex-wrap: nowrap;
        overflow: hidden;
        width: 100%;
        justify-self: stretch;
    }

    /* Show mobile bottom tab bar */
    .mobile-tab-bar {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: calc(56px + env(safe-area-inset-bottom, 0));
        padding-bottom: env(safe-area-inset-bottom, 0);
        background-color: var(--color-surface);
        border-top: 1px solid var(--color-border);
        z-index: 100;
        justify-content: space-around;
        align-items: center;
    }

    .tab-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 2px;
        flex: 1;
        height: 100%;
        text-decoration: none;
        color: var(--color-text-muted);
        transition: color var(--transition);
    }

    .tab-item:hover,
    .tab-item:active {
        text-decoration: none;
        color: var(--color-brand);
    }

    .tab-active {
        color: var(--color-brand);
    }

    .tab-icon {
        width: 22px;
        height: 22px;
    }

    .tab-label {
        font-size: 0.65rem;
        font-weight: 600;
        letter-spacing: 0.01em;
    }

    /* Prevent content from hiding behind the tab bar */
    .main-content {
        padding-bottom: 72px;
    }

    /* ── Mobile declutter: Account picker (register/index.php) ──────────────── */

    /* Hide secondary info on account cards: type badges, account codes */
    .account-picker-card-left .account-type-badge,
    .account-picker-card-left .account-code,
    .account-group-header-left .account-type-badge {
        display: none;
    }

    /* Drag handle: hidden by default on mobile — Reorder button toggles them on */
    .drag-handle {
        display: none;
        width: 44px;
        height: 44px;
        opacity: 0.5;
    }
    .drag-handle-sub {
        display: none;
        width: 40px;
        height: 44px;
    }

    /* Reorder button: show on mobile */
    #reorderModeBtn {
        display: inline-flex;
    }

    /* Reorder mode active: show all handles */
    .reorder-mode-active .drag-handle,
    .reorder-mode-active .drag-handle-sub {
        display: inline-flex;
    }

    /* Budget list: no Reorder button on this page — the drag handle is
       always visible on mobile (touch has no hover to reveal it), and
       hover-revealed on desktop instead (see .budget-card:hover rule
       above ~line 2333). Overrides the default hidden-until-reorder-mode
       rule for every other reorderable list on the site. */
    .budget-card .drag-handle {
        display: inline-flex;
    }


    /* Account picker cards: tighter padding, larger touch target on mobile
       (flat list styling itself is unconditional now — see base rule). */
    .account-picker-card {
        padding: 10px 16px;
        gap: 12px;
        min-height: 48px;
    }

    /* Account picker rows: just card + edit icon */
    .account-picker-row,
    .account-group-row {
        gap: 4px;
    }

    /* Tighter padding on mobile for drag handle */
    .account-group-row {
        padding-left: 0;
        padding-right: 4px;
    }

    /* Icon-only edit button: larger touch target on mobile everywhere */
    .edit-icon-btn {
        width: 44px;
        height: 44px;
        border-radius: var(--radius);
    }

    /* Register account list rows only: edit icon hidden by default on mobile,
       revealed while the list is in reorder (drag) mode. Scoped to the
       sortable row contexts so this hide/reveal behavior stays local to
       register/index.php and doesn't hide the edit icon on other pages that
       reuse .edit-icon-btn but have no reorder mode. */
    .account-picker-row .edit-icon-btn,
    .account-group-row .edit-icon-btn,
    .account-sub-row .edit-icon-btn {
        display: none;
    }

    .reorder-mode-active .account-picker-row .edit-icon-btn,
    .reorder-mode-active .account-group-row .edit-icon-btn,
    .reorder-mode-active .account-sub-row .edit-icon-btn {
        display: inline-flex;
    }

    .account-delete-btn {
        width: 44px;
        height: 44px;
    }

    /* Account picker grid: bleed edge-to-edge on mobile */
    .account-picker-grid {
        margin-inline: -16px;
    }

    /* ── Mobile declutter: Account groups (sub-accounts) ────────────────────── */

    /* Match group header to standalone card dimensions on mobile */
    .account-group-header {
        padding: 10px 16px;
        gap: 12px;
        min-height: 48px;
    }

    /* Group children: 16px indent on mobile to show nesting under parent */
    .account-group-children {
        padding-left: 16px;
        gap: 0;
    }

    .account-sub-row-with-edit {
        padding: 0;
        gap: 2px;
    }

    .account-sub-row-add {
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .account-sub-row-add .btn {
        flex: 1;
        min-width: 0;
        text-align: center;
    }

    /* Group header right side: tighter */
    .account-group-header-right {
        gap: 6px;
    }

    /* ── Mobile declutter: Register header (account.php) ────────────────────── */

    /* Hide account code below account name on mobile */
    .register-header-left .account-code {
        display: none;
    }

    /* Hide type badge in register header on mobile */
    .register-header h1 .account-type-badge {
        display: none;
    }

    /* Register header h1: smaller on mobile */
    .register-header h1 {
        font-size: 1.2rem;
    }

    /* ── Mobile declutter: Transaction register grid (account.php) ──────────── */

    /* Hide payment method badge on mobile — too dense */
    .payment-method-badge {
        display: none;
    }

    /* Transaction row cards: more whitespace */
    .register-grid-row {
        padding: 14px 16px;
        gap: 4px 10px;
    }

    /* Cleared button: ensure adequate touch target */
    .cleared-btn {
        width: 44px;
        height: 44px;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
    }

    /* Summary bar: stack to single column for clarity */
    .register-summary-bar {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* Summary stat: horizontal layout when stacked */
    .summary-stat {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 10px 16px;
    }

    /* Register toolbar: Add Transaction + Transfer share one row on mobile,
       44px touch target each (mirrors .register-index-actions pattern). */
    .register-toolbar .btn {
        flex: 1 1 0;
        width: auto;
        min-height: 44px;
    }

    /* Pagination: compact on mobile — page-jump smaller, per-page select inline, wrap if needed */
    .pagination {
        flex-wrap: wrap;
        gap: 6px;
        justify-content: space-between;
    }

    .pagination-btn {
        flex: 0 0 auto;
        min-height: 44px;
        padding-inline: 16px;
    }

    .pagination-page-select {
        max-width: 80px;
        font-size: 0.8rem;
    }

    .pagination-label {
        font-size: 0.875rem;
        color: var(--color-text-muted);
        white-space: nowrap;
    }

    .per-page-pagination-select {
        max-width: 72px;
        font-size: 0.8rem;
    }

    /* Account picker total: more breathing room on mobile */
    .account-picker-total {
        padding: 12px 16px;
    }

    /* Filter toggle button: full-width on mobile */
    .filter-toggle-btn {
        width: 100%;
        justify-content: center;
        min-height: 44px;
    }

    /* Transaction modal: full-screen on mobile */
    .tx-modal-backdrop {
        padding: 0;
        align-items: stretch;
    }

    .tx-modal {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        padding: 20px 16px;
    }

    /* Title takes its own row; checkbox + close share the row below */
    .tx-modal-title {
        flex: 1 1 100%;
    }

    .tx-modal-cleared {
        order: 2;
    }

    .tx-modal-close {
        order: 3;
        margin-left: auto;
    }

    .tx-modal-actions .btn {
        min-height: 44px;
    }

    /* Modal form inputs: prevent iOS zoom */
    .tx-modal-form input[type="text"],
    .tx-modal-form input[type="number"],
    .tx-modal-form input[type="date"],
    .tx-modal-form select,
    .tx-modal-form textarea {
        font-size: 16px;
    }

    /* Company + Amount, Date + Type: paired 2-up rows to fit one screen */
    .tx-modal-row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0 10px;
    }

    /* Tighter vertical rhythm so the whole form fits without scrolling */
    .tx-modal-form .form-group {
        margin-bottom: 10px;
    }

    /* Type control: compact segmented toggle next to Date, not two large cards */
    .tx-modal-form .type-toggle {
        gap: 6px;
    }

    .tx-modal-form .type-option {
        padding: 8px 4px;
        font-size: 0.8rem;
        gap: 4px;
        white-space: nowrap;
    }

    .tx-modal-form .type-option-detail {
        display: none;
    }

    /* Notes: single-line field on mobile instead of a 3-row textarea */
    .tx-modal-form textarea#modalNotes {
        height: 40px;
        min-height: 40px;
        resize: none;
        overflow: hidden;
    }

    /* Onboarding card: tighter on mobile */
    .onboarding-card {
        padding: 20px 16px;
    }

    .budget-create-banner {
        padding: 20px 16px;
    }

    .budget-create-banner .btn {
        width: 100%;
        min-height: 44px;
    }

    /* ── Profile page mobile ────────────────────────────────────────────────── */

    .profile-page {
        padding: 0 0 72px;
        gap: 12px;
    }

    .profile-card {
        padding: 24px 20px;
        border-radius: 0;
        box-shadow: none;
        border-bottom: 1px solid var(--color-border);
    }

    .profile-quick-links {
        gap: 8px;
    }

    .profile-quick-link {
        padding: 14px 12px;
        min-height: 48px;
    }

    .profile-inline-form {
        flex-direction: column;
        gap: 8px;
    }

    .profile-inline-form .btn {
        width: 100%;
        min-height: 44px;
    }

    .profile-actions .btn {
        min-height: 44px;
    }

    /* M3: widget drag handle — 44px touch target */
    .widget-header .drag-handle {
        width: 44px;
        height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    /* M5: dashboard header — allow wrapping on narrow viewport */
    .dashboard-header {
        flex-wrap: wrap;
    }

    /* M6: hidden-widgets bar "Show All" button — 44px touch target */
    #hiddenWidgetsBar .btn {
        min-height: 44px;
    }

    /* L3: account picker total balance — remove fixed min-width on mobile */
    .account-picker-total-balance {
        min-width: unset;
    }
}

/* ── iOS auto-zoom prevention: all form inputs ≥16px on mobile ─────────── */
@media (max-width: 768px) {
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="number"],
    input[type="date"],
    input[type="month"],
    input[type="search"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* Phone — very narrow */
@media (max-width: 380px) {
    .auth-card {
        padding: 20px 14px;
    }

    .dashboard-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    /* On very narrow phones, stack navbar selects if both are present */
    .navbar-user {
        gap: 4px;
    }

    .navbar-user .navbar-budget-select,
    .navbar-user .navbar-household-label {
        font-size: 14px;
        min-height: 36px;
    }

    .navbar-user .navbar-budget-select {
        padding: 4px 24px 4px 8px;
    }

    .navbar-user .navbar-household-label {
        padding: 4px 10px;
    }

    /* Tighter register header */
    .register-header h1 {
        font-size: 1.1rem;
    }

    /* Summary stat labels: slightly smaller on very narrow */
    .summary-stat-label {
        font-size: 0.65rem;
    }

    .summary-stat-value {
        font-size: 1rem;
    }

    /* M1: import wizard step labels — too narrow to show at 320px */
    .import-step-label {
        display: none;
    }
}

/* ── 14c. Admin & Household pages ────────────────────────────────────────────── */

.admin-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}

.admin-stat-card {
    flex: 1;
    text-align: center;
}

.admin-stat-number {
    font-size: 2em;
    font-weight: 700;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-header-spaced {
    margin-top: 24px;
}

@media (max-width: 640px) {
    /* Mirrors .page-header's mobile stacking (~3379) — prevents heading +
       action button(s) from squeezing onto one cramped row. */
    .section-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .section-header .btn {
        width: 100%;
    }
}

.username-label {
    font-size: 0.85em;
}

.form-inline {
    display: inline;
}

.leave-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
    text-align: center;
}

.help-text-center {
    font-size: 0.85em;
    margin-top: 8px;
    text-align: center;
}

.back-link-spaced {
    margin-top: 24px;
}

/* ── 14. Reduced motion ─────────────────────────────────────────────────────── */

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

/* ── Utility ────────────────────────────────────────────── */
.hidden { display: none !important; }
.btn-group-wrap { display: flex; gap: 12px; flex-wrap: wrap; }

/* ── Dashboard Widget Controls ──────────────────────────── */
.widget-hidden { opacity: 0.4; }
.widget-header { position: relative; }
.widget-header .drag-handle { cursor: grab; padding: 4px; color: var(--color-text-muted); }
.widget-header .drag-handle:active { cursor: grabbing; }
.widget-visibility-toggle { background: none; border: none; cursor: pointer; padding: 4px; color: var(--color-text-muted); display: inline-flex; align-items: center; }
.widget-visibility-toggle:hover { color: var(--color-text); }
.widget-visibility-toggle.toggle-off { opacity: 0.4; }
.widget-header-controls { display: flex; align-items: center; gap: 4px; }
.hidden-widgets-bar { display: flex; align-items: center; justify-content: space-between; padding: 8px 16px; margin-bottom: 16px; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); font-size: 0.875rem; color: var(--color-text-muted); }
/* ── Trash Page ─────────────────────────────────────────── */
/* Tab row itself uses the shared .page-tabs/.page-tab/.page-tab--active
   classes (main.css ~6092) — consolidated 2026-07-31, was a near-duplicate
   .trash-tab* family with drifted padding/font-size/active-class naming. */
.trash-tab-count { font-size: 0.85em; color: var(--color-text-muted); margin-left: 0.25rem; }

.trash-list { display: flex; flex-direction: column; gap: 0.5rem; }
.trash-item { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 1rem; padding: 1rem 1.25rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); }
.trash-item-info { display: flex; flex-direction: column; gap: 0.25rem; }
.trash-item-name { font-weight: 600; color: var(--color-text); }
.trash-item-meta { font-size: 0.875rem; color: var(--color-text-muted); display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.trash-item-meta span { display: inline-flex; align-items: center; }
.trash-item-actions { display: flex; gap: 0.5rem; align-items: center; }
.trash-item-actions form { margin: 0; }
.trash-item-sub { margin-left: 1.5rem; border-left: 2px solid var(--color-border); padding-left: 1rem; }

.trash-card-wide { max-width: 800px; }
.trash-amount-inline { margin-left: 0.5rem; font-weight: 600; }
.trash-acct-deleted-notice { color: var(--color-error); }
.trash-back-link { margin-top: 1.5rem; }
.trash-sub-hint { font-size: 0.8rem; }

/* Amount formatting in trash */
.trash-amount-debit { color: var(--color-error); }
.trash-amount-credit { color: var(--color-success); }

/* Responsive */
@media (max-width: 640px) {
    .trash-item { grid-template-columns: 1fr; gap: 0.75rem; }
    .trash-item-actions { justify-content: center; }
    .trash-tabs { overflow-x: auto; }

    /* M2: reduce sub-item indentation on narrow mobile */
    .trash-item-sub { margin-left: 0.5rem; padding-left: 0.5rem; }
}

/* ══════════════════════════════════════════════════════════════════════
   CSV Import Wizard
   ══════════════════════════════════════════════════════════════════════ */

.import-wizard {
    max-width: 800px;
    margin: 0 auto;
}

.import-wizard .form-card {
    max-width: 100%;
    margin: 0 auto;
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 1.5rem;
    padding: 10px 16px;
    background: var(--color-bg-secondary);
    border-radius: var(--radius);
}

.pagination-select-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    padding: 6px 16px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    background: var(--color-bg-secondary);
    color: var(--color-brand);
    border: 1px solid var(--color-border);
    text-decoration: none;
    transition: background var(--transition);
}

.pagination-btn:hover {
    background: var(--color-brand-bg-subtle);
}

.pagination-btn-disabled {
    color: var(--color-text-muted);
    pointer-events: none;
    opacity: 0.5;
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.pagination-count {
    font-size: 0.8rem;
}

.pagination-page-select {
    font-size: 0.875rem;
    padding: 4px 6px;
    height: 32px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}

.pagination-page-select:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
    border-color: var(--color-brand);
}

/* "X of N" label inside pagination */
.pagination-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Per-page select inside pagination (AJAX-swapped zone) */
.per-page-pagination-select {
    width: auto;
    min-width: 72px;
    padding: 4px 24px 4px 8px;
    font-size: 0.8125rem;
    height: 32px;
    font-family: inherit;
    color: var(--color-text);
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
}

.per-page-pagination-select:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
    border-color: var(--color-brand);
}

/* Per-page selector in register toolbar */
.per-page-label {
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--color-text-muted);
    white-space: nowrap;
}

#perPageSelect {
    width: auto;
    min-width: 72px;
    padding: 4px 24px 4px 8px;
    font-size: 0.8125rem;
    height: 32px;
    font-family: inherit;
    color: var(--color-text);
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    cursor: pointer;
}

#perPageSelect:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-ring);
}

/* ── Step indicator ───────────────────────────────────────────────── */
.import-steps {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 2rem;
    padding: 0 1rem;
}

.import-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.import-step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    background: var(--color-badge-bg);
    color: var(--color-text-muted);
    border: 2px solid var(--color-border);
    transition: all var(--transition);
}

.import-step-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 500;
    transition: color var(--transition);
}

.import-step.active .import-step-number {
    background: var(--color-brand-fill);
    color: var(--color-text-on-brand);
    border-color: var(--color-brand-fill);
}

.import-step.active .import-step-label {
    color: var(--color-brand);
    font-weight: 600;
}

.import-step.completed .import-step-number {
    background: var(--color-success);
    color: var(--color-on-solid);
    border-color: var(--color-success);
}

.import-step.completed .import-step-label {
    color: var(--color-success);
}

/* A step the reviewer never actually saw (e.g. a wizard step that's skipped
   entirely when there's nothing to review at that step) — distinct from
   .completed so the indicator never implies a screen was shown when it
   wasn't. First used by the Budget Merge Wizard's Step 3 (Envelope
   Conflicts) when a merge has no conflicts to resolve. */
.import-step.skipped .import-step-number {
    background: var(--color-badge-bg);
    color: var(--color-text-muted);
    border-color: var(--color-border);
    border-style: dashed;
}

.import-step.skipped .import-step-label {
    color: var(--color-text-muted);
    font-style: italic;
}

.import-step-connector {
    flex: 1;
    height: 2px;
    background: var(--color-border);
    margin: 0 0.5rem;
    margin-bottom: 1.2rem;
    min-width: 20px;
}

/* ── File drop area ───────────────────────────────────────────────── */
.import-file-drop {
    position: relative;
    border: 2px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    transition: border-color var(--transition), background var(--transition);
    cursor: pointer;
}

.import-file-drop:hover,
.import-file-drop.drag-over {
    border-color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
}

.import-file-drop.has-file {
    border-style: solid;
    border-color: var(--color-success);
    background: var(--color-success-bg);
}

.import-file-drop.has-file .import-file-drop-text {
    display: none;
}

.import-file-drop.has-file .import-file-input {
    pointer-events: none;
}

.import-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.import-file-drop-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    color: var(--color-text-muted);
}

.import-file-drop-text svg {
    color: var(--color-brand);
}

.import-file-hint {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}

.import-file-selected {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-weight: 500;
    color: var(--color-text);
}

/* .import-file-clear: visual styling comes from the shared .remove-row (B-64 item 9);
   the class stays as the JS hook. */

.import-upload-hint {
    font-size: 0.82rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 0.5rem;
}

/* ── Column mapping ───────────────────────────────────────────────── */
.import-mapping-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    gap: 0.5rem 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
}

.import-mapping-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    padding-bottom: 0.25rem;
    border-bottom: 1px solid var(--color-border);
}

.import-mapping-header-spacer {
    /* empty middle cell in header row */
}

.import-mapping-csv-col {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.import-mapping-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--color-text);
    overflow-wrap: anywhere;
}


.import-mapping-sample {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-mapping-arrow {
    color: var(--color-text-muted);
    font-size: 1rem;
    text-align: center;
}

/* ── Date format & amount mode ────────────────────────────────────── */
.import-date-format,
.import-amount-mode {
    margin-bottom: 1rem;
}

/* ── Preview grid ─────────────────────────────────────────────────── */
.import-preview-card {
    max-width: 100%;
}

.import-preview-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    padding: 0 0.25rem;
}

.import-preview-scroll {
    overflow-x: auto;
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}

.import-preview-grid {
    min-width: 600px;
}

.import-preview-row {
    display: grid;
    grid-template-columns: 36px 100px 1fr 100px 140px 60px 1fr auto;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    align-items: center;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}

.import-preview-row:last-child {
    border-bottom: none;
}

.import-preview-header {
    font-weight: 600;
    background: var(--color-badge-bg);
    color: var(--color-text-muted);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    position: sticky;
    top: 0;
}

.import-preview-row--duplicate {
    background: var(--color-warning-bg);
}

.import-preview-check {
    display: flex;
    align-items: center;
    justify-content: center;
}

.import-preview-payee,
.import-preview-memo {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.import-cell-error {
    color: var(--color-error);
    font-weight: 500;
}

/* ── Bills CSV import (pages/bills/import.php) ───────────────────────
   Different column set than the register import above (Name, Amount,
   Category, Frequency, Start Date, Status vs. Date/Company/Amount/Category/
   Type/Memo) — scoped under #bills-import-wizard so it doesn't disturb
   .import-preview-row's grid-template-columns used by register/import.php.
   Horizontal scroll (.import-preview-scroll, inherited) covers narrow
   viewports instead of hiding columns. */
#bills-import-wizard .import-preview-row {
    grid-template-columns: 36px 1fr 90px 130px 100px 110px 110px;
}

.import-preview-row--flagged {
    background: var(--color-warning-bg);
}

.import-preview-status {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-warning-text);
}

.import-preview-row--flagged .import-preview-name {
    color: var(--color-text);
}

/* ── Results ──────────────────────────────────────────────────────── */
.import-results {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    margin: 2rem 0;
}

.import-result-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    min-width: 100px;
}

.import-result-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

.import-result-label {
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.import-result-imported {
    background: var(--color-success-bg);
    color: var(--color-success);
}

.import-result-skipped {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.import-result-errors {
    background: var(--color-error-bg);
    color: var(--color-error);
}

/* ── Error list ───────────────────────────────────────────────────── */
.import-error-list {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    border-radius: var(--radius);
}

.import-error-list h3 {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
    color: var(--color-error);
}

.import-error-item {
    font-size: 0.85rem;
    padding: 0.25rem 0;
    color: var(--color-text);
    border-bottom: 1px solid var(--color-hairline);
}

.import-error-item:last-child {
    border-bottom: none;
}

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .import-steps {
        gap: 0;
        padding: 0 0.25rem;
    }

    .import-step-label {
        font-size: 0.65rem;
    }

    .import-step-number {
        width: 28px;
        height: 28px;
        font-size: 0.75rem;
    }

    .import-step-connector {
        min-width: 12px;
        margin: 0 0.25rem;
    }

    .import-mapping-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    .import-mapping-arrow,
    .import-mapping-header-spacer {
        display: none;
    }

    .import-preview-row {
        grid-template-columns: 28px 80px 1fr 80px 120px;
        font-size: 0.8rem;
    }

    .import-preview-row > :nth-child(6),
    .import-preview-row > :nth-child(7),
    .import-preview-row > :nth-child(8) {
        display: none;
    }

    /* Bills import wizard has a different, shorter column set (see
       #bills-import-wizard .import-preview-row above) — un-hide its 6th/7th
       columns (Start Date/Status) that the unscoped rule above would
       otherwise also catch; scroll (.import-preview-scroll) covers overflow
       instead. Higher specificity (ID + descendant) wins over the plain
       class rule above regardless of source order. */
    #bills-import-wizard .import-preview-row > :nth-child(6),
    #bills-import-wizard .import-preview-row > :nth-child(7) {
        display: block;
    }

    .import-results {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }

    .import-result-stat {
        flex-direction: row;
        gap: 0.75rem;
        width: 100%;
        justify-content: center;
    }

    .import-result-number {
        font-size: 1.5rem;
    }
}

/* ── Import preview pagination ───────────────────────────────────────── */
.preview-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 0.75rem 0 0.25rem;
}

/* ── Import preview horizontal scroll indicator (mobile) ─────────────── */
.import-preview-wrap {
    position: relative;
}

.import-preview-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 32px;
    background: linear-gradient(to right, transparent, var(--scrim-edge));
    pointer-events: none;
    border-radius: 0 var(--radius) var(--radius) 0;
}

@media (min-width: 641px) {
    .import-preview-wrap::after {
        display: none;
    }
}

.import-scroll-hint {
    display: none;
    font-size: 0.72rem;
    color: var(--color-text-muted);
    text-align: center;
    margin-top: 4px;
    margin-bottom: 0.25rem;
}

@media (max-width: 640px) {
    .import-scroll-hint {
        display: block;
    }
}

/* ── Bulk bar select-all (mobile) ────────────────────────────────────── */
.bulk-select-all-wrap {
    display: none;
    align-items: center;
    gap: 6px;
    font-size: 0.875rem;
    color: var(--color-text);
    cursor: pointer;
    margin-right: 0.25rem;
}

.bulk-select-all-wrap input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    cursor: pointer;
}

@media (max-width: 640px) {
    .bulk-select-all-wrap {
        display: flex;
    }
}

/* ── Bills page ──────────────────────────────────────────────────────────────── */

.bills-group {
    margin-bottom: 2rem;
}

.bills-group-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    padding: 0 0 0.5rem 0;
    margin-bottom: 0.75rem;
    border-bottom: 2px solid var(--color-border);
}

.bills-group-name {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.bills-group-total {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.bills-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.bill-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.875rem 1rem;
    transition: box-shadow var(--transition), border-color var(--transition);
}

.bill-card:hover {
    background-color: var(--color-row-hover);
    box-shadow: var(--shadow-card);
    border-color: var(--color-border);
}

.bill-card--inactive {
    opacity: 0.55;
}

/* Archive feature (distinct from soft-delete/trash) — archived bills/accounts
   are hidden from lists by default; when the "Show Archived" toggle reveals
   them, dim the row and label it, same treatment for both bills and accounts. */
.bill-card--archived,
.account-picker-row--archived,
.account-sub-row--archived,
.account-group--archived {
    opacity: 0.55;
}

/* .account-archived-badge: hook only (badge badge--neutral badge--caps) — look lives on .badge. */

/* Parent bill (has sub-bills): left accent border, clickable to expand */
.bill-card--parent {
    border-left: 3px solid var(--color-brand);
    cursor: pointer;
    user-select: none;
}
.bill-card--parent:hover {
    background: var(--color-brand-bg-subtle);
}

.bill-card-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    align-self: center;
    color: var(--color-text-muted);
    transition: transform var(--transition);
    margin-right: 2px;
    margin-left: -2px;
}
.bill-card--parent[aria-expanded="true"] .bill-card-chevron {
    transform: rotate(90deg);
}

/* ════════════════════════════════════════════════════════════════════
   Bank Reconciliation (pages/accounts/reconcile.php, assets/js/reconcile.js)
   Approved via preview/ui-preview.html slides 101-113 — see md/glossary.md's
   "Bank Reconciliation" entry. Reuses .import-steps/.import-file-drop/
   .form-actions-row/.form-error-banner/.form-success-banner as-is (no new
   rules needed for those). Everything below with a .recon- prefix, plus the
   generic .dot-ok/.dot-bad/.dot-none status dots, is new — ported 1:1 from
   the approved preview's mock CSS with preview shorthand var names mapped
   to this file's real --color-* tokens.
   ════════════════════════════════════════════════════════════════════ */

/* Wizard container — mirrors .import-wizard/.merge-wizard's 800px-centered
   convention (see md/glossary.md's "Multi-Step Wizard Flow" entry) so Map
   Columns/Review/Complete don't fall back to the bare 480px .form-card
   default while Match alone opts into 680px via .form-card--wide. */
.recon-wizard {
    max-width: 800px;
    margin: 0 auto;
}

.recon-wizard .form-card {
    max-width: 100%;
    margin: 0 auto;
}

/* Recon page header badge distinguishing this from the now-removed "Funding Reconciliation" feature */
.recon-feature-badge {
    vertical-align: middle; /* layout only; look = badge badge--brand badge--caps */
}

.recon-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 16px 0 8px;
}
.recon-section-title:first-child { margin-top: 0; }

/* Two-list matching layout */
.recon-match-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 16px;
}
/* min-width:0 on both columns: a grid item's automatic minimum is its
   min-content, and the no-wrap row contents (date, tags, amount) otherwise
   widened the column past the card. */
.recon-match-grid > * { min-width: 0; }
.recon-match-col-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 8px;
}
.recon-match-col-count { font-weight: 500; color: var(--color-text-muted); font-size: 0.72rem; }
.recon-line-list { display: flex; flex-direction: column; gap: 6px; }
.recon-line {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    background: var(--color-surface);
    cursor: pointer;
    text-align: left;
    width: 100%;
    font: inherit;
    color: inherit;
}
.recon-line-date { font-size: 0.72rem; color: var(--color-text-muted); width: 52px; flex-shrink: 0; }
.recon-line-desc {
    flex: 1;
    min-width: 0;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.recon-line-amount { font-size: 0.8125rem; font-weight: 700; color: var(--color-text); flex-shrink: 0; }
.recon-line-amount.neg { color: var(--color-error); }

/* Tick-to-select interaction states [B-01, 2026-09-21]. A selectable row is a
   real <button aria-pressed> with a checkbox-style affordance (.recon-check),
   so state is never colour-only. .is-candidate = a Suggest result previewed
   (dashed) before "Select these" is pressed. */
.recon-line.is-selected {
    border-color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
    box-shadow: 0 0 0 1px var(--color-brand) inset;
}
.recon-line.is-candidate { border-style: dashed; border-color: var(--color-brand); opacity: 0.85; }
.recon-check {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid var(--color-text-muted);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-on-brand);
}
.recon-check.is-on { background: var(--color-brand-fill); border-color: var(--color-brand-fill); }
.recon-line-tags { display: inline-flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px 6px; flex-shrink: 0; max-width: 60%; }
/* .recon-tag(--period|--after): hooks only (badge badge--neutral badge--dashed) — look lives on .badge. */

/* Group hues — a small cycle (blue, teal, amber, violet, magenta) so a group
   reads the same in both panes. The number is ALWAYS printed too (.recon-gchip),
   so colour is never the only signal. Same idea as the shared colour band on
   rollup child rows (.bill-period-row--rollup-child). Tints stay low-opacity so
   row text keeps normal text contrast in both themes. */
:root {
    --recon-g1: #1f6feb; --recon-g1b: rgba(31, 111, 235, 0.09);
    --recon-g2: #0d7f83; --recon-g2b: rgba(13, 127, 131, 0.09);
    --recon-g3: #9a6210; --recon-g3b: rgba(154, 98, 16, 0.10);
    --recon-g4: #7c3aed; --recon-g4b: rgba(124, 58, 237, 0.08);
    --recon-g5: #b8336a; --recon-g5b: rgba(184, 51, 106, 0.08);
    --recon-chip-text: #ffffff;
}
[data-theme="dark"] {
    --recon-g1: #4a9eff; --recon-g1b: rgba(74, 158, 255, 0.13);
    --recon-g2: #3ccfd1; --recon-g2b: rgba(60, 207, 209, 0.12);
    --recon-g3: #f0b74a; --recon-g3b: rgba(240, 183, 74, 0.12);
    --recon-g4: #a78bfa; --recon-g4b: rgba(167, 139, 250, 0.13);
    --recon-g5: #f472b6; --recon-g5b: rgba(244, 114, 182, 0.12);
    --recon-chip-text: #10101a;
}
.recon-g1 { --recon-g: var(--recon-g1); --recon-gb: var(--recon-g1b); }
.recon-g2 { --recon-g: var(--recon-g2); --recon-gb: var(--recon-g2b); }
.recon-g3 { --recon-g: var(--recon-g3); --recon-gb: var(--recon-g3b); }
.recon-g4 { --recon-g: var(--recon-g4); --recon-gb: var(--recon-g4b); }
.recon-g5 { --recon-g: var(--recon-g5); --recon-gb: var(--recon-g5b); }

.recon-gchip {
    font-size: 0.66rem;
    font-weight: 700;
    color: var(--recon-g);
    background: var(--color-surface);
    border: 1px solid var(--recon-g);
    border-radius: 99px;
    padding: 0 7px;
    white-space: nowrap;
    flex-shrink: 0;
}
.recon-gchip--solid { background: var(--recon-g); color: var(--recon-chip-text); }

/* A grouped row (1:1 pair line, or a member row inside a boxed unit) is not
   selectable: coloured left band + tint, default cursor. */
.recon-line.in-group {
    border-left: 3px solid var(--recon-g);
    padding-left: 8px;
    background: var(--recon-gb);
    cursor: default;
}

/* Boxed unit for a group of 3+ items (1:1 pairs stay a single line). */
.recon-group {
    border: 1px solid var(--recon-g);
    border-left: 4px solid var(--recon-g);
    border-radius: var(--radius);
    background: var(--recon-gb);
    padding: 8px;
    min-width: 0;
}
.recon-group-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 6px; }
.recon-group-meta { font-size: 0.72rem; font-weight: 600; color: var(--color-text-muted); min-width: 0; }
.recon-group-acts { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.recon-group-rows { display: flex; flex-direction: column; gap: 5px; }
.recon-group-rows .recon-line.in-group { background: var(--color-surface); }
.recon-group .recon-group-sum-row { padding: 6px 2px 0; }
.recon-group-sum-row.is-unbalanced { color: var(--color-error); }
/* "Show in register/bank" lands here: a brief plain outline (no animation, so
   nothing to disable under prefers-reduced-motion). */
.recon-group.is-pulse,
.recon-line-row.is-pulse .recon-line { outline: 2px solid var(--recon-g); outline-offset: 2px; }

/* .recon-match-badge(--auto|--manual|--unmatched): hooks only (badge + brand / neutral / danger, caps) — look lives on .badge. */

/* Suggested/confirmed split-match group box */
.recon-group-box {
    border: 1.5px dashed var(--color-brand);
    border-radius: var(--radius-sm);
    padding: 8px;
    margin-top: 4px;
    background: var(--color-brand-bg-subtle);
}
.recon-group-box .recon-line { background: var(--color-surface); }
.recon-group-sum-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 6px 2px 2px;
}
.recon-group-sum-row.is-balanced { color: var(--color-success); }

.recon-unmatched-list .recon-line { border-color: var(--color-error-border); cursor: default; }
.recon-unmatched-note { font-size: 0.7rem; color: var(--color-text-muted); margin-top: 6px; }

/* Running math summary card */
.recon-summary-card {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    background: var(--color-surface);
}
.recon-summary-row { display: flex; justify-content: space-between; align-items: baseline; padding: 5px 0; font-size: 0.85rem; }
.recon-summary-row .recon-summary-label { color: var(--color-text-muted); }
.recon-summary-row .recon-summary-value { font-weight: 700; color: var(--color-text); }
.recon-summary-row--total { border-top: 1px solid var(--color-border); margin-top: 4px; padding-top: 10px; font-size: 0.9rem; }
.recon-summary-row--total .recon-summary-value { font-size: 1.05rem; }
.recon-summary-result {
    display: flex;
    align-items: center;
    gap: 8px;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-top: 10px;
    font-size: 0.85rem;
    font-weight: 700;
}
.recon-summary-result.is-clear { background: var(--color-success-bg); color: var(--color-success); }
.recon-summary-result.is-discrepancy { background: var(--color-error-bg); color: var(--color-error); }

/* "Last reconciled" account-page indicator */
.recon-last-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 0.78rem; color: var(--color-text-muted); }

/* Generic status dots — reused by .recon-last-badge, .recon-accuracy-stat,
   and .recon-rollup-row alike, not scoped to any one of them. */
.dot-ok { width: 7px; height: 7px; border-radius: 50%; background: var(--color-success); flex-shrink: 0; display: inline-block; }
.dot-bad { width: 7px; height: 7px; border-radius: 50%; background: var(--color-error); flex-shrink: 0; display: inline-block; }
.dot-none { width: 7px; height: 7px; border-radius: 50%; background: var(--color-border); flex-shrink: 0; display: inline-block; }

/* Account-page badge-row stat (slide 107) */
.recon-badge-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.recon-accuracy-stat {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-success);
    background: var(--color-success-bg);
    border: 1px solid var(--color-success);
    border-radius: 99px;
    padding: 3px 10px 3px 8px;
    cursor: pointer;
    font-family: inherit;
}
.recon-accuracy-stat.is-mixed { color: var(--color-error); background: var(--color-error-bg); border-color: var(--color-error-border); }
.recon-accuracy-stat svg { flex-shrink: 0; transition: transform var(--transition); }
.recon-accuracy-stat.is-expanded svg { transform: rotate(180deg); }

/* Parent/sub-account pooling note (wizard entry + matching + account-page badge) */
.recon-pooled-note { font-size: 0.72rem; color: var(--color-text-muted); margin: 2px 0 10px; }

/* Account-page history drill-in (slide 108) */
.recon-history-list { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; }
.recon-history-row {
    display: grid;
    grid-template-columns: 48px 1fr auto;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    background: var(--color-surface);
    font-size: 0.8125rem;
}
.recon-history-date { color: var(--color-text-muted); font-size: 0.72rem; }
.recon-history-outcome { font-weight: 700; }
.recon-history-outcome.is-clean { color: var(--color-success); }
.recon-history-outcome.is-discrepancy { color: var(--color-error); }
.recon-history-counts { font-size: 0.7rem; color: var(--color-text-muted); white-space: nowrap; }
.recon-history-note { font-size: 0.7rem; color: var(--color-text-muted); margin-top: 6px; }

/* Budget summary page rollup (slide 109) */
.recon-rollup-card { border: 1px solid var(--color-border); border-radius: var(--radius); padding: 14px 16px; background: var(--color-surface); }
.recon-rollup-summary { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; font-weight: 700; color: var(--color-text); margin-bottom: 10px; }
.recon-rollup-list { display: flex; flex-direction: column; gap: 2px; }
.recon-rollup-row { display: flex; align-items: center; gap: 8px; font-size: 0.8125rem; padding: 7px 2px; border-bottom: 1px dashed var(--color-border); }
.recon-rollup-row:last-child { border-bottom: none; }
.recon-rollup-row.is-never { opacity: 0.75; }
.recon-rollup-account {
    font-weight: 600;
    color: var(--color-text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.recon-rollup-meta { margin-left: auto; font-size: 0.72rem; color: var(--color-text-muted); white-space: nowrap; }
.recon-rollup-btn { margin-left: 10px; padding: 4px 10px; font-size: 0.72rem; flex-shrink: 0; }

@media (max-width: 640px) {
    .recon-rollup-row { flex-wrap: wrap; row-gap: 6px; }
    .recon-rollup-meta { margin-left: 15px; }
    .recon-rollup-btn { margin-left: auto; }
}

/* Wizard-step parent/sub-account pooling tag — names which pooled child a
   register row actually posted to (slide 112). */
.recon-line-source {
    font-size: 0.66rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-radius: 99px;
    padding: 1px 7px;
    white-space: nowrap;
    flex-shrink: 0;
}

.recon-account-heading { font-size: 0.78rem; color: var(--color-text-muted); margin-bottom: 12px; }
.recon-account-heading strong { color: var(--color-text); }

/* Remove-from-consideration control (Match step) — a bank line or register
   transaction that lands inside the padded Statement Period range but
   doesn't actually belong in this reconciliation. Same plain icon-only
   shape as the Move/Reset Icon-Button Cluster (.bs-move-btn, see
   md/glossary.md) — no border/background at rest, muted icon color, hover
   tint — reused here rather than invented fresh, but kept as its own class
   since this is a different feature/scope. Sits as a sibling to (not
   nested inside) the row's own <button>, since a <button> can't nest
   another <button>. */
.recon-line-row { display: flex; align-items: center; gap: 4px; }
.recon-line-row .recon-line { flex: 1; min-width: 0; }
.recon-line-remove-btn,
.recon-line-unlink-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    padding: 0;
    flex-shrink: 0;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition);
}
.recon-line-remove-btn:hover {
    background: var(--color-error-bg);
    color: var(--color-error);
}
/* Unlink (Ungroup) sits in the same slot as the remove icon but is not
   destructive, so it tints brand rather than error — the two stay visually
   distinct. Slightly larger than the remove icon (28px vs 22px). */
.recon-line-unlink-btn { width: 28px; height: 28px; }
.recon-line-unlink-btn:hover {
    background: var(--color-brand-bg-subtle);
    color: var(--color-brand);
}

/* Removed-lines disclosure — never a silent permanent delete (soft-delete-
   everywhere philosophy applied at UI-state level). Collapsed by default;
   expands to a plain list of removed lines, each with its own Undo. */
.recon-removed-disclosure { margin-top: 8px; }
.recon-removed-toggle {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.76rem;
    font-weight: 600;
    padding: 4px 2px;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: var(--color-border);
}
.recon-removed-toggle:hover { color: var(--color-text); }
.recon-removed-list { margin-top: 6px; }
.recon-removed-row { opacity: 0.75; cursor: default; }
.recon-removed-row .btn-sm { margin-left: auto; flex-shrink: 0; }

.recon-removed-note { font-size: 0.7rem; color: var(--color-text-muted); margin-top: 6px; }

/* ── Match step: sticky group bar, suggestions, status, notes [B-01] ──────────
   The dock sticks to the viewport bottom while either list scrolls (in-flow
   sticky, so it never covers the Continue buttons at the end of the card) and,
   on phones, sits ABOVE the fixed .mobile-tab-bar — same 56px +
   safe-area-inset-bottom clearance as .sticky-save-bar. It is only in the DOM
   flow visibly while a selection exists (.hidden otherwise). */
.recon-select-hint { margin: 0 0 12px; }
.recon-period-note { font-size: 0.72rem; color: var(--color-text-muted); margin: 0 0 8px; }
.recon-match-status {
    margin-top: 10px;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--color-success-bg);
    color: var(--color-success);
}
.recon-match-status:empty { display: none; }

.recon-group-dock { position: sticky; bottom: 0; z-index: 15; margin-top: 14px; }
.recon-group-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 18px;
    padding: 10px 14px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-bar-lg);
}
.recon-group-bar.has-sugg { border-top-left-radius: 0; border-top-right-radius: 0; }
.recon-bar-sums { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 18px; flex: 1 1 auto; min-width: 0; }
.recon-bar-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.recon-bar-hint { flex-basis: 100%; font-size: 0.75rem; color: var(--color-text-muted); }
.recon-stat { display: flex; flex-direction: column; min-width: 0; }
.recon-stat-l { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); }
.recon-stat-v { font-size: 0.95rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.recon-diff { padding: 3px 10px; border-radius: var(--radius-sm); border: 1px solid transparent; }
.recon-diff.is-idle { color: var(--color-text-muted); }
.recon-diff.is-off { color: var(--color-error); background: var(--color-error-bg); border-color: var(--color-error-border); }
.recon-diff.is-bal { color: var(--color-success); background: var(--color-success-bg); }
.recon-bal { font-size: 0.72rem; font-weight: 700; margin-left: 4px; }

/* Suggest results dock directly above the bar (so they stick with it). */
.recon-suggest {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 10px 14px 6px;
    box-shadow: var(--shadow-bar-lg);
    max-height: 40vh;
    overflow-y: auto;
}
.recon-sugg-head { display: flex; justify-content: space-between; gap: 8px; font-size: 0.78rem; margin-bottom: 6px; }
.recon-sugg-head span { color: var(--color-text-muted); flex-shrink: 0; }
.recon-sugg-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    margin-bottom: 6px;
}
.recon-sugg-item.is-active { border-style: dashed; border-color: var(--color-brand); background: var(--color-brand-bg-subtle); }
.recon-sugg-item .btn { flex-shrink: 0; }
.recon-sugg-main {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    min-width: 0;
    flex: 1;
    padding: 0;
    border: none;
    background: transparent;
    font: inherit;
    font-size: 0.75rem;
    color: inherit;
    text-align: left;
    cursor: pointer;
}
.recon-sugg-main span { color: var(--color-text-muted); overflow-wrap: anywhere; }
.recon-sugg-note { font-size: 0.72rem; color: var(--color-text-muted); padding: 0 2px 6px; }

/* Block-and-explain banner (groups no longer match the live register) and the
   Review step's re-check / stale-list note. */
.recon-group-block-title { font-weight: 700; margin-bottom: 4px; }
.recon-group-block ul,
.recon-review-note ul { margin: 6px 0 0 18px; font-weight: 500; }
.recon-group-block-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.recon-review-note {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius-sm);
    color: var(--color-warning-text);
    font-size: 0.8125rem;
    padding: 10px 14px;
    margin-bottom: 16px;
}

/* Generic 20px top-spacer for a block following another block that has no
   margin of its own to lean on (CSP's style-src has no 'unsafe-inline', so
   this can't be a one-off style="margin-top:20px" attribute). */
.recon-block-spaced { margin-top: 20px; }
.recon-undo-btn { margin-top: 8px; }

@media (max-width: 640px) {
    .recon-match-grid { grid-template-columns: 1fr; gap: 20px; }
    .recon-history-row { grid-template-columns: 40px 1fr; }
    .recon-history-counts { grid-column: 1 / -1; white-space: normal; }
    /* [MEDIUM fix, code-review pass, 2026-09-08] .recon-line computed to
       roughly 35px tall on mobile (8px/10px padding + 0.8125rem text) —
       under the project's 44px touch-target minimum, despite being the
       primary tap interaction for Step 2's anchor/group matching. Matches
       the same min-height pattern already used for .edit-icon-btn/
       .account-delete-btn above. */
    .recon-line { min-height: 44px; }
    /* Touch-target floor for the remove-icon and disclosure-toggle buttons,
       same reasoning as .recon-line above and .bs-move-btn's own mobile
       override. */
    .recon-line-remove-btn,
    .recon-line-unlink-btn { width: 44px; height: 44px; }
    .recon-removed-toggle { min-height: 44px; }

    /* [B-01] Two-line Match rows: description + amount on line 1 (the
       description gets the full width), date + tags on line 2. Scoped to
       .recon-line--two so the Review/removed rows keep their one-line flex
       shape. Rows stay >= 44px via .recon-line's min-height above. */
    .recon-line--two {
        display: grid;
        grid-template-columns: auto minmax(0, 1fr) auto;
        column-gap: 0;
        row-gap: 1px;
        align-content: center;
        padding-top: 6px;
        padding-bottom: 6px;
    }
    .recon-line--two > .recon-check,
    .recon-line--two > .recon-gchip { grid-row: 1 / span 2; grid-column: 1; align-self: center; margin-right: 10px; }
    .recon-line--two > .recon-check { width: 22px; height: 22px; }
    .recon-line--two > .recon-line-desc { grid-column: 2; grid-row: 1; }
    .recon-line--two > .recon-line-amount { grid-column: 3; grid-row: 1; margin-left: 10px; text-align: right; }
    .recon-line--two > .recon-line-date { grid-column: 2; grid-row: 2; width: auto; }
    .recon-line--two > .recon-line-tags { grid-column: 3; grid-row: 2; justify-self: end; margin-left: 10px; }

    /* Group bar: pinned above the mobile tab bar (56px + safe-area inset, the
       same clearance .sticky-save-bar uses). Sums are a 3-cell row; the three
       buttons are one full-width row; every button >= 44px tall. */
    .recon-group-dock { bottom: calc(56px + env(safe-area-inset-bottom, 0)); }
    .recon-group-bar { padding: 10px 12px; gap: 8px; }
    .recon-bar-sums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; width: 100%; flex: none; }
    .recon-stat-l { font-size: 0.6rem; }
    .recon-stat-v { font-size: 0.85rem; }
    .recon-diff { padding: 2px 6px; }
    .recon-bal { display: block; margin-left: 0; font-size: 0.65rem; }
    .recon-bar-actions { width: 100%; margin-left: 0; flex-wrap: nowrap; }
    .recon-bar-actions .btn { min-height: 44px; flex: 1; padding-left: 8px; padding-right: 8px; }
    .recon-bar-actions .btn-primary { flex: 1.7; }
    .recon-group-acts { margin-left: 0; width: 100%; }
    .recon-group-acts .btn { min-height: 44px; flex: 1; }
    .recon-sugg-item .btn { min-height: 44px; }
    .recon-sugg-main { min-height: 44px; justify-content: center; }
    .recon-group-block-actions .btn { min-height: 44px; }
}

/* Archived bills section: collapsed-by-default group rendered above the active bills
   list when "Show Archived" is on (Fix A). Reuses .bill-card-chevron's rotate-on-expand
   treatment; the header is a real <button> for free keyboard/focus support. */
.bills-archived-section {
    margin-bottom: 1.5rem;
}

.bills-archived-header {
    display: flex;
    align-items: center;
    gap: 6px;
    width: 100%;
    background: transparent;
    border: none;
    padding: 0.5rem 0;
    margin: 0;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: var(--color-text-muted);
}

.bills-archived-header:hover {
    color: var(--color-text);
}

.bills-archived-header-text {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.bills-archived-header[aria-expanded="true"] .bills-archived-chevron {
    transform: rotate(90deg);
}

.bills-archived-body {
    padding-top: 0.25rem;
}

.bills-archived-body[hidden] { display: none; }

/* Touch target: .bills-archived-header is a real <button> but its compact
   0.5rem vertical padding falls under the 44px mobile floor. Desktop keeps
   the compact sizing; mobile gets a min-height bump (same desktop-compact/
   mobile-44px split pattern used by .page-tabs-actions .btn). */
@media (max-width: 640px) {
    .bills-archived-header {
        min-height: 44px;
        padding: 0.75rem 0;
    }
}

/* Children wrapper: indent under the parent card */
.bill-card--children {
    display: flex;
    flex-direction: column;
    gap: 0;
    padding-left: 16px;
    margin-top: 0;
}
.bill-card--children[hidden] { display: none; }

/* Thin divider between sibling child cards */
.bill-card--children > .bill-card--child + .bill-card--child {
    border-top: none;
    margin-top: -1px; /* collapse double border */
}

/* Child bill: flush borders create a grouped look under the parent.
   Left accent border continues the parent card's own 3px brand-color
   border-left down through every child card, so the group reads as one
   connected block (same technique as .bill-period-row--rollup-child).
   Padding reduced from the base 1rem (16px) to 13px to offset the new
   3px border so child row text doesn't shift right when the border
   appears (text still starts at the same 16px total inset). */
.bill-card--child {
    border-radius: 0;
    border-left: 3px solid var(--color-brand);
    padding-left: 13px;
    border-right: 1px solid var(--color-border);
    border-bottom: 1px solid var(--color-border);
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.bill-card--child:first-child {
    border-top: none; /* parent's bottom border serves as the divider */
}

.bill-card--child:last-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Child bill name: slightly smaller and muted to show subordinate hierarchy */
.bill-card--child .bill-card-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.bill-card-left {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    min-width: 0;
    flex: 1;
}

.drag-handle--bill {
    display: none;
    cursor: grab;
    color: var(--color-text-muted);
    padding: 4px 2px;
    flex-shrink: 0;
    touch-action: none;
    width: 24px;
    height: 36px;
}
.drag-handle--bill svg { display: block; }
.drag-handle--bill:active { cursor: grabbing; }

/* Category drag handle — hidden by default, shown in reorder mode */
.drag-handle--category {
    display: none;
    cursor: grab;
    color: var(--color-text-muted);
    padding: 4px;
    flex-shrink: 0;
    touch-action: none;
}
.drag-handle--category svg { display: block; }
.drag-handle--category:active { cursor: grabbing; }

/* Reorder button bar */
.bills-reorder-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

/* Reorder mode: show both handle types */
.reorder-mode .drag-handle--category,
.reorder-mode .drag-handle--bill {
    display: flex;
    align-items: center;
}

/* Both handles carry the base .drag-handle class, which on desktop
   (see `@media (min-width: 641px) { .drag-handle { opacity: 0; } }` above)
   is invisible until revealed by a row-hover selector — the accounts page
   already lists its own row classes there. Without a matching entry here,
   the only thing that could reveal these handles was hovering the handle's
   own narrow box (the bare `.drag-handle:hover` rule), so reordering felt
   like it only worked in a thin left-side sliver. Revealing on hover of the
   full category/bill row fixes that. */
@media (min-width: 641px) {
    .bills-group-header:hover .drag-handle--category,
    .bill-card:hover .drag-handle--bill {
        opacity: 0.4;
    }

    .bills-group-header:hover .drag-handle--category:hover,
    .bill-card:hover .drag-handle--bill:hover {
        opacity: 1;
    }
}

/* Reorder mode: category groups get a visual cue they're draggable */
.reorder-mode .bills-group {
    cursor: default;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 4px;
}

.bill-card-name {
    font-size: 0.975rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bill-card-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.bill-card-mismatch-warn {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.75rem;
    color: var(--color-warning);
    font-weight: 500;
}

/* .bill-freq-badge(--<freq>): hooks only (badge badge--neutral badge--caps). B-64 #18: the five
   frequency hues (B-56) are retired — hue must not reuse success/warning meaning. */

.bill-card-dot {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    line-height: 1;
}

.bill-card-date,
.bill-card-category {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

/* Budget-date chip on the Bills list (F3, slides 185-186): neutral .badge, only the nowrap/size hook lives
   here. The rule suffix + its dot (.bill-card-rule / .bill-card-dot--rule) hide under 640px (see the mobile block). */
.bill-budget-chip {
    font-size: 0.7rem;
    max-width: 100%;
}

.bill-card-right {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    flex-shrink: 0;
}

.bill-card-amount {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    min-width: 5rem;
    text-align: right;
}

.bills-empty {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--color-text-muted);
}

.bills-empty p {
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

/* Bills view segmented control (All Bills / Per Period on bills/index.php;
   Accounts / Liabilities on register/index.php) — sits in its own row below
   the page header/tab strip (.bills-mobile-filter-row, ~5437 below), not next
   to the title, at every breakpoint. Both pages render this row the same way
   so the two instances resolve to identical computed CSS.
   Sliding-pill style approved 2026-07-30 (see preview/ui-preview.html slides
   58-60): one continuous capsule track (--color-border, matched to the
   Show Archived toggle's track color [2026-07-31] — the app-wide standard
   for segmented-pill tracks) with the active option rendered as a smaller,
   fully-rounded brand-blue pill floating inside
   it, replacing the old two-bordered-button hard-seam style. This is a shared
   component — pages/bills/index.php and pages/register/index.php both reuse
   these classes as-is, so this single restyle covers both. Both real toggles
   here are server-rendered <a href="?view=x"> links causing a full page
   navigation, not client-side radio-driven state like the preview's live
   demo — there is no DOM state to animate a thumb between across a page
   load, so only the static pill AESTHETIC is implemented (no slide
   transition on click). The `transition` below still animates hover/focus
   feedback within a single page view. */
.bills-view-segmented {
    display: flex;
    flex-shrink: 0;
    background: var(--color-border);
    border-radius: 99px;
    padding: 3px;
    gap: 2px;
}
.bills-seg-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 6px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    background: transparent;
    border: none;
    border-radius: 99px;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}
.bills-seg-btn--active {
    background: var(--color-brand-fill);
    color: var(--color-text-on-brand);
}
.bills-seg-btn:hover:not(.bills-seg-btn--active) {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

/* Global `a:hover { text-decoration: underline; }` (see top of file) does not
   share the text-decoration property with the rule above, so it wins on hover
   regardless of specificity — explicitly kill underline in every link state. */
.bills-seg-btn,
.bills-seg-btn:hover,
.bills-seg-btn:focus,
.bills-seg-btn:focus-visible,
.bills-seg-btn:active,
.bills-seg-btn:visited {
    text-decoration: none;
}

@media (max-width: 640px) {
    /* .page-header-title wraps (flex-wrap: wrap), so a full-width segmented
       control drops to its own line below the title on narrow phones while
       still living in the same title row container. */
    .bills-view-segmented {
        width: 100%;
    }
    .bills-seg-btn {
        flex: 1 1 0;
        justify-content: center;
        padding: 11px 12px;
        min-height: 44px;
        font-size: 0.875rem;
    }
}

/* ── Bills/Register filter row (segmented pill + Show Archived switch) ──
   Unified to ONE row at all breakpoints per the icon/method/layout parity
   rule (2026-07-31): "more horizontal space available" is not a legitimate
   reason to render this control differently on desktop vs. mobile. Sits
   directly below .page-tabs on bills/index.php, and directly below
   .page-header on register/index.php (which has no tab strip). Class name
   kept for continuity with slides 55/56 in preview/ui-preview.html even
   though it is no longer mobile-only, and is now shared by both pages. */
.bills-mobile-filter-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 1rem;
}
/* When there's no pay schedule, the segmented pill doesn't render and Show
   Archived is the row's only child — space-between would otherwise leave it
   flush left looking stray; push it to the end instead. */
.bills-mobile-filter-row--end {
    justify-content: flex-end;
}
/* The segmented control on this row is not full-width like the old
   title-row copy used to be — it shares the row with the archived switch. */
.bills-mobile-filter-row .bills-view-segmented {
    width: auto;
}
.bills-mobile-filter-row .bills-seg-btn {
    flex: initial;
    min-height: 36px;
    padding: 7px 12px;
    font-size: 0.8125rem;
}
.bills-archived-toggle-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.bills-archived-toggle-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
}

/* Period nav on bills page */
.bills-period-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.bills-period-label {
    flex: 1;
    text-align: center;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
}
.bills-period-label > .bills-period-dates { min-width: 0; }
/* Slot holds either the "Current" badge or the Jump-to-Current button so the
   row height is the same in both states. */
.bills-period-slot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
/* Jump to Current button: .period-nav-btn.period-nav-btn--current look, compact.
   Selector is scoped under .bills-period-nav so the 640px .period-nav-btn
   padding override (later in the file) does not inflate it. */
.bills-period-nav .period-jump-btn {
    position: relative;
    justify-content: center;
    gap: 5px;
    padding: 4px 10px;
    min-height: 32px;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1.4;
    box-sizing: border-box;
}
.period-jump-btn svg { flex: none; }
@media (max-width: 640px) {
    /* Phone: date stacked above the Current slot; 32px visual button with an
       invisible ::after that extends the tap area to 44px tall. */
    .bills-period-label {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 4px;
    }
    .bills-period-slot { min-height: 32px; }
    .bills-period-nav .period-jump-btn::after {
        content: "";
        position: absolute;
        left: -4px;
        right: -4px;
        top: -6px;
        bottom: -6px;
    }
}
.bills-period-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
}
.bill-period-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    gap: 12px;
}
.bill-period-row:last-child { border-bottom: none; }
.bill-period-row-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    flex-wrap: wrap;
}
.bill-period-row-name {
    font-weight: 500;
}
.bill-period-row-date,
.bill-period-row-cat {
    font-size: 0.8rem;
    color: var(--color-text-muted);
}
/* Budget-date tag row (F3, slide 187): own full-width line under the name/date inside the wrapping left group. */
.bill-period-row-tags {
    flex-basis: 100%;
    margin-top: 0;
}
.bill-period-row-amount {
    font-weight: 600;
    white-space: nowrap;
    color: var(--color-danger);
}
.bill-period-row-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Batch-select checkbox on unpaid Per Period rows (see assets/js/bills.js).
   Wrapped in a cell so the visible 16px checkbox (global input[type=checkbox]
   rule, ~line 882) gets a larger tap target on mobile without inflating its
   own visual size. */
.bill-period-row-check-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
@media (max-width: 640px) {
    .bill-period-row-check-cell {
        min-width: 44px;
        min-height: 44px;
    }
}

/* ── Parent bill rollup (Per Period view) ────────────────────────────────────
   Display-only summary header rendered above a parent bill's cluster of
   sub-bill rows within .bills-period-list (pages/bills/index.php). Purely
   informational — no action button. Three states via modifier class, reusing
   existing design tokens (brand for partial, success for fully paid, the
   existing --color-warning-* trio — already used by .budget-alert-banner —
   for zero-paid, since "not yet paid" isn't an error). Approved design:
   ui-preview.html slide 34. */
.bill-period-rollup {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    border-left: 3px solid var(--color-brand);
    background: var(--color-brand-bg-subtle);
}
.bill-period-rollup-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}
.bill-period-rollup-icon {
    flex-shrink: 0;
    color: var(--color-brand);
}
.bill-period-rollup-name {
    font-weight: 700;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
/* .bill-period-rollup-badge: hook only. Tone (badge--brand / --success / --warning) is set per
   state by PHP and bills.js; look lives on .badge — no colour rules here. */
.bill-period-rollup-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    flex-shrink: 0;
}
.bill-period-rollup-amount {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
}
.bill-period-rollup-bar {
    width: 88px;
    height: 5px;
    border-radius: 99px;
    background: var(--color-border);
    overflow: hidden;
}
/* Width set from data-pct via assets/js/bills.js (CSSOM write — inline
   style="" attributes are silently dropped by this app's CSP style-src). */
.bill-period-rollup-bar-fill {
    height: 100%;
    width: 0;
    background: var(--color-brand);
    transition: width var(--transition);
}

.bill-period-rollup--complete {
    border-left-color: var(--color-success);
    background: var(--color-success-bg);
}
.bill-period-rollup--complete .bill-period-rollup-icon { color: var(--color-success); }
.bill-period-rollup--complete .bill-period-rollup-amount { color: var(--color-success); }
.bill-period-rollup--complete .bill-period-rollup-bar-fill { background: var(--color-success); }

/* "Pay from Sinking Fund" action row — full-width, right-aligned, sits below
   the left/right summary line (requires .bill-period-rollup's flex-wrap above).
   Approved design: ui-preview.html slide 38. */
.bill-period-rollup-actions {
    flex-basis: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 10px;
}

.bill-period-rollup--none {
    border-left-color: var(--color-warning-border);
    background: var(--color-warning-bg);
}
.bill-period-rollup--none .bill-period-rollup-icon,
.bill-period-rollup--none .bill-period-rollup-name { color: var(--color-warning-text); }
.bill-period-rollup--none .bill-period-rollup-amount { color: var(--color-warning-text); }
.bill-period-rollup--none .bill-period-rollup-bar-fill { background: var(--color-warning-border); }

/* Sub-bill rows under a rollup header: continue the same left-accent color
   band down through the child rows so the whole group reads as one
   continuous colored block (approved design: ui-preview.html slide 62,
   "Option B — Shared Color Band"). Border color mirrors the parent
   .bill-period-rollup's state-specific border-left color exactly. Padding
   reduced from 28px to 25px to offset the new 3px border so row text still
   aligns with the parent rollup's own 3px-border + 14px-padding text start.
   Fully-paid rollups additionally dim their children — same treatment as
   .bill-card--inactive — since there's nothing left to act on. */
.bill-period-row--rollup-child {
    padding-left: 25px;
    border-left: 3px solid var(--color-brand);
}
.bill-period-row--rollup-state-complete { border-left-color: var(--color-success); }
.bill-period-row--rollup-state-none { border-left-color: var(--color-warning-border); }
.bill-period-row--rollup-complete-child { opacity: 0.85; }

@media (max-width: 640px) {
    .bill-period-rollup {
        flex-wrap: wrap;
    }
    .bill-period-rollup-right {
        align-items: flex-start;
        width: 100%;
    }
}

/* ── Batch action bar (Per Period view) ──────────────────────────────────────
   Appears once 1+ unpaid bill-period rows are checked (assets/js/bills.js).
   Same position:fixed + mobile-tab-bar-clearance mechanism as .sticky-save-bar
   (~line 1601) but centered to .page-container's wider max-width
   (--container-wide, 960px) since bills/index.php is a data page, not a
   --container-max (480px) form-card. Not a form-submit-button wrapper — it's
   toggled via the `hidden` attribute from JS based on checkbox selection
   count, independent of any single <form>. */
.batch-action-bar {
    position: fixed;
    left: 50%;
    bottom: 0;
    transform: translateX(-50%);
    width: 100%;
    max-width: var(--container-wide);
    box-sizing: border-box;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0;
    box-shadow: var(--shadow-bar);
}
.batch-action-bar[hidden] { display: none; }
.batch-action-bar-summary {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
}
.batch-action-bar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.batch-action-bar-actions .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.page-container:has(.batch-action-bar:not([hidden])) {
    padding-bottom: 96px;
}

/* :has() fallback (L6): pre-:has() browsers (e.g. Safari <15.4) can't react
   to the batch bar's [hidden] toggle at all, and the rule above is simply
   dropped (invalid selector). .page-has-batch-bar is the static marker class
   on bills/index.php's #bills-page wrapper — the only page that ever renders
   .batch-action-bar — so this gives those browsers an always-on clearance
   floor instead of zero clearance. Lower specificity (two classes) than the
   :has() rule above (class + :has(class + :not(attr))), so browsers that DO
   support :has() keep the precise conditional behavior; this only ever acts
   as the fallback floor. */
.page-container.page-has-batch-bar {
    padding-bottom: 96px;
}

@media (prefers-color-scheme: dark) {
    .batch-action-bar { box-shadow: var(--shadow-bar-dark); }
}

@media (max-width: 640px) {
    .batch-action-bar {
        left: 0;
        bottom: calc(56px + env(safe-area-inset-bottom, 0));
        transform: none;
        width: 100%;
        max-width: 100%;
        border-radius: 0;
        flex-wrap: wrap;
    }
    .batch-action-bar-actions {
        width: 100%;
    }
    .batch-action-bar-actions .btn {
        flex: 1 1 0;
        min-height: 44px;
    }
    .page-container:has(.batch-action-bar:not([hidden])) {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 96px);
    }
    /* :has() fallback (L6) — mobile floor, mirrors the desktop fallback
       above; still clears both the batch bar AND the mobile tab bar. */
    .page-container.page-has-batch-bar {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 96px);
    }
}

/* ── Batch confirm modal (paid / transfer groups) ────────────────────────────
   Third modal instance sharing the same fixed/centered backdrop shape as
   #mark-paid-backdrop and #bill-scope-backdrop (see those blocks) — same
   .is-open toggle mechanism, own ID pair since backdrop/box positioning is
   boilerplate per modal in this file. Header/title/close/actions/error reuse
   the existing class-scoped .mark-paid-* rules directly (those are classes,
   not #mark-paid-* ids, so they already apply here with no duplication). */
#batch-confirm-backdrop {
    position: fixed;
    inset: 0;
    background: var(--color-backdrop);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}
#batch-confirm-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}
#batch-confirm-modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px 28px 24px;
    transform: translateY(8px);
    transition: transform 0.2s ease;
}
#batch-confirm-backdrop.is-open #batch-confirm-modal {
    transform: translateY(0);
}
.batch-confirm-list {
    max-height: 220px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}
.batch-confirm-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.875rem;
}
.batch-confirm-item:last-child { border-bottom: none; }
.batch-confirm-item-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.batch-confirm-item-amount {
    font-weight: 600;
    color: var(--color-text-muted);
    flex-shrink: 0;
}
.batch-confirm-total {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.875rem;
    padding: 8px 12px 0;
}

@media (max-width: 640px) {
    #batch-confirm-modal {
        padding: 20px 16px 16px;
    }
}

.bills-period-footer {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    padding: 4px 0 12px;
}
.bills-empty-text {
    color: var(--color-text-muted);
    padding: 24px 0;
    text-align: center;
}

/* Bills page footer totals */
.bills-page-footer {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.875rem;
    color: var(--color-text-muted);
    padding: 12px 0;
    border-top: 1px solid var(--color-border);
    margin-top: 16px;
}

/* Living Expenses section on bills page */
.bills-alloc-section {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 2px solid var(--color-border);
}
.bills-alloc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.bills-alloc-heading {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0;
}
.alloc-list {
    margin-bottom: 8px;
}
.alloc-item {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 6px;
    overflow: hidden;
}
.alloc-item-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 0.875rem;
    min-height: 44px;
}
.alloc-item-form .alloc-name-input {
    flex: 1;
    min-width: 0;
}
.alloc-item-form .alloc-amount-input {
    width: 6rem;
}
.alloc-item-name {
    flex: 1;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
}
.alloc-item-amount {
    font-variant-numeric: tabular-nums;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
    min-width: 5rem;
    text-align: right;
}
.alloc-item-actions {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    margin-left: 0.5rem;
}
.alloc-add-form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 12px;
    padding: 0.75rem 0.875rem;
}
.alloc-add-fields {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.alloc-projection-link {
    display: inline-block;
    margin-top: 0.75rem;
}
.bills-alloc-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* Bills page: section-level alloc edit mode */
.bills-alloc-section .alloc-edit-el { display: none; }
.bills-alloc-section.alloc-edit-mode .alloc-edit-el { display: block; }
.bills-alloc-section.alloc-edit-mode .drag-handle--alloc.alloc-edit-el { display: inline-flex; }
.bills-alloc-section.alloc-edit-mode .alloc-item-actions.alloc-edit-el { display: flex; }
.bills-alloc-section.alloc-edit-mode .alloc-display-el { display: none; }

@media (max-width: 640px) {
    .alloc-item-form {
        gap: 0.375rem;
        padding: 0.625rem 0.75rem;
    }
    .alloc-item-amount {
        min-width: 4rem;
    }
    .alloc-item-actions {
        gap: 0.25rem;
    }
    .alloc-fund-row {
        padding: 0.5rem 0.75rem 0.625rem;
    }
    .alloc-add-fields {
        flex-direction: column;
        align-items: stretch;
    }
    .alloc-add-fields .alloc-name-input,
    .alloc-add-fields .alloc-amount-input {
        width: 100%;
    }
}

/* Living Expenses total row */
.alloc-total-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0 4px;
    margin-top: 4px;
    border-top: 2px solid var(--color-border);
}
.alloc-total-label {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
}
.alloc-total-amount {
    font-size: 0.9375rem;
    font-weight: 700;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
    min-width: 5rem;
    text-align: right;
}

/* Overview alloc reorder section */
.period-alloc-reorder-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}
.period-alloc-reorder-header .period-section-title {
    flex: 1;
    font-weight: 600;
}
.alloc-proj-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}
.alloc-proj-row:last-child { border-bottom: none; }
.alloc-proj-name { flex: 1; }
.alloc-proj-amount { font-weight: 500; color: var(--color-text-muted); }

/* Alloc drag handles: hidden by default on overview (shown in edit mode) */
.sortable-allocs-proj .drag-handle--alloc {
    display: none;
    cursor: grab;
}
.sortable-allocs-proj.alloc-edit-mode .drag-handle--alloc {
    display: flex;
}

@media (max-width: 640px) {
    .bill-card {
        padding: 0.75rem;
    }
    .bill-card-amount {
        font-size: 0.95rem;
        min-width: 4rem;
    }
    .bill-card-category,
    .bill-card-dot--category,
    .bill-card-rule,
    .bill-card-dot--rule {
        display: none;
    }
}

/* ── Page utilities ──────────────────────────────────────────────────────────── */

.page-subtitle {
    font-size: 0.875rem;
    color: var(--color-text-muted);
    margin-top: 0.2rem;
}

/* When a subtitle sits inside the flex-wrap .page-header-title row (e.g.
   alongside an h1 and a mobile overflow-menu trigger), force it onto its
   own line rather than floating beside the title. */
.page-header-title .page-subtitle {
    flex-basis: 100%;
    margin-top: 0;
}

/* ── Page tabs ───────────────────────────────────────────────────────────────── */

.page-tabs {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.5rem;
    gap: 12px;
}

.page-tabs-links {
    display: flex;
    gap: 0;
    min-width: 0;
}

/* Add Bill + reorder (Edit) actions inline with the tab row — shown at all
   breakpoints so mobile gets the same "actions live next to the tabs"
   layout as desktop (compact button sizing handles the tighter width). */
.page-tabs-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 0;
}

/* Edit / + Add Bill sit inline with the tab row — default .btn-sm padding
   reads as too tall/heavy next to the bare tab labels, so trim it here
   (scoped to this row only, not a global .btn-sm change). */
.page-tabs-actions .btn {
    padding: 5px 10px;
    font-size: 0.78rem;
    min-height: 30px;
}

.page-tab {
    padding: 0.6rem 1.1rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color var(--transition), border-color var(--transition);
    white-space: nowrap;
}

.page-tab:hover {
    color: var(--color-text);
}

.page-tab--active {
    color: var(--color-brand);
    border-bottom-color: var(--color-brand);
    font-weight: 600;
}

/* Pay Schedule tab strip (components/pay_schedule_tabs.php) — small
   modifiers on the shared .page-tab: the primary schedule's tab gets a small star suffix, and the
   trailing "+ Add" tab reads a bit heavier so it doesn't look like just
   another schedule name. */
.page-tab-primary-star {
    font-size: 0.7em;
    margin-left: 2px;
    opacity: 0.85;
}

.page-tab-add {
    font-weight: 700;
}

@media (max-width: 640px) {
    /* Tabs + actions (Edit / + Add Bill) stay on one row on mobile — compact
       tab and button sizing makes room instead of wrapping to a second line. */
    .page-tabs {
        flex-wrap: nowrap;
        gap: 6px;
    }
    .page-tabs-links {
        gap: 0;
        flex-shrink: 1;
        overflow-x: auto;
        scrollbar-width: none;
    }
    .page-tabs-links::-webkit-scrollbar {
        display: none;
    }
    .page-tab {
        padding: 0.5rem 0.5rem;
        font-size: 0.8rem;
    }
    .page-tabs-actions {
        flex-shrink: 0;
        gap: 6px;
    }
    .page-tabs-actions .btn {
        padding: 6px 10px;
        font-size: 0.75rem;
        min-height: 38px;
        white-space: nowrap;
    }
}

/* ── Tabbed form page [2026-09-20] — bills/edit.php + bills/create.php ───────────
   Approved via preview/ui-preview.html slide 125 (Variant B). Extends the shared
   .page-tabs/.page-tab look for IN-FORM panels instead of forking it: the strip
   is <div class="page-tabs page-tabs--form"> with role=tablist on .page-tabs-links
   and each tab a <button role="tab" class="page-tab"> (buttons, not links — the
   panels are same-page). Behaviour lives in assets/js/form-tabs.js. Inactive
   panels use the `hidden` attribute, so their inputs still submit with the form.
   The strip draws its baseline as an inset shadow on the scroll container (not a
   negative-margin border) so the active underline is not clipped by overflow-x. */
.page-tabs--form {
    border-bottom: 0;
    margin-bottom: 1.25rem;
    gap: 0;
}

.page-tabs--form .page-tabs-links {
    flex: 1;
    overflow-x: auto;
    scrollbar-width: none;
    box-shadow: inset 0 -2px 0 var(--color-border);
}

.page-tabs--form .page-tabs-links::-webkit-scrollbar {
    display: none;
}

.page-tabs--form .page-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    margin-bottom: 0;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    cursor: pointer;
}

.page-tabs--form .page-tab--active {
    border-bottom-color: var(--color-brand);
}

.page-tabs--form .page-tab:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: -2px;
}

/* Error dot on a tab whose panel holds an invalid / server-error field. */
.page-tab-error {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-error);
    flex-shrink: 0;
}

.page-tab-error[hidden] {
    display: none;
}

.form-tab-panel[hidden] {
    display: none;
}

/* Read-only fact line at the top of a panel (e.g. "Started Jul 3, 2026 ..."). */
.form-tab-caption {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin: 0 0 14px;
}

@media (max-width: 640px) {
    .page-tabs--form .page-tab {
        flex: 1 0 auto;
        justify-content: center;
        padding: 0.5rem 0.4rem;
        font-size: 0.8rem;
    }
}

/* Page shell WITHOUT an outer .form-card [2026-09-20, approved slides 125/126]:
   <div class="form-page"><div class="form-page-body form-page-body--wide"> ... The
   back link, header row, tab strip, Save bar and danger zone sit on the page
   background; the tabbed area (.form-tabs = strip + panels) is the only card.
   Desktop: .form-tabs is one surface card (slide 125), Save is a bare full-width
   button in flow below it. Mobile: no card at all around the strip; each panel is a
   full-bleed surface band with top/bottom rules (slide 125 phone), and the fixed
   Save bar (.sticky-save-bar's own mobile rules) sits flush above the tab bar.
   Other pages still use .form-card — none of these selectors touch it. */
.form-page-body {
    width: 100%;
    min-width: 0;
    max-width: var(--container-max);
}

.form-page-body .register-back-link {
    margin-bottom: 16px;
}

.form-page-body .form-card-title-row {
    margin-bottom: 16px;
}

@media (min-width: 641px) {
    .form-page-body--wide {
        max-width: 680px;
    }

    .form-tabs {
        background-color: var(--color-surface);
        border-radius: var(--radius);
        box-shadow: var(--shadow-card);
        padding: 0 24px 8px;
    }

    /* Bar is in flow on page background here: drop the surface fill and the divider
       rule the in-card version used. */
    .form-page-body .sticky-save-bar {
        background-color: transparent;
        border-top: 0;
        margin-top: 24px;
        padding: 0;
    }
}

@media (max-width: 640px) {
    .form-page-body {
        max-width: 100%;
        padding: 20px 16px;
    }

    /* Reserve room under the fixed Save bar + mobile tab bar (same amount the
       .form-card:has(.sticky-save-bar) rule reserves). */
    .form-page-body:has(.sticky-save-bar) {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 96px);
    }

    .page-tabs--form {
        margin-bottom: 12px;
    }

    /* Panel = full-bleed band: negative margin cancels the body's 16px gutter, so
       the band reaches both viewport edges without causing horizontal scroll. */
    .form-tabs .form-tab-panel {
        background-color: var(--color-surface);
        border-top: 1px solid var(--color-border);
        border-bottom: 1px solid var(--color-border);
        margin-left: -16px;
        margin-right: -16px;
        padding: 16px 16px 4px;
    }
}

/* Single-tab page [2026-09-21, B-02 / slide 142 open question 1]: a tabbed page that ends up
   with only one tab (Add Sub-Account, editing a system sub-account) renders NO strip — the
   .form-tabs root simply has no [data-form-tabs] and its lone panel carries no tab
   semantics. With no strip to open the card, give the desktop card top padding of its own.
   Mobile needs nothing: the full-bleed panel band already has its own padding. */
@media (min-width: 641px) {
    .form-tabs--single {
        padding-top: 24px;
    }
}

/* Header status cluster: Active switch (+ Archived badge) at the right of the
   title row. Reuses .form-card-title-row for the row itself. The switch is a real
   checkbox (role=switch) so it still submits like any checkbox; the track is CSS. */
.form-status {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

/* .form-status-badge: hook only (badge badge--neutral badge--caps) — look lives on .badge. */

.form-status-switch {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
    cursor: pointer;
}

.form-status-switch .form-status-switch-input {
    position: absolute;
    right: 0;
    width: 44px;
    height: 24px;
    margin: 0;
    opacity: 0;
    cursor: pointer;
}

.form-status-switch-track {
    position: relative;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    background: var(--color-border);
    border-radius: 99px;
    transition: background var(--transition);
}

.form-status-switch-track::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--color-surface);
    border-radius: 99px;
    box-shadow: 0 1px 3px var(--shadow-knob);
    transition: transform 0.18s ease;
}

.form-status-switch-input:checked + .form-status-switch-track {
    background: var(--color-brand);
}

.form-status-switch-input:checked + .form-status-switch-track::after {
    transform: translateX(20px);
}

.form-status-switch-input:focus-visible + .form-status-switch-track {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

.form-status-switch-input:disabled,
.form-status-switch-input:disabled + .form-status-switch-track {
    cursor: not-allowed;
}

.form-status-switch-input:disabled + .form-status-switch-track {
    opacity: 0.5;
}

/* Inline reveal: a setting that only matters when the checkbox above it is on
   (e.g. Sinking Fund -> Savings Account). Indented with a left rule; replaces an
   accordion whose only job was hiding one dependent field. */
.form-reveal {
    margin: 8px 0 4px 8px;
    padding: 4px 0 4px 16px;
    border-left: 2px solid var(--color-brand-ring);
    align-self: stretch;
}

/* Structure panel: title + hint on the left, one action on the right. Shared by the
   Bill structure rows and the danger-zone rows (danger rows are <form>s). */
.form-action-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 12px 0;
    border-top: 1px solid var(--color-border);
}

.form-action-row-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.form-action-row-desc {
    display: block;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-top: 1px;
}

.form-action-row .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

.form-action-row-buttons {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Open state of a row's panel-toggle button. */
.form-action-row .btn[aria-expanded="true"],
.form-struct-actions .btn[aria-expanded="true"] {
    background-color: var(--color-brand-bg-subtle);
}

.form-struct-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.form-struct-head p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* .form-struct-pill(--brand): hooks only (badge badge--neutral, or badge--brand for the --brand
   variant) — look lives on .badge. */

.form-struct-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.form-sublist {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
}

.form-sublist-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 14px;
    font-size: 0.875rem;
    border-top: 1px solid var(--color-border);
}

.form-sublist-row:first-child {
    border-top: 0;
}

.form-sublist-row span {
    color: var(--color-text-muted);
}

.form-sublist-row--total {
    background: var(--color-surface-alt);
    font-weight: 600;
}

.form-sublist-row--total span {
    color: var(--color-text);
}

/* Inline ACTION panel opened from a Structure row (its own Cancel + confirm; holds
   no persistent settings — NOT a collapsible section). Closed = .u-hidden. */
.form-panel {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin: 2px 0 14px;
}

.form-panel-title {
    font-size: 0.875rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.form-panel-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.btn-ghost {
    background-color: transparent;
    color: var(--color-text-muted);
    border-color: transparent;
}

.btn-ghost:hover {
    color: var(--color-text);
    background-color: var(--color-brand-bg-subtle);
    text-decoration: none;
}

/* Danger zone: Archive/Unarchive + Delete, at the very bottom (after Save). Border
   only, no shadow (ghost-card rule). Supersedes .form-delete-section on converted
   pages. Each row is its own <form> (data-confirm on the form, unchanged). */
.form-danger-zone {
    border: 1px solid var(--color-error-border);
    border-radius: var(--radius);
    padding: 14px 20px 4px;
    margin-top: 32px;
}

.form-danger-zone-title {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-error);
    margin-bottom: 6px;
}

@media (max-width: 640px) {
    .form-danger-zone {
        padding: 14px 16px 4px;
        margin-top: 24px;
    }

    .form-action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .form-action-row .btn {
        width: 100%;
    }

    .form-action-row-buttons {
        flex-direction: column;
    }

    .form-struct-actions .btn {
        flex: 1 1 100%;
    }

    .form-struct-head {
        align-items: flex-start;
    }

    /* Sub-bill name links: 44px tap target inside the 44px-tall row. */
    .form-sublist-row {
        align-items: center;
    }

    .form-sublist-row a {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        margin: -9px 0;
    }
}

/* ── Period nav controls ─────────────────────────────────────────────────────── */

.period-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.period-col-picker {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.period-col-picker-label {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-right: 0.25rem;
}

.period-col-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.period-col-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.period-col-btn--active {
    background: var(--color-brand-fill);
    border-color: var(--color-brand-fill);
    color: var(--color-text-on-brand);
}

.period-nav-buttons {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.period-nav-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.period-nav-btn:hover:not(.period-nav-btn--disabled) {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.period-nav-btn--disabled {
    opacity: 0.4;
    pointer-events: none;
}

.period-nav-btn--current {
    border-color: var(--color-brand);
    color: var(--color-brand);
}

.period-nav-btn--current:hover:not(.period-nav-btn--disabled) {
    background: var(--color-brand-fill);
    color: var(--color-text-on-brand);
}

/* ── Allocation rows (budget edit) ───────────────────────────────────────────── */

.alloc-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.drag-handle--alloc {
    width: 20px;
    height: 32px;
    flex-shrink: 0;
    cursor: grab;
    color: var(--color-text-muted);
    opacity: 0.4;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: opacity var(--transition);
    touch-action: none;
}

.drag-handle--alloc:hover {
    opacity: 1;
    color: var(--color-brand);
}

.drag-handle--alloc:active {
    cursor: grabbing;
}

/* Scoped to .alloc-row (not bare .alloc-name-input/.alloc-amount-input):
   the global `input[type="number"]` reset rule (line ~783) has specificity
   (0,1,1) — one attribute selector + one type selector — which beats a bare
   single-class selector like `.alloc-amount-input` (0,1,0). Without the
   `.alloc-row` ancestor, the amount input's `width: 100%` from the reset
   rule wins over `width: 110px` here, so the amount field balloons to fill
   the row and the name field (flex-basis: 0%) collapses to near-zero width.
   Scoping to `.alloc-row .alloc-amount-input` (0,2,0) reliably outranks the
   reset rule regardless of source order. */
.alloc-row .alloc-name-input {
    flex: 1;
    min-width: 0;
}

.alloc-row .alloc-amount-input {
    width: 110px;
    flex-shrink: 0;
    text-align: right;
}

@media (max-width: 640px) {
    .period-controls {
        gap: 0.5rem;
    }
    .period-col-picker {
        display: none;
    }
    /* Columns picker is hidden here, so the label is the row's own line when it
       wraps away from the nav buttons — stretch it full-width so its existing
       text-align: center actually centers it instead of hugging the left edge. */
    .period-controls .summary-period-label {
        flex: 1 1 100%;
    }
}

/* ── Budget period view ──────────────────────────────────────────────────────── */

.period-no-schedule {
    text-align: center;
    padding: 4rem 1rem;
    color: var(--color-text-muted);
}

.period-no-schedule-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 1rem;
    color: var(--color-text-muted);
}

.period-no-schedule-icon svg {
    width: 100%;
    height: 100%;
}

.period-no-schedule h2 {
    font-size: 1.1rem;
    color: var(--color-text);
    margin-bottom: 0.5rem;
}

.period-no-schedule p {
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    max-width: 32rem;
    margin-left: auto;
    margin-right: auto;
}

/* ── Unified empty state component ─────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 40px 24px;
    gap: 12px;
}

.empty-state-icon {
    font-size: 2rem;
    opacity: 0.45;
    line-height: 1;
}

.empty-state p {
    color: var(--color-text-muted);
    font-size: 0.9rem;
    max-width: 260px;
    line-height: 1.5;
}

.empty-state .btn {
    margin-top: 4px;
}

.period-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    margin-bottom: 1rem;
}

.period-table {
    min-width: 520px;
    width: 100%;
}

.period-table--cols-1 {
    min-width: 0;
}

.period-table--cols-1 .period-cell:not(.period-cell--label) {
    text-align: left;
    padding-left: 0.75rem;
}

.period-table--cols-1 .period-cell--head {
    align-items: flex-start;
}

/* Every row is a flex container */
.period-row {
    display: flex;
    border-bottom: 1px solid var(--color-border);
}

.period-row:last-child {
    border-bottom: none;
}

.period-row--last-in-group {
    border-bottom: 2px solid var(--color-border);
}

.period-cell {
    flex: 1;
    padding: 0.5rem 1rem;
    text-align: right;
    font-size: 0.875rem;
    font-variant-numeric: tabular-nums;
    color: var(--color-text);
}

.period-cell--label {
    flex: 0 0 170px;
    text-align: left;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    padding-left: 1rem;
}

/* Header row: period date ranges */
.period-row--header {
    background: var(--color-bg-secondary);
    border-bottom: 2px solid var(--color-border);
}

.period-cell--head {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--color-text);
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 2px;
}

.period-cell--head--current {
    background: var(--color-brand-bg-subtle);
}

.period-head-range {
    white-space: nowrap;
}

.period-head-override {
    color: var(--color-brand);
    font-size: 0.9rem;
    cursor: help;
}

/* Section labels (Income, Bills, Allocations) */
.period-row--section-label {
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
}

.period-row--section-label .period-cell--label {
    border-left: 3px solid var(--color-brand);
    padding-left: calc(1rem - 3px);
}

.period-section-title {
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
}

/* Sub-rows: individual bills and allocations */
.period-row--sub {
    background: var(--color-bg);
}

.period-cell--sub {
    padding-left: 1.75rem;
    font-size: 0.82rem;
}

/* Total rows */
.period-row--total .period-cell--label {
    font-weight: 600;
    color: var(--color-text);
}

.period-row--total .period-cell {
    font-weight: 600;
}

/* Highlight rows: key waterfall checkpoints */
.period-row--highlight {
    background: var(--color-brand-bg-subtle);
    border-top: 1px solid var(--color-brand-ring);
    border-bottom: 1px solid var(--color-brand-ring);
}

.period-cell--highlight-label {
    font-weight: 700;
    color: var(--color-text) !important;
}

/* Spending row — the bottom line */
.period-row--spending {
    background: var(--color-brand-bg-strong);
    border-top: 2px solid var(--color-brand);
}

.period-cell--spending-label {
    font-weight: 700;
    color: var(--color-text) !important;
    font-size: 0.95rem !important;
}

.period-rate {
    font-size: 0.75em;
    color: var(--color-text-muted);
    margin-left: 0.25em;
}

/* Value styles */
.period-val--pos {
    color: var(--color-success);
}

.period-val--deduct {
    color: var(--color-error);
}

/* Committed deductions (Tithe) — known, not a deficit */
.period-val--committed {
    color: var(--color-text-muted);
}

/* Summary totals — stronger than line items */
.period-val--summary {
    color: var(--color-text);
    font-weight: 700;
}

.period-val--key {
    font-weight: 700;
    color: var(--color-text);
}

.period-val--spending {
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-success);
}

.period-val--neg {
    color: var(--color-error) !important;
}
/* B-26: dark --color-error (#e06050) on the brand-tinted checkpoint / spending
   rows measured ~3.99:1 (< 4.5:1). Dark theme only: lift the negative figure
   toward the theme's body text colour (both existing tokens, no new token). */
[data-theme="dark"] .period-val--neg {
    color: color-mix(in srgb, var(--color-error) 75%, var(--color-text)) !important;
}

.period-val--none {
    color: var(--color-text-muted);
    font-size: 0.85em;
}

.period-section-manage {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--color-brand);
    margin-left: 0.5rem;
    text-decoration: none;
    opacity: 0.8;
}

.period-section-manage:hover {
    opacity: 1;
    text-decoration: underline;
}

.period-head-past {
    font-size: 0.68rem;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.period-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
}

/* Reorder button (formerly "Edit Order") inside section label row */
.alloc-reorder-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: center;
    flex-shrink: 0;
    margin: 0 0.5rem;
    padding: 0.25rem 0.6rem;
    min-height: 36px;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}

.alloc-reorder-btn svg {
    flex-shrink: 0;
}

.alloc-reorder-btn:hover {
    background: var(--color-bg-secondary);
    color: var(--color-text);
    border-color: var(--color-text-muted);
}

/* Income override toggle — active state (override currently set) */
.income-override-toggle--active {
    border-color: var(--color-brand);
    color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
}

/* Small asterisk badge next to overridden income values */
.income-override-badge {
    display: inline-block;
    margin-left: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--color-brand);
    vertical-align: super;
    line-height: 1;
    cursor: default;
}

/* Inline income override form panel */
.income-override-panel {
    margin: 0.25rem 0.75rem 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.override-form-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.override-label {
    width: 6rem;
    flex-shrink: 0;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    font-weight: 500;
}

.override-input {
    flex: 1;
    padding: 0.35rem 0.5rem;
    font-size: 0.875rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-bg);
    color: var(--color-text);
    min-width: 0;
}

.override-input:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-ring);
}

.override-form-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.625rem;
    flex-wrap: wrap;
}

.income-override-cancel {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    text-decoration: none;
    margin-left: 0.25rem;
}

.income-override-cancel:hover {
    color: var(--color-text);
    text-decoration: underline;
}

/* Empty allocations note */
.period-empty-note {
    color: var(--color-text-muted);
}

/* Allocation management section on overview page */
.period-alloc-section {
    margin-top: 1.75rem;
    padding-top: 1.25rem;
    border-top: 2px solid var(--color-border);
}

.period-alloc-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 0.25rem;
}

.period-alloc-desc {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 0.875rem;
}

@media (max-width: 640px) {
    /* Period table: tighter cells, horizontal scroll already handled by wrapper */
    .period-cell {
        padding: 0.4rem 0.5rem;
        font-size: 0.78rem;
    }
    .period-cell--label {
        flex: 0 0 105px;
        font-size: 0.78rem;
        padding-left: 0.5rem;
    }
    .period-cell--sub {
        padding-left: 1rem;
    }
    .period-val--spending {
        font-size: 0.875rem;
    }
    /* Period controls: stack on very narrow screens */
    .period-controls {
        gap: 0.625rem;
    }
    /* Alloc row: wrap inputs on mobile */
    .alloc-row {
        flex-wrap: wrap;
    }
    .alloc-row .alloc-name-input {
        flex: 1 1 100%;
    }
    .alloc-row .alloc-amount-input {
        flex: 1;
        width: auto;
    }
    /* Period alloc section: full width */
    .period-alloc-section {
        margin-top: 1.25rem;
    }
    /* Touch targets */
    .period-col-btn {
        min-width: 44px;
        min-height: 44px;
    }
    .period-nav-btn {
        padding: 0.65rem 0.875rem;
    }
    .alloc-reorder-btn {
        min-height: 44px;
        padding: 0.5rem 0.75rem;
    }
    /* Force single-card layout on mobile (belt-and-suspenders with JS redirect) */
    .card-row > .budget-statement-card {
        width: 100%;
        flex: none;
        max-width: 100%;
    }
}

/* ── Budget Statement Cards (overview page) ────────────────────────────────── */

/* Base card */
.budget-statement-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}

/* Vertical Stack Redesign [2026-09-04], slide 87: .card-single now doubles
   as the ALWAYS-ON vertical period feed at every breakpoint (replaces the
   old side-by-side .card-row grid that used to apply at cols=2/3 on
   desktop) — flex column + gap instead of relying on default block-flow
   stacking, so multiple periods (cols=2/3 still controls how many are
   fetched/shown) get consistent breathing room between cards. */
.card-single {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.card-single .budget-statement-card {
    max-width: 520px;
    width: 100%;
    margin: 0;
}

/* Card header */
.bs-card-header {
    background: var(--color-brand-bg-subtle);
    border-bottom: 2px solid var(--color-brand-ring);
    padding: 1rem 1.25rem 0.875rem;
}

.bs-card-eyebrow {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-brand);
    margin-bottom: 0.15rem;
}

.bs-card-period {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-text);
}

.bs-card-meta {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 0.15rem;
}

/* Card body sections */
.bs-section {
    padding: 0.5rem 0;
}

.bs-section-label {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    padding: 0.5rem 1.25rem 0.35rem;
    gap: 0.5rem;
}

/* Real element (not ::after) so trailing content — e.g. the Sync Bills
   button on the "Bills" heading — can be placed AFTER the divider line in
   DOM order and still render at the far right. Any inline toggle that
   already sat between the label text and the divider (Income's Override
   toggle, Living Expenses' Reorder) keeps its exact spot by staying
   before this span in markup — only content placed after it moves past
   the line. Visual output is identical to the old ::after everywhere this
   span is inserted immediately after .bs-section-label-text. */
.bs-section-label-divider {
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

.bs-section-label-text {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.bs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.35rem 1.25rem;
    font-size: 0.875rem;
    color: var(--color-text);
}

.bs-row-label {
    color: var(--color-text-muted);
}

.bs-row-date {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.bs-row-date {
    opacity: 0.75;
    margin-left: 4px;
}

.bs-row-value {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Wraps a .btn-mark-paid trigger + .bs-row-value together on rows that carry
   an inline action (bill "Mark Paid"/"Mark Xfer", Save/Spending Money "Save"/
   "Fund" quick-transfer pills) so both sit flush right as one group. */
.bs-row-value-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    min-width: 0;
}


/* Checkpoint row (subtotal / balance after income) */
.bs-row--checkpoint {
    background: var(--color-brand-bg-subtle);
    border-top: 1px solid var(--color-brand-ring);
    border-bottom: 1px solid var(--color-brand-ring);
    padding-top: 0.55rem;
    padding-bottom: 0.55rem;
    margin: 0.15rem 0;
}

.bs-row--checkpoint .bs-row-label {
    font-weight: 700;
    color: var(--color-text);
}

.bs-row--checkpoint .bs-row-value {
    font-size: 1rem;
    font-weight: 700;
}

/* Small muted hint line under a checkpoint row's label (where the number comes
   from / what it means): used by the footer rows (.bs-row--hinted, below the
   paycheck timeline section). */
.bs-row-hint {
    display: block;
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.35;
    /* B-26: plain --color-text-muted on the brand-tinted checkpoint background
       was ~4.4:1 (light) / ~4.0:1 (dark) at this size, under the 4.5:1 floor.
       No intermediate token exists, so this blends two EXISTING tokens (no new
       token); 85% muted keeps it clearly quieter than the label (>= 4.5:1 in
       both themes, measured in headless Chrome). */
    color: color-mix(in srgb, var(--color-text-muted) 85%, var(--color-text));
    margin-top: 1px;
}

/* Spending row (bottom-line result) */
.bs-row--spending {
    background: var(--color-brand-bg-strong);
    border-top: 2px solid var(--color-brand);
    padding: 0.85rem 1.25rem;
    margin-top: 0.1rem;
}

.bs-row--spending .bs-row-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--color-text);
}

.bs-row--spending .bs-row-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--color-success);
}

/* Child bill row (indented label, muted to show subordinate hierarchy) */
.bs-row--child .bs-row-label {
    padding-left: 1.25rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

/* Paycheck Timeline / Bill Planner [2026-09-04] — a bill line item manually
   moved to a non-natural pay period (bill_instances.planned_pay_period_id
   override). Reuses the app's established left-accent-border convention for
   "this row's state/placement was manually decided" (see
   .bill-period-row--rollup-child / .bill-period-row--rollup-state-* above)
   rather than inventing a new visual language — padding-left is reduced by
   the border's own width so label text still lines up with a non-overridden
   row's text start. */
.bs-row--overridden {
    border-left: 3px solid var(--color-brand);
    padding-left: calc(1.25rem - 3px);
}

/* Move/reset icon-button cluster (Paycheck Timeline / Bill Planner), rebalanced
   [2026-09-30, slide 165 option A]: a bordered square button with a 16px
   stroke-2.5 chevron (28px box on desktop, 32px on phones), 28%-brand border /
   5%-brand fill (reset: 12% fill, 60% border), 12px gap between buttons. The
   44px touch target is an invisible ::after (6px out on every side) so the
   visible box can stay small; the 12px gap makes neighbours' hit areas abut
   without overlapping. Sits on the bill row's action line (left), see the
   "Income block expanded body" rules below. */
.bs-move-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid color-mix(in srgb, var(--color-brand) 28%, var(--color-border));
    background: color-mix(in srgb, var(--color-brand) 5%, var(--color-surface));
    color: var(--color-brand);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color var(--transition), color var(--transition), border-color var(--transition);
}

.bs-move-btn::after {
    content: "";
    position: absolute;
    inset: -6px;
}

.bs-move-btn svg {
    width: 16px;
    height: 16px;
    stroke-width: 2.5;
    flex-shrink: 0;
}

.bs-move-btn:hover {
    background: color-mix(in srgb, var(--color-brand) 12%, var(--color-surface));
    border-color: var(--color-brand);
}

.bs-move-btn:disabled {
    opacity: 0.35;
    cursor: default;
    pointer-events: none;
}

/* The row's "Move to another paycheck or income" icon: stays hoverable when
   disabled (view-only period) so its "View only" title still shows. */
.bs-move-open:disabled {
    pointer-events: auto;
}

@media (max-width: 640px) {
    /* Touch-target floor: 32px visible box + the 44px ::after hit area above
       (was a 44px visible box). Placed after the unconditional .bs-move-btn
       rules so it wins the cascade at equal specificity. */
    .bs-move-btn {
        width: 32px;
        height: 32px;
    }

    /* .bs-income-toggle-btn is a whole row acting as one tap target (the
       Primary/Secondary schedule collapse/expand toggle) — its unmodified .bs-row
       padding (0.35rem) is well under the 44px floor. */
    .bs-income-block--collapsible .bs-income-toggle-btn {
        min-height: 44px;
    }
}

/* ── Merged Income card (Vertical Stack Redesign, slide 89; slide 148) ───────
   EVERY schedule's block (Primary and each Secondary) carries
   .bs-income-block--collapsible plus the .collapsed state class — same
   single-class-toggle convention as .account-group/.collapsed: one class
   flips both the chevron rotation and which content shows, no dual-DOM-swap
   needed. Primary renders expanded on load; Secondary renders collapsed.

   Visual look [2026-09-30, slides 163-165]: every block shares one tinted
   shape whose shade/stripe come from its data-step (glossary "Income Block
   Colour Steps"); this supersedes the slide-145/148 Primary-outline vs
   Secondary-tint split. */
/* Income block colour steps [2026-09-30, preview slides 163-164, glossary
   "Income Block Colour Steps"]. Blocks are numbered by display position
   (data-step 1..4, 5th+ = 4, set in overview.php after sorting by first paycheck).
   Every block gets the same tinted look: --ib-shade (10/20/30/40% brand over
   surface) fill + a 4px --ib-stripe left stripe (35/55/75/100%); Primary is
   marked by the .schedule-primary-badge only, not by a different border. */
.bs-income-block {
    --ib-shade: var(--income-shade-1);
    --ib-stripe: var(--income-stripe-1);
    border-radius: var(--radius-sm);
    background: var(--ib-shade);
    border: 1px solid color-mix(in srgb, var(--color-brand) 30%, var(--color-border));
    border-left: 4px solid var(--ib-stripe);
}
.bs-income-block[data-step="2"] { --ib-shade: var(--income-shade-2); --ib-stripe: var(--income-stripe-2); }
.bs-income-block[data-step="3"] { --ib-shade: var(--income-shade-3); --ib-stripe: var(--income-stripe-3); }
.bs-income-block[data-step="4"] { --ib-shade: var(--income-shade-4); --ib-stripe: var(--income-stripe-4); }

/* Inset (2026-09-26): the parent card has zero padding (rows carry their own
   1.25rem), so blocks sit in 0.5rem from the card edge with a little vertical
   air. */
.bs-income-block {
    margin: 0.25rem 0.5rem;
}

.bs-income-block + .bs-income-block {
    margin-top: 0.25rem;
}

/* Header row (the whole-row collapse toggle): transparent over the block tint,
   its own padding (the generic .bs-row padding no longer applies here).
   Title 15px/600 collapsed, 16px/700 open; expanded gets a divider under it. */
.bs-income-block .bs-income-toggle-btn {
    padding: 8px 10px;
    min-height: 44px;
    box-sizing: border-box;
}

.bs-income-block--collapsible .bs-income-toggle-btn {
    width: 100%;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    font: inherit;
    transition: background-color var(--transition);
}

.bs-income-block--collapsible .bs-income-toggle-btn:hover {
    background: color-mix(in srgb, var(--color-brand) 10%, transparent);
}

.bs-income-block .bs-income-toggle-btn .bs-row-label {
    color: var(--color-text);
    font-size: 0.9375rem;
    font-weight: 600;
}

.bs-income-block:not(.collapsed) .bs-income-toggle-btn {
    border-bottom: 1px solid color-mix(in srgb, var(--color-brand) 40%, var(--color-border));
}

.bs-income-block:not(.collapsed) .bs-income-toggle-btn .bs-row-label {
    font-size: 1rem;
    font-weight: 700;
}

/* Secondary text on the tint: the on-tint token, not plain muted (contrast). */
.bs-income-block .bs-income-toggle-btn .bs-collapse-chevron,
.bs-income-block .bs-income-toggle-btn .hint-text,
.bs-income-block .income-block__next-pay {
    color: var(--color-text-muted-on-tint);
}

/* Primary badge: solid surface fill so the pill stays legible on the tint. */
.bs-income-block .schedule-primary-badge {
    background: var(--color-surface);
    vertical-align: 1px;
    margin-left: 6px;
}

.bs-collapse-chevron {
    display: inline-block;
    transition: transform var(--transition);
    transform: rotate(90deg);
    margin-right: 2px;
    font-size: 0.65em;
}

.bs-income-block--collapsible.collapsed .bs-collapse-chevron {
    transform: rotate(0deg);
}

.bs-income-block--collapsible.collapsed .bs-income-detail {
    display: none;
}

/* Primary AND Secondary markup wrap the paycheck rows AND the bill windows in
   one outer .bs-income-detail--all (overview.php), so collapsing either block
   hides everything under the header row. */

/* "Next pay: Oct 2" / "Next pay: None this period" in the income block header,
   inline after the name (and the Primary badge) inside .bs-row-label. Muted,
   small, regular weight; it wraps normally (each date is its own nowrap
   .income-block__date span). Solid --color-text-muted (no opacity) for contrast in
   both themes. Shown collapsed and expanded (not tied to .collapsed). */
.income-block__next-pay {
    /* Own line under the title (slide 165): 12px, indented past the chevron;
       colour comes from the on-tint rule in the income block section above. */
    display: block;
    margin-left: 1.05rem;
    font-size: 0.75rem;
    font-weight: 400;
    line-height: 1.3;
    color: var(--color-text-muted);
    white-space: normal;      /* long "Paid a, b, c" lists wrap */
    min-width: 0;
    overflow-wrap: anywhere;
}

/* Each date stays together when the list wraps (overview.php wraps them). */
.income-block__date {
    white-space: nowrap;
}

/* B-27 (phone width): the Secondary toggle row put the schedule name and the
   "Net Pay ... · Next payday ..." summary side by side in one flex line; at 390px
   the name wrapped to two lines and butted against the summary with no gap.
   Stack them instead — name on the first line, summary/meta on its own line
   beneath it, indented to sit under the name text (past the chevron). Desktop
   keeps the single-line layout. min-height 44px (above) still applies. */
@media (max-width: 640px) {
    .bs-income-block--collapsible .bs-income-toggle-btn {
        flex-wrap: wrap;
        align-items: flex-start;
        row-gap: 2px;
    }
    .bs-income-block--collapsible .bs-income-toggle-btn .bs-row-label {
        flex: 1 1 100%;
        min-width: 0;
    }
    .bs-income-block--collapsible .bs-income-toggle-btn .bs-row-value-group {
        flex: 1 1 100%;
        min-width: 0;
        padding-left: 1.05rem;
    }
    /* Expanded (slide 165): the two-line meta is short, so title/pay date stay
       left and the meta sits right on the same row instead of stacking. */
    .bs-income-block:not(.collapsed) .bs-income-toggle-btn {
        flex-wrap: nowrap;
        align-items: center;
    }
    .bs-income-block:not(.collapsed) .bs-income-toggle-btn .bs-row-label {
        flex: 1 1 0;
    }
    .bs-income-block:not(.collapsed) .bs-income-toggle-btn .bs-row-value-group {
        flex: 0 0 auto;
        padding-left: 0;
        margin-left: 8px;
    }
}

/* ── Bill–paycheck-window grouping (Vertical Stack Redesign, slide 90) ───────
   Display-only nesting of a paycheck window's bills under the schedule that
   window belongs to — see group_bills_by_paycheck_window(),
   includes/budget_helpers.php, and bs_window_display_rows()/
   render_bs_window_bill_row(), pages/bills/overview.php. */
.bs-paycheck-window-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 0.4rem 1.25rem 0.15rem;
}

.bs-paycheck-window-label--empty {
    font-style: italic;
    font-weight: 400;
    opacity: 0.85;
}

/* Reuses .bs-row--child's indent convention (see above) for bills nested
   under a paycheck window, kept as a separate class since a bill can be
   BOTH nested under a window AND a rollup child at the same time (both
   classes combine, indents stack). */
.bs-row--nested .bs-row-label {
    padding-left: 0.75rem;
}

/* B-27 (phone width): a bill row's label sized to its content, so the amount +
   Paid/Xfer group filled whatever was left and each row's amount started at a
   different x (right edges wandered ~10px, chip wrapped under a left-hugging
   amount). Give the label the free width (it wraps, incl. the move arrows on
   their own line) and stack the amount over the chip right-aligned, so every
   amount shares one right edge — the same edge as the parent-header amounts. */
@media (max-width: 640px) {
    .bs-row--nested .bs-row-label {
        flex: 1 1 0;
        min-width: 0;
    }
    .bs-row--nested .bs-row-value-group {
        flex: 0 0 auto;
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
    }
}

.bs-paycheck-subtotal {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    text-align: right;
    padding: 0.1rem 1.25rem 0.5rem;
}

/* Income block expanded body [2026-09-30, slide 165]: the outer
   .bs-income-detail--all becomes an inset SURFACE panel (6px in, 1px border,
   6px radius) so the tint frames it and the outline controls keep their
   contrast. Every row/label/subtotal inside uses one plain 0.75rem side
   padding (the old per-block border compensation is gone: the block border
   no longer changes width between Primary and Secondary). Three-class
   selectors so they outrank the generic .bs-row / label rules above. */
.bs-income-block .bs-income-detail--all {
    margin: 6px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 6px;
    overflow: hidden;
}

.bs-income-block .bs-income-detail--all .bs-row,
.bs-income-block .bs-income-detail--all .bs-paycheck-window-label,
.bs-income-block .bs-income-detail--all .bs-paycheck-subtotal {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

/* Gross / Net / Tithe rows: separated by hairlines, roomy enough that the 32px
   controls (28px Override) and their 44px hit areas do not collide. */
.bs-income-block .bs-income-detail > .bs-row:not(.bs-row--checkpoint):not(.bs-row--nested) {
    min-height: 44px;
    box-sizing: border-box;
}

.bs-income-block .bs-income-detail > .bs-row:not(.bs-row--checkpoint):not(.bs-row--nested) + .bs-row:not(.bs-row--checkpoint):not(.bs-row--nested) {
    border-top: 1px solid var(--color-border);
}

/* Bill rows: each its own separated card (surface-alt fill, 1px border, 5px
   radius, 4px gap). Two-line grid: line 1 = name + due date (left) and amount
   (right); line 2 = action row, move arrows left / Paid-Xfer-badge right.
   .bs-row-value-group becomes display: contents so its amount and button
   place directly into the row grid; the DOM, classes, aria-labels and JS
   hooks (.bs-move-open stays inside the .bs-row, .bs-row-value-group
   still wraps amount + button) are unchanged. Applies to every
   .bs-row--nested inside a block (bills and parent-group subtotal rows). */
.bs-income-block .bs-income-detail--all .bs-row--nested {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
    column-gap: 8px;
    row-gap: 2px;
    margin: 0 8px 4px;
    padding: 8px 10px 4px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 5px;
}

.bs-income-block .bs-income-detail--all .bs-paycheck-window-label + .bs-row--nested {
    margin-top: 4px;
}

/* Bills that are pinned to a paycheck keep the 3px brand accent. */
.bs-income-block .bs-income-detail--all .bs-row--overridden {
    border-left: 3px solid var(--color-brand);
    padding-left: calc(0.75rem - 3px);
}

.bs-income-block .bs-row--nested .bs-row-label {
    grid-column: 1;
    grid-row: 1;
    flex: none;
    min-width: 0;
    padding-left: 0;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text);
}

/* Parent/child distinction inside a block (L-IB5): the parent_header subtotal
   row is stronger (bold, brand top accent, brand-subtle fill); rollup children
   are indented with a subtle brand connector line on the left. */
.bs-income-block .bs-row--parent-header {
    background: var(--color-brand-bg-subtle);
    border-top: 2px solid var(--color-brand-ring);
}

.bs-income-block .bs-row--parent-header .bs-row-label,
.bs-income-block .bs-row--parent-header .bs-row-value {
    font-weight: 700;
}

.bs-income-block .bs-row--child .bs-row-label {
    padding-left: 0.75rem;
}

.bs-income-block .bs-income-detail--all .bs-row--child {
    margin-left: 20px;
    border-left: 3px solid var(--color-brand-ring);
    padding-left: calc(0.75rem - 3px);
}

.bs-income-block .bs-row--child .bs-row-label,
.bs-income-block .bs-row--child .bs-row-value {
    font-weight: 500;
}

.bs-income-block .bs-row--nested .bs-row-date {
    display: block;
    margin-left: 0;
    opacity: 1;
    font-size: 0.75rem;
    font-weight: 400;
    color: var(--color-text-muted-on-tint);
}

.bs-income-block .bs-row--nested .bs-row-value-group {
    display: contents;
}

.bs-income-block .bs-row--nested .bs-row-value {
    grid-column: 2;
    grid-row: 1;
    justify-self: end;
    font-size: 0.9375rem;
    font-weight: 600;
}

.bs-income-block .bs-row--nested .bs-move-open {
    grid-column: 1;
    grid-row: 2;
    justify-self: start;
    align-self: center;
    margin: 6px 0;
}

/* [2026-11-12, lock fix] A locked Paid / Xfer is wrapped in .fund-tipwrap (glossary
   "Disabled-Button Tooltip"); under display:contents the WRAPPER is the grid child, so it
   takes the button's placement and the button inside it drops its own margin. */
.bs-income-block .bs-row--nested .btn-mark-paid,
.bs-income-block .bs-row--nested .sync-locked-badge,
.bs-income-block .bs-row--nested .bs-row-value-group > .fund-tipwrap {
    grid-column: 2;
    grid-row: 2;
    justify-self: end;
    align-self: center;
    margin: 2px 0;
}

.bs-income-block .bs-row--nested .fund-tipwrap > .btn-mark-paid {
    margin: 0;
}

/* bills.js setFundTip() leaves the (empty) wrapper in place after an unlock, so a later
   Paid -> Unmark swaps the inline unmark-confirm box INTO it. A wrapper that no longer holds
   the button takes the catch-all's full-width row 3, like an unwrapped confirm box. Own rule
   (not in the list above) so a browser without :has() only loses this rule. */
.bs-income-block .bs-row--nested .bs-row-value-group > .fund-tipwrap:not(:has(> .btn-mark-paid)) {
    grid-column: 1 / -1;
    grid-row: 3;
}

/* Anything else that lands in the value group (the inline unmark-confirm box
   swapped in by bills.js) takes its own full-width row under the action row. */
.bs-income-block .bs-row--nested .bs-row-value-group > :not(.bs-row-value):not(.btn-mark-paid):not(.sync-locked-badge):not(.fund-tipwrap) {
    grid-column: 1 / -1;
    grid-row: 3;
}

/* ── Paycheck timeline [2026-09-30, preview slides 170-171, glossary "Paycheck
   Card"] ─────────────────────────────────────────────────────────────────────
   The per-income wrapper is gone: every paycheck is its own top-level
   collapsible card. A card IS a .bs-income-block (tint, stripe, data-step,
   header button, .collapsed toggle, inset body panel, bill-row cards and the
   phone hit-area rules all come from the rules above) plus the .bs-paycheck-card
   hook, so nothing is duplicated. Only the header content (date, source, badges,
   summary line), the income summary and the mini breakdown are new. */
.bs-card-totals {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    margin-top: 0.25rem;
    font-variant-numeric: tabular-nums;
}

.bs-paycheck-card .bs-pc-date {
    font-variant-numeric: tabular-nums;
}

/* Status badge (Received success / Not received neutral): surface fill so the
   pill stays legible on the tint, same treatment as .schedule-primary-badge. */
.bs-paycheck-card .bs-pc-status {
    background: var(--color-surface);
    vertical-align: 1px;
    margin-left: 6px;
}

/* Collapsed-summary line under the title (reuses .income-block__next-pay's
   block / 12px / on-tint / indent-past-chevron shape); shown collapsed AND
   expanded, so it is not tied to .collapsed. */
.bs-paycheck-card .bs-pc-summary {
    font-variant-numeric: tabular-nums;
}

/* Mini breakdown (this paycheck only, no carry-over). */
.bs-pc-mini {
    border-top: 1px solid var(--color-border);
    margin-top: 6px;
    padding: 4px 0;
}

.bs-pc-mini .bs-row-label {
    color: var(--color-text-muted);
}

.bs-pc-mini .bs-row-value {
    font-variant-numeric: tabular-nums;
}

.bs-pc-mini .bs-pc-mini-left {
    border-top: 1px solid var(--color-border);
    margin-top: 2px;
}

.bs-pc-mini .bs-pc-mini-left .bs-row-label,
.bs-pc-mini .bs-pc-mini-left .bs-row-value {
    font-weight: 700;
    color: var(--color-text);
}

/* Per-paycheck Available line + Save / Spending rows (multi-income budgets,
   dispatch 4 of item 14). The Available row reuses .bs-pc-mini-left (bold, top
   rule); the hint ("after $N living expenses") is the shared .bs-row-hint. Each
   Save / Spending row follows Row Action Order: amount, THEN the button. Labels
   take the free width (and wrap, hint under them) so the value + 32px button
   always fit at 320px; amounts never wrap. */
.bs-pc-avail .bs-row-label,
.bs-pc-fund-row .bs-row-label {
    flex: 1 1 0;
    min-width: 0;
}

.bs-pc-mini .bs-pc-fund-row .bs-row-label {
    color: var(--color-text);
}

.bs-pc-mini .bs-pc-avail .bs-row-hint,
.bs-pc-mini .bs-pc-fund-hint {
    color: color-mix(in srgb, var(--color-text-muted) 85%, var(--color-text));
}

.bs-pc-avail .bs-row-value-group,
.bs-pc-fund-row .bs-row-value-group {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex: 0 1 auto;
    flex-wrap: wrap;
    min-width: 0;
}

.bs-pc-avail .bs-row-value,
.bs-pc-fund-row .bs-row-value {
    white-space: nowrap;
}

/* "Short" flag next to a negative Available figure (badge--danger tone). */
.bs-pc-short {
    flex: 0 0 auto;
}

/* Disabled per-paycheck button: shared 0.5 opacity, and no hover fill (the base
   hover rule would otherwise paint a disabled button solid brand). */
.btn-pc-fund:disabled:hover {
    background: transparent;
    color: var(--color-brand);
}

/* "Refresh" action in the stale-figure error: a button that looks like a link. */
.pc-fund-refresh {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: var(--color-brand);
    text-decoration: underline;
    cursor: pointer;
}

.pc-fund-refresh:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

/* Legacy whole-period Saved / Funded rows on a multi-income period. */
.bs-pc-legacy-row .bs-row-label {
    flex: 1 1 0;
    min-width: 0;
}

/* Income summary: one line per source (only with 2+ sources). Each row keeps its
   source's colour step as a left stripe so the timeline cards below can be
   matched by colour. Four-column grid; the name column may wrap (badge under the
   name) at phone width. */
.bs-isum {
    --isum-cols: minmax(0, 1.7fr) repeat(3, minmax(0, 1fr));
    margin: 0.25rem 0.5rem 0.5rem;
    padding: 6px 10px 8px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
}

.bs-isum-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.bs-isum-grid {
    display: grid;
    grid-template-columns: var(--isum-cols);
    column-gap: 8px;
    align-items: center;
}

.bs-isum-grid > span:not(.bs-isum-name):not(.bs-isum-none) {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.bs-isum-head {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--color-text-muted);
    padding: 0 0 2px 11px;
}

.bs-isum-row {
    --ib-stripe: var(--income-stripe-1);
    min-height: 32px;
    padding: 3px 0 3px 8px;
    border-left: 3px solid var(--ib-stripe);
    border-top: 1px solid var(--color-border);
}

.bs-isum-row[data-step="2"] { --ib-stripe: var(--income-stripe-2); }
.bs-isum-row[data-step="3"] { --ib-stripe: var(--income-stripe-3); }
.bs-isum-row[data-step="4"] { --ib-stripe: var(--income-stripe-4); }

.bs-isum-name {
    font-weight: 600;
    color: var(--color-text);
    min-width: 0;
    overflow-wrap: anywhere;
}

.bs-isum-name .schedule-primary-badge {
    margin-left: 6px;
    vertical-align: 1px;
}

.bs-isum-none {
    grid-column: 2 / -1;
    text-align: right;
    font-style: italic;
    color: var(--color-text-muted);
}

/* ── Desktop sticky right rail [2026-09-30, preview slide 173, glossary "Paycheck
   Card"] ─────────────────────────────────────────────────────────────────────
   Below 900px nothing changes: .bs-card-layout/.bs-card-main are plain blocks,
   the footer wrapper is display:contents and the rail copy is display:none.
   At >= 900px the card widens to two columns: the existing content (paycheck
   cards, Living Expenses, Available, Save, Spending) on the left, and a sticky
   rail on the right holding COPIES of the period totals line, the Income summary
   and the footer rows (Bills Total, Paid so far, Left after all bills (all
   incomes); the old primary-income "Left After Bills" row was removed
   2026-09-30). The in-flow originals (.bs-rail-src inside .bs-card-main) are
   hidden at >= 900px so each figure shows once. Scoped with :has() so Deep
   History's synthetic cards (no .bs-card-layout) keep the 520px single card. */
.bs-card-rail { display: none; }
.bs-rail-wrap { display: contents; }

@media (min-width: 900px) {
    .card-single .budget-statement-card:has(> .bs-card-layout) {
        max-width: 920px;
        overflow: visible; /* sticky cannot work inside overflow:hidden */
    }

    /* keep the rounded top corners the clip used to provide */
    .budget-statement-card:has(> .bs-card-layout) > .bs-card-header {
        border-top-left-radius: inherit;
        border-top-right-radius: inherit;
    }

    /* the section header above the first card matches the wider card */
    .schedule-section-header--single:has(+ .card-single .bs-card-layout) {
        max-width: 920px;
    }

    .bs-card-layout {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 340px;
        column-gap: var(--space-3);
        align-items: start;
        padding-right: var(--space-3);
    }

    .bs-card-main { min-width: 0; }

    .bs-card-main .bs-rail-src,
    .budget-statement-card:has(> .bs-card-layout) > .bs-card-header .bs-card-totals {
        display: none;
    }

    .bs-card-rail {
        display: block;
        position: sticky;
        top: calc(var(--nav-height) + var(--space-4));
        max-height: calc(100vh - var(--nav-height) - var(--space-4) - var(--space-3));
        overflow-y: auto;
        margin: 0.5rem 0;
        padding: var(--space-2) 0;
        background: var(--color-surface-alt);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
    }

    .bs-card-rail > .bs-card-totals {
        margin: 0;
        padding: 0 var(--space-3) var(--space-2);
        border-bottom: 1px solid var(--color-border);
    }

    /* the summary sits directly in the rail box: drop its own nested box */
    .bs-card-rail .bs-isum {
        margin: var(--space-2) 0 var(--space-1);
        border: 0;
        border-radius: 0;
        background: transparent;
    }
}

/* Footer rows with a short hint line under the label (Left after all bills,
   all incomes): same flex + hint treatment as the old per-window
   checkpoint, which is gone. */
.bs-row--hinted .bs-row-label {
    flex: 1 1 0;
    min-width: 0;
}

.bs-row--hinted .bs-row-value {
    white-space: nowrap;
    margin-left: 0.75rem;
}

/* ── Bill default income rule [2026-09-30, preview slides 166-168] ────────────
   The centered popup (opened from the row's .bs-move-open
   icon, styled with .bs-move-btn above). The dialog reuses #bill-scope-backdrop's chrome as the .income-rule-*
   classes (same tokens) and .bill-scope-option / .bill-scope-title /
   .bill-scope-body / .bill-scope-actions; all built by assets/js/bills.js.
   Glossary: "Bill Default Income Rule". */

/* Dialog: same backdrop/box treatment as #bill-scope-backdrop. */
.income-rule-backdrop {
    position: fixed;
    inset: 0;
    background: var(--color-backdrop);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

.income-rule-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

.income-rule-modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 22px 22px 18px;
    transform: translateY(8px);
    transition: transform 0.2s ease;
}

.income-rule-backdrop.is-open .income-rule-modal {
    transform: translateY(0);
}

.income-rule-step:empty,
.income-rule-message:empty {
    display: none;
}

.income-rule-step {
    margin: 0 0 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

/* "Which paycheck?" label above the paycheck list on the "Just for this period" step. */
.income-rule-subhead {
    margin: 14px 0 6px;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

/* 44px rows for the radio cards and the buttons (touch floor). */
.income-rule-modal .bill-scope-option {
    min-height: 44px;
    box-sizing: border-box;
    align-items: center;
}

.income-rule-modal .bill-scope-option:last-of-type {
    margin-bottom: 8px;
}

.income-rule-modal .bill-scope-option.is-busy {
    opacity: 0.5;
    pointer-events: none;
}

.income-rule-modal .bill-scope-option.is-unavailable {
    opacity: 0.5;
    cursor: default;
}

.income-rule-modal .bill-scope-option:has(input:focus-visible) {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

.income-rule-modal .period-view-only-banner {
    margin-bottom: 12px;
}

.income-rule-modal .bill-scope-actions {
    margin-top: 14px;
}

.income-rule-modal .bill-scope-actions .btn {
    min-height: 44px;
    padding-left: 18px;
    padding-right: 18px;
}

/* Step-1 choice buttons ("Just for this period" outline / "Permanently" brand):
   equal-width pair on desktop, stacked on phone; each carries a one-line helper. */
.income-rule-choices {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 14px;
}

.income-rule-choices.u-hidden {
    display: none;
}

.income-rule-modal .income-rule-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: 56px;
    padding: 8px 14px;
    box-sizing: border-box;
    text-align: center;
    white-space: normal;
}

.income-rule-choice-label {
    font-weight: 600;
}

.income-rule-choice-help {
    font-size: 0.75rem;
    font-weight: 400;
    opacity: 0.85;
}

@media (max-width: 640px) {
    .income-rule-choices {
        grid-template-columns: 1fr;
    }
}

/* "Put back to automatic": quiet text action above the Cancel/Continue row. */
.income-rule-reset {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    margin-top: 6px;
    padding: 0 4px;
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--color-brand);
    font-family: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
}

.income-rule-reset.u-hidden {
    display: none;
}

.income-rule-reset:hover:not(:disabled) {
    text-decoration: underline;
}

.income-rule-reset:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

.income-rule-reset:disabled {
    opacity: 0.5;
    cursor: default;
}

.income-rule-message {
    margin: 10px 0 0;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    line-height: 1.4;
}

.income-rule-message--error {
    color: var(--color-error);
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
}

.income-rule-message--note {
    color: var(--color-text-muted);
    background: var(--color-surface-alt);
    border: 1px dashed var(--color-border);
}

/* Hairline divider */
.bs-divider {
    height: 1px;
    background: var(--color-border);
    margin: 0.25rem 0;
}

/* ── Card states ─────────────────────────────────────────────────────────────── */

/* Current period: brand ring + solid brand header */
.budget-statement-card--current {
    box-shadow: var(--shadow-card), 0 0 0 2px var(--color-brand);
}

.budget-statement-card--current .bs-card-header {
    background: var(--color-brand-fill);
    border-bottom: 2px solid var(--color-brand-fill);
}

.budget-statement-card--current .bs-card-eyebrow {
    color: var(--color-text-on-brand-soft);
}

.budget-statement-card--current .bs-card-period {
    color: var(--color-text-on-brand);
}

.budget-statement-card--current .bs-card-meta {
    color: var(--color-text-on-brand-muted);
}

/* Gross/Net/Tithe line inside the brand-filled header. Scoped to the header so
   the rail's copy (on --color-surface-alt) keeps its normal text color. */
.budget-statement-card--current .bs-card-header .bs-card-totals {
    color: var(--color-text-on-brand);
}

/* Past period: muted */
.budget-statement-card--past {
    opacity: 0.72;
}

.budget-statement-card--past .bs-card-header {
    background: var(--color-border);
    border-bottom: 2px solid var(--color-border);
}

.budget-statement-card--past .bs-card-eyebrow {
    color: var(--color-text-muted);
}

.budget-statement-card--past .bs-card-period {
    color: var(--color-text-muted);
}

/* ── Multi-card row layout ────────────────────────────────────────────────────── */

.card-row {
    display: flex;
    gap: 1.25rem;
    align-items: flex-start;
}

.card-row > .budget-statement-card {
    flex: 1;
    min-width: 0;
    max-width: none;
}

/* ── Quick Transfer (pages/bills/overview.php) ─────────────────────────────
   "Save to Savings" / "Spending Money" one-off account transfers, logged
   without leaving the page. Trigger buttons are the inline
   .quick-transfer-trigger pills (styled via .btn-mark-paid) on each period
   card's Save/Spending Money rows; both open the same inline panel
   (assets/js/quick-transfer.js); form-field styling reuses
   .form-grid-2col/.cleared-toggle-group/.form-error-banner as-is. */

.quick-transfer-panel {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 16px 18px;
    margin-bottom: 1rem;
}

.quick-transfer-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.quick-transfer-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
}

/* .quick-transfer-close: visual styling comes from the shared .icon-close (B-64 item 9). */

/* Note: no isolated :focus-visible rule needed here — the bare
   `button:focus-visible` entry in this file's shared focus-visible selector
   list already covers this <button type="button">. */

/* ── Deep History (synthetic pre-history periods, overview page) ──────────────
   Quiet pill toggle above the period-nav bar + a visually distinct "synthetic"
   variant of .budget-statement-card (dashed amber border, no brand header block)
   for the on-the-fly, never-persisted look-back estimate. Reuses --color-warning-*
   tokens only — no new colors. See assets/js/deep-history.js for the toggle/fetch/
   render logic (this card's contents are built entirely client-side). ── */

.dh-toggle-row {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 1rem;
}

.period-mode-toggle {
    display: inline-flex;
    background: var(--color-border);
    border-radius: 99px;
    padding: 3px;
    gap: 2px;
}

.period-mode-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 7px 12px;
    min-height: 36px;
    border: none;
    border-radius: 99px;
    background: transparent;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
}

.period-mode-btn:hover {
    color: var(--color-text);
}

.period-mode-btn--active {
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 700;
    box-shadow: var(--shadow-hairline);
}

@media (max-width: 640px) {
    /* Touch-target floor: .bills-mobile-filter-row .bills-seg-btn and
       .period-mode-btn were unified to a shared 36px desktop size, but that
       size is below the 44px mobile touch-target minimum. Unify UP to 44px
       on mobile instead so the two controls stay matched to each other AND
       meet the floor. Placed after both rules' unconditional definitions
       (~5449, ~7125) so this wins the cascade at equal specificity —
       positioning it earlier caused the later unconditional rules to win
       and silently cancel the override. Desktop keeps the 36px size. */
    .bills-mobile-filter-row .bills-seg-btn,
    .period-mode-btn {
        min-height: 44px;
        padding: 11px 12px;
        font-size: 0.875rem;
    }
}

/* Estimate badge — reuses the same warning-token recipe as .budget-alert-banner */
/* B-64 #25: markup is `budget-alert-banner dh-estimate-badge` — the shared warning banner
   recipe supplies the look; this only overrides its margin for the Deep History card. */
.budget-alert-banner.dh-estimate-badge {
    margin: 0.875rem 1.25rem 0;
}

.dh-estimate-badge svg {
    flex-shrink: 0;
}

/* Quiet heads-up shown from the moment the card opens — separate from
   .dh-cap-message, which only appears once the 1-year limit is actually hit. */
.dh-range-note {
    color: var(--color-text-muted);
    font-size: 0.7rem;
    margin: 0.35rem 1.25rem 0;
}

/* Synthetic card variant: dashed amber border + faint diagonal tint instead of the
   solid brand header block a real period card uses. */
.budget-statement-card--synthetic {
    border: 1.5px dashed var(--color-warning-text);
    box-shadow: none;
    background-color: var(--color-surface);
    background-image: repeating-linear-gradient(
        135deg,
        color-mix(in srgb, var(--color-warning-text) 8%, transparent) 0 10px,
        transparent 10px 20px
    );
}

.budget-statement-card--synthetic .bs-card-header {
    background: transparent;
    border-bottom: none;
    padding-top: 0.375rem;
}

.budget-statement-card--synthetic .bs-card-eyebrow {
    color: var(--color-warning-text);
}

.dh-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.15rem;
}

.dh-step-controls {
    display: flex;
    align-items: center;
    gap: 4px;
}

.dh-step-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.4rem;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}

.dh-step-btn:hover:not(:disabled) {
    background: var(--color-bg-secondary);
    color: var(--color-text);
}

.dh-step-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Editable Gross/Net Pay pair — same visual weight as .override-input, laid out
   side by side per the approved mockup (mirrors the real card's Income row order). */
.dh-pay-inputs {
    display: flex;
    gap: 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.625rem;
}

.dh-pay-field {
    flex: 1;
    min-width: 0;
}

.dh-pay-field label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.dh-pay-input {
    width: 100%;
    height: 30px;
    padding: 0.25rem 0.5rem;
    font-size: 0.8125rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
}

.dh-pay-input:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-ring);
}

.dh-pay-hint {
    font-size: 0.68rem;
    color: var(--color-text-muted);
    margin: 0.4rem 1.25rem 0;
}

/* End-state message once the 1-year cap is reached */
.dh-cap-message {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 0.625rem 0.75rem;
    margin: 0.75rem 1.25rem 1rem;
}

.dh-cap-message svg {
    flex-shrink: 0;
    color: var(--color-text-muted);
    margin-top: 1px;
}

.dh-cap-message span {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

/* At-cap card: gray out the amber accent (no further steps possible) */
.budget-statement-card--synthetic-cap {
    border-color: var(--color-text-muted);
    background-image: repeating-linear-gradient(
        135deg,
        color-mix(in srgb, var(--color-text-muted) 8%, transparent) 0 10px,
        transparent 10px 20px
    );
}

.budget-statement-card--synthetic-cap .bs-card-eyebrow {
    color: var(--color-text-muted);
}

.dh-back-link-wrap {
    text-align: center;
    margin-top: 0.75rem;
}

.dh-back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: none;
    background: transparent;
    color: var(--color-brand);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.5rem;
}

.dh-back-link:hover {
    text-decoration: underline;
}

.dh-loading,
.dh-error {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--color-text-muted);
    font-size: 0.85rem;
}

.dh-error {
    color: var(--color-warning-text);
}

@media (max-width: 640px) {
    .dh-step-btn {
        min-height: 36px;
        padding: 0.3rem 0.5rem;
    }
    .dh-back-link {
        min-height: 44px;
    }
}

/* ── Period summary page ─────────────────────────────────────────────────────── */

.summary-period-label {
    text-align: center;
    font-size: 14px;
    color: var(--color-text-muted);
    margin: 4px 0 20px;
}

/* Third flex item inside .period-controls (bills/overview.php) — sits between the
   Columns picker and the Prev/Current/Next nav buttons on the same row [2026-09-12].
   Resets the standalone-block margin so it doesn't add extra vertical space while
   living inside the flex row; .period-controls' own margin-bottom still applies. */
.period-controls .summary-period-label {
    margin: 0;
    white-space: nowrap;
}

.summary-stat-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
    margin: 0 0 24px;
}

@media (min-width: 640px) {
    .summary-stat-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.summary-stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.summary-stat-card--negative {
    background: var(--color-warn-tint);
    border-color: var(--color-warn-tint-border);
}

@media (prefers-color-scheme: dark) {
    .summary-stat-card--negative {
        background: var(--color-warn-tint-dark);
        border-color: var(--color-warn-tint-border-dark);
    }
}

.summary-stat-card .summary-card-label {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.summary-stat-card .summary-card-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

/* Income value — brand blue, same as positive values across the app */
.summary-stat-card .summary-card-value--income {
    color: var(--color-brand);
}

/* Expense value — deduction red, matches period-val--deduct */
.summary-stat-card .summary-card-value--expense {
    color: var(--color-error);
}

/* Positive net balance — inherits default text color (neutral) */
/* .summary-card-value--balance needs no override */

/* Negative net balance — matches period-val--neg */
.summary-stat-card .summary-card-value--negative {
    color: var(--color-error);
}

/* ── Envelope Progress (Budget vs. Actual bars, objective #7) ───────────────────
   pages/bills/summary.php, below .summary-stat-grid. One row per opted-in
   account. Bar fill never blends in the cushion figure (shown as a separate
   line below/beside the bar) — see md/plans/budget-vs-actual-and-carryforward.md.
   Reuses the existing --color-warning-* trio (already used by
   .budget-alert-banner/.budget-negative-badge) for the over-budget state and
   --color-success for on-pace, so no new colors are introduced. Approved
   design: ui-preview.html slide 40. */

.envelope-progress-heading {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin: 0 0 10px;
}

.envelope-progress-list {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}

.envelope-progress-row {
    padding: 11px 14px;
}

.envelope-progress-row:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

.envelope-progress-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 10px;
    margin-bottom: 6px;
}

.envelope-progress-row--tbd .envelope-progress-row-head {
    margin-bottom: 0;
}

.envelope-progress-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 0.92rem;
}

.envelope-progress-amount {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-success);
    white-space: nowrap;
}

.envelope-progress-row--over .envelope-progress-amount {
    color: var(--color-warning-text);
}

/* .envelope-progress-badge(--over|--tbd): hooks only (badge badge--warning / badge--neutral) —
   look lives on .badge. */

.envelope-progress-bar {
    width: 100%;
    height: 7px;
    border-radius: 99px;
    background: var(--color-border);
    overflow: hidden;
}

/* Width set from data-pct via assets/js/app.js (CSSOM write — inline style=""
   attributes are silently dropped by this app's CSP style-src). */
.envelope-progress-bar-fill {
    height: 100%;
    width: 0;
    background: var(--color-success);
    transition: width var(--transition);
}

.envelope-progress-row--over .envelope-progress-bar-fill {
    background: var(--color-warning-border);
}

.envelope-progress-row--over {
    background: var(--color-warning-bg);
}

.envelope-progress-cushion {
    font-size: 0.74rem;
    color: var(--color-text-muted);
    margin-top: 5px;
}

.envelope-progress-row--over .envelope-progress-cushion {
    color: var(--color-warning-text);
}

/* ── Category Group Breakdown (pages/bills/summary.php) ─────────────────────────
   Actual $ spend by category_group for the current period, reporting-only (no
   target-setting). Row layout mirrors .envelope-progress-row/-bar above — same
   track/fill mechanics (width set via CSSOM from data-pct, see assets/js/app.js;
   this app's CSP style-src has no 'unsafe-inline' so a literal style="" can't be
   baked into the template). Reuses --color-brand for the fill (no new tokens),
   matching --color-brand's use elsewhere for neutral/informational bars
   (.liability-bar-fill's default state). */

.group-breakdown-heading {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    margin: 0 0 10px;
}

.group-breakdown-list {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}

.group-breakdown-row {
    padding: 11px 14px;
}

.group-breakdown-row:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

.group-breakdown-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 10px;
    margin-bottom: 6px;
}

.group-breakdown-name {
    font-weight: 700;
    font-size: 0.92rem;
}

.group-breakdown-amount {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.group-breakdown-row--uncategorized .group-breakdown-name,
.group-breakdown-row--uncategorized .group-breakdown-amount {
    color: var(--color-text-muted);
    font-style: italic;
}

.group-breakdown-bar {
    width: 100%;
    height: 7px;
    border-radius: 99px;
    background: var(--color-border);
    overflow: hidden;
}

/* Width set from data-pct via assets/js/app.js (CSSOM write — inline style=""
   attributes are silently dropped by this app's CSP style-src). */
.group-breakdown-bar-fill {
    height: 100%;
    width: 0;
    background: var(--color-brand);
    transition: width var(--transition);
}

.group-breakdown-row--uncategorized .group-breakdown-bar-fill {
    background: var(--color-text-muted);
}

/* ── Liabilities view (Register page, objective #9) ─────────────────────────────
   pages/register/index.php, ?view=liabilities. Row layout/tokens mirror
   .envelope-progress-* above: bar tracks + fill via CSSOM (data-pct, CSP-safe),
   brand blue = normal utilization, warning tokens = high usage (>=80%,
   consistent with .budget-alert-banner/.envelope-progress--over), success
   green = loan payoff progress. No new colors introduced. Approved design:
   ui-preview.html slide 41. */

.liability-list {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 24px;
}

.liability-row {
    display: flex;
    align-items: stretch;
}

.liability-row:not(:last-child) {
    border-bottom: 1px solid var(--color-border);
}

.liability-row--high {
    background: var(--color-warning-bg);
}

.liability-row--danger {
    background: var(--color-error-bg);
}

.liability-row-body {
    flex: 1 1 auto;
    display: block;
    padding: 11px 14px;
    color: inherit;
    text-decoration: none;
    min-width: 0;
}

.liability-row-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 10px;
    margin-bottom: 6px;
}

.liability-name {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    font-size: 0.92rem;
}

.liability-amount {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
}

.liability-row--high .liability-amount,
.liability-row--high .liability-name {
    color: var(--color-warning-text);
}

.liability-row--danger .liability-amount,
.liability-row--danger .liability-name {
    color: var(--color-error);
}

/* .liability-badge(--high-usage|--danger): hooks only (badge badge--warning / badge--danger) —
   look lives on .badge. */

.liability-bar {
    width: 100%;
    height: 7px;
    border-radius: 99px;
    background: var(--color-border);
    overflow: hidden;
}

/* Width set from data-pct via assets/js/app.js (CSSOM write — inline style=""
   attributes are silently dropped by this app's CSP style-src). */
.liability-bar-fill {
    height: 100%;
    width: 0;
    background: var(--color-brand);
    transition: width var(--transition);
}

.liability-row--high .liability-bar-fill {
    background: var(--color-warning-border);
}

.liability-row--danger .liability-bar-fill {
    background: var(--color-error-border);
}

.liability-row--loan .liability-bar-fill {
    background: var(--color-success);
}

.liability-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 12px;
    font-size: 0.74rem;
    color: var(--color-text-muted);
}

.liability-row--high .liability-meta {
    color: var(--color-warning-text);
}

.liability-row--danger .liability-meta {
    color: var(--color-error);
}

.liability-row .edit-icon-btn {
    flex-shrink: 0;
    margin: 11px 14px 11px 0;
    align-self: center;
}

/* ── Mark Paid button & confirmed state ──────────────────────────────────────── */

/* .btn-mark-paid's box-model/shape now lives in the shared action-chip group
   below (.btn-sync-bills, .btn-tithe-mark, etc. — see ~line 8565) so it
   renders identically to the other "mark it done" chips app-wide. Focus ring
   is in the shared :focus-visible list at ~line 1107.

   [Confirm-row button persistence, preview slide 68 Option A] .bill-paid-badge
   (the standalone green pill that used to REPLACE .btn-mark-paid on confirm)
   is retired — the confirmed state is now the SAME <button class="btn-mark-paid
   is-confirmed"> re-styled in place (see the shared .is-confirmed rule below),
   never a separately-shaped element. Clicking the confirmed button re-opens
   the same showUnmarkConfirm() flow that used to live on the badge. */

/* Budget negative alert — uses the shared --color-warning-* tokens (already
   tuned for contrast in both themes) instead of ad hoc low-alpha amber,
   which read as too washed-out/hard to read. */
.budget-alert-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    color: var(--color-warning-text);
    font-weight: 600;
    font-size: 13px;
}

/* .budget-negative-badge: hook only (badge badge--warning) — look lives on .badge. */

/* ── Project Status (admin) ──────────────────────────────────────────────────── */

.project-status-list {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.project-status-card {
    align-items: stretch;
}

.project-status-phase-name {
    justify-content: space-between;
    flex-wrap: wrap;
}

/* .project-status-badge(--complete|--in_progress|--planned): hooks only (badge badge--caps +
   success / warning / neutral) — look lives on .badge. */

.project-status-objectives {
    list-style: none;
    margin: 14px 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.project-status-objective {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: 0.9rem;
}

.project-status-objective-marker {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border-radius: 99px;
    font-size: 0.75rem;
    line-height: 1;
    margin-top: 1px;
}

.project-status-objective--done .project-status-objective-marker {
    background-color: var(--color-success-bg);
    color: var(--color-success);
}

.project-status-objective--pending .project-status-objective-marker {
    background-color: transparent;
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
}

.project-status-objective--done span:last-child {
    color: var(--color-text);
}

.project-status-objective--pending span:last-child {
    color: var(--color-text-muted);
}

/* ── Mark Paid modal ─────────────────────────────────────────────────────────── */

#mark-paid-backdrop {
    position: fixed;
    inset: 0;
    background: var(--color-backdrop);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

#mark-paid-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

#mark-paid-modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
    /* Never scroll sideways, and reserve the vertical scrollbar's width up
       front: without the gutter, the scrollbar appearing near the 90vh cap
       narrowed the content, re-wrapped text and toggled the scrollbar again
       (visible as a flicker while the open transition ran). */
    overflow-x: hidden;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    padding: 28px 28px 24px;
    transform: translateY(8px);
    transition: transform 0.2s ease;
}

#mark-paid-modal form,
#mark-paid-modal .form-group {
    min-width: 0;
}

#mark-paid-backdrop.is-open #mark-paid-modal {
    transform: translateY(0);
}

.mark-paid-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.mark-paid-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.3;
    flex: 1;
    min-width: 0;
    padding-right: 12px;
}

.mark-paid-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-text-muted);
    padding: 6px;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: color var(--transition), background-color var(--transition);
}

.mark-paid-close:hover {
    color: var(--color-text);
    background: var(--color-bg);
}

.mark-paid-close:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

/* "Mark as cleared" checkbox group — shared by every modal that creates a
   transaction (Mark Paid, Batch confirm, Pay from Sinking Fund). Dashed
   divider matches the account-lock-note field-separation convention already
   used elsewhere in these modals. See carry-forward #41 / preview slide 42. */
.cleared-toggle-group {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed var(--color-border);
}

.cleared-toggle-group .checkbox-label {
    margin-bottom: 4px;
}

.cleared-toggle-group .hint-text {
    display: block;
}

/* Actions area */
.mark-paid-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 4px;
    margin-top: 20px;
}

/* "Mark paid only" secondary text link */
.mark-paid-secondary {
    background: none;
    border: none;
    font-family: inherit;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px;
    text-align: center;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color var(--transition);
}

.mark-paid-secondary:hover {
    color: var(--color-text);
}

.mark-paid-secondary:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Inline error message */
.mark-paid-error {
    color: var(--color-error);
    font-size: 0.875rem;
    margin-top: 0.5rem;
    display: none;
}

.mark-paid-error.visible {
    display: block;
}

/* Mobile: full-width modal */
@media (max-width: 640px) {
    #mark-paid-modal {
        padding: 20px 16px 16px;
    }
}

/* ── Bill Edit: instance-scope confirmation modal ────────────────────────────── */
/* Reuses the same backdrop/box treatment as #mark-paid-backdrop (fixed, centered,
   opacity/pointer-events transition — CSP-safe, no inline style writes needed for
   show/hide beyond the .is-open class toggle already established by that pattern). */

#bill-scope-backdrop {
    position: fixed;
    inset: 0;
    background: var(--color-backdrop);
    z-index: 400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition);
}

#bill-scope-backdrop.is-open {
    opacity: 1;
    pointer-events: auto;
}

#bill-scope-modal {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-modal);
    width: 100%;
    max-width: 400px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 22px 22px 18px;
    transform: translateY(8px);
    transition: transform 0.2s ease;
}

#bill-scope-backdrop.is-open #bill-scope-modal {
    transform: translateY(0);
}

.bill-scope-title {
    font-size: 1rem;
    font-weight: 800;
    color: var(--color-text);
    margin-bottom: 8px;
}

.bill-scope-body {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    line-height: 1.6;
    margin-bottom: 16px;
}

.bill-scope-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}

.bill-scope-option:last-of-type {
    margin-bottom: 18px;
}

.bill-scope-option:hover {
    border-color: var(--color-brand);
}

.bill-scope-option.is-selected {
    border-color: var(--color-brand);
    background-color: var(--color-brand-bg-subtle);
}

.bill-scope-option input[type="radio"] {
    accent-color: var(--color-brand);
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 2px;
}

.bill-scope-option-title {
    display: block;
    font-size: 0.8125rem;
    font-weight: 700;
    color: var(--color-text);
}

.bill-scope-option-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.bill-scope-backward-note {
    display: none;
    font-size: 0.75rem;
    line-height: 1.5;
    padding: 8px 10px;
    margin-bottom: 18px;
    border-radius: var(--radius-sm);
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    color: var(--color-warning-text);
}

.bill-scope-backward-note.is-visible {
    display: block;
}

.bill-scope-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* ── Pay from Sinking Fund: two-leg payout modal [2026-08-14] ─────────────────
   Injected into the same #bill-scope-backdrop/#bill-scope-modal chrome as the
   scope-confirm dialogs above (assets/js/bills.js) — reuses .bill-scope-option
   for each leg's Create/Link/Skip choice and .mp-link-list/.mp-tx-row (Mark
   Paid modal, ~line 9300) for each leg's "link existing transaction" panel,
   rather than introducing new component patterns for either. Slightly wider
   than the other #bill-scope-modal dialogs since it holds two full sections. */

#bill-scope-modal.sinkfund-payout-modal {
    max-width: 460px;
}

.sinkfund-leg-section {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--color-border);
}

.sinkfund-leg-section:last-of-type {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.sinkfund-leg-heading {
    font-size: 0.875rem;
    font-weight: 700;
    color: var(--color-text);
    margin: 0 0 4px;
}

.sinkfund-leg-intro {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin: 0 0 12px;
}

.sinkfund-leg-detail {
    margin-top: 10px;
}

.sinkfund-leg-link-list {
    max-height: 160px;
}

/* ── Pay Schedule: change-tithe-base confirmation dialog ──────────────────────
   Injected into the same #bill-scope-backdrop/#bill-scope-modal chrome as the
   Bill Edit scope-confirm dialog above (assets/js/pay-schedule-form.js) — this
   page never loads bills-form.js, so there's no ID collision. Only the "Live
   estimate" highlight box below is new. See preview/ui-preview.html slide 36. */

.tithe-scope-estimate {
    background: var(--color-brand-bg-subtle);
    border: 1px solid var(--color-brand);
    border-radius: var(--radius-sm);
    padding: 9px 11px;
    margin-bottom: 12px;
    font-size: 0.72rem;
    color: var(--color-text);
    line-height: 1.5;
}

.tithe-scope-estimate-label { font-weight: 700; }
.tithe-scope-estimate-old   { font-variant-numeric: tabular-nums; }
.tithe-scope-estimate-arrow { color: var(--color-text-muted); margin: 0 3px; }
.tithe-scope-estimate-new   { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--color-brand); }

/* ══════════════════════════════════════════════════════════════════════
   Budget Merge Wizard — pages/budgets/merge.php / assets/js/budget-merge.js
   Approved via preview/ui-preview.html slides 94-100. Reuses .bill-scope-option,
   .default-star-badge/.btn-set-default, .edit-section, .form-card, .import-steps,
   .form-actions-row, .btn as-is (no new rules needed for those). New classes
   below translate the preview's mock-frame-scoped rules 1:1 into real
   CSS-variable-driven (theme-aware) rules. See md/glossary.md's "Budget Merge
   Wizard (backend)" entry and the UI/UX Standards section for the component
   reuse rules this build followed.
   ══════════════════════════════════════════════════════════════════════ */

.merge-budget-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }

.merge-checkbox-row {
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color var(--transition), background-color var(--transition);
}
.merge-checkbox-row input[type="checkbox"] { accent-color: var(--color-brand); flex-shrink: 0; cursor: pointer; }
.merge-checkbox-row.is-checked { border-color: var(--color-brand); background-color: var(--color-brand-bg-subtle); }
.merge-checkbox-row-body { flex: 1; min-width: 0; }
.merge-checkbox-row-title { font-size: 0.8125rem; font-weight: 700; color: var(--color-text); }
.merge-checkbox-row-meta { font-size: 0.75rem; color: var(--color-text-muted); margin-top: 2px; }

.merge-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 18px 0 8px;
}
.merge-section-title:first-child { margin-top: 0; }

.merge-review-list { display: flex; flex-direction: column; gap: 6px; }

.merge-review-item {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    background: var(--color-surface);
}
.merge-review-item--deleted { opacity: 0.55; }
.merge-review-item--unresolved { border-color: var(--color-error-border); background: var(--color-error-bg); }
.merge-review-item-name { flex: 1; min-width: 140px; font-size: 0.8125rem; font-weight: 600; color: var(--color-text); }
.merge-review-item-name input {
    width: 100%;
    font: inherit;
    font-size: 0.8125rem;
    padding: 5px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
}
.merge-review-item-name input:disabled { opacity: 0.6; cursor: not-allowed; }
.merge-review-item-sub-note { font-size: 0.72rem; font-weight: 400; color: var(--color-text-muted); }
.merge-review-item-block-reason { font-size: 0.72rem; font-weight: 600; color: var(--color-error); }

.merge-item-toggle {
    display: inline-flex;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    flex-shrink: 0;
}
.merge-item-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 5px 12px;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: none;
    cursor: pointer;
}
.merge-item-toggle-btn:disabled { cursor: not-allowed; opacity: 0.7; }
.merge-item-toggle-btn + .merge-item-toggle-btn { border-left: 1px solid var(--color-border); }
.merge-item-toggle-btn.is-active { background: var(--color-brand-fill); color: var(--color-text-on-brand); }
.merge-item-toggle-btn.is-active.merge-item-toggle-btn--danger { background: var(--color-error); color: var(--color-on-solid); }

/* .merge-unresolved-tag: hook only (badge badge--danger badge--caps; toggled with .u-hidden) —
   look lives on .badge. */

.merge-progress-banner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--color-error-border);
    background: var(--color-error-bg);
    color: var(--color-error);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.8125rem;
    font-weight: 600;
    margin-bottom: 14px;
}
.merge-progress-banner.is-clear {
    border-color: var(--color-success);
    background: var(--color-success-bg);
    color: var(--color-success);
}

.merge-confirm-group-title { font-size: 0.85rem; font-weight: 700; color: var(--color-text); margin: 16px 0 6px; }
.merge-confirm-group-title:first-child { margin-top: 0; }
.merge-confirm-list { display: flex; flex-direction: column; gap: 4px; font-size: 0.8125rem; }
.merge-confirm-row { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--color-border); color: var(--color-text); }
.merge-confirm-row:last-child { border-bottom: none; }
.merge-confirm-row-arrow { color: var(--color-text-muted); }
.merge-confirm-row--delete .merge-confirm-row-arrow { color: var(--color-error); }
/* Replaces an inline style="" attribute previously injected via innerHTML —
   CSP's style-src has no 'unsafe-inline' outside preview/, so that markup was
   silently dropped in production. */
.merge-renamed-tag { color: var(--color-text-muted); }
.merge-auto-move-note { font-size: 0.75rem; color: var(--color-text-muted); margin: 8px 0 0; }
/* Replaces an inline style="" attribute previously injected via innerHTML on
   the commit validation-error list — same CSP reason as .merge-renamed-tag. */
.merge-error-list { margin: 6px 0 0 18px; }

.merge-wizard { max-width: 640px; margin: 0 auto; }
.merge-wizard .form-card { max-width: 100%; margin: 0 auto; }
.merge-source-progress { font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 4px; }

@media (max-width: 640px) {
    .merge-review-item { padding: 10px; }
    /* 44px is this project's mobile touch-target minimum, applied per
       individual control — not "44px combined across the two fused buttons"
       as the previous comment here reasoned. 7px 12px padding + line-height
       computed to ~30px per button, well under the floor. */
    .merge-item-toggle-btn { padding: 7px 12px; min-height: 44px; }
}

/* ============================================================
   PAYEE AUTOCOMPLETE
   ============================================================ */
.payee-input-wrapper {
    position: relative;
}

.payee-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-menu);
    list-style: none;
    margin: 4px 0 0;
    padding: 4px 0;
    max-height: 240px;
    overflow-y: auto;
    display: none;
}

.payee-dropdown.is-open {
    display: block;
}

.payee-dropdown li {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.9375rem;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.payee-dropdown li:hover,
.payee-dropdown li.active {
    background: var(--color-brand-bg-subtle);
    color: var(--color-brand);
}

/* Mobile: shorter list so the dropdown is less likely to reach down over the
   field below it (viewport is short, especially with the keyboard open).
   132px = 3 full 44px rows (44px is this project's mobile touch-target
   minimum — see the li rule below), so the cap lands on a row boundary
   instead of cutting a row in half. */
@media (max-width: 640px) {
    .payee-dropdown {
        max-height: 132px;
    }

    .payee-dropdown li {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
}

/* ── Bill Sync collapsible (budget edit page) ──────────────────────────────── */

.bill-sync-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.bill-sync-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 14px;
    background: var(--color-badge-bg);
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text);
    text-align: left;
    gap: 8px;
    transition: background var(--transition);
}

.bill-sync-toggle:hover { background: var(--color-brand-bg-subtle); }

.bill-sync-toggle-label { flex: 1; }

.bill-sync-toggle-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.bill-sync-chevron {
    transition: transform var(--transition);
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.bill-sync-chevron.open { transform: rotate(180deg); }

.bill-sync-body {
    padding: 0 14px 14px;
}

/* ── Sync Bills button (overview page) ────────────────────────────────────── */
/* .bs-sync-row (the old standalone-row wrapper) is dead — Fix B moved the
   Sync Bills button/locked state inline with the "Bills" .bs-section-label
   heading, and Fix C #1 merged the Tithe/Paycheck rows that also used this
   class into their own .bs-row. Rule intentionally removed; if a similar
   standalone action row is ever needed again, don't resurrect this name
   without checking it isn't still assumed dead elsewhere. */

.btn-sync-bills,
.btn-tithe-mark,
.btn-paycheck-mark,
.btn-sinkfund-pay,
.btn-alloc-fund,
.btn-fund-save-mark,
.btn-fund-spending-mark,
.btn-pc-fund,
.btn-mark-paid {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-family: inherit;
    line-height: 1.4;
    padding: 5px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid var(--color-brand);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-brand);
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
    white-space: nowrap;
}

.btn-sync-bills:hover,
.btn-tithe-mark:hover,
.btn-paycheck-mark:hover,
.btn-sinkfund-pay:hover,
.btn-alloc-fund:hover,
.btn-fund-save-mark:hover,
.btn-fund-spending-mark:hover,
.btn-pc-fund:hover,
.btn-mark-paid:hover {
    background: var(--color-brand-fill);
    color: var(--color-text-on-brand);
}

.btn-sync-bills:disabled,
.btn-tithe-mark:disabled,
.btn-paycheck-mark:disabled,
.btn-sinkfund-pay:disabled,
.btn-alloc-fund:disabled,
.btn-fund-save-mark:disabled,
.btn-fund-spending-mark:disabled,
.btn-pc-fund:disabled,
.btn-mark-paid:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Disabled fund button + reason [B-110, preview slide 184] ────────────────
   Hover tooltip for a DISABLED .btn-alloc-fund / .btn-pc-fund: data-tooltip sits on
   this wrapper span (the global data-tooltip handler in app.js reads it), never on the
   button, because a disabled button swallows mouse events. The disabled child gets
   pointer-events:none so the hover lands on the wrapper (the :disabled look above,
   opacity .5 / not-allowed, still applies; the cursor shown is the wrapper's, so it is
   restated here). Desktop only; phones read .bs-fund-block-note. */
.fund-tipwrap {
    display: inline-flex;
}

.fund-tipwrap[data-tooltip] {
    cursor: not-allowed;
}

.fund-tipwrap > button:disabled {
    pointer-events: none;
}

/* ONE visible reason sentence under the Living Expenses section title (the block
   reason is per period and identical for every allocation, so it is not repeated per
   row). Brand-tinted note, tokens only; hidden with .u-hidden by bills.js when the
   bearing paycheck is marked received live. Sets no display, so .u-hidden wins. */
/* [2026-11-12] .bs-pay-block-note = the same one-sentence phone hint for the bill Paid / Xfer
   paycheck-received lock (glossary "Paycheck-received lock"); one note per bill list. */
.bs-fund-block-note,
.bs-pay-block-note {
    margin: 0.15rem 1.25rem 0.35rem;
    padding: 0.5rem 0.75rem;
    background: var(--color-brand-bg-subtle);
    border-left: 3px solid var(--color-brand);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--color-text);
}

/* Per Period view (pages/bills/index.php): page-level note above .bills-period-list, not
   inside a card, so no card-inset side margin. Margin only (no display: .u-hidden still wins). */
.bs-pay-block-note--page {
    margin: 0 0 0.75rem;
}

/* ── Confirmed state modifier (toggle-in-place) ──────────────────────────────
   [Preview slide 68, Option A — approved 2026-08-09] Every "confirm this
   happened" button (Mark Paid/Xfer, Net Pay Received, Tithe Given, Save
   Saved, Spending Money Funded, Living Expenses Fund) is the SAME button
   element in both states — never removed and replaced by a badge+separate-
   Unmark-button combo. Pre-confirm: outline chip (base rule above). Post-
   confirm: this .is-confirmed modifier re-colors the identical button with
   the exact token recipe the old .bill-paid-badge pill used (background/
   color/border only — box model, padding, and font-size are intentionally
   left untouched so the button doesn't change shape when it flips state).
   Clicking the confirmed button re-opens that row's existing unmark-confirm
   flow (.unmark-confirm-wrap and its feature-specific variants). Not applied
   to .btn-sync-bills — the standalone "Sync Bills" row keeps its own
   pre-existing locked-badge treatment; it was not part of this pass.
   .btn-sinkfund-pay ("Pay from Sinking Fund") converged onto this pattern
   later — see the single-element rollup button in pages/bills/index.php and
   its click handler in bills.js. */
.btn-tithe-mark.is-confirmed,
.btn-paycheck-mark.is-confirmed,
.btn-alloc-fund.is-confirmed,
.btn-fund-save-mark.is-confirmed,
.btn-fund-spending-mark.is-confirmed,
.btn-sinkfund-pay.is-confirmed,
.btn-pc-fund.is-confirmed,
.btn-mark-paid.is-confirmed {
    background: var(--color-success-bg);
    color: var(--color-success);
    border-color: var(--color-success);
}

.btn-tithe-mark.is-confirmed:hover,
.btn-paycheck-mark.is-confirmed:hover,
.btn-alloc-fund.is-confirmed:hover,
.btn-fund-save-mark.is-confirmed:hover,
.btn-fund-spending-mark.is-confirmed:hover,
.btn-sinkfund-pay.is-confirmed:hover,
.btn-pc-fund.is-confirmed:hover,
.btn-mark-paid.is-confirmed:hover {
    background: var(--color-success-bg);
    color: var(--color-success);
    opacity: 0.85;
}

/* Confirm state (inline, replaces button content).
   Fix 1 (grey box restore) restored the bordered callout box (border +
   radius + surface-alt background) that the old stacked .unmark-confirm-wrap
   had, but kept the content as a single horizontal row.
   Round 3 (mark-cleared box shape correction, "mark cleared issues.png") —
   Daniel confirmed the box shape itself was wrong: it needs to match the
   ORIGINAL .unmark-confirm-wrap / makeFundConfirm() 3-line STACKED layout
   exactly (question text line, checkbox line, Confirm/Cancel line), not a
   single wrapped row. flex-direction switched to column; the "Cleared"
   checkbox label and the Confirm/Cancel action row (wrapped in
   .sync-confirm-actions) are now separate stacked children instead of
   inline siblings. */
.sync-confirm-wrap {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 6px 10px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    max-width: 220px;
}

.sync-confirm-text {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}

/* Fix C #4 — "Cleared" checkbox label; the explanatory hint lives in this
   label's title tooltip instead of a separate visible line. Round 3: now
   its own stacked line (middle of 3) within .sync-confirm-wrap's column,
   not inline with the question text/buttons. */
.sync-confirm-cleared-label {
    font-size: 0.82rem;
    white-space: nowrap;
}

/* Round 3 — Confirm/Cancel button row, the 3rd stacked line in
   .sync-confirm-wrap's column layout. */
.sync-confirm-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-sync-confirm {
    padding: 4px 11px;
    font-size: 0.8rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-brand-fill);
    color: var(--color-text-on-brand);
    cursor: pointer;
    transition: background var(--transition);
}

.btn-sync-confirm:hover { background: var(--color-brand-fill-hover); }

.btn-sync-cancel {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.btn-sync-cancel:hover { color: var(--color-text); }

/* Fix 1 (mark-cleared confirm compaction round) — .inline-confirm-cleared
   (the old 2-line checkbox+hint block forced above the confirm text via
   flex-basis 100%) was removed. Every mark-cleared confirm step (Sync Bills,
   Fund Living Expenses, Tithe/Paycheck, Save/Spending) now uses the single
   .sync-confirm-cleared-label pattern below instead — see that rule. */

/* Synced badge */
/* .bill-synced-badge: hook only (badge badge--brand) — look lives on .badge. Same look as
   .sync-locked-badge (B-64 #15: one brand badge). */

.sync-error-inline {
    font-size: 0.8rem;
    color: var(--color-error);
    margin-top: 4px;
    text-align: right;
}

.sync-info-inline {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-top: 4px;
    text-align: right;
}

/* ── Unmark paid confirm ──────────────────────────────────────────────────── */
.unmark-confirm-wrap { display: inline-flex; flex-direction: column; gap: 4px; font-size: 0.8rem; padding: 6px 10px; background: var(--color-surface-alt); border: 1px solid var(--color-border); border-radius: var(--radius); max-width: 220px; }
.unmark-confirm-text { font-weight: 600; color: var(--color-text); }
.unmark-confirm-note { color: var(--color-text-muted); font-size: 0.75rem; }
.unmark-confirm-warning { display: block; background: var(--color-warning-bg); border: 1px solid var(--color-warning-border); border-radius: var(--radius-sm); color: var(--color-warning-text); font-size: 0.78rem; font-weight: 500; line-height: 1.35; padding: 6px 9px; margin-top: 2px; }
.unmark-confirm-actions { display: flex; gap: 6px; margin-top: 4px; }
.btn-unmark-confirm { font-size: 0.8rem; padding: 4px 11px; font-weight: 700; background: var(--color-danger); color: var(--color-on-solid); border: none; border-radius: var(--radius-sm); cursor: pointer; font-family: inherit; }
.btn-unmark-confirm:hover { opacity: 0.88; }
.btn-unmark-confirm:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-unmark-cancel { font-size: 0.8rem; padding: 0; background: none; color: var(--color-text-muted); border: none; cursor: pointer; font-family: inherit; text-decoration: underline; }
.btn-unmark-cancel:hover { color: var(--color-text); }
.unmark-error { color: var(--color-error); font-size: 0.75rem; }

/* Fund Save/Spending confirm error — sits as its own line below the
   Confirm/Cancel row within .sync-confirm-wrap's stacked column (Round 3). */
.fund-save-error,
.fund-spending-error,
.pc-fund-error,
.pc-unfund-error {
    text-align: left;
}

/* ── Bill Sync: locked state & override (overview page) ───────────────────── */

.sync-locked-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* .sync-locked-badge: hook only (badge badge--brand) — look lives on .badge. */

/* [Confirm-row button persistence, preview slide 68] .btn-tithe-unmark,
   .btn-paycheck-unmark, .btn-alloc-unfund, .btn-fund-save-unmark,
   .btn-fund-spending-unmark, and .btn-sinkfund-unmark used to be separate
   "Unmark"/"Unfund" buttons sitting next to a locked badge — all retired.
   Those rows now trigger the same unmark-confirm flow by clicking the single
   persistent .is-confirmed button itself (see the .is-confirmed rule above).
   .btn-sync-override (Bill Sync's reverse-sync link) was not part of this
   pass and keeps this separate-button shape. */
.btn-sync-override {
    padding: 3px 9px;
    font-size: 0.75rem;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: border-color var(--transition), color var(--transition);
}

.btn-sync-override:hover {
    border-color: var(--color-error-border);
    color: var(--color-error);
}

.sync-override-confirm {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    padding: 4px 0;
}

.sync-override-text {
    font-size: 0.82rem;
    color: var(--color-text);
}

.btn-override-confirm {
    padding: 4px 11px;
    font-size: 0.8rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-error);
    color: var(--color-on-solid);
    cursor: pointer;
    transition: background var(--transition);
}

.btn-override-confirm:hover { background: var(--color-error-hover); }

.btn-override-cancel {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
    font-family: inherit;
}

.btn-override-cancel:hover { color: var(--color-text); }

/* ── Tithe: Mark Tithe Given button & locked state (overview page) ─────────
   Mirrors the Bill Sync button/lock pattern immediately above — reuses
   .btn-sync-bills, .sync-locked-wrap, .sync-locked-badge, .btn-sync-override,
   .unmark-confirm-wrap and friends as-is. Only new classes below are the row
   wrapper and the "Given on <date>" label, plus tithe-specific confirm/cancel
   button classes (kept distinct from .btn-unmark-confirm/.btn-unmark-cancel
   so the two features' delegated click handlers in bills.js never collide on
   the same class name). See preview/ui-preview.html slide 37. */

/* .bs-tithe-row is now applied directly to the .bs-row that already carries
   the Tithe amount (Fix C #1 — converged onto the same single-line pattern
   as the "Mark Paid"/"Xfer'd" rows instead of rendering as its own stacked
   row below the amount). No layout rules needed here — it inherits .bs-row's
   flex layout as-is; the class only remains as a hook bills.js uses via
   .closest('.bs-tithe-row') to find the cleared-checkbox/error insertion
   point. */

/* "Cleared" confirm step for Mark Tithe/Paycheck Given. Clicking the mark
   button no longer fires the request directly — it swaps to this confirm
   block (checkbox + Confirm/Cancel). Fix 1 (mark-cleared confirm compaction
   round) moved this from the old stacked .unmark-confirm-wrap box shape
   onto .sync-confirm-wrap's single-line row (see makeTitheClearedConfirm()/
   makePaycheckClearedConfirm() in bills.js) — .tithe-cleared-confirm-wrap/
   .paycheck-cleared-confirm-wrap remain only as bills.js hooks, no layout
   rules needed. Own .btn-tithe-confirm-cleared/-cancel-cleared and
   .btn-paycheck-confirm-cleared/-cancel-cleared button classes keep this
   distinct from .btn-*-unmark-confirm/-cancel so delegated clicks in
   bills.js never collide. See preview/ui-preview.html slide 50 and
   shared-classname-click-delegation-collision memory. */

.btn-tithe-confirm-cleared,
.btn-paycheck-confirm-cleared,
.btn-fund-save-confirm,
.btn-fund-spending-confirm,
.btn-pc-fund-confirm {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: var(--color-brand-fill);
    color: var(--color-text-on-brand);
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
}

.btn-tithe-confirm-cleared:hover,
.btn-paycheck-confirm-cleared:hover,
.btn-fund-save-confirm:hover,
.btn-fund-spending-confirm:hover,
.btn-pc-fund-confirm:hover { opacity: 0.88; }

.btn-tithe-confirm-cleared:disabled,
.btn-paycheck-confirm-cleared:disabled,
.btn-fund-save-confirm:disabled,
.btn-fund-spending-confirm:disabled,
.btn-pc-fund-confirm:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-tithe-cancel-cleared,
.btn-paycheck-cancel-cleared,
.btn-fund-save-cancel,
.btn-fund-spending-cancel,
.btn-pc-fund-cancel {
    font-size: 0.75rem;
    padding: 3px 8px;
    background: none;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-family: inherit;
}

.btn-tithe-cancel-cleared:hover,
.btn-paycheck-cancel-cleared:hover,
.btn-fund-save-cancel:hover,
.btn-fund-spending-cancel:hover,
.btn-pc-fund-cancel:hover { color: var(--color-text); }

.tithe-given-date {
    font-size: 0.68rem;
    color: var(--color-text-muted);
}

/* ── Paycheck: Mark Paycheck Received button & locked state (overview page)
   Mirrors the Tithe button/lock pattern immediately above 1:1 (s/tithe/
   paycheck/) — reuses .btn-sync-bills/.btn-tithe-mark, .sync-locked-wrap,
   .sync-locked-badge and friends via the comma-separated selectors above.
   Only new classes are the row wrapper and "Received on <date>" label, plus
   paycheck-specific confirm/cancel button classes (kept distinct from both
   .btn-unmark-confirm/.btn-unmark-cancel and the tithe unmark classes so all
   three features' delegated click handlers in bills.js never collide on the
   same class name — see shared-classname-click-delegation-collision memory). */

/* .bs-paycheck-row mirrors .bs-tithe-row above 1:1 — see comment there.
   Now applied directly to the .bs-row carrying the Net Pay amount; no
   layout rules needed, kept only as a bills.js .closest() hook. */

.paycheck-given-date {
    font-size: 0.68rem;
    color: var(--color-text-muted);
}

/* ── Save / Fund (Spending Money) one-click (overview page) ────────────────
   Mirrors the Tithe/Paycheck button/lock pattern above 1:1 (s/tithe/
   fund-save or fund-spending/) — reuses .btn-tithe-mark/.btn-paycheck-mark,
   .sync-locked-wrap, .sync-locked-badge and .sync-confirm-wrap (Fix 1 —
   see makeFundConfirm() in bills.js) via the comma-separated selectors
   above. Own .btn-fund-save-confirm/-cancel and .btn-fund-spending-confirm/
   -cancel button classes keep this distinct from the tithe/paycheck confirm
   classes so bills.js's delegated clicks never collide (see
   shared-classname-click-delegation-collision memory). Unlike Tithe/
   Paycheck, .bs-fund-save-row/.bs-fund-spending-row are the row itself
   (label + value on the same line) rather than a standalone action row
   below it — they inherit .bs-row's flex layout as-is, so no extra rules
   are needed beyond the "Saved/Funded on <date>" label styling here. */

.save-funded-date,
.spending-funded-date {
    font-size: 0.68rem;
    color: var(--color-text-muted);
}

/* ── Multi-Income Pay Schedules (overview page) [2026-09-01] ──────────────────
   A budget can now have more than one pay_schedules row (one per income
   source); one is flagged primary. Approved via preview/ui-preview.html
   slides 70-72 (md/plans/multi-income-pay-schedules.md). Two new pieces:
   (1) .schedule-mgmt-strip — a budget-level "Income Sources" list sitting
   above the stacked grids (Add/Edit/Make Primary); (2) .schedule-section-
   header — the small header naming each schedule directly above its own
   .budget-statement-card grid, primary vs. non-primary distinguished only by
   background tint + badge (the card markup underneath is identical either
   way — see .schedule-grid-light-note for the only new row inside a
   non-primary card). .schedule-primary-badge is shared with
   pages/pay_schedules/index.php's own primary indicator so both pages use
   one visual for "this is the primary schedule." */

.schedule-mgmt-strip {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    margin-bottom: 1.25rem;
    overflow: hidden;
}

.schedule-mgmt-strip-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    padding: 0.625rem 0.875rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.schedule-mgmt-strip-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.schedule-mgmt-strip-title-group {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.schedule-mgmt-strip-title-total {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text);
}

.schedule-mgmt-strip-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 0.625rem 0.875rem;
    border-top: 1px solid var(--color-border);
}

.schedule-mgmt-strip-row:first-of-type {
    border-top: none;
}

.schedule-mgmt-strip-name {
    font-weight: 700;
    font-size: 0.86rem;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.schedule-mgmt-strip-meta {
    font-size: 0.72rem;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.schedule-mgmt-strip-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.schedule-mgmt-inline-form {
    display: inline-flex;
}

/* Shared "Primary" indicator — also used by pages/pay_schedules/index.php. */
/* .schedule-primary-badge: hook only (badge badge--brand badge--caps badge--outline) — look
   lives on .badge; the income-block rule above keeps its solid surface fill. */

/* Rounded-rectangle action button per the app-wide button corner-radius
   standard (not a pill) — this is a clickable action, not a badge. */
.btn-make-primary {
    font-size: 0.74rem;
    font-weight: 600;
    color: var(--color-text-muted);
    background: transparent;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    cursor: pointer;
    transition: color var(--transition), background-color var(--transition), border-color var(--transition);
}

.btn-make-primary:hover {
    color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
    border-color: var(--color-brand);
}

/* Header sitting directly above each schedule's own stacked grid of period
   cards, naming the income source. Primary gets the brand tint (matching
   .bs-card-header/.bs-row--checkpoint's existing brand-tint convention on
   this page); non-primary sits on the plain --color-bg-secondary tint with
   no badge. */
.schedule-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius) var(--radius) 0 0;
    background: var(--color-bg-secondary);
    border: 1px solid var(--color-border);
    border-bottom: none;
    margin: 1.5rem 0 0;
}

/* Matches .card-single .budget-statement-card's own width/centering so a
   1-column schedule header sits flush above its single card instead of
   spanning the full row width. */
.schedule-section-header--single {
    max-width: 520px;
    margin-left: auto;
    margin-right: auto;
}

.schedule-section-header--primary {
    background: var(--color-brand-bg-subtle);
    border-color: var(--color-brand-ring);
}

.schedule-section-header-name {
    font-size: 0.95rem;
    font-weight: 800;
    color: var(--color-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.schedule-section-header-meta {
    font-size: 0.72rem;
    color: var(--color-text-muted);
}

/* The grid immediately below a schedule header sits flush against it (no
   gap), and its first card's top corners square off so the header/grid read
   as one attached unit, mirroring .mock-schedule-grid's look in the preview. */
/* Vertical Stack Redesign [2026-09-04]: .card-single can now hold 2-3 stacked
   cards (cols=2/3 still controls fetch count, just stacked instead of
   side-by-side) — :first-child added so only the card actually touching the
   header gets its top corners squared, matching .card-row's existing
   :first-child scoping (previously .card-single was only ever given exactly
   one card, so the unscoped selector happened to be safe; it no longer is). */
.schedule-section-header + .card-single .budget-statement-card:first-child,
.schedule-section-header + .card-row .budget-statement-card:first-child {
    border-radius: 0 0 var(--radius) var(--radius);
}

.schedule-grid-light-note {
    font-size: 0.72rem;
    font-style: italic;
    color: var(--color-text-muted);
    padding: 0.5rem 1.25rem 0.75rem;
}

@media (max-width: 640px) {
    .schedule-mgmt-strip-row {
        flex-wrap: wrap;
    }
    .schedule-mgmt-strip-actions {
        width: 100%;
        justify-content: flex-end;
    }
    .btn-make-primary {
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }
}

/* ── Fund Living Expenses (bills/index.php Living Expenses allocation rows)
   .btn-alloc-fund/.btn-alloc-unfund reuse the Bill Sync button rules above
   (comma-separated selectors) for visual consistency, and .sync-locked-wrap/
   .sync-locked-badge are reused as-is for the funded state (same generic
   locked-state classes the Tithe/Paycheck features already share). The
   confirm dialogs mirror .sync-confirm-wrap/.sync-override-confirm exactly
   (Fund is a money transfer, so it gets the confirm-first UX like Sync
   Bills) but use their own .btn-alloc-fund-confirm/-cancel and .btn-alloc-unfund-confirm/
   -cancel classes so delegated clicks never collide with the sync/override
   handlers. See shared-classname-click-delegation-collision memory. */

.alloc-fund-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    padding: 0.5rem 0.875rem 0.625rem;
    border-top: 1px solid var(--color-border);
}

.alloc-fund-dest {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-right: auto;
}

.alloc-fund-hint {
    justify-content: flex-start;
}

.alloc-fund-hint-link {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    text-decoration: underline;
}

.alloc-fund-hint-link:hover { color: var(--color-text); }

/* Fix C #2 — on pages/bills/overview.php's Living Expenses list, the Fund/
   Unfund control is now nested inside .bs-row-value-group alongside the
   allocation's amount (same single-line pattern as "Mark Paid"/"Xfer'd")
   instead of rendering as its own bordered/padded row below it. This is a
   CSS-only, ancestor-scoped reset — render_alloc_fund_control() itself is
   untouched and unchanged for its other caller, the standalone allocation
   editor on pages/bills/index.php, which keeps the full .alloc-fund-row
   treatment (border, padding, destination text) as before.
   Mark-cleared confirm compaction round Fix 1 — the .alloc-fund-confirm-wrap
   exclusion below was removed. It was the root cause of the "Needs" row
   confirm floating disconnected between the label and value (see "mark
   cleared issues.png"): the confirm step kept .alloc-fund-row's border-top/
   padding/width:100% while excluded from this reset, producing a bordered
   box overlapping the row instead of sitting inline in it. The confirm step
   now gets the same reset as the resting/funded states so it renders inline
   within its own row, matching Sync Bills. .alloc-unfund-confirm (the
   reverse-transfer undo confirm, a different UX step not touched by Fix 1)
   keeps its own wider layout, so it stays excluded. */
.bs-row-value-group .alloc-fund-row:not(.alloc-unfund-confirm) {
    border-top: none;
    padding: 0;
    justify-content: flex-start;
    width: auto;
}

.bs-row-value-group .alloc-fund-dest {
    display: none;
}

/* Round 3 fix — restores the bordered/surface-alt/radius box that this
   confirm step was missing (the ".bs-row-value-group .alloc-fund-row:not(...)"
   reset above stripped border/padding/width for ALL alloc-fund-row states,
   but this box was never given its own override to grow them back the way
   .sync-confirm-wrap has). This was the root cause of the "Needs" row
   rendering as a borderless, overlapping/floating 3-line block instead of a
   clean stacked box (see "mark cleared issues.png"). The doubled selector
   matches the reset rule's specificity (0,3,0) so this wins the cascade tie
   inside .bs-row-value-group context (overview.php's inline rows) while the
   bare class still applies standalone (bills/index.php's allocation editor). */
.bs-row-value-group .alloc-fund-row.alloc-fund-confirm-wrap,
.alloc-fund-confirm-wrap {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 6px 10px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    width: auto;
    max-width: 220px;
}

.btn-alloc-fund-confirm {
    padding: 4px 11px;
    font-size: 0.8rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-brand-fill);
    color: var(--color-text-on-brand);
    cursor: pointer;
    transition: background var(--transition);
}

.btn-alloc-fund-confirm:hover { background: var(--color-brand-fill-hover); }

.btn-alloc-fund-cancel {
    font-size: 0.8rem;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.btn-alloc-fund-cancel:hover { color: var(--color-text); }

.alloc-unfund-confirm {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
    width: 100%;
}

.btn-alloc-unfund-confirm {
    padding: 4px 10px;
    font-size: 0.78rem;
    font-weight: 700;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--color-error);
    color: var(--color-on-solid);
    cursor: pointer;
    transition: background var(--transition);
}

.btn-alloc-unfund-confirm:hover { background: var(--color-error-hover); }

.btn-alloc-unfund-cancel {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    background: none;
    border: none;
    cursor: pointer;
    text-decoration: underline;
    padding: 0;
}

.btn-alloc-unfund-cancel:hover { color: var(--color-text); }

/* Touch target: these JS-injected confirm/cancel button pairs are compact
   inline controls on desktop, but need to meet the 44px minimum on mobile.
   Cancel siblings are included so each pair stays evenly sized and tappable
   (previously only the Confirm half of each pair was bumped). */
@media (max-width: 640px) {
    .btn-sync-confirm,
    .btn-unmark-confirm,
    .btn-override-confirm,
    .btn-tithe-unmark-confirm,
    .btn-paycheck-unmark-confirm,
    .btn-sinkfund-unmark-confirm,
    .btn-alloc-fund-confirm,
    .btn-alloc-unfund-confirm,
    .btn-fund-save-unmark-confirm,
    .btn-fund-spending-unmark-confirm,
    .btn-pc-fund-confirm,
    .btn-pc-unfund-confirm,
    .btn-sync-cancel,
    .btn-unmark-cancel,
    .btn-override-cancel,
    .btn-tithe-unmark-cancel,
    .btn-paycheck-unmark-cancel,
    .btn-sinkfund-unmark-cancel,
    .btn-alloc-fund-cancel,
    .btn-alloc-unfund-cancel,
    .btn-fund-save-unmark-cancel,
    .btn-fund-spending-unmark-cancel,
    .btn-pc-fund-cancel,
    .btn-pc-unfund-cancel,
    .btn-pc-fund,
    .btn-tithe-mark,
    .btn-paycheck-mark,
    .btn-sinkfund-pay,
    .btn-alloc-fund,
    .btn-fund-save-mark,
    .btn-fund-spending-mark {
        min-height: 44px;
        padding: 10px 16px;
    }
}

/* Income block action controls on phones [2026-09-30, slide 165]: the same
   32px visible box + invisible 44px ::after hit area as .bs-move-btn (28px
   for the Override toggle, ::after 8px out), instead of a 44px visible box.
   Scoped to .bs-income-block so the other pages that reuse .btn-mark-paid /
   .btn-tithe-mark / .btn-paycheck-mark keep their own sizing. This also
   brings .btn-mark-paid (Paid / Xfer, ~30px before) and the Override toggle
   (36px before) onto the 44px hit-area floor. Two-class selectors outrank the
   single-class 44px group above and .alloc-reorder-btn's phone rule. Each
   control sits on its own row or side of a row (>= 44px row pitch, 12px+
   gaps), so the hit areas do not reach another tap target. */
@media (max-width: 640px) {
    .bs-income-block .btn-mark-paid,
    .bs-income-block .btn-paycheck-mark,
    .bs-income-block .btn-tithe-mark,
    .bs-income-block .btn-pc-fund {
        position: relative;
        min-height: 32px;
        padding: 0 12px;
        font-size: 0.78rem;
    }

    .bs-income-block .income-override-toggle {
        position: relative;
        min-height: 28px;
        padding: 0 10px;
    }

    .bs-income-block .btn-mark-paid::after,
    .bs-income-block .btn-paycheck-mark::after,
    .bs-income-block .btn-tithe-mark::after,
    .bs-income-block .btn-pc-fund::after {
        content: "";
        position: absolute;
        inset: -6px 0;
    }

    .bs-income-block .income-override-toggle::after {
        content: "";
        position: absolute;
        inset: -8px 0;
    }
}

/* ── Pay from Sinking Fund: rollup-level payout + undo ────────────────────────
   .btn-sinkfund-pay reuses the Bill Sync/Tithe button rules above (comma-
   separated selectors) for visual consistency, and its .is-confirmed state
   reuses the same shared confirmed-state rules as every other "confirm this
   happened" button (see the .is-confirmed rule group). It's a single
   persistent element in both states — never swapped for a separate Unmark
   button — matching the app-wide pattern (Mark Paid, Tithe, Net Pay, etc).
   The confirm dialog reuses #bill-scope-backdrop/#bill-scope-modal
   (assets/js/bills.js never coexists with bills-form.js or
   pay-schedule-form.js on the same page, so there's no ID collision — same
   reuse already established by pay-schedule-form.js's tithe-base-change
   dialog). The undo affordance reuses .unmark-confirm-wrap's shape with its
   own .btn-sinkfund-unmark-confirm/.btn-sinkfund-unmark-cancel/
   .sinkfund-unmark-wrap classes so its delegated click handling never
   collides with the per-instance unmark handler or the tithe unmark handler.
   See preview/ui-preview.html slide 38. */

/* ── Mark-paid modal: Bill Sync account lock ────────────────────────────────── */

.mp-lock-note {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-top: 5px;
}

.mp-lock-note svg { flex-shrink: 0; }

.mp-change-account {
    color: var(--color-brand);
    font-size: 0.78rem;
    text-decoration: underline;
    cursor: pointer;
}

.mp-account-warning {
    font-size: 0.78rem;
    color: var(--color-error);
    display: block;
    width: 100%;
    margin-top: 2px;
}

/* .mp-lock-note and .mp-account-warning both set their own `display` and
   appear later in this file than the shared `.u-hidden` utility (same
   specificity, later source order wins) — without this override,
   `u-hidden` silently loses the cascade on these two elements and they
   stay visible even with the class applied. Two-class selector raises
   specificity so u-hidden reliably wins regardless of source order. */
.mp-lock-note.u-hidden,
.mp-account-warning.u-hidden {
    display: none;
}

/* ── Mark-paid: link existing transaction panel ──────────────────────────────── */

.mp-link-toggle-row { text-align: center; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--color-border); }
.mp-link-toggle { font-size: 0.85rem; color: var(--color-brand); text-decoration: none; }
.mp-link-toggle:hover { text-decoration: underline; }
.mp-link-back { font-size: 0.85rem; color: var(--color-text-muted); text-decoration: none; }
.mp-link-back:hover { color: var(--color-text); }
.mp-link-header { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.mp-link-hint { font-size: 0.85rem; color: var(--color-text-muted); margin: 0; }
.mp-link-list { max-height: 240px; overflow-y: auto; border: 1px solid var(--color-border); border-radius: var(--radius); }
.mp-link-loading,
.mp-link-empty { padding: 16px; text-align: center; color: var(--color-text-muted); font-size: 0.875rem; margin: 0; }
.mp-tx-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; cursor: pointer; border-bottom: 1px solid var(--color-border); gap: 8px; }
.mp-tx-row:last-child { border-bottom: none; }
.mp-tx-row:hover { background: var(--color-row-hover); }
.mp-tx-row--selected { background: var(--color-brand-bg-subtle); outline: 2px solid var(--color-brand); outline-offset: -2px; }
.mp-tx-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.mp-tx-payee { font-size: 0.9rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mp-tx-meta { font-size: 0.78rem; color: var(--color-text-muted); }
.mp-tx-amount { font-size: 0.9rem; font-weight: 600; flex-shrink: 0; }
.mp-tx-debit { color: var(--color-danger); }
.mp-tx-credit { color: var(--color-success); }

/* ── Bill edit: sync grayout note ───────────────────────────────────────────── */

.field-hint {
    display: block;
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin-top: 4px;
}

.field-hint a { color: var(--color-brand); }

/* ── Sub-bills inline section (bills/create.php) ─────────────────────────────── */

.sub-bills-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--color-border);
}

.sub-bills-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    background: none;
    border: none;
    padding: 0.25rem 0;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
}

.sub-bills-toggle:hover .sub-bills-title {
    color: var(--color-brand);
}

.sub-bills-toggle-icon {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.sub-bills-body {
    padding-top: 0.5rem;
}

.sub-bills-header-actions {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 0.5rem;
}

.sub-bills-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
}

.sub-bills-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--color-text);
}

.sub-bills-hint {
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    margin-top: 0.5rem;
}

/* Each sub-bill row — labeled card layout */
.sub-bill-row {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 14px 14px 10px;
    margin-bottom: 8px;
    position: relative;
}

.sub-bill-row-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 14px;
    margin-bottom: 10px;
}

/* Wider screens: 4 fields (Name, Amount, Budget Date, Frequency) fit in one row */
@media (min-width: 900px) {
    .sub-bill-row-grid {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }
}

/* Read-only derived values (e.g. parent bill's Amount, sub-bill's inherited Category) */
.input-readonly {
    width: 100%;
    background: var(--color-surface-alt);
    color: var(--color-text-muted);
    cursor: not-allowed;
}

.field-readonly-value {
    margin: 0;
    padding: 8px 10px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 0.9rem;
}

.sub-bill-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sub-bill-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.sub-bill-label-optional {
    font-weight: 400;
    opacity: 0.65;
}

/* Visual styling comes from the shared .remove-row (B-64 item 9). This one is the
   text form ("x Remove") on its own line under the sub-bill fields, so the glyph
   size drops to the body-small size. */
.btn-remove-sub-bill {
    font-size: var(--font-size-md);
}

/* Mobile: single column sub-bill grid */
@media (max-width: 640px) {
    .sub-bill-row-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Sub-bills index rows ────────────────────────────────────────────────── */
.sub-bills-expand-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 6px;
    color: var(--color-text-muted);
    font-size: 0.75rem;
    line-height: 1;
    border-radius: var(--radius-sm);
    transition: color var(--transition);
    font-family: inherit;
}
.sub-bills-expand-btn:hover { color: var(--color-brand); }

.sub-bills-chevron { display: inline-block; transition: transform var(--transition); }

.sub-bills-rows { padding-left: 0; }

.sub-bill-row-index {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px 6px 32px;
    border-bottom: 1px solid var(--color-bg);
    font-size: 0.875rem;
}
.sub-bill-row-index:last-child { border-bottom: none; }

.sub-bill-indent-icon {
    color: var(--color-text-muted);
    font-size: 0.8rem;
    flex-shrink: 0;
}

.sub-bill-row-name { flex: 1; color: var(--color-text); }
.sub-bill-row-amount { color: var(--color-text-muted); font-size: 0.8rem; flex-shrink: 0; }

/* ── Convert-to-Parent preview list (bills/edit.php) ─────────────────────── */
.sub-bills-preview-list {
    list-style: none;
    margin: 0 0 4px;
    padding: 0;
}

.sub-bills-preview-list li {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 10px;
    padding: 6px 12px;
    border-bottom: 1px solid var(--color-bg);
    font-size: 0.875rem;
}
.sub-bills-preview-list li:last-child { border-bottom: none; }

.sub-bills-preview-name {
    flex: 1;
    min-width: 0;
    color: var(--color-text);
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* .sub-bills-preview-badge: hook only (badge badge--brand) — look lives on .badge. */

/* Sub-bills checkbox enable row */
.sub-bills-enable-row {
    margin-bottom: 12px;
}
.sub-bills-enable-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    color: var(--color-text);
}

/* Amount warning */
.sub-bills-amount-warning {
    background: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius-sm);
    color: var(--color-warning-text);
    font-size: 0.85rem;
    padding: 8px 12px;
    margin-top: 8px;
}

/* ── Sub-accounts inline section (accounts/create.php) ───────────────────────── */

/* [2026-09-21, B-02 / slide 142] The section is now a .form-reveal (indented, left rule)
   inside the Structure tab instead of its own bordered box, so the id no longer carries a
   box — .form-reveal supplies margin/padding/rule. The id stays as the bills-form.js hook. */
#sub-accounts-section {
    margin-top: 12px;
}

.sub-account-row {
    display: grid;
    grid-template-columns: 1fr 7rem 2rem;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.sub-account-row--auto {
    grid-template-columns: 1fr;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-style: italic;
}

/* Visual styling comes from the shared .remove-row (B-64 item 9). The grid's last
   column is the button's hit area, so it grows to 32px (44px on phones). */
.btn-remove-sub-acct {
    padding: 0;
}

@media (max-width: 640px) {
    .sub-account-row:not(.sub-account-row--auto) {
        grid-template-columns: 1fr 6rem 44px;
    }
}

/* ── Edit Account tabs (pages/accounts/edit.php, B-02 / slide 142) ───────────────
   Only what the page-neutral tab CSS (.form-struct-*, .form-sublist*, .form-panel,
   .form-action-row) cannot cover. */

/* Sub-account list row: name in body colour on the left (the shared .form-sublist-row
   mutes every span), "(system)" hint + the shared icon-only edit button on the right. */
.form-sublist-row .account-sublist-name {
    color: var(--color-text);
    align-self: center;
}

.form-sublist-row .account-sublist-tail {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

/* Blocked "Move to another account" reason sits under its row (the shared
   .edit-section-block-reason box, just given bottom spacing inside a panel). */
.account-move-blocked {
    margin-bottom: 12px;
}

/* Reconciliation panel: the badge/toggle/undo controls were 44px-short on touch. */
@media (max-width: 640px) {
    .account-recon-panel .recon-accuracy-stat,
    .account-recon-panel .recon-undo-btn {
        min-height: 44px;
    }
}

/* Archive resolve-balances panel is focused programmatically on load (accounts-form.js),
   so it takes no visible ring of its own — its controls carry the app's own focus rings. */
#archive-resolve-panel:focus {
    outline: none;
}

/* ── Edit Budget tabs (pages/budgets/edit.php, B-02 / slide 143) ─────────────────
   Only what the page-neutral tab CSS (.form-tabs, .form-tab-panel, .form-action-row,
   .form-reveal, .form-status-switch*, .form-danger-zone) cannot cover. */

/* Bill Sync row (Behavior tab): title + hint left, the shared .form-status-switch right.
   Stays a row on mobile (unlike .form-action-row, which stacks its button full-width). */
.budget-sync-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 4px;
}

/* Pay tab: the Pay Schedule row is the first thing in the panel, so it has no divider or
   top padding of its own (.form-action-row draws a top rule for rows that follow another). */
.budget-pay-row {
    border-top: 0;
    padding-top: 0;
}

@media (max-width: 640px) {
    /* 44px touch floor for the behavior checkbox rows (were ~40px). */
    .budget-behavior-list .checkbox-label {
        min-height: 44px;
        box-sizing: border-box;
    }
}

/* ── Pay Schedule create/edit tabs (pages/pay_schedules/*.php, B-02 / slide 144) ─────
   Only what the page-neutral tab CSS cannot cover: the header status slot holds either the
   .default-star-badge (Primary) or a one-button <form> (Set Primary, .btn-set-default). */
.form-status-form {
    margin: 0;
}

@media (max-width: 640px) {
    /* 44px touch floor for the header Set Primary button (was ~28px in its old own row). */
    .form-status-form .btn-set-default {
        min-height: 44px;
        box-sizing: border-box;
    }
}

/* ── Bill edit: account override warning ─────────────────────────────────────── */

/* ── Category combobox (styled dropdown-you-can-also-type-in) ────────────────
   Replaces the native <input list> + <datalist> pattern (rendered inconsistently
   across browsers — Chrome shows a dropdown arrow, Firefox/Safari don't). The
   listbox is positioned with `position: fixed` (set inline via JS from
   getBoundingClientRect, see category-combobox.js) rather than `position:
   absolute`, so it always escapes ancestor stacking/overflow without needing to
   audit every .form-card/.sub-bill-row container that might clip it. All
   colors use existing CSS variables, so this already adapts to dark mode
   automatically — no separate dark-mode override block needed. */
.category-combobox {
    position: relative;
}

.category-combobox-control {
    position: relative;
    display: flex;
    align-items: center;
}

.category-combobox-input {
    padding-right: 34px !important;
}

.category-combobox-toggle {
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color var(--transition), background-color var(--transition);
}

.category-combobox-toggle:hover {
    color: var(--color-brand);
    background-color: var(--color-brand-bg-subtle);
}

.category-combobox-toggle svg {
    transition: transform var(--transition);
}

.category-combobox.open .category-combobox-toggle svg {
    transform: rotate(180deg);
}

.category-combobox-list {
    display: none;
    position: fixed;
    list-style: none;
    margin: 0;
    padding: 4px 0;
    max-height: 280px;
    overflow-y: auto;
    background-color: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    /* One higher than .payee-dropdown's z-index: 1000 — pages/register/add.php
       and edit.php can have both widgets' dropdowns open near each other, and
       the category combobox (the more complex of the two) should win the tie. */
    z-index: 1001;
}

.category-combobox.open .category-combobox-list {
    display: block;
}

.category-combobox-group-header {
    padding: 8px 12px 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--color-text-muted);
}

.category-combobox-option {
    padding: 8px 12px;
    font-size: 0.875rem;
    color: var(--color-text);
    cursor: pointer;
    transition: background-color var(--transition);
}

.category-combobox-option:hover,
.category-combobox-option.active {
    background-color: var(--color-brand-bg-subtle);
    color: var(--color-brand);
}

.category-combobox-option[aria-selected="true"] {
    font-weight: 600;
}

.category-combobox-empty {
    padding: 8px 12px;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
    font-style: italic;
}

/* Mobile: taller touch targets (44px minimum) */
@media (max-width: 640px) {
    .category-combobox-option,
    .category-combobox-group-header {
        padding: 12px;
    }
}

/* ── Bill edit: account override warning ─────────────────────────────────────── */

/* :not(.u-hidden) — a bare display:block here sits later in the cascade than
   .u-hidden and would defeat it (warning always visible). */
.bill-edit-acct-override-warning:not(.u-hidden) {
    display: block;
    font-size: 0.8125rem;
    color: var(--color-error);
    margin-top: 0.25rem;
}

/* ══ Admin Glossary page [2026-09-28] ═══════════════════════════════════════════
   pages/admin/glossary.php (markup, rendered from md/glossary.md by
   includes/glossary_helpers.php) + assets/js/glossary.js (search, filters,
   hash-open, expand/collapse, live UI/UX demos). Everything here is namespaced
   .gl-* so no other page is affected. Mobile first: one column with the index
   as a top block (its sections are native <details>, collapsed by default);
   from 641px a sticky index column sits beside the entries. Colours are theme
   tokens only, so dark mode follows [data-theme="dark"]. Focus-visible rings for
   the summaries/demo controls live in the shared 7b focus-visible list. */

.gl-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
}

.gl-sidebar,
.gl-main {
    min-width: 0;
}

/* Filtering uses the `hidden` attribute; keep it authoritative. */
.gl-entry[hidden],
.gl-section[hidden],
.gl-nav-section[hidden],
.gl-nav-item[hidden],
.gl-no-results[hidden] {
    display: none;
}

/* ── Index / sidebar ── */
.gl-nav {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    padding: 14px;
}

.gl-search {
    margin-bottom: 0;
}

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

.gl-search-input {
    width: 100%;
    min-height: 44px;
    padding: 10px var(--space-3);
    font-family: inherit;
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-input-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.gl-search-input::placeholder {
    color: var(--color-text-muted);
}

.gl-search-input:focus {
    outline: none;
    border-color: var(--color-brand);
    box-shadow: 0 0 0 3px var(--color-brand-ring);
}

.gl-nav-section {
    border-top: 1px solid var(--color-border);
}

/* With section tabs the index holds only the selected section's list. On
   desktop (sticky side column) it is always open, so its collapsible header
   and divider would only repeat the tab; on phones, where the index sits above
   the entries, the header stays so the list can stay collapsed. */
@media (min-width: 641px) {
    .gl-nav--tabbed .gl-nav-section {
        border-top: 0;
    }

    .gl-nav--tabbed .gl-nav-section-summary {
        display: none;
    }

    .gl-nav--tabbed .gl-nav-list {
        margin-bottom: 0;
        padding-left: 0;
    }
}

/* Shared summary chrome: no native marker, custom chevron, 44px rows. */
.gl-nav-section-summary,
.gl-entry-summary {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background-color var(--transition), color var(--transition);
}

.gl-nav-section-summary::-webkit-details-marker,
.gl-entry-summary::-webkit-details-marker {
    display: none;
}

.gl-nav-section-summary::before,
.gl-entry-summary::before {
    content: '';
    display: inline-block;
    flex-shrink: 0;
    width: 7px;
    height: 7px;
    margin: 0 3px 0 2px;
    border-right: 2px solid var(--color-text-muted);
    border-bottom: 2px solid var(--color-text-muted);
    transform: rotate(-45deg);
    transition: transform var(--transition), border-color var(--transition);
}

.gl-nav-section[open] > .gl-nav-section-summary::before,
.gl-entry[open] > .gl-entry-summary::before {
    transform: rotate(45deg);
    border-color: var(--color-brand);
}

.gl-nav-section-summary:focus-visible,
.gl-entry-summary:focus-visible {
    outline-offset: -2px;
}

.gl-nav-section-summary {
    padding: 6px 6px;
    font-size: var(--font-size-md);
    font-weight: 600;
    color: var(--color-text);
    border-radius: var(--radius-sm);
}

.gl-nav-section-summary:hover {
    color: var(--color-brand);
}

.gl-nav-section-label {
    flex: 1;
    min-width: 0;
}

.gl-count {
    flex-shrink: 0;
    min-width: 24px;
    padding: 1px var(--space-2);
    font-size: 0.72rem;
    font-weight: 700;
    text-align: center;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted);
    background: var(--color-badge-bg);
    border-radius: 99px;
}

.gl-nav-list {
    list-style: none;
    margin: 0 0 var(--space-2);
    padding: 0 0 0 var(--space-3);
}

.gl-nav-link {
    display: block;
    padding: 5px var(--space-2);
    font-size: var(--font-size-sm);
    line-height: 1.35;
    color: var(--color-text-muted);
    text-decoration: none;
    border-left: 2px solid transparent;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    overflow-wrap: anywhere;
    transition: background-color var(--transition), color var(--transition);
}

.gl-nav-link:hover {
    color: var(--color-text);
    background: var(--color-row-hover);
    text-decoration: none;
}

.gl-nav-link[aria-current="true"] {
    color: var(--color-brand);
    font-weight: 600;
    background: var(--color-brand-bg-subtle);
    border-left-color: var(--color-brand);
}

/* ── Main column ── */
.gl-main {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.gl-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-3);
}

.gl-toolbar-status {
    margin: 0;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.gl-toolbar-actions {
    display: flex;
    gap: var(--space-2);
}

.gl-no-results {
    margin: 0;
    padding: 20px var(--space-4);
    text-align: center;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.gl-section {
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
    scroll-margin-top: calc(var(--nav-height) + var(--gl-strip-h) + 12px);
}

/* Section header: a plain heading row now that each section is its own tab
   (it was a collapsible summary on the one-long-page layout). */
.gl-section-head {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: var(--space-3) var(--space-4);
}

.gl-section-title {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--color-text);
}

.gl-section-intro {
    padding: var(--space-1) var(--space-4) var(--space-2);
    font-size: var(--font-size-md);
    color: var(--color-text-muted);
}

.gl-entry {
    border-top: 1px solid var(--color-border);
    scroll-margin-top: calc(var(--nav-height) + var(--gl-strip-h) + 12px);
}

.gl-section > .gl-entry:last-child,
.gl-section > .gl-entry:last-child > .gl-entry-summary {
    border-radius: 0 0 var(--radius) var(--radius);
}

.gl-entry-summary {
    flex-wrap: wrap;
    row-gap: var(--space-1);
    padding: 10px var(--space-4);
    font-size: var(--font-size-base);
    font-weight: 600;
    color: var(--color-text);
}

.gl-entry-summary:hover {
    background: var(--color-row-hover);
}

.gl-entry[open] > .gl-entry-summary {
    background: var(--color-brand-bg-subtle);
}

.gl-entry-title {
    flex: 1 1 12em;
    min-width: 0;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

/* Status/date tag from "Title [2026-09-05, security audit]" — a badge, so pill shape. */
.gl-entry-tag {
    flex-shrink: 1;
    max-width: 100%;
    padding: 2px 9px;
    font-size: var(--font-size-2xs);
    font-weight: 600;
    color: var(--color-text-muted);
    background: var(--color-badge-bg);
    border-radius: 99px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gl-entry-body {
    padding: var(--space-3) var(--space-4) var(--space-4) 36px;
}

/* ── Rendered markdown ── */
.gl-entry-text,
.gl-section-intro {
    font-size: 0.9rem;
    line-height: 1.6;
    overflow-wrap: break-word;
}

.gl-entry-text p,
.gl-section-intro p,
.gl-quote p {
    margin: 0 0 10px;
}

.gl-entry-text > :last-child,
.gl-section-intro > :last-child,
.gl-quote > :last-child,
.gl-list li > :last-child {
    margin-bottom: 0;
}

.gl-list {
    margin: 0 0 10px;
    padding-left: 1.4em;
}

.gl-list li {
    margin: 3px 0;
}

.gl-list .gl-list {
    margin: var(--space-1) 0 0;
}

.gl-code-inline,
.gl-code-block,
.gl-wikilink {
    font-family: var(--font-mono);
}

.gl-code-inline {
    padding: 0 var(--space-1);
    font-size: 0.85em;
    color: var(--color-text);
    background: var(--color-badge-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow-wrap: anywhere;
}

.gl-code-block {
    margin: 0 0 var(--space-3);
    padding: var(--space-3) 14px;
    font-size: var(--font-size-sm);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    white-space: pre;
}

.gl-code-block code {
    font-family: inherit;
}

.gl-quote {
    margin: 0 0 var(--space-3);
    padding: var(--space-2) 14px;
    color: var(--color-text);
    background: var(--color-brand-bg-subtle);
    border-left: 3px solid var(--color-brand);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.gl-subhead {
    margin: var(--space-4) 0 6px;
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--color-text);
}

.gl-rule {
    margin: 14px 0;
    border: 0;
    border-top: 1px solid var(--color-border);
}

.gl-link {
    color: var(--color-brand);
    overflow-wrap: anywhere;
}

.gl-wikilink {
    padding: 0 var(--space-1);
    font-size: 0.8em;
    color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
    border-radius: var(--radius-sm);
    overflow-wrap: anywhere;
}

.gl-link-blocked,
.gl-entry-text del {
    color: var(--color-text-muted);
}

/* Pipe tables -> CSS grid (no <table>). Column count comes from data-cols; any
   count without an explicit rule falls back to auto columns. Narrow screens
   scroll the table sideways inside its own box, never the page. */
.gl-table {
    margin: 0 0 var(--space-3);
    font-size: var(--font-size-sm);
    line-height: 1.45;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow-x: auto;
}

.gl-row {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(120px, 1fr);
}

.gl-table[data-cols="1"] .gl-row { grid-auto-flow: row; grid-template-columns: minmax(0, 1fr); }
.gl-table[data-cols="2"] .gl-row { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(130px, 1fr)); min-width: 260px; }
.gl-table[data-cols="3"] .gl-row { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(120px, 1fr)); min-width: 360px; }
.gl-table[data-cols="4"] .gl-row { grid-auto-flow: row; grid-template-columns: repeat(4, minmax(115px, 1fr)); min-width: 460px; }
.gl-table[data-cols="5"] .gl-row { grid-auto-flow: row; grid-template-columns: repeat(5, minmax(110px, 1fr)); min-width: 550px; }
.gl-table[data-cols="6"] .gl-row { grid-auto-flow: row; grid-template-columns: repeat(6, minmax(105px, 1fr)); min-width: 630px; }

.gl-row + .gl-row {
    border-top: 1px solid var(--color-border);
}

.gl-row--head {
    font-weight: 700;
    background: var(--color-surface-alt);
}

.gl-cell {
    min-width: 0;
    padding: 7px 10px;
    border-left: 1px solid var(--color-border);
    overflow-wrap: anywhere;
}

.gl-cell:first-child {
    border-left: 0;
}

/* ── Live UI/UX demos (built by glossary.js with the app's real classes) ──
   Entries with no visual component keep an empty .gl-demo, hidden here. The
   frame is border-only (dashed = "example", not a real card). */
.gl-demo {
    margin: 0 0 14px;
    padding: 10px var(--space-3) var(--space-3);
    background: var(--color-bg);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
}

.gl-demo:empty {
    display: none;
}

.gl-demo-caption {
    margin: 0 0 var(--space-2);
    font-size: var(--font-size-2xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.gl-demo-stage {
    padding: 14px;
    background: var(--color-surface);
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.9rem;
}

.gl-demo-note {
    margin: var(--space-2) 0 0;
    font-size: var(--font-size-xs);
    line-height: 1.45;
    color: var(--color-text-muted);
}

.gl-demo-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.gl-demo-stack {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.gl-demo-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
}

.gl-demo-label--do {
    color: var(--color-success);
}

.gl-demo-label--dont {
    color: var(--color-error);
}

.gl-demo-dont {
    color: var(--color-text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--color-error);
}

.gl-demo-status {
    margin: 0;
    font-size: var(--font-size-xs);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.gl-demo button {
    font-family: inherit;
}

/* Demo JS toggles the `hidden` attribute on elements whose real classes set a
   display value (.bs-move-btn, .recon-line-list ...); keep `hidden` winning. */
.gl-demo [hidden] {
    display: none;
}

.gl-demo .form-group:last-child {
    margin-bottom: 0;
}

/* Statement-card family: narrower than the overview page, same classes. */
.gl-demo .budget-statement-card {
    width: 100%;
    max-width: 440px;
}

.gl-demo .card-single .budget-statement-card {
    max-width: 440px;
}

.gl-demo .card-single {
    align-items: stretch;
}

.gl-demo .schedule-section-header {
    max-width: 440px;
    margin: 0;
}

.gl-demo .gl-demo-stack > .schedule-section-header ~ .schedule-section-header {
    margin-top: var(--space-2);
}

.gl-demo .schedule-section-header + .budget-statement-card {
    border-radius: 0 0 var(--radius) var(--radius);
}

/* Category combobox: the real list is position:fixed (escapes clipping); in a
   demo it opens in flow instead. */
.gl-demo .category-combobox {
    max-width: 320px;
}

.gl-demo .category-combobox-list {
    position: static;
    margin-top: var(--space-1);
    max-height: 220px;
    box-shadow: none;
}

.gl-demo select {
    max-width: 320px;
}

/* Sticky save bar, contained: sticks to the bottom of a small scroll box instead
   of the viewport. */
.gl-demo-save-frame {
    max-height: 210px;
    max-width: 440px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.gl-demo-save-fields {
    padding: var(--space-3) var(--space-3) var(--space-1);
}

.gl-demo .gl-demo-save-frame .sticky-save-bar {
    position: sticky;
    left: auto;
    bottom: 0;
    transform: none;
    width: auto;
    max-width: none;
    z-index: 1;
    margin: 0;
    padding: 10px var(--space-3);
    background-color: var(--color-surface);
    border-top: 1px solid var(--color-border);
    box-shadow: 0 -4px 10px var(--color-shadow-hover);
}

/* Tabbed form page: the real mobile panel is a full-bleed band (negative
   margins cancel the page gutter); inside a demo keep it in the box. */
.gl-demo .form-tabs {
    max-width: 520px;
}

.gl-demo .form-danger-zone {
    max-width: 520px;
    margin-top: var(--space-4);
}

/* Entity tab strip uses real .page-tab links in the app; demo tabs are buttons. */
.gl-demo button.page-tab {
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    font-family: inherit;
    cursor: pointer;
}

.gl-demo button.page-tab.page-tab--active {
    border-bottom-color: var(--color-brand);
}

.gl-demo .page-tabs {
    margin-bottom: 0;
}

/* Drag demo: handles always visible (the app hides them until hover / Reorder). */
.gl-demo-sortable {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 360px;
}

.gl-demo-sortable .edit-row-item {
    justify-content: flex-start;
    gap: var(--space-2);
    padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
}

.gl-demo-sortable .gl-demo-sortable-amount {
    margin-left: auto;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-muted);
}

.gl-demo-sortable .drag-handle {
    display: inline-flex;
    opacity: 0.5;
}

.gl-demo-sortable .drag-handle:hover {
    opacity: 1;
}

.gl-demo .info-dot {
    margin-left: 6px;
}

.gl-demo .import-steps {
    margin-bottom: var(--space-3);
    padding: 0;
}

.gl-demo .merge-review-list,
.gl-demo .recon-line-list,
.gl-demo .bill-sync-section {
    max-width: 480px;
}

.gl-demo .bill-scope-option {
    max-width: 480px;
}

/* ── Desktop: sticky index column ── */
@media (min-width: 641px) {
    .gl-layout {
        grid-template-columns: 230px minmax(0, 1fr);
        gap: var(--space-5);
        align-items: start;
    }

    .gl-sidebar {
        position: sticky;
        top: calc(var(--nav-height) + var(--gl-strip-h) + 16px);
    }

    .gl-nav {
        max-height: calc(100vh - var(--nav-height) - var(--gl-strip-h) - 32px);
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

@media (min-width: 900px) {
    .gl-layout {
        grid-template-columns: 260px minmax(0, 1fr);
    }
}

/* ── Phone ── */
@media (max-width: 640px) {
    .gl-page .page-header {
        flex-wrap: wrap;
    }

    .gl-nav-link {
        display: flex;
        align-items: center;
        min-height: 44px;
    }

    .gl-section-intro,
    .gl-entry-body {
        padding-left: var(--space-4);
    }

    .gl-entry-body {
        padding-right: var(--space-3);
    }

    .gl-demo {
        padding: var(--space-2);
    }

    .gl-demo-stage {
        padding: 10px;
    }

    .gl-demo .form-tabs .form-tab-panel {
        margin-left: 0;
        margin-right: 0;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-sm);
    }

    /* Same 44px floor the app gives its segmented pills in their real row. */
    .gl-demo .bills-seg-btn {
        min-height: 44px;
    }

    .gl-toolbar-actions {
        width: 100%;
    }

    .gl-toolbar-actions .btn {
        flex: 1;
    }
}

@media (prefers-reduced-motion: reduce) {
    .gl-nav-section-summary::before,
    .gl-entry-summary::before {
        transition: none;
    }
}

/* ══ Admin Glossary: view switcher + Style Guide [2026-09-28] ═══════════════════
   Style Guide | Reference tabs (the shared .bills-view-segmented/.bills-seg-btn
   segmented toggle, used here as buttons) and the Style Guide view built by
   assets/js/styleguide.js. Every specimen value is read from the live CSS by
   that script; this block only lays specimens out. Preview panels carry their
   own data-theme ([data-theme="dark"] re-themes the tokens on the panel), so
   everything here uses tokens only. Focus rings: shared 7b list. */

/* Height of the sticky tab strip (44px tabs + 1px baseline): sticky offsets
   and scroll margins below the strip add it. */
.gl-page {
    --gl-strip-h: 45px;
}

.gl-page button.bills-seg-btn {
    font-family: inherit;
    cursor: pointer;
}

.gl-viewbar {
    display: flex;
    margin: -8px 0 20px;
}

.gl-view[hidden] {
    display: none;
}

.sg-root {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sg-intro,
.sg-section-lede,
.sg-toolbar-note,
.sg-note {
    margin: 0;
    color: var(--color-text-muted);
}

.sg-intro {
    font-size: var(--font-size-base);
}

/* ── Sticky jump-nav (scrolls sideways on phones) ── */
.sg-jumpnav {
    position: sticky;
    top: var(--nav-height);
    z-index: 20;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

/* Edge fades: shown only while there is more to scroll that way. */
.sg-jumpnav::before,
.sg-jumpnav::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 1px;
    width: 40px;
    z-index: 1;
    pointer-events: none;
    opacity: 0;
    transition: opacity var(--transition);
}

.sg-jumpnav::before {
    left: 0;
    background: linear-gradient(to right, var(--color-bg) 35%, transparent);
}

.sg-jumpnav::after {
    right: 0;
    background: linear-gradient(to left, var(--color-bg) 35%, transparent);
}

.sg-jumpnav.has-prev::before,
.sg-jumpnav.has-next::after {
    opacity: 1;
}

.sg-jump-arrow {
    position: absolute;
    top: 0;
    bottom: 1px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    padding: 0;
    color: var(--color-text-muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    transition: color var(--transition);
}

.sg-jump-arrow[hidden] {
    display: none;
}

.sg-jump-arrow--prev { left: 0; }
.sg-jump-arrow--next { right: 0; }

.sg-jump-arrow:hover {
    color: var(--color-brand);
}

.sg-jump-arrow:focus-visible {
    outline-offset: -2px;
}

/* Touch: swipe scrolls; the arrows would only add tap clutter. Fades remain. */
@media (hover: none) and (pointer: coarse) {
    .sg-jump-arrow {
        display: none;
    }
}

.sg-jump-list {
    display: flex;
    gap: 2px;
    margin: 0;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.sg-jump-list::-webkit-scrollbar {
    display: none;
}

.sg-jump-item {
    flex-shrink: 0;
}

/* Group labels (Foundations / Components / Patterns): a filled brand-tint chip
   with a brand accent bar, a different kind of element from the tabs. Not
   focusable, no hover, default cursor. Text = 70% brand / 30% text on the
   chip: 5.4:1 light, 7.0:1 dark. A divider precedes each group after the first. */
.sg-jump-item--label {
    display: flex;
    align-items: center;
    padding: 0 var(--space-2) 0 var(--space-3);
    cursor: default;
    user-select: none;
}

.sg-jump-item--label:not(:first-child) {
    margin-left: var(--space-2);
    border-left: 1px solid var(--color-border);
}

.sg-jump-label {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px 3px 8px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: color-mix(in srgb, var(--color-brand) 70%, var(--color-text));
    background: var(--color-brand-bg-strong);
    border-left: 3px solid var(--color-brand);
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

/* Tabs (<button role="tab">): the .page-tab look, muted until selected. */
.sg-jump-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    padding: 0 var(--space-3);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-muted);
    white-space: nowrap;
    background: none;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    cursor: pointer;
    transition: color var(--transition), border-color var(--transition);
}

.sg-jump-link:hover {
    color: var(--color-text);
}

/* Selected tab: the .page-tab--active treatment. */
.sg-jump-link[aria-selected="true"] {
    color: var(--color-brand);
    font-weight: 600;
    border-bottom-color: var(--color-brand);
}

.sg-jump-count {
    min-width: 20px;
    padding: 0 6px;
    font-size: 0.68rem;
}

/* The Reference view's section strip sits directly above its two-column layout. */
.gl-view > .sg-jumpnav {
    margin-bottom: var(--space-4);
}

.sg-jump-link:focus-visible {
    outline-offset: -2px;
}

/* ── Theme preview toolbar ── */
.sg-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
}

.sg-toolbar-label,
.sg-section-eyebrow,
.sg-family-title,
.sg-panel-label {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
}

.sg-toolbar-note {
    flex-basis: 100%;
    font-size: var(--font-size-xs);
}

/* ── Sections and group cards ── */
/* One tab panel: section eyebrow + lede, then the group card. */
.sg-tabpanel {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    scroll-margin-top: calc(var(--nav-height) + var(--gl-strip-h) + 12px);
}

.sg-tabpanel[hidden] {
    display: none;
}

.sg-section-head {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sg-section-lede {
    font-size: var(--font-size-md);
}

.sg-group {
    min-width: 0;
    padding: var(--space-4);
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.sg-group-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-1) var(--space-3);
    margin-bottom: 10px;
}

.sg-group-title {
    margin: 0;
    font-size: 1.05rem;
}

.sg-glossary-links {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
}

.sg-glossary-link {
    font-size: var(--font-size-sm);
    font-weight: 600;
}

.sg-standard {
    margin: 0 0 14px;
    padding: var(--space-2) var(--space-3);
    font-size: var(--font-size-md);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-brand-bg-subtle);
    border-left: 3px solid var(--color-brand);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    overflow-wrap: anywhere;
}

.sg-standard-label {
    font-weight: 700;
    color: var(--color-brand);
}

/* ── Themed specimen stage: one panel, or light | dark side by side ── */
.sg-stage {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-3);
}

.sg-panel {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-width: 0;
    padding: 14px;
    font-size: 1rem;
    color: var(--color-text);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.sg-family {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    min-width: 0;
}

.sg-value,
.sg-token,
.sg-bp-query {
    font-family: var(--font-mono);
}

.sg-value {
    font-size: var(--font-size-xs);
    color: var(--color-text);
    overflow-wrap: anywhere;
}

.sg-meta {
    font-size: var(--font-size-2xs);
    line-height: 1.4;
    color: var(--color-text-muted);
    overflow-wrap: anywhere;
}

.sg-note {
    font-size: var(--font-size-sm);
}

/* Token name = copy button. */
.sg-token {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 2px 6px;
    max-width: 100%;
    min-height: 28px;
    margin-left: -6px;
    padding: 2px 6px;
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-align: left;
    color: var(--color-text);
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    cursor: copy;
    overflow-wrap: anywhere;
    transition: background-color var(--transition);
}

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

.sg-token-flag {
    font-family: inherit;
    font-size: var(--font-size-2xs);
    font-weight: 600;
    color: var(--color-success);
}

.sg-token-flag:empty {
    display: none;
}

.sg-copy-buffer {
    position: fixed;
    top: 0;
    left: -9999px;
    opacity: 0;
}

/* Colours */
.sg-swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 10px;
}

.sg-swatch {
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.sg-swatch-chip {
    display: block;
    height: 44px;
    border-bottom: 1px solid var(--color-border);
}

.sg-swatch-body {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    padding: 6px var(--space-2) var(--space-2);
}

.sg-contrast {
    font-size: var(--font-size-2xs);
    font-weight: 600;
}

.sg-contrast--pass { color: var(--color-success); }
.sg-contrast--warn { color: var(--color-warning-text); }
.sg-contrast--fail { color: var(--color-error); }

/* Typography */
.sg-type-stack {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin: 0;
}

.sg-type-list {
    display: flex;
    flex-direction: column;
}

.sg-type-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding: 10px 0;
    border-top: 1px solid var(--color-border);
}

.sg-type-row:first-child {
    padding-top: 0;
    border-top: 0;
}

.sg-type-sample {
    min-width: 0;
    overflow-wrap: anywhere;
}

.sg-type-sample .page-header {
    margin: 0;
}

.sg-type-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 2px var(--space-2);
}

.sg-type-name {
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--color-text);
}

/* Radius, sizes, other tokens */
.sg-radius-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.sg-radius-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
    min-width: 0;
}

.sg-radius-box {
    display: block;
    width: 72px;
    height: 52px;
    background: var(--color-brand-bg-subtle);
    border: 2px solid var(--color-brand);
}

.sg-radius-box--pill {
    height: 32px;
    border-radius: 99px;
}

.sg-bar-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sg-bar-row {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    min-width: 0;
}

.sg-bar-label,
.sg-other-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
}

.sg-bar-track {
    width: 100%;
    overflow: hidden;
}

.sg-bar,
.sg-bp-bar {
    display: block;
    max-width: 100%;
    height: 8px;
    background: var(--color-brand);
    border-radius: var(--radius-sm);
}

/* Shadows */
.sg-shadow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 20px;
    padding: var(--space-1) var(--space-1) var(--space-3);
}

.sg-shadow-box {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    gap: 2px;
    min-width: 0;
    min-height: 96px;
    padding: 10px var(--space-3);
    background: var(--color-surface);
    border-radius: var(--radius);
}

/* Focus ring */
.sg-focus-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-4);
}

.sg-focus-ring {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 var(--space-3);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

/* Breakpoints */
.sg-bp-now {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: 600;
}

.sg-bp-list {
    display: flex;
    flex-direction: column;
}

.sg-bp-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: var(--space-2) 0;
    border-top: 1px solid var(--color-border);
}

.sg-bp-row:first-child {
    border-top: 0;
}

.sg-bp-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) 10px;
}

.sg-bp-query {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--color-text);
}

.sg-bp-tag,
.sg-placeholder-tag {
    padding: 1px 9px;
    font-size: var(--font-size-2xs);
    font-weight: 700;
    color: var(--color-text-muted);
    background: var(--color-badge-bg);
    border-radius: 99px;
}

.sg-bp-tag--std {
    color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
}

.sg-bp-bar {
    height: 6px;
    background: var(--color-border);
}

.sg-bp-bar--std {
    background: var(--color-brand);
}

/* "Coming next" sections: dashed border only (not a real card). */
.sg-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-2);
    padding: 20px var(--space-4);
    text-align: center;
    font-size: 0.9rem;
    color: var(--color-text-muted);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius);
}

.sg-placeholder p {
    margin: 0;
}

/* ── Components: specimen cards ──
   Each specimen's live part is a .gl-demo container (so glossary.js's shared
   demo behaviour and the .gl-demo containment rules above apply), restyled here
   as a plain bordered surface. Border only, no shadow (ghost-card rule). */
.sg-spec-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
    gap: var(--space-3);
}

.sg-spec {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.sg-spec--wide {
    grid-column: 1 / -1;
}

.gl-demo.sg-demo {
    margin: 0;
    padding: 14px;
    background: var(--color-surface);
    border: 0;
    border-bottom: 1px solid var(--color-border);
    border-radius: 0;
    overflow-x: auto;
    font-size: 0.9rem;
}

.sg-spec-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-1);
    min-width: 0;
    padding: 10px var(--space-3) var(--space-3);
    background: var(--color-bg);
}

.sg-spec-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-2);
    margin: 0;
}

.sg-spec-name {
    font-size: var(--font-size-md);
    font-weight: 700;
    color: var(--color-text);
}

/* Status tag: a label, so the 99px pill is correct here. */
.sg-spec-status {
    padding: 1px var(--space-2);
    font-size: var(--font-size-2xs);
    font-weight: 700;
    border-radius: 99px;
    white-space: nowrap;
}

.sg-spec-status--std {
    color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
}

.sg-spec-status--nostd {
    color: var(--color-warning-text);
    background: var(--color-warning-bg);
}

.sg-spec-status--unused {
    color: var(--color-text-muted);
    background: var(--color-badge-bg);
}

.sg-spec-status--outlier {
    color: var(--color-error);
    background: var(--color-error-bg);
}

.sg-spec-caption {
    margin: 0;
    font-size: var(--font-size-sm);
    line-height: 1.45;
    color: var(--color-text-muted);
}

.sg-spec-meta .sg-glossary-links {
    margin-top: 2px;
}

/* Components part 2 + Patterns: page-level components contained in a specimen.
   Only spacing/containment is touched; the components keep their own look. */
.sg-form {
    min-width: 0;
}

.gl-demo.sg-demo > :last-child,
.gl-demo.sg-demo [class*="-banner"]:last-child {
    margin-bottom: 0;
}

/* .form-card is min-height: 100vh on phones (it fills the page there). */
.gl-demo.sg-demo .form-card {
    min-height: 0;
    max-width: 480px;
}

.sg-card-row {
    align-items: flex-start;
}

.sg-card-row > .budget-statement-card {
    flex: 1 1 240px;
}

/* "Theme preview limits": theme-scoped rules a group's specimens hit. */
.sg-theme-notes {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: var(--space-3);
    padding: 10px var(--space-3);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
}

.sg-theme-notes[hidden] {
    display: none;
}

.sg-theme-note-codes {
    display: inline-flex;
    flex-wrap: wrap;
    gap: var(--space-1) 10px;
}

@media (min-width: 641px) {
    .sg-stage--compare {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .sg-group {
        padding: var(--space-3);
    }

    .sg-panel {
        padding: 10px;
    }

    .sg-spec-list {
        grid-template-columns: minmax(0, 1fr);
    }

    .gl-demo.sg-demo {
        padding: 10px;
    }

    .sg-token,
    .sg-glossary-link {
        min-height: 44px;
    }

    .sg-glossary-link {
        display: inline-flex;
        align-items: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    .sg-jump-link,
    .sg-jump-arrow,
    .sg-jumpnav::before,
    .sg-jumpnav::after,
    .sg-token {
        transition: none;
    }
}

/* ── Edit Budget: Change period dates (Details tab, own <form> -> change_cadence.php) ── */
.budget-cadence-notes {
    margin: 0 0 12px;
    padding-left: 20px;
    font-size: 0.8125rem;
}

.budget-cadence-notes li + li {
    margin-top: 4px;
}

.budget-cadence-form {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.budget-cadence-form .form-group {
    margin-bottom: 0;
    width: 100%;
    max-width: 280px;
}

@media (max-width: 640px) {
    .budget-cadence-form,
    .budget-cadence-form .form-group {
        max-width: none;
    }
    .budget-cadence-form .btn {
        width: 100%;
        min-height: 44px;
        box-sizing: border-box;
    }
    .budget-cadence-form .checkbox-label {
        min-height: 44px;
        box-sizing: border-box;
    }
}

/* ── Editable-window rule: "View only" banner atop a locked (non prev/current/next) period ── */
.period-view-only-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    margin-bottom: 12px;
    border-radius: var(--radius);
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.35;
}

.period-view-only-banner svg {
    flex-shrink: 0;
}

.budget-statement-card > .period-view-only-banner {
    margin: var(--space-3) var(--space-3) 0;
}

/* ── Locked Field [B-111, preview slides 181-183, glossary "Locked Field"] ─────
   Bill EDIT Schedule tab: Upcoming Date / Actual Due Date / End Date open locked.
   Locked = a grey box (lock icon + the saved date, or "No end date" / "Not set") shown
   INSTEAD of the real date input; the input itself stays in the form with the `readonly`
   attribute (NEVER `disabled`: disabled controls are dropped from the POST) and is only
   hidden with display:none, which does not affect submission. ONE persistent
   `.btn .btn-secondary .btn-sm` toggles the state in place (pencil + "Change" while
   locked, "Cancel" while unlocked; JS swaps the label span only). State lives on the
   wrapper: .is-locked / .is-unlocked (+ .is-changed once the value differs from the saved
   one, which swaps the consequence sentence for the "Changed from ..." tag + sentence).
   .is-permanent = a sub-bill's Actual Due Date (no button). Tokens only, so dark mode
   follows. No display on anything carrying .u-hidden or .field-hint. */
.locked-field-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.locked-field .locked-field-box,
.locked-field .locked-field-input {
    flex: 1 1 140px;
    min-width: 0;
    width: auto;
    box-sizing: border-box;
}

.locked-field .locked-field-box {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 42px;
    padding: 10px 12px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    color: var(--color-text-muted);
    font-size: 0.9375rem;
    cursor: not-allowed;
}

.locked-field-box > svg {
    flex-shrink: 0;
}

.locked-field-value.is-empty {
    font-style: italic;
}

.locked-field.is-locked .locked-field-input,
.locked-field.is-unlocked .locked-field-box {
    display: none;
}

.locked-field-tipwrap {
    display: inline-flex;
}

.locked-field.is-unlocked .locked-field-toggle > svg {
    display: none;
}

.locked-field-changed {
    display: none;
    margin-top: 6px;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--color-text);
}

.locked-field.is-changed .locked-field-changed {
    display: block;
}

.locked-field.is-changed .locked-field-note {
    display: none;
}

.locked-field-changed-tag {
    margin-right: 6px;
    vertical-align: middle;
}

@media (max-width: 640px) {
    .locked-field-row {
        flex-direction: column;
        align-items: stretch;
    }

    .locked-field .locked-field-box,
    .locked-field .locked-field-input {
        flex: 0 0 auto;
        min-height: 44px;
    }

    .locked-field-tipwrap {
        display: flex;
    }

    .locked-field-tipwrap > .locked-field-toggle {
        flex: 1 1 auto;
    }
}

/* ── Budget date section [F1, 2026-10-01, preview slides 174-180 / 178-179, glossary
   "Budget Date Form Section"] ─────────────────────────────────────────────────────────
   Bill create/edit Schedule tab, directly under the Upcoming/Start Date field. A
   fieldset of radio rows (Same as due date / On a fixed day each month / Some days before
   it is due; one-time bills: Same / Pick a date) + a live example line + a helper note.
   Tokens only, so dark mode follows. The row shows its own state with :has(:checked);
   hiding uses the [hidden] attribute with an explicit rule below (never .u-hidden on
   .field-hint). assets/js/bills-form.js section 11 drives frequency changes + the example. */
.budget-date-cluster > .form-group:first-child {
    max-width: calc(50% - 8px);
}

.budget-date {
    margin: 4px 0 var(--space-3, 12px);
    padding: 0;
    border: 0;
    min-inline-size: 0;
}

.budget-date-legend {
    padding: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-text);
}

.budget-date-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    min-height: 44px;
    margin-top: 8px;
    padding: 10px 12px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-weight: 400;
    cursor: pointer;
}

.budget-date-option[hidden],
.budget-date-reason[hidden] {
    display: none;
}

.budget-date-option:has(input[type="radio"]:checked) {
    border-color: var(--color-brand);
    background: var(--color-brand-bg-subtle);
}

.budget-date-option input[type="radio"] {
    flex-shrink: 0;
    margin: 3px 0 0;
    accent-color: var(--color-brand);
    cursor: pointer;
}

.budget-date-option-body {
    flex: 1 1 auto;
    min-width: 0;
}

.budget-date-option-title {
    display: block;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--color-text);
}

.budget-date-option-desc {
    display: block;
    margin-top: 2px;
    font-size: 0.78rem;
    color: var(--color-text-muted);
}

.budget-date-fld {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 0.875rem;
    color: var(--color-text);
}

.budget-date-fld select,
.budget-date-fld input[type="number"] {
    width: 5.5rem;
    min-height: 40px;
}

.budget-date-fld input[type="date"] {
    width: 11rem;
    max-width: 100%;
    min-height: 40px;
}

.budget-date-reason {
    margin-top: 8px;
}

.budget-date-example {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--color-surface-alt);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--color-text);
}

.budget-date-example.is-warn {
    background: var(--color-warning-bg);
    color: var(--color-warning-text);
}

.budget-date-example-arrow {
    flex-shrink: 0;
    color: var(--color-text-muted);
}

.budget-date-note {
    margin-top: 8px;
}

.budget-date-follows {
    margin-top: 6px;
    padding: 10px 12px;
    background: var(--color-surface-alt);
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    color: var(--color-text);
}

.budget-date-follows a {
    color: var(--color-brand);
}

/* The app never sets color-scheme: opt the native radio into the dark control palette
   (standard theme-selector trio, same as .type-option radios). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .budget-date-option input[type="radio"] {
        color-scheme: dark;
    }
}
:root[data-theme="dark"] .budget-date-option input[type="radio"] {
    color-scheme: dark;
}

@media (max-width: 640px) {
    .budget-date-cluster > .form-group:first-child {
        max-width: none;
    }

    .budget-date-option {
        min-height: 44px;
        padding: 12px;
    }

    .budget-date-fld select,
    .budget-date-fld input[type="number"],
    .budget-date-fld input[type="date"] {
        min-height: 44px;
    }
}

/* ── Budget date (overview) [2026-10-01, F2; previews 174-177, 180; glossary "Budgeted / Due tag and
   hint"] ───────────────────────────────────────────────────────────────────────
   1) Row tags: a bill budgeted in a different period than it is due shows "Budgeted <date>"
      (the existing .bs-row-date line) plus a shared .badge "Due <date>" (brand outline, or neutral
      once the budget date has passed: "Due Oct 1 . in 2 days", never red) and, for a one-off,
      a neutral "This month only" badge. Tokens only; the badges' look comes from .badge.
   2) .bdate-hint: the "Due before your first paycheck" prompt, a full-width row under the
      bill's action line (grid row 3 of the bill card).
   3) The popup's budget step (.bdate-form) and the confirmation banner (.bdate-notice, same
      warning look as .undo-banner; kept as its own class so app.js's one-time .undo-banner
      dismiss-button pass cannot add a second close button).
   Own focus-visible rules below (plain buttons / links not in the section 7b list). */
.bdate-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    margin-top: 3px;
    font-weight: 400;
}

.bdate-due-tag,
.bdate-once-tag {
    max-width: 100%;
}

.bdate-hint {
    grid-column: 1 / -1;
    grid-row: 3;
    flex: 1 1 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 4px 0 6px;
    padding: 8px 10px;
    background: var(--color-brand-bg-subtle);
    border-left: 3px solid var(--color-brand);
    border-radius: var(--radius-sm);
    font-weight: 400;
}

/* Review PR2-L6: in a flex .bs-row (unassigned bucket, no grid) the hint must take its own full
   line. flex-wrap is ignored when the row is a grid (income blocks), so that case is unchanged. */
.bs-row:has(> .bdate-hint) {
    flex-wrap: wrap;
}

.bdate-hint-note {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.4;
    color: var(--color-text-muted);
}

.bdate-hint.is-busy {
    opacity: 0.7;
}

.bdate-hint-text,
.bdate-hint-done {
    margin: 0;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--color-text);
}

.bdate-hint-done {
    color: var(--color-text-muted);
}

.bdate-hint-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 12px;
}

/* Quiet text action (button or link): 32px box + an invisible hit area that makes it 44px tall. */
.bdate-link {
    position: relative;
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    padding: 0 6px;
    background: none;
    border: 0;
    border-radius: var(--radius-sm);
    color: var(--color-brand);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
}

.bdate-link::after {
    content: "";
    position: absolute;
    inset: -6px 0;
}

.bdate-link:hover:not(:disabled) {
    text-decoration: underline;
}

.bdate-link:disabled {
    opacity: 0.5;
    cursor: default;
}

.bdate-link:focus-visible,
.bdate-notice .undo-dismiss-btn:focus-visible {
    outline: 2px solid var(--color-brand);
    outline-offset: 2px;
}

.bdate-hint-error {
    margin: 0;
    padding: 6px 10px;
    border: 1px solid var(--color-error-border);
    border-radius: var(--radius-sm);
    background: var(--color-error-bg);
    color: var(--color-error);
    font-size: 0.78rem;
    line-height: 1.4;
}

/* Popup 'budget' step */
.income-rule-modal .income-rule-choice.u-hidden {
    display: none;
}

.income-rule-budget {
    margin-right: 12px;
}

.bdate-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.bdate-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text);
}

.bdate-form .bdate-input {
    width: 100%;
    max-width: 14rem;
    min-height: 44px;
    box-sizing: border-box;
    padding: 6px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    font-family: inherit;
    font-size: 0.9375rem;
}

:root[data-theme="dark"] .bdate-form .bdate-input {
    color-scheme: dark;
}

.bdate-example {
    margin: 4px 0 0;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    background: var(--color-surface-alt);
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--color-text);
}

.bdate-example.is-error {
    background: var(--color-error-bg);
    border: 1px solid var(--color-error-border);
    color: var(--color-error);
}

/* Confirmation banner after a budget-date change (+ Undo, + warnings[]) */
.bdate-notice {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
    background-color: var(--color-warning-bg);
    border: 1px solid var(--color-warning-border);
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: var(--color-warning-text);
}

.bdate-notice-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bdate-notice-warnings {
    margin: 0;
    padding-left: 18px;
    font-size: 0.8125rem;
}

.bdate-notice-error {
    font-weight: 600;
}

@media (max-width: 640px) {
    /* 44px floor on every control this feature adds (the links get it from ::after) */
    .bdate-hint .btn,
    .bdate-notice .undo-btn,
    .bdate-notice .undo-dismiss-btn {
        min-height: 44px;
    }

    .bdate-notice .undo-dismiss-btn {
        min-width: 44px;
    }

    .bdate-due-tag,
    .bdate-once-tag {
        white-space: normal;
    }
}

/* ── Budget date ghost row [2026-10-01, F2 follow-up; preview slide 176 Variant A] ──────────────
   "Due this month, budgeted earlier": a faint, dashed, NON-interactive list of bills that are DUE
   in this period but were budgeted in another one (already counted there; never in this card's
   totals). Not a button, no hit area, nothing focusable. The Due tag is the shared .badge
   (brand outline when unpaid, neutral when paid). Tokens only. */
.bdate-ghosts {
    margin: 2px 0 6px;
}

.bdate-ghost-list {
    list-style: none;
    margin: 0;
    padding: 0 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bdate-ghost {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 10px;
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-muted);
    font-size: 0.875rem;
    font-weight: 500;
}

.bdate-ghost-main {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.bdate-ghost-name {
    overflow-wrap: anywhere;
}

.bdate-ghost-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 3px 6px;
    font-size: 0.75rem;
    font-weight: 400;
}

.bdate-ghost-amt {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.bdate-ghost .badge--outline {
    border-style: dashed;
}

@media (max-width: 640px) {
    .bdate-ghost-list {
        padding: 0 1rem;
    }
}

/* ── Reconcile Start Marker (register) [2026-10-03, preview slides 189-191] ──────
   The modal set-chip was removed 2026-11-08 (UI moves to the Reconcile Match step, Phase 6).
   The row badge is the stock
   "badge badge--brand badge--caps" (Badge Base and Tones), so no badge CSS here.
   .reconcile-start-note mirrors the brand-tinted note shape (.bs-fund-block-note);
   .is-warn swaps to the warning tokens (amber: deleted marker / before last statement). */
.reconcile-start-notes:empty { display: none; }
.reconcile-start-notes { margin-bottom: 8px; }
.reconcile-start-note {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 10px;
    margin-bottom: 8px;
    padding: 8px 12px;
    background: var(--color-brand-bg-subtle);
    border: 1px solid var(--color-border);
    border-left: 3px solid var(--color-brand);
    border-radius: var(--radius-sm);
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--color-text);
}
.reconcile-start-note.is-warn {
    background: var(--color-warning-bg);
    border-color: var(--color-warning-border);
    border-left-color: var(--color-warning-text);
    color: var(--color-warning-text);
}
.reconcile-start-note-actions { margin-left: auto; display: inline-flex; gap: 6px; }
.register-grid-row.is-reconcile-start { box-shadow: inset 3px 0 0 var(--color-brand); }
.reconcile-start-badge { margin-left: 6px; vertical-align: middle; }
.recon-start-link { margin-left: 6px; font-weight: 600; }

@media (max-width: 640px) {
    .reconcile-start-goto,
    .reconcile-start-note-actions .btn { min-height: 44px; }
}
