/* ============================================================================
   AZS Finance — theme tokens (light + dark)
   Single source of truth for surfaces, text, borders, brand, money & charts.
   Loaded in <head> AFTER Bootstrap, BEFORE the inline chrome <style>.
   Theme is driven by data-theme (+ data-bs-theme, synced) on <html>.
   RULE: theme changes presentation only — never a monetary VALUE.
   Identity: AZS Finance kit v1.0 (Ink #0B3D2E, Green #22C47E, Mint #3DDC97, Instrument Sans), adapted
   for a financial tool (owner, 18.10): a clean, neutral page; colour only where it means something,
   always the same thing (docs/TECH-NOTES.md → „Culorile au un singur sens”):
     ink      = actions and "you are here" (primary button, active menu, chosen tab), the church side;
     green    = good: validated, active, paid, money in, a positive difference — never decoration;
     amber    = to check: draft, pending, attention;   red = rejected, negative, error;
     indigo   = the conference side;                   grey = structure and neutral facts.
   The kit's bright green stays in the logo and the keyboard focus ring only.
   ============================================================================ */

/* ---- Light (default) ---------------------------------------------------- */
:root {
    color-scheme: light;

    --font-sans: 'Instrument Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;

    /* Surfaces — neutral, near white; cards white */
    --surface:          #f5f6f5;   /* app background            */
    --surface-raised:   #ffffff;   /* cards, sidebar, header    */
    --surface-sunken:   #f0f2f1;   /* table heads, wells, subtotal bands */
    --surface-hover:    #f6f7f6;   /* row/nav hover             */

    /* Text — near-black for reading and figures; muted clears AA on white */
    --text:             #18211d;
    --text-muted:       #5a6560;
    --text-subtle:      #8b948f;

    /* Borders / shadow / radius */
    --border:           #e2e6e4;
    --border-strong:    #cbd1ce;
    --shadow-card:      0 1px 2px rgba(16, 24, 20, 0.04), 0 2px 8px rgba(16, 24, 20, 0.04);
    --shadow-raised:    0 6px 16px rgba(16, 24, 20, 0.08), 0 16px 40px rgba(16, 24, 20, 0.10);
    --radius:           16px;
    --radius-sm:        11px;

    /* Brand — the kit's ink: actions, links, where you are */
    --brand:            #0b3d2e;   /* interactive fill (buttons, active) */
    --brand-strong:     #145a44;   /* its hover / pressed state         */
    --brand-text:       #0b3d2e;   /* brand as text/icon on a surface   */
    --brand-contrast:   #ffffff;   /* text/icon ON a brand fill         */
    --brand-soft:       rgba(11, 61, 46, 0.06);
    --brand-soft-strong:rgba(11, 61, 46, 0.10);

    /* "Where you are" (active menu, chosen option): the ink, not a colour of its own */
    --accent:           #0b3d2e;
    --accent-ink:       #ffffff;   /* text ON the accent */
    --accent-soft:      rgba(11, 61, 46, 0.07);
    --focus-ring:       0 0 0 3px rgba(34, 196, 126, 0.45);   /* the kit's green: keyboard focus only */

    /* Inline logo (partials.logo): the dark parts follow currentColor */
    --logo-muted:       #1a9a62;
    --logo-accent:      #22c47e;

    /* Money & status (AA-checked on white) — green means good, nothing else */
    --positive-money:   #15803d;
    --negative-money:   #b42318;
    --warning:          #b45309;
    --info:             #4a5a53;   /* explanations: neutral, not a hue */

    /* Soft status fills (pills, attention rows). Light = pale tint; dark = translucent. */
    --positive-soft:    #e8f5ec;
    --negative-soft:    #fdecea;
    --warning-soft:     #fef3e2;
    --info-soft:        #f0f2f1;

    /* Report roles: church = the brand ink (home), conference = indigo, total = grey;
       the raised/received pair stays amber/teal, apart from the church/conference pair. */
    --role-church:      #0b3d2e;
    --role-conference:  #4f46e5;
    --role-total:       #6b7570;
    --role-raised:      #d97706;
    --role-received:    #0d9488;

    --role-church-soft:     rgba(11, 61, 46, 0.08);
    --role-conference-soft: rgba(79, 70, 229, 0.10);
    --role-total-soft:      rgba(107, 117, 112, 0.10);

    /* Chart chrome */
    --chart-grid:            rgba(16, 24, 20, 0.07);
    --chart-tick:            #5a6560;
    --chart-legend:          #2c3632;
    --chart-border-contrast: #ffffff;  /* gaps between pie slices */

    /* Categorical series — distinct, sober hues; no status green and no red (those mean plus and
       minus). A single-series chart takes series 1, the ink. Same order in both themes. */
    --chart-series-1:  #1f4e43;
    --chart-series-2:  #5b5bd6;
    --chart-series-3:  #d4932b;
    --chart-series-4:  #64748b;
    --chart-series-5:  #9b5c8f;
    --chart-series-6:  #4f8fc0;
    --chart-series-7:  #b79b6c;
    --chart-series-8:  #c26a48;
    --chart-series-9:  #2a9d8f;
    --chart-series-10: #a3a8a5;

    --sidebar-width: 260px;

    /* Map Bootstrap 5.3 vars onto our tokens (themes dropdowns/modals/etc). */
    --bs-body-font-family: var(--font-sans);
    --bs-body-bg:        var(--surface);
    --bs-body-color:     var(--text);
    --bs-border-color:   var(--border);
    --bs-card-bg:        var(--surface-raised);
    --bs-secondary-color: var(--text-muted);
    --bs-tertiary-bg:    var(--surface-sunken);
    --bs-emphasis-color: var(--text);
    --bs-link-color:     var(--brand-text);
    --bs-link-hover-color: var(--brand-strong);
    /* Bootstrap's own primary/secondary/info/success (#0d6efd, #6c757d, #0dcaf0, #198754) drive the
       border-*, bg-*-opacity and badge utilities the pages use; they follow the palette instead. */
    --bs-primary:        var(--brand);
    --bs-primary-rgb:    11, 61, 46;
    --bs-secondary-rgb:  90, 101, 96;
    --bs-info-rgb:       74, 90, 83;
    --bs-success-rgb:    21, 128, 61;
}

/* ---- Dark --------------------------------------------------------------- */
/* Neutral dark surfaces; actions in a pale ink tint, green still only for "good". */
:root[data-theme="dark"] {
    color-scheme: dark;

    --surface:          #111513;
    --surface-raised:   #181d1a;
    --surface-sunken:   #0d100f;
    --surface-hover:    #1f2522;

    --text:             #e9eeeb;
    --text-muted:       #a3ada8;
    --text-subtle:      #77817c;

    --border:           #29312d;
    --border-strong:    #39433e;
    --shadow-card:      0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-raised:    0 6px 20px rgba(0, 0, 0, 0.55);

    --brand:            #d6e6de;
    --brand-strong:     #ffffff;
    --brand-text:       #d6e6de;
    --brand-contrast:   #0b1410;
    --brand-soft:       rgba(214, 230, 222, 0.08);
    --brand-soft-strong:rgba(214, 230, 222, 0.14);

    --accent:           #d6e6de;
    --accent-ink:       #0b1410;
    --accent-soft:      rgba(214, 230, 222, 0.09);
    --focus-ring:       0 0 0 3px rgba(61, 220, 151, 0.40);
    --logo-muted:       #3ddc97;
    --logo-accent:      #3ddc97;

    --positive-money:   #4ade80;
    --negative-money:   #f87171;
    --warning:          #fbbf24;
    --info:             #b4c0ba;

    --positive-soft:    rgba(74, 222, 128, 0.14);
    --negative-soft:    rgba(248, 113, 113, 0.14);
    --warning-soft:     rgba(251, 191, 36, 0.15);
    --info-soft:        rgba(180, 192, 186, 0.10);

    --role-church:      #b8d8c9;
    --role-conference:  #a5b4fc;
    --role-total:       #a3ada8;
    --role-raised:      #fbbf24;
    --role-received:    #2dd4bf;

    --role-church-soft:     rgba(184, 216, 201, 0.12);
    --role-conference-soft: rgba(165, 180, 252, 0.16);
    --role-total-soft:      rgba(163, 173, 168, 0.14);

    --chart-grid:            rgba(233, 238, 235, 0.09);
    --chart-tick:            #a3ada8;
    --chart-legend:          #d3dad6;
    --chart-border-contrast: #181d1a;

    /* The same series, lifted to hold up on dark surfaces. */
    --chart-series-1:  #8fc4b3;
    --chart-series-2:  #9a9af0;
    --chart-series-3:  #f0b65a;
    --chart-series-4:  #9aa8bb;
    --chart-series-5:  #c99bbd;
    --chart-series-6:  #86b9e0;
    --chart-series-7:  #d4bd93;
    --chart-series-8:  #e3977a;
    --chart-series-9:  #5cc7b9;
    --chart-series-10: #c4c9c6;

    --bs-primary-rgb:   214, 230, 222;
    --bs-secondary-rgb: 60, 70, 65;
    --bs-info-rgb:      180, 192, 186;
    --bs-success-rgb:   74, 222, 128;
}

/* ============================================================================
   Bootstrap literal-utility overrides for dark (these classes don't respond
   to data-bs-theme on their own; the app uses them heavily).
   ============================================================================ */
:root[data-theme="dark"] .bg-white   { background-color: var(--surface-raised) !important; }
:root[data-theme="dark"] .bg-light   { background-color: var(--surface-sunken) !important; }
:root[data-theme="dark"] .text-dark  { color: var(--text) !important; }
:root[data-theme="dark"] .text-muted { color: var(--text-muted) !important; }
:root[data-theme="dark"] .text-secondary { color: var(--text-muted) !important; }
:root[data-theme="dark"] .border,
:root[data-theme="dark"] .border-top,
:root[data-theme="dark"] .border-bottom,
:root[data-theme="dark"] .border-start,
:root[data-theme="dark"] .border-end { border-color: var(--border) !important; }

/* Money / status text utilities — Bootstrap's fixed greens/reds are too dark
   on a dark surface; a treasurer misreading red/green is a real risk. */
:root[data-theme="dark"] .text-success { color: var(--positive-money) !important; }
:root[data-theme="dark"] .text-danger  { color: var(--negative-money) !important; }
:root[data-theme="dark"] .text-warning { color: var(--warning) !important; }
:root[data-theme="dark"] .text-info    { color: var(--info) !important; }
:root[data-theme="dark"] .text-primary { color: var(--brand-text) !important; }

:root[data-theme="dark"] .table-light,
:root[data-theme="dark"] .table > thead.table-light > tr > * {
    --bs-table-bg: var(--surface-sunken);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
}
:root[data-theme="dark"] .table {
    --bs-table-color: var(--text);
    --bs-table-bg: transparent;
    --bs-table-border-color: var(--border);
    --bs-table-striped-color: var(--text);
    --bs-table-striped-bg: rgba(255, 255, 255, 0.03);
    --bs-table-hover-color: var(--text);
    --bs-table-hover-bg: var(--surface-hover);
}

/* A card framed with a colour (`card border-primary`, `border-info`…) got Bootstrap's full-strength
   line: a dark or cyan frame heavier than the content. The frame keeps the colour, at a third. */
.card:is(.border-primary, .border-secondary, .border-success, .border-info, .border-warning, .border-danger) { --bs-border-opacity: 0.35; }
.text-info { color: var(--info) !important; }

/* Soft status backgrounds (bg-opacity utilities) keep their hue but the text
   tokens above make them readable; nothing else needed. */

/* ============================================================================
   Shared report role helpers (replace the copy-pasted :root palette blocks
   that lived in each graphic report view).
   ============================================================================ */
.badge-local { background-color: var(--role-church-soft)     !important; color: var(--role-church); }
.badge-conf  { background-color: var(--role-conference-soft) !important; color: var(--role-conference); }
.text-role-church     { color: var(--role-church)     !important; }
.text-role-conference { color: var(--role-conference) !important; }
.text-role-total      { color: var(--role-total)      !important; }
.palette-raised   { color: var(--role-raised)   !important; }
.palette-received { color: var(--role-received) !important; }
.palette-neutral  { color: var(--role-total)    !important; }
.group-accent-local { box-shadow: inset 4px 0 0 var(--role-church); }
.group-accent-conf  { box-shadow: inset 4px 0 0 var(--role-conference); }

/* Money helpers usable in tables/KPIs. */
.money-positive { color: var(--positive-money) !important; }
.money-negative { color: var(--negative-money) !important; }

/* Surface / soft-fill helpers (theme-aware replacements for hardcoded pastels
   like #e7f5ec income heads or #f8f9fa wells). Use these instead of literal hex
   so a view follows the active theme. */
.bg-surface        { background-color: var(--surface)        !important; }
.bg-surface-raised { background-color: var(--surface-raised) !important; }
.bg-surface-sunken { background-color: var(--surface-sunken) !important; }
.bg-positive-soft  { background-color: var(--positive-soft)  !important; }
.bg-negative-soft  { background-color: var(--negative-soft)  !important; }
.bg-warning-soft   { background-color: var(--warning-soft)   !important; }
.bg-info-soft      { background-color: var(--info-soft)      !important; }
.txt-default { color: var(--text)        !important; }
.txt-muted   { color: var(--text-muted)  !important; }
.txt-subtle  { color: var(--text-subtle) !important; }
.bd-token    { border-color: var(--border) !important; }

/* ============================================================================
   Component polish — softer radii, brand-coloured primaries (Bootstrap ships a
   generic blue), calmer forms/tables/menus. Presentation only; both themes.
   ============================================================================ */
.btn { border-radius: 10px; font-weight: 500; }
.btn-lg { border-radius: 12px; }
.btn-sm { border-radius: 8px; }

/* Primary = the ink, not Bootstrap #0d6efd. Its text is the brand's contrast colour, so it stays
   readable when the brand turns pale on the dark theme. */
.btn-primary {
    --bs-btn-color: var(--brand-contrast);
    --bs-btn-hover-color: var(--brand-contrast);
    --bs-btn-active-color: var(--brand-contrast);
    --bs-btn-disabled-color: var(--brand-contrast);
    --bs-btn-focus-shadow-rgb: 34, 196, 126;   /* the focus ring keeps the kit's green */
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-strong);
    --bs-btn-hover-border-color: var(--brand-strong);
    --bs-btn-active-bg: var(--brand-strong);
    --bs-btn-active-border-color: var(--brand-strong);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    box-shadow: 0 2px 6px rgba(11, 61, 46, 0.18);
}
.btn:focus-visible { box-shadow: var(--focus-ring); }
/* On dark nothing lights up (3.11.1): a solid pale block would be the brightest thing on the page,
   so the primary action is a tint of the brand with brand-coloured text, like the status fills there. */
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .hero .btn-light {
    --bs-btn-color: var(--accent); --bs-btn-bg: var(--brand-soft-strong); --bs-btn-border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    --bs-btn-hover-color: var(--accent); --bs-btn-hover-bg: rgba(214, 230, 222, 0.20); --bs-btn-hover-border-color: var(--accent);
    --bs-btn-active-color: var(--accent); --bs-btn-active-bg: rgba(214, 230, 222, 0.24); --bs-btn-active-border-color: var(--accent);
    --bs-btn-disabled-color: var(--accent); --bs-btn-disabled-bg: var(--brand-soft); --bs-btn-disabled-border-color: color-mix(in srgb, var(--accent) 30%, transparent);
    box-shadow: none;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-text);
    --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand-strong);
    --bs-btn-active-border-color: var(--brand-strong);
}
.btn-link { color: var(--brand-text); }

.badge { border-radius: 7px; font-weight: 600; letter-spacing: 0.01em; }

.form-control, .form-select {
    border-radius: 10px;
    border-color: var(--border-strong);
    background-color: var(--surface-raised);
    color: var(--text);
    padding: 0.42rem 0.75rem;
}
/* The shorthand above also wiped Bootstrap's room for the select arrow and every -sm size
   (same specificity, loaded later): text ran under the arrow and "small" fields were not small. */
.form-select { padding-right: 2.25rem; }
.form-control-sm, .form-select-sm { padding-top: 0.22rem; padding-bottom: 0.22rem; font-size: 0.875rem; border-radius: 8px; }
.form-control-sm { padding-left: 0.6rem; padding-right: 0.6rem; }
.form-select-sm { padding-left: 0.6rem; padding-right: 2rem; background-position: right 0.5rem center; }
.form-control-lg, .form-select-lg { padding-top: 0.55rem; padding-bottom: 0.55rem; }
/* Every text field on a touch screen, whatever its class: the search box of a list, a calendar's
   input, a field in a modal. iOS zooms in on a smaller one and stays zoomed after it closes, which
   leaves the page scrolling sideways; it does so on a landscape phone and an iPad as well. */
@media (max-width: 767.98px), (pointer: coarse) {
    input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]):not([type="color"]),
    select, textarea { font-size: max(16px, 1em); }
    /* Safari on iOS gives date and time fields a minimum width of its own, wider than their box. */
    input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] { min-width: 0; max-width: 100%; }
}
/* Phones (mobile audit, 2026-10-24). A field under 16px makes iOS zoom the whole page in when it
   gets the focus, and a fingertip needs about 44px: the compact -sm sizes are a desktop density. */
@media (max-width: 767.98px) {
    .form-control, .form-select, .form-control-sm, .form-select-sm,
    .input-group-sm > .form-control, .input-group-sm > .form-select, .input-group-sm > .input-group-text { font-size: 16px; }
    .form-control:not(textarea):not([type="file"]), .form-select,
    .input-group-sm > .form-control, .input-group-sm > .form-select, .input-group-sm > .btn, .input-group-sm > .input-group-text { min-height: 44px; }
    .btn { min-height: 44px; }
    .btn-sm, .btn-group-sm > .btn { min-height: 40px; }
    .btn.btn-link.p-0 { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
    .form-check-input:not([role="switch"]) { width: 1.25rem; height: 1.25rem; }
    /* The label is the tap target: a checkbox and its text on one 40px line. */
    .form-check:not(.form-check-inline):not(.form-switch) { min-height: 40px; display: flex; align-items: center; gap: 0.6rem; padding-left: 0; }
    .form-check:not(.form-check-inline):not(.form-switch) > .form-check-input { float: none; margin: 0; flex-shrink: 0; }
    .table > thead > tr > th { font-size: 0.75rem; }
    /* The sticky header is two rows on a phone; a field brought into view by focus or a jump
       must land below it, not behind it. */
    html { scroll-padding-top: 7.5rem; }
    .btn-sm, .btn-group-sm > .btn { min-width: 40px; }
    .app-notice .btn { min-height: 40px; }
    /* A page title with its buttons beside it: on a phone the buttons go under the title and wrap.
       Kept on one line, three buttons pushed the page 30–130px wider than the screen. The title
       may sit in a div with its subtitle (14 pages; a conference payment was 65px wider, #52). */
    .d-flex:has(> h1, > div > h1) { flex-wrap: wrap; row-gap: 0.75rem; }
    .d-flex:has(> h1, > div > h1) > .btn-group, .d-flex:has(> h1, > div > h1) > .d-flex { flex-wrap: wrap; max-width: 100%; }
}
.form-label { margin-bottom: 0.3rem; }
.form-control::placeholder { color: var(--text-subtle); }
.input-group-text { border-radius: 10px; border-color: var(--border-strong); background: var(--surface-sunken); color: var(--text-muted); }

/* Checkboxes and radios are `appearance: none`, so the border IS the control. Bootstrap draws it
   with --bs-border-color, which we remapped onto --border (a hairline meant for card edges) —
   that left every unchecked box invisible on a light card and unclickable in practice. */
.form-check-input {
    border-color: var(--text-subtle);
    background-color: var(--surface-raised);
    cursor: pointer;
}
.form-check-input:hover:not(:checked):not(:disabled) { border-color: var(--brand-text); }
.form-check-input:disabled { border-color: var(--border-strong); cursor: default; }

/* Bootstrap greys out disabled/readonly fields with a hardcoded light --bs-secondary-bg, which in
   dark mode paints a white box under white text — the value becomes unreadable. */
.form-control:disabled, .form-control[readonly], .form-select:disabled {
    background-color: var(--surface-sunken);
    color: var(--text-muted);
    border-color: var(--border-strong);
}

.dropdown-menu {
    border-radius: 13px;
    border-color: var(--border);
    box-shadow: var(--shadow-raised);
    padding: 0.4rem;
}
.dropdown-item { border-radius: 8px; padding: 0.45rem 0.7rem; }
.dropdown-item.active, .dropdown-item:active { background: var(--brand); color: var(--brand-contrast); }

/* Focus: the kit's green ring, on every field (keyboard focus is the one place the bright green
   lives); the checked box in the brand colour. On dark the box is a dimmed brand tint (below), so
   Bootstrap's white tick, dot and switch knob take the pale brand colour. */
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--text);
    box-shadow: var(--focus-ring);
}
.form-control:focus, .form-select:focus { background-color: var(--surface-raised); }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
:root[data-theme="dark"] .form-check-input:checked[type=checkbox] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23d6e6de' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/%3e%3c/svg%3e");
}
:root[data-theme="dark"] .form-check-input:checked[type=radio] {
    --bs-form-check-bg-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='2' fill='%23d6e6de'/%3e%3c/svg%3e");
}
:root[data-theme="dark"] .form-switch .form-check-input:checked {
    --bs-form-switch-bg: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%23d6e6de'/%3e%3c/svg%3e");
}
/* Solid primary fills (the chosen toggle or tab, the active menu item, an avatar) would be pale
   blocks on dark: they become the brand tint with brand-coloured text, like the primary button. */
:root[data-theme="dark"] .bg-primary:not([class*="bg-opacity"]):not(.progress-bar):not(.card-header):not(.card-footer):not(.modal-header) { background-color: var(--brand-soft-strong) !important; color: var(--accent) !important; }
:root[data-theme="dark"] .bg-primary:not([class*="bg-opacity"]) .text-white { color: inherit !important; }
:root[data-theme="dark"] :is(.btn-check:checked + .btn-outline-primary, .btn-outline-primary.active, .nav-pills .nav-link.active, .dropdown-item.active, .dropdown-item:active) {
    background-color: var(--brand-soft-strong); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent);
}
/* The checked box stays a filled square (the state must read at a glance), a dimmed brand tint with a pale tick. */
:root[data-theme="dark"] .form-check-input:checked { background-color: color-mix(in srgb, var(--accent) 28%, var(--surface-raised)); border-color: var(--accent); }

.alert { border-radius: 13px; border: 1px solid var(--border); }
.modal-content { border-radius: 16px; border-color: var(--border); }
.list-group { border-radius: var(--radius-sm); }

/* Tables — calm header, rows that fit a screenful. `table-sm` must stay smaller than the default:
   this rule has Bootstrap's specificity and comes later, so it used to flatten both to one size. */
.table > thead th {
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    color: var(--text-muted);
}
.table > :not(caption) > * > * { padding: 0.5rem 0.75rem; }
.table-sm > :not(caption) > * > * { padding: 0.3rem 0.5rem; }
.table-hover > tbody > tr:hover > * { background-color: var(--surface-hover); }

/* ============================================================================
   Density — one vertical rhythm for every page.
   The chrome already pads the content; pages then stacked Bootstrap's largest spacers on top
   (container py-4, mb-4/mt-4 between cards, g-4 gutters), so a form was mostly air. Inside the
   content area these steps are one notch tighter, everywhere at once.
   ============================================================================ */
.content-wrapper > .container-fluid.py-4 { padding-top: 0 !important; padding-bottom: 0.5rem !important; }
.content-wrapper .mb-4 { margin-bottom: 1rem !important; }
.content-wrapper .mt-4 { margin-top: 1rem !important; }
.content-wrapper .g-4 { --bs-gutter-x: 1rem; --bs-gutter-y: 1rem; }
.card-header .card-title, .card-header h5 { font-size: 1rem; }
.alert { padding: 0.65rem 0.9rem; }

/* ============================================================================
   One type scale inside pages. Views asked for Bootstrap's poster sizes (h1 = 2.5rem, .h3 =
   1.75rem, light weights) and each picked a different one, so the same kind of page title came
   out in four sizes. The page heading is the first rung; everything below steps down from it.
   ============================================================================ */
.content-wrapper h1:not(.hero-title) {
    font-size: 1.3rem; font-weight: 700; letter-spacing: -0.015em; line-height: 1.25; color: var(--text);
}
.content-wrapper :is(h2, .h2) { font-size: 1.15rem; font-weight: 700; letter-spacing: -0.01em; }
.content-wrapper :is(h3, .h3) { font-size: 1.075rem; font-weight: 650; }
.content-wrapper :is(h4, .h4) { font-size: 1.025rem; font-weight: 600; }
.content-wrapper :is(h5, .h5) { font-size: 0.975rem; font-weight: 600; }
.content-wrapper :is(h6, .h6) { font-size: 0.9rem; font-weight: 600; }
.content-wrapper h1 small, .content-wrapper h1 .small { font-size: 0.8rem; font-weight: 500; }

/* Summary cards marked with a coloured left edge (`border-start border-4 border-*`). On a .card
   the border-4 utility thickened all four sides and the colour went all the way round, so a
   total read as a loud framed box. The accent stays on the left; the other sides are the card's. */
.card.border-start.border-4 {
    border-width: 1px 1px 1px 3px !important;
    border-top-color: var(--border) !important;
    border-right-color: var(--border) !important;
    border-bottom-color: var(--border) !important;
}

/* ============================================================================
   Colour means one thing (owner, 18.10): structure is neutral; a colour appears only to say
   good (green), to check (amber), wrong (red). Pages asked Bootstrap for coloured section heads,
   frames and solid badges by habit — sibling sections came out grey, blue, green and amber for
   no reason. These rules bring every page to the same reading, without touching the views.
   ============================================================================ */

/* Section heads and subtotal footers: a neutral band. Only "to check" (warning) and "wrong"
   (danger) keep their tint — a section painted amber means look here. */
.card > :is(.card-header, .card-footer):is(.bg-primary, .bg-success, .bg-info, .bg-secondary, .bg-light, .bg-white) {
    background-color: var(--surface-sunken) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}
.card > :is(.card-header, .card-footer):is(.bg-primary, .bg-success, .bg-info, .bg-secondary) :is(.text-white, .text-dark, .text-primary, .text-info, .text-secondary) { color: inherit !important; }
.card > .card-footer:is(.bg-primary, .bg-success, .bg-info, .bg-secondary) { font-weight: 700; }
.card > :is(.card-header, .card-footer):is(.bg-warning, .bg-danger) {
    background-color: var(--tone-soft) !important;
    color: var(--tone) !important;
    border-color: color-mix(in srgb, var(--tone) 22%, transparent) !important;
}
.card > :is(.card-header, .card-footer).bg-warning { --tone: var(--warning);        --tone-soft: var(--warning-soft); }
.card > :is(.card-header, .card-footer).bg-danger  { --tone: var(--negative-money); --tone-soft: var(--negative-soft); }
.card > :is(.card-header, .card-footer):is(.bg-warning, .bg-danger) :is(.text-white, .text-dark) { color: inherit !important; }

/* Frames: a coloured frame was decoration; only amber/red frames (look here / wrong) stay, at a third.
   A summary card's coloured left edge (`border-start border-4`) names what the figure is (income in
   green, a neutral total in ink) and stays. */
.card:is(.border-primary, .border-success, .border-info, .border-secondary, .border-dark):not(.border-4) { border-color: var(--border) !important; }

/* The grand total keeps the one solid block of the page, in the brand ink; a header in bg-dark
   would be heavier than the total it introduces, so headers stay a neutral band. */
.card > .card-header.bg-dark { background-color: var(--surface-sunken) !important; color: var(--text) !important; border-bottom-color: var(--border); }
.card > .card-header.bg-dark .text-white { color: inherit !important; }
.content-wrapper .card.bg-dark { background-color: var(--brand) !important; border-color: var(--brand); }

/* Badges and status chips: a soft tint with the colour as text, never a solid block — on a list the
   same solid green "Active" on every row was the loudest thing on the page and said nothing new.
   Green = good, amber = to check, red = wrong; role, currency, category = a neutral outlined chip. */
.badge:is(.bg-success, .bg-warning, .bg-danger, .bg-info, .bg-secondary, .bg-primary, .bg-light):not([class*="bg-opacity"]) {
    background-color: var(--tone-soft) !important;
    color: var(--tone) !important;
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 18%, transparent);
}
.badge.bg-success { --tone: var(--positive-money); --tone-soft: var(--positive-soft); }
.badge.bg-warning { --tone: var(--warning);        --tone-soft: var(--warning-soft); }
.badge.bg-danger  { --tone: var(--negative-money); --tone-soft: var(--negative-soft); }
.badge:is(.bg-info, .bg-secondary, .bg-light) { --tone: var(--text-muted); --tone-soft: var(--surface-sunken); }
.badge.bg-primary { --tone: var(--brand-text);     --tone-soft: var(--brand-soft-strong); }
.badge:is(.bg-success, .bg-warning, .bg-danger, .bg-info, .bg-secondary, .bg-primary, .bg-light) :is(.text-white, .text-dark) { color: inherit !important; }

/* Table rows: white rows, a neutral band for heads and subtotals; a tinted row only when the row
   is good / to check / wrong. Bootstrap's pastel table-primary/-info (blue) carried no meaning. */
:is(.table-primary, .table-info, .table-secondary, .table-light) {
    --bs-table-bg: var(--surface-sunken);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--surface-sunken);
    --bs-table-hover-bg: var(--surface-hover);
    --bs-table-active-bg: var(--surface-sunken);
}
:is(.table-success, .table-warning, .table-danger) {
    --bs-table-bg: var(--tone-soft);
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    --bs-table-striped-bg: var(--tone-soft);
    --bs-table-hover-bg: var(--surface-hover);
    --bs-table-active-bg: var(--tone-soft);
}
.table-success { --tone-soft: var(--positive-soft); }
.table-warning { --tone-soft: var(--warning-soft); }
.table-danger  { --tone-soft: var(--negative-soft); }
.table { --bs-table-striped-bg: var(--surface-hover); }

/* Dialog heads follow the section heads: neutral, amber/red only when the dialog warns. */
.modal-header:is(.bg-primary, .bg-success, .bg-info, .bg-secondary) { background-color: var(--surface-sunken) !important; color: var(--text) !important; border-bottom-color: var(--border); }
.modal-header:is(.bg-warning, .bg-danger) { background-color: var(--tone-soft) !important; color: var(--tone) !important; }
.modal-header.bg-warning { --tone: var(--warning);        --tone-soft: var(--warning-soft); }
.modal-header.bg-danger  { --tone: var(--negative-money); --tone-soft: var(--negative-soft); }
.modal-header:is(.bg-primary, .bg-success, .bg-info, .bg-secondary, .bg-warning, .bg-danger) :is(.text-white, .text-dark) { color: inherit !important; }
.modal-header:is(.bg-primary, .bg-success, .bg-info, .bg-secondary, .bg-danger) .btn-close-white { filter: none; }

/* A whole card filled green or red for a state (the counting check: difference 0 or not): the state
   stays readable as a tint with a coloured frame, the figures in the normal ink. */
.card:is(.bg-success, .bg-danger, .bg-warning):not([class*="bg-opacity"]) {
    background-color: var(--tone-soft) !important;
    border-color: color-mix(in srgb, var(--tone) 40%, transparent) !important;
    color: var(--text) !important;
}
.card.bg-success { --tone: var(--positive-money); --tone-soft: var(--positive-soft); }
.card.bg-danger  { --tone: var(--negative-money); --tone-soft: var(--negative-soft); }
.card.bg-warning { --tone: var(--warning);        --tone-soft: var(--warning-soft); }
.card:is(.bg-success, .bg-danger, .bg-warning):not([class*="bg-opacity"]) .text-white { color: inherit !important; }

/* A card header is bold for its title only; the explanation line and filter labels under it
   inherited the weight and read as a second title. */
.card-header :is(p, small, .small, .form-label, label) { font-weight: 400; }

/* Row actions: the delete button sits in a <form> inside the btn-group, so Bootstrap's
   btn-group-sm sizing and joined corners never reached it — a big round button next to a small
   square one. The form's button now takes the group's size and seam. */
.btn-group-sm > form > .btn { --bs-btn-padding-y: 0.25rem; --bs-btn-padding-x: 0.5rem; --bs-btn-font-size: 0.875rem; border-radius: 8px; }
.btn-group > form:not(:first-child) > .btn { margin-left: -1px; border-top-left-radius: 0; border-bottom-left-radius: 0; }
.btn-group > form:not(:last-child) > .btn { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* Empty lists: one quiet icon size instead of six. */
.empty-icon { display: block; font-size: 2rem; line-height: 1; color: var(--text-subtle); opacity: 0.75; margin: 0 auto 0.5rem; }

/* The "?" next to a page title: a hint, not a call to action. */
.help-trigger-btn { color: var(--text-subtle); font-size: 1rem; line-height: 1; vertical-align: 0.05em; text-decoration: none; transition: color 0.15s ease; }
.help-trigger-btn:hover, .help-trigger-btn:focus-visible { color: var(--brand-text); }
.help-popup-layer { position: fixed; inset: 0; z-index: 1060; display: grid; place-items: center; padding: 1rem; }
.help-popup-backdrop { position: absolute; inset: 0; background: rgba(11, 61, 46, 0.45); }
.help-popup { position: relative; width: 100%; max-width: 34rem; max-height: 85vh; overflow-y: auto; background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-raised); padding: 1.25rem 1.4rem; text-align: left; font-weight: 400; font-size: 0.95rem; letter-spacing: normal; text-transform: none; }
.help-popup-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-bottom: 0.75rem; margin-bottom: 0.9rem; border-bottom: 1px solid var(--border); }
.help-popup .help-content p:last-child, .help-popup .help-content ul:last-child { margin-bottom: 0; }
.help-popup-foot { display: flex; align-items: center; gap: 1rem; margin-top: 1.1rem; padding-top: 0.85rem; border-top: 1px solid var(--border); }

/* The special collection's date calendar. It lives on <body>, fixed, like the searchable lists:
   opened inside the collections table it was cut off by the table's scroll box, and no day could
   be picked (2026-10-24). On a phone it is a sheet along the bottom edge, with fingertip days. */
.collection-calendar-backdrop { position: fixed; inset: 0; z-index: 1079; background: rgba(11, 61, 46, 0.35); }
.collection-calendar-panel { position: fixed; z-index: 1080; width: 280px; padding: 0.6rem; background: var(--surface-raised); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-raised); }
.collection-calendar-head { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.35rem; }
.collection-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.collection-calendar-weekday { text-align: center; text-transform: uppercase; font-size: 0.6rem; color: var(--text-muted); }
.collection-calendar-grid .btn { min-width: 0; height: 30px; padding: 0; font-size: 0.75rem; }
.collection-calendar.is-sheet .collection-calendar-panel { left: 0; right: 0; bottom: 0; top: auto; width: auto; padding: 1rem 1rem calc(1rem + env(safe-area-inset-bottom)); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.collection-calendar.is-sheet .collection-calendar-grid { gap: 4px; }
.collection-calendar.is-sheet .collection-calendar-grid .btn { height: 44px; font-size: 1rem; }
.collection-calendar.is-sheet .collection-calendar-weekday { font-size: 0.75rem; }

/* ============================================================================
   Buttons — one family. Solid fills are for the one action that moves the page forward
   (primary) or that cannot be taken back (danger, warning); the rest are tonal or outlined,
   and every hover is a tint of the button's own colour, never a jump to a loud fill.
   Bootstrap's stock success/warning/info (#198754, #ffc107 with black text, #0dcaf0) were
   brighter than everything around them.
   ============================================================================ */
:root {
    --btn-success: #1f7a50; --btn-success-strong: #17603f;
    --btn-danger:  #b42318; --btn-danger-strong:  #912018;
    --btn-warning: #b45309; --btn-warning-strong: #92400e;
    --btn-info:    #0e7490; --btn-info-strong:    #155e75;
    --on-warning:  #ffffff;
}
:root[data-theme="dark"] { --on-warning: #1f1300; }

.btn-secondary {
    --bs-btn-color: var(--brand-text); --bs-btn-bg: var(--brand-soft); --bs-btn-border-color: transparent;
    --bs-btn-hover-color: var(--brand-text); --bs-btn-hover-bg: var(--brand-soft-strong); --bs-btn-hover-border-color: transparent;
    --bs-btn-active-color: var(--brand-text); --bs-btn-active-bg: var(--brand-soft-strong); --bs-btn-active-border-color: transparent;
    --bs-btn-disabled-color: var(--text-subtle); --bs-btn-disabled-bg: var(--surface-sunken); --bs-btn-disabled-border-color: transparent;
    font-weight: 600;
}
.btn-success, .btn-danger, .btn-warning, .btn-info {
    --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; --bs-btn-disabled-color: #fff;
}
.btn-success { --bs-btn-bg: var(--btn-success); --bs-btn-border-color: var(--btn-success); --bs-btn-hover-bg: var(--btn-success-strong); --bs-btn-hover-border-color: var(--btn-success-strong); --bs-btn-active-bg: var(--btn-success-strong); --bs-btn-active-border-color: var(--btn-success-strong); --bs-btn-disabled-bg: var(--btn-success); --bs-btn-disabled-border-color: var(--btn-success); }
.btn-danger  { --bs-btn-bg: var(--btn-danger);  --bs-btn-border-color: var(--btn-danger);  --bs-btn-hover-bg: var(--btn-danger-strong);  --bs-btn-hover-border-color: var(--btn-danger-strong);  --bs-btn-active-bg: var(--btn-danger-strong);  --bs-btn-active-border-color: var(--btn-danger-strong);  --bs-btn-disabled-bg: var(--btn-danger);  --bs-btn-disabled-border-color: var(--btn-danger); }
.btn-warning { --bs-btn-bg: var(--btn-warning); --bs-btn-border-color: var(--btn-warning); --bs-btn-hover-bg: var(--btn-warning-strong); --bs-btn-hover-border-color: var(--btn-warning-strong); --bs-btn-active-bg: var(--btn-warning-strong); --bs-btn-active-border-color: var(--btn-warning-strong); --bs-btn-disabled-bg: var(--btn-warning); --bs-btn-disabled-border-color: var(--btn-warning); }
.btn-info    { --bs-btn-bg: var(--btn-info);    --bs-btn-border-color: var(--btn-info);    --bs-btn-hover-bg: var(--btn-info-strong);    --bs-btn-hover-border-color: var(--btn-info-strong);    --bs-btn-active-bg: var(--btn-info-strong);    --bs-btn-active-border-color: var(--btn-info-strong);    --bs-btn-disabled-bg: var(--btn-info);    --bs-btn-disabled-border-color: var(--btn-info); }

/* Outlined: the colour in the text, a soft border, a tint on hover. A pressed toggle
   (btn-check) stays a clear solid so the chosen option reads at a glance. */
.btn-outline-primary { --bs-btn-hover-color: var(--brand-text); --bs-btn-hover-bg: var(--brand-soft); --bs-btn-hover-border-color: var(--brand-text); --bs-btn-active-color: var(--brand-contrast); }
.btn-outline-secondary {
    --bs-btn-color: var(--text-muted); --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-color: var(--text); --bs-btn-hover-bg: var(--surface-hover); --bs-btn-hover-border-color: var(--border-strong);
    --bs-btn-active-color: var(--brand-text); --bs-btn-active-bg: var(--brand-soft-strong); --bs-btn-active-border-color: var(--brand-text);
}
.btn-outline-success, .btn-outline-danger, .btn-outline-warning, .btn-outline-info {
    --bs-btn-color: var(--tone); --bs-btn-border-color: color-mix(in srgb, var(--tone) 45%, transparent);
    --bs-btn-hover-color: var(--tone); --bs-btn-hover-bg: var(--tone-soft); --bs-btn-hover-border-color: var(--tone);
    --bs-btn-active-color: var(--tone); --bs-btn-active-bg: var(--tone-soft); --bs-btn-active-border-color: var(--tone);
    --bs-btn-disabled-color: var(--tone); --bs-btn-disabled-border-color: color-mix(in srgb, var(--tone) 30%, transparent);
}
.btn-outline-success { --tone: var(--positive-money); --tone-soft: var(--positive-soft); }
.btn-outline-danger  { --tone: var(--negative-money); --tone-soft: var(--negative-soft); }
.btn-outline-warning { --tone: var(--warning);        --tone-soft: var(--warning-soft); }
.btn-outline-info    { --tone: var(--info);           --tone-soft: var(--info-soft); }

/* Alerts — the same soft fills as the status pills, body text in the normal colour. */
.alert { font-size: 0.9rem; }
.alert-info, .alert-success, .alert-warning, .alert-danger, .alert-primary, .alert-secondary, .alert-light {
    --bs-alert-color: var(--text); --bs-alert-bg: var(--tone-soft);
    --bs-alert-border-color: color-mix(in srgb, var(--tone) 22%, transparent); --bs-alert-link-color: var(--tone);
}
.alert-info      { --tone: var(--info);           --tone-soft: var(--info-soft); }
.alert-success   { --tone: var(--positive-money); --tone-soft: var(--positive-soft); }
.alert-warning   { --tone: var(--warning);        --tone-soft: var(--warning-soft); }
.alert-danger    { --tone: var(--negative-money); --tone-soft: var(--negative-soft); }
.alert-primary   { --tone: var(--brand-text);     --tone-soft: var(--brand-soft); }
.alert-secondary, .alert-light { --tone: var(--text-muted); --tone-soft: var(--surface-sunken); }
.alert > .bi:first-child, .alert > i.bi { color: var(--tone); }

/* ============================================================================
   Counting session — one envelope per row, keyboard first.
   ============================================================================ */
.env-row {
    display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.5rem;
    padding: 0.3rem 0.5rem; border-bottom: 1px solid var(--border);
}
.env-row:hover { background: var(--surface-hover); }
.env-row:focus-within { background: var(--brand-soft); }
.env-no { min-width: 2.4rem; color: var(--text-muted); font-size: 0.78rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.env-items { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem 0.6rem; flex: 1 1 auto; min-width: 0; }
.env-item { display: flex; align-items: center; gap: 0.25rem; }
.env-item .form-select-sm, .env-item .form-control-sm { padding-top: 0.2rem; padding-bottom: 0.2rem; border-radius: 8px; }
.env-dest { width: 13rem; }
.env-curr { width: 5.4rem; }
.env-desc { width: 9rem; }
.env-code { width: 4.6rem; }
.env-amount { width: 7rem; font-variant-numeric: tabular-nums; }
.env-add { padding: 0.05rem 0.4rem; line-height: 1.2; }
.env-total { margin-left: auto; font-size: 0.85rem; font-weight: 700; color: var(--positive-money); white-space: nowrap; font-variant-numeric: tabular-nums; }
.env-notes { flex-basis: 100%; margin-left: 2.9rem; font-size: 0.8rem; }
.env-add-label { display: none; }
@media (max-width: 575.98px) {
    /* Number, total and actions on the first line; then each budget full width, with its
       currency and amount side by side under it — two lines per budget, not three. */
    .env-row { padding: 0.5rem 0.25rem; }
    .env-items { order: 5; flex-basis: 100%; }
    .env-notes { order: 6; margin-left: 0; }
    .env-item { display: grid; grid-template-columns: 6rem minmax(0, 1fr) auto; gap: 0.4rem; flex: 1 1 100%; }
    .env-item > .env-dest, .env-item > .env-desc { grid-column: 1 / -1; width: auto; }
    .env-item > .env-curr { grid-column: 1; width: auto; }
    .env-item > .env-code { grid-column: 1 / -1; width: auto; }
    .env-item > .env-amount { grid-column: 2; width: auto; }
    .env-add { flex: 1 1 100%; padding: 0.3rem 0.6rem; }
    .env-add-label { display: inline; }
}
/* No physical keyboard on a phone: the shortcut legend is only clutter there. */
@media (max-width: 767.98px) {
    .env-footer .env-keys { display: none; }
}

/* Lists on a phone (public/js/phone-lists.js): filters behind one button, wide tables as cards. */
.filter-toggle { display: none; }
@media (max-width: 767.98px) {
    .filter-toggle { display: flex; align-items: center; gap: 0.5rem; }
    .filter-toggle-count { background: var(--accent); color: var(--surface-raised); }
    .filter-toggle-caret { margin-left: auto; transition: transform 0.15s ease; }
    .filter-toggle[aria-expanded="true"] .filter-toggle-caret { transform: rotate(180deg); }
    .filter-foldable.is-folded { display: none !important; }

    table.is-cards, table.is-cards > tbody, table.is-cards > tfoot, table.is-cards > tbody > tr, table.is-cards > tfoot > tr { display: block; width: 100%; }
    table.is-cards > thead { display: none; }
    table.is-cards > tbody > tr, table.is-cards > tfoot > tr { padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--border); }
    /* The value keeps its own flow (a date and its weekday, two buttons) at the right; the column's
       name floats left. A flex cell spread a cell's pieces across the line. */
    table.is-cards > tbody > tr > td, table.is-cards > tfoot > tr > * {
        display: block; width: auto !important; padding: 0.2rem 0 !important; border: 0 !important;
        text-align: right !important; background: transparent; box-shadow: none;
    }
    table.is-cards > tbody > tr > td::before, table.is-cards > tfoot > tr > *::before {
        content: attr(data-label); float: left; max-width: 45%; margin-right: 1rem; text-align: left;
        font-size: 0.8rem; font-weight: 400; color: var(--text-muted);
    }
    table.is-cards > tbody > tr > td::after, table.is-cards > tfoot > tr > *::after { content: ""; display: block; clear: both; }
    table.is-cards > tbody > tr > td:not([data-label])::before, table.is-cards > tfoot > tr > *:not([data-label])::before { content: none; }
    table.is-cards > tbody > tr > td:first-child { font-weight: 600; }
    table.is-cards > tbody > tr > td[colspan] { text-align: center !important; font-weight: 400; }
    table.is-cards > tbody > tr > td:empty, table.is-cards > tfoot > tr > *:empty { display: none; }
}

/* Step 2 on a phone: the session's fields are folded into the one-line summary above them. */
@media (max-width: 767.98px) {
    .counting-basics-folded { display: none !important; }
}

/* The session's own fields two by two on a phone (number and date, then time), the note and the
   deposit location full width; fixed desktop widths cut the time at 16px. */
@media (max-width: 767.98px) {
    .counting-basics > div { flex: 1 1 calc(50% - 0.5rem); width: auto !important; min-width: 0 !important; }
    .counting-basics > div:nth-child(n+4) { flex-basis: 100%; }
}

/* The basket collections table becomes one block per collection on a phone: number, budget and
   delete on the first line, then the count and the note at full width (the same order). Four
   columns at 360px cut the budget to "Zecim" and the amount to "2.0(". */
@media (max-width: 767.98px) {
    .collections-table thead { display: none; }
    .collections-table tbody tr.collection-row {
        display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) auto; gap: 0.45rem 0.5rem;
        grid-template-areas: "no dest del" ". amount amount" ". notes notes";
        padding: 0.65rem 0.75rem; border-bottom: 1px solid var(--border);
    }
    .collections-table tbody tr.collection-row > td { display: block; padding: 0; border: 0; width: auto; background: transparent; box-shadow: none; }
    .collections-table .collection-no { grid-area: no; padding-top: 0.7rem !important; }
    .collections-table .collection-dest { grid-area: dest; }
    .collections-table .collection-amount { grid-area: amount; }
    .collections-table .collection-notes { grid-area: notes; }
    .collections-table .collection-del { grid-area: del; }
    .collections-table tfoot tr { display: flex; justify-content: space-between; padding: 0.6rem 0.75rem; }
    .collections-table tfoot th { padding: 0; border: 0; }
    .collections-table tfoot th:empty { display: none; }
}

/* Step 2's "which baskets are in the count" table on a phone: tick, name, amount on one line; the
   status badge only repeats the tick (and the greyed row) and was cut off at the right edge. The
   name is the tick's label, so the whole line toggles it. */
@media (max-width: 767.98px) {
    .verify-collections-table thead { display: none; }
    .verify-collections-table tbody tr { display: grid; grid-template-columns: 2.5rem minmax(0, 1fr) auto; align-items: center; }
    .verify-collections-table tbody td { border: 0; padding: 0.6rem 0.5rem; }
    .verify-collections-table tbody td:nth-child(4) { display: none; }
    .verify-collections-table tbody label { display: block; cursor: pointer; }
    .verify-collections-table tfoot tr { display: flex; justify-content: space-between; gap: 0.5rem; }
    .verify-collections-table tfoot td { border: 0; background: transparent; box-shadow: none; }
    .verify-collections-table tfoot td:empty { display: none; }
}

/* The step's buttons stacked full width on a phone, the step's main action first. */
@media (max-width: 575.98px) {
    .counting-nav, .counting-nav > .d-flex { flex-direction: column-reverse; gap: 0.5rem !important; width: 100%; }
    .counting-nav .btn { width: 100%; }
    .counting-nav > div:empty { display: none; }
}

/* Opening balance lines on a phone: one block each, every field named (its data-label), the
   budget with its delete button, then where, currency beside amount, and the note. Six columns
   at 360px left the budget blank and the location as "Cas". */
@media (max-width: 767.98px) {
    .opening-items-table thead { display: none; }
    .opening-items-table tbody tr.item-row {
        display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 0.5rem 0.6rem;
        grid-template-areas: "type type del" "loc loc loc" "cur amt amt" "notes notes notes";
        padding: 0.75rem 0; border-bottom: 1px solid var(--border);
    }
    .opening-items-table tbody tr.item-row > td { display: block; padding: 0; border: 0; background: transparent; box-shadow: none; }
    .opening-items-table tbody tr.item-row > td::before { content: attr(data-label); display: block; font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.2rem; }
    .opening-items-table tbody tr.item-row > td:nth-child(1) { grid-area: type; }
    .opening-items-table tbody tr.item-row > td:nth-child(2) { grid-area: loc; }
    .opening-items-table tbody tr.item-row > td:nth-child(3) { grid-area: cur; }
    .opening-items-table tbody tr.item-row > td:nth-child(4) { grid-area: amt; }
    .opening-items-table tbody tr.item-row > td:nth-child(5) { grid-area: notes; }
    .opening-items-table tbody tr.item-row > td:nth-child(6) { grid-area: del; align-self: end; }
}

/* Counting steps side by side on a phone, not stacked a screen deep. */
@media (max-width: 767.98px) {
    .counting-steps { display: grid; grid-template-columns: 1fr 1fr; gap: 0.35rem; border-bottom: 0; }
    .counting-steps .nav-link { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; gap: 0.3rem; text-align: center; font-size: 0.85rem; line-height: 1.2; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.5rem; }
    .counting-steps .nav-link.active { border-color: var(--accent); }
}
.env-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.5rem;
    padding: 0.5rem; border-top: 1px solid var(--border);
}
.env-keys { display: flex; flex-wrap: wrap; gap: 0.25rem 0.9rem; font-size: 0.75rem; color: var(--text-muted); }
.env-keys kbd {
    background: var(--surface-sunken); color: var(--text); border: 1px solid var(--border-strong);
    border-radius: 4px; padding: 0 0.3rem; font-size: 0.72rem; box-shadow: inset 0 -1px 0 var(--border-strong);
}
.env-summary-well { padding: 0.6rem; border-top: 1px solid var(--border); background: var(--surface-sunken); }
.env-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.6rem; }
.env-summary-side {
    padding: 0.45rem 0.75rem; background: var(--surface-raised);
    border: 1px solid var(--border); border-left: 3px solid var(--role-conference); border-radius: var(--radius-sm);
}
.env-summary-side.is-church { border-left-color: var(--role-church); }
.env-summary-head {
    margin-bottom: 0.2rem; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase;
    color: var(--role-conference);
}
.env-summary-side.is-church .env-summary-head { color: var(--role-church); }
.env-summary-line { display: flex; justify-content: space-between; gap: 1rem; padding: 0.12rem 0; font-size: 0.85rem; }
.env-summary-line .money, .env-summary-total .money { white-space: nowrap; font-variant-numeric: tabular-nums; }
.env-summary-subtotal { margin-top: 0.2rem; padding-top: 0.3rem; border-top: 1px solid var(--border); font-weight: 700; }
.env-summary-total {
    display: flex; justify-content: space-between; gap: 1rem; margin-top: 0.6rem; padding: 0.45rem 0.75rem;
    background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius-sm); font-weight: 700;
}
.env-summary-total .money { color: var(--positive-money); }

/* ============================================================================
   Motion — tasteful, opt-in, and fully disabled under reduced-motion.
   Base state is always the FINAL state (opacity:1) so anything is visible
   without JS or with motion off.
   ============================================================================ */
.reveal { opacity: 1; }
.kpi-value { font-variant-numeric: tabular-nums; }

@media (prefers-reduced-motion: no-preference) {
    /* Cards/rows rise + fade in, staggered via inline --i (loop index). */
    .reveal {
        opacity: 0;
        animation: azs-reveal 0.5s cubic-bezier(0.2, 0.6, 0.2, 1) both;
        animation-delay: calc(var(--i, 0) * 60ms);
    }
    @keyframes azs-reveal {
        from { opacity: 0; transform: translateY(10px); }
        to   { opacity: 1; transform: none; }
    }

    /* Smooth cross-fade when the theme flips. */
    body,
    .card, .sidebar, .top-header, .stat-card, .summary-card,
    .btn, .form-control, .form-select, .dropdown-menu, .nav-link {
        transition: background-color 0.25s ease, color 0.25s ease,
                    border-color 0.25s ease, box-shadow 0.25s ease;
    }

    /* Subtle lift on interactive list/report cards (never on KPI stat cards). */
    .card-hover { transition: transform 0.18s ease, box-shadow 0.18s ease; }
    .card-hover:hover { transform: translateY(-2px); box-shadow: var(--shadow-raised); }
}

/* ============================================================================
   Premium surfaces — dashboard hero, KPI stat cards, chart panels, status pills.
   Built entirely on the tokens above; both themes. Presentation only.
   ============================================================================ */

/* Hero greeting band — ink in BOTH themes (paper copy always clears AA), with the symbol (equals
   sign + mint "checked" dot) large and faint beside the text. */
.hero {
    position: relative;
    overflow: hidden;
    border-radius: var(--radius);
    padding: 1.1rem 1.5rem;
    color: #f1f7f3;
    background: #0b3d2e;
    border: 1px solid #0b3d2e;
    box-shadow: 0 10px 30px -14px rgba(11, 61, 46, 0.55);
}
:root[data-theme="dark"] .hero { border-color: var(--border); background: #082c21; }
.hero::after {
    content: "";
    position: absolute;
    right: 200px;
    top: 50%;
    width: 180px;
    height: 104px;
    transform: translateY(-50%);
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 52 30'%3E%3Crect width='36' height='12' rx='6' fill='%23f1f7f3' fill-opacity='.06'/%3E%3Ccircle cx='46' cy='6' r='6' fill='%233ddc97' fill-opacity='.6'/%3E%3Crect y='18' width='52' height='12' rx='6' fill='%23f1f7f3' fill-opacity='.06'/%3E%3C/svg%3E") no-repeat center / contain;
    pointer-events: none;
}
@media (max-width: 991.98px) { .hero::after { display: none; } }
.hero > * { position: relative; }
.hero-eyebrow { text-transform: uppercase; letter-spacing: 0.14em; font-size: 0.72rem; font-weight: 600; color: rgba(241, 247, 243, 0.62); }
.hero-title { font-weight: 600; letter-spacing: -0.02em; font-size: 1.4rem; margin: 0.1rem 0 0; }
.hero-sub { color: rgba(241, 247, 243, 0.82); margin: 0.35rem 0 0; }
.hero-meta { color: rgba(241, 247, 243, 0.62); font-size: 0.85rem; }
.hero .btn-light { --bs-btn-bg: #ffffff; --bs-btn-border-color: #ffffff; --bs-btn-color: #0b3d2e; --bs-btn-hover-bg: #e8f0ec; --bs-btn-hover-border-color: #e8f0ec; --bs-btn-hover-color: #0b3d2e; --bs-btn-active-bg: #e8f0ec; --bs-btn-active-color: #0b3d2e; font-weight: 600; box-shadow: none; }
.hero .btn-outline-light { --bs-btn-color: #f1f7f3; --bs-btn-border-color: rgba(241, 247, 243,0.35); --bs-btn-hover-bg: rgba(241, 247, 243,0.1); --bs-btn-hover-color: #f1f7f3; --bs-btn-hover-border-color: rgba(241, 247, 243,0.6); font-weight: 600; }

/* KPI card — flagship stat tile: gradient icon, big tabular figure, trend chip. */
.kpi-card {
    position: relative;
    height: 100%;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}
.kpi-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--kpi-accent, var(--brand));
    opacity: 0.85;
}
.kpi-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.kpi-icon {
    width: 38px;
    height: 38px;
    flex: none;
    border-radius: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    color: var(--kpi-accent, var(--brand));
    background: color-mix(in srgb, var(--kpi-accent, var(--brand)) 13%, transparent);
}
.kpi-label { color: var(--text-muted); font-size: 0.78rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; margin: 0; }
.kpi-value { display: block; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.45rem; line-height: 1.2; letter-spacing: -0.015em; color: var(--text); margin-top: 0.45rem; }
.kpi-unit { font-size: 0.9rem; font-weight: 600; color: var(--text-muted); margin-left: 0.15rem; }
.kpi-delta { display: inline-flex; align-items: center; gap: 0.25rem; margin-top: 0.55rem; font-size: 0.76rem; font-weight: 600; padding: 0.16rem 0.5rem; border-radius: 999px; }
.kpi-delta.up   { color: var(--positive-money); background: var(--positive-soft); }
.kpi-delta.down { color: var(--negative-money); background: var(--negative-soft); }
.kpi-delta.flat { color: var(--text-muted); background: var(--surface-sunken); }
.kpi-note { display: block; margin-top: 0.5rem; color: var(--text-subtle); font-size: 0.72rem; line-height: 1.35; }

.kpi-brand   { --kpi-accent: var(--brand); }
.kpi-success { --kpi-accent: var(--positive-money); }
.kpi-danger  { --kpi-accent: var(--negative-money); }
.kpi-warning { --kpi-accent: var(--warning); }
.kpi-info    { --kpi-accent: var(--info); }
.kpi-church     { --kpi-accent: var(--role-church); }
.kpi-conference { --kpi-accent: var(--role-conference); }
.kpi-total      { --kpi-accent: var(--role-total); }

/* Chart panel + generic canvas sizing. */
.chart-wrap { position: relative; width: 100%; height: 300px; }
.chart-wrap-sm { height: 220px; }

/* Section headers used above panels. */
.section-eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.72rem; font-weight: 700; color: var(--brand-text); }
.section-title { font-weight: 700; letter-spacing: -0.01em; margin: 0; }

/* Status pill — softer, dotted, theme-aware. Replaces raw Bootstrap badges in
   status columns without touching the badge component elsewhere. */
.pill { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.28rem 0.62rem; border-radius: 999px; font-size: 0.74rem; font-weight: 600; line-height: 1; }
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-success   { color: var(--positive-money); background: var(--positive-soft); }
.pill-warning   { color: var(--warning); background: var(--warning-soft); }
.pill-info      { color: var(--info); background: var(--info-soft); }
.pill-danger    { color: var(--negative-money); background: var(--negative-soft); }
.pill-secondary { color: var(--text-muted); background: var(--surface-sunken); }

@media (prefers-reduced-motion: no-preference) {
    .kpi-card { transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease; }
    .kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-raised); border-color: var(--border-strong); }
}

/* Active pill tabs: Bootstrap's generic #0d6efd, in both themes. */
.nav-pills { --bs-nav-pills-link-active-bg: var(--brand); --bs-nav-pills-link-active-color: var(--brand-contrast); }

/* ============================================================================
   Dark theme — nothing lights up. Bootstrap's solid status fills (badges, status chips),
   its coloured table rows (pastels with black text, not theme-aware in 5.3), the hero's white
   button and the amber DEMO tag were the brightest things on a dark page. On dark they become
   tints of their own colour with the colour as text (badges, section heads, rows and state cards
   already follow the "colour means one thing" rules above, in both themes).
   Check with: node tools/ui-probe/probe.cjs <page> --dark --glare
   ============================================================================ */
:root[data-theme="dark"] :is(.bg-success, .bg-danger, .bg-warning, .bg-info):not([class*="bg-opacity"]):not(.progress-bar):not(.badge):not(.card-header):not(.card-footer):not(.modal-header):not(.card) {
    background-color: color-mix(in srgb, var(--tone) 22%, transparent) !important;
    color: var(--tone) !important;
}
:root[data-theme="dark"] .bg-success { --tone: var(--positive-money); }
:root[data-theme="dark"] .bg-danger  { --tone: var(--negative-money); }
:root[data-theme="dark"] .bg-warning { --tone: var(--warning); }
:root[data-theme="dark"] .bg-info    { --tone: var(--info); }
:root[data-theme="dark"] :is(.badge-local, .badge-conf) {
    background-color: color-mix(in srgb, var(--tone) 24%, transparent) !important;
    color: var(--tone) !important;
}
:root[data-theme="dark"] .badge-local { --tone: var(--role-church); }
:root[data-theme="dark"] .badge-conf  { --tone: var(--role-conference); }
/* Legend chips coloured inline with a role token: the dark role colours are bright by design
   (lines on a dark chart); as a filled chip with white text they glare, so they are dimmed. */
:root[data-theme="dark"] .badge[style*="var(--role"],
:root[data-theme="dark"] .badge[style*="var(--palette"] { filter: brightness(0.72) saturate(0.85); }

:root[data-theme="dark"] .context-chip-tag { background: color-mix(in srgb, var(--warning) 24%, transparent); color: var(--warning); }
:root[data-theme="dark"] .content-wrapper .card.bg-dark { background-color: var(--surface-hover) !important; border-color: var(--border-strong); border-top: 3px solid var(--accent); }

/* ============================================================================
   Print — always render light on paper, regardless of the on-screen theme.
   ============================================================================ */
@media print {
    :root,
    :root[data-theme="dark"] {
        color-scheme: light;
        --surface: #ffffff;
        --surface-raised: #ffffff;
        --surface-sunken: #f4f6f9;
        --surface-hover: #f4f6f9;
        --text: #111827;
        --text-muted: #4b5563;
        --border: #d1d5db;
        --border-strong: #333333;   /* signature lines + register gridlines print crisp, never faint */
        --positive-soft: #e7f5ec;
        --negative-soft: #fdecea;
        --warning-soft: #fef3e2;
        --info-soft: #e0f2fe;
        --chart-grid: rgba(0,0,0,0.08);
        --chart-tick: #4b5563;
        --chart-border-contrast: #ffffff;
    }
    :root[data-theme="dark"] .bg-white { background-color: #ffffff !important; }
    :root[data-theme="dark"] .text-dark,
    :root[data-theme="dark"] .text-muted { color: inherit !important; }
}
