/* ==========================================================================
   VMS design system
   One light theme. Tokens first, then the vms-* components, then a
   compatibility layer that maps the legacy slate/blue Tailwind classes onto
   the tokens so views that have not been migrated yet still look right.
   New markup should use the tokens (Tailwind: bg-surface, text-ink, bg-brand…)
   or the <x-ui.*> components, never the legacy classes.
   ========================================================================== */

:root {
    --ground: #f5f7fa;
    --surface: #ffffff;
    --surface-sunken: #f1f4f8;
    --line: #e2e7ee;
    --line-strong: #8792a4;
    --ink: #16202f;
    --ink-muted: #526071;
    --brand: #1d4ea8;
    --brand-hover: #173f8a;
    --brand-soft: #eaf0fb;
    --on-brand: #ffffff;
    --paid: #17692f;
    --paid-soft: #e6f4ea;
    --due: #8a4a00;
    --due-soft: #fdf2de;
    --overdue: #b42318;
    --overdue-soft: #fdecea;
    --promised: #5b3fa3;
    --promised-soft: #f1edfa;
    --info: #0e6570;
    --info-soft: #e3f2f3;
    --neutral-soft: #eef1f5;
    --rail: #ffffff;
    --rail-hover: #f1f4f8;
    --rail-active: #eaf0fb;
    --rail-ink: #16202f;
    --rail-muted: #5f6b7c;
    --rail-accent: var(--brand);
    --plate: #ffffff;
    --plate-ink: #111111;
    --plate-band: #0b6b3a;
    --scrim: rgba(16, 24, 40, 0.5);
    --link: var(--brand);
    --focus: var(--brand);

    --font-sans: "Public Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    --font-display: var(--font-sans);
    --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;

    --space-1: 4px; --space-2: 8px; --space-3: 12px; --space-4: 16px;
    --space-5: 20px; --space-6: 24px; --space-8: 32px;
    --radius-sm: 4px; --radius-md: 6px; --radius-lg: 8px; --radius-pill: 999px;
    --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05);
    --shadow-overlay: 0 12px 32px rgba(16, 24, 40, 0.16), 0 2px 6px rgba(16, 24, 40, 0.06);

    color-scheme: light;
}

/* ---------- Base ---------- */
html, body { background-color: var(--ground); }
body {
    font-family: var(--font-sans);
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    -webkit-font-smoothing: antialiased;
}
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cfd6e0; border-radius: 999px; border: 2px solid var(--ground); }
::-webkit-scrollbar-thumb:hover { background: #aab4c2; }

.vms-muted { color: var(--ink-muted); }
.vms-label { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); }
.vms-id { font-family: var(--font-mono); font-size: 13px; font-weight: 500; }
.vms-money { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.vms-money small { font-size: .78em; font-weight: 500; color: var(--ink-muted); margin-right: 2px; }

/* ---------- Button ---------- */
.vms-btn { font: inherit; font-weight: 600; font-size: 14px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); height: 36px; padding: 0 14px; border-radius: var(--radius-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .12s, border-color .12s, color .12s; }
.vms-btn:hover { background: var(--surface-sunken); }
.vms-btn-primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.vms-btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.vms-btn-danger { border-color: var(--overdue); color: var(--overdue); }
.vms-btn-danger:hover { background: var(--overdue-soft); }
.vms-btn-ghost { border-color: transparent; background: transparent; color: var(--ink-muted); }
.vms-btn-ghost:hover { background: var(--surface-sunken); color: var(--ink); }
.vms-btn-sm { height: 32px; padding: 0 12px; font-size: 13px; gap: 6px; }
.vms-btn[disabled], .vms-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }

/* ---------- Row action ---------- */
.vms-act { font: inherit; font-size: 13px; font-weight: 600; line-height: 1; display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; border-radius: var(--radius-md); border: 0; background: transparent; color: var(--ink-muted); cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .12s, color .12s; }
.vms-act:hover { background: var(--surface-sunken); color: var(--ink); }
.vms-act-primary { color: var(--brand); }
.vms-act-primary:hover { background: var(--brand-soft); color: var(--brand); }
.vms-act-danger { color: var(--overdue); }
.vms-act-danger:hover { background: var(--overdue-soft); color: var(--overdue); }
.vms-act[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------- Status pill ---------- */
.vms-pill { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 9px 0 7px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 600; line-height: 1; white-space: nowrap; background: var(--neutral-soft); color: var(--ink-muted); }
.vms-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.vms-pill-paid { background: var(--paid-soft); color: var(--paid); }
.vms-pill-due { background: var(--due-soft); color: var(--due); }
.vms-pill-overdue { background: var(--overdue-soft); color: var(--overdue); }
.vms-pill-promised { background: var(--promised-soft); color: var(--promised); }
.vms-pill-info { background: var(--info-soft); color: var(--info); }
.vms-pill-brand { background: var(--brand-soft); color: var(--brand); }
.vms-pill-overdue::before { border-radius: 1px; transform: rotate(45deg); }
.vms-pill-paid::before { width: 7px; height: 4px; border-radius: 0; background: none; border: solid currentColor; border-width: 0 0 2px 2px; transform: rotate(-45deg) translate(1px, -1px); }

/* ---------- Card ---------- */
.vms-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.vms-card-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: var(--space-4) var(--space-5); border-bottom: 1px solid var(--line); }
.vms-card-title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 600; color: var(--ink); }
.vms-card-body { padding: var(--space-5); }

/* ---------- Stat tile ---------- */
.vms-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: var(--space-3); }
.vms-tile { display: grid; align-content: start; gap: 6px; padding: var(--space-4) var(--space-5); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); color: var(--ink); text-decoration: none; transition: border-color .12s; }
a.vms-tile:hover { border-color: var(--line-strong); }
.vms-tile[aria-current="true"] { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); background: var(--brand-soft); }
.vms-tile-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.vms-tile-value { font-size: 26px; line-height: 32px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.vms-tile-value small { font-size: 14px; font-weight: 500; color: var(--ink-muted); margin-right: 3px; letter-spacing: 0; }
.vms-tile-foot { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.vms-tile-overdue .vms-tile-value { color: var(--overdue); }
.vms-tile-due .vms-tile-value { color: var(--due); }
.vms-tile-paid .vms-tile-value { color: var(--paid); }
.vms-tile-info .vms-tile-value { color: var(--info); }
.vms-count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--radius-pill); font-size: 12px; font-weight: 700; line-height: 1; background: var(--surface-sunken); color: var(--ink-muted); }

/* ---------- Forms ---------- */
.vms-field { display: grid; gap: 6px; min-width: 0; align-content: start; }
.vms-field > label, .vms-field-label { font-size: 13px; font-weight: 600; color: var(--ink); }
.vms-hint { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.vms-error { font-size: 12px; line-height: 16px; color: var(--overdue); font-weight: 500; }
.vms-input { font: inherit; font-size: 14px; height: 38px; width: 100%; box-sizing: border-box; padding: 0 12px; border-radius: var(--radius-md); border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.vms-input::placeholder { color: var(--ink-muted); opacity: .8; }
.vms-input:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--brand); box-shadow: none; }
.vms-input[aria-invalid="true"] { border-color: var(--overdue); }
.vms-input-id { font-family: var(--font-mono); font-size: 13px; }

/* ---------- Filter bar ---------- */
.vms-filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-items: end; gap: var(--space-3); padding: var(--space-4); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.vms-filters .vms-field > label, .vms-filters label.block { font-size: 11px !important; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted) !important; font-weight: 600; }
.vms-filters-actions { display: flex; gap: var(--space-2); align-items: end; }
/* Cells from partials (date-range-filter) are plain <div>s: space them like fields */
.vms-filters > div:not(.vms-filters-actions):not(.vms-field) { display: grid; gap: 6px; align-content: start; min-width: 0; }

/* ---------- Table ---------- */
.vms-table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.vms-table-scroll { overflow-x: auto; }
.vms-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.vms-table th { text-align: left; font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted); background: var(--surface-sunken); padding: 10px 16px; white-space: nowrap; border-bottom: 1px solid var(--line); }
.vms-table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--ink); }
.vms-table tbody tr:last-child td { border-bottom: 0; }
.vms-table tbody tr:hover td { background: var(--surface-sunken); }
.vms-table .num { text-align: right; }
.vms-table .act { text-align: right; white-space: nowrap; }
.vms-cell-2 { display: grid; gap: 2px; }
.vms-cell-2 > :first-child { font-weight: 600; }
.vms-cell-sub { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.vms-table a.vms-link { color: var(--ink); text-decoration: none; font-weight: 600; }
.vms-table a.vms-link:hover { color: var(--brand); text-decoration: underline; }
.vms-table-foot { padding: 10px 16px; border-top: 1px solid var(--line); }
.vms-empty { padding: 48px 16px; text-align: center; color: var(--ink-muted); }

/* ---------- Plate chip ---------- */
.vms-plate { display: inline-flex; align-items: stretch; height: 22px; border: 1.5px solid var(--plate-ink); border-radius: var(--radius-sm); background: var(--plate); color: var(--plate-ink); overflow: hidden; font-family: var(--font-mono); font-weight: 600; font-size: 12px; letter-spacing: .04em; white-space: nowrap; width: max-content; }
.vms-plate::before { content: ""; width: 5px; background: var(--plate-band); }
.vms-plate > span { display: inline-flex; align-items: center; padding: 0 6px; }
.vms-plate-pending { border-style: dashed; }
.vms-plate-pending::before { background: transparent; }

/* ---------- Callout ---------- */
.vms-callout { display: grid; grid-template-columns: auto 1fr; gap: var(--space-3); align-items: start; padding: 14px var(--space-4); border-radius: var(--radius-lg); border: 1px solid var(--line); background: var(--surface); }
.vms-callout > .vms-callout-icon { width: 20px; text-align: center; margin-top: 2px; }
.vms-callout-title { font-weight: 600; color: var(--ink); }
.vms-callout-text { color: var(--ink-muted); font-size: 13px; }
.vms-callout-due { background: var(--due-soft); border-color: #f1dcb4; }
.vms-callout-due > .vms-callout-icon { color: var(--due); }
.vms-callout-overdue { background: var(--overdue-soft); border-color: #f6cdc7; }
.vms-callout-overdue > .vms-callout-icon { color: var(--overdue); }
.vms-callout-promised { background: var(--promised-soft); border-color: #dcd3f1; }
.vms-callout-promised > .vms-callout-icon { color: var(--promised); }
.vms-callout-info > .vms-callout-icon { color: var(--brand); }
.vms-callout-list { display: grid; gap: var(--space-2); margin-top: var(--space-3); }
.vms-callout-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-3); padding: 10px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); }

/* ---------- Toast ---------- */
.vms-toast { position: fixed; top: 16px; right: 16px; z-index: 60; display: grid; grid-template-columns: auto 1fr auto; gap: var(--space-3); align-items: start; width: min(400px, calc(100vw - 32px)); box-sizing: border-box; padding: 12px 12px 12px 14px; border-radius: var(--radius-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-overlay); color: var(--ink); font-size: 14px; }
.vms-toast > i { font-size: 18px; margin-top: 1px; }
.vms-toast-paid > i { color: var(--paid); }
.vms-toast-overdue > i { color: var(--overdue); }
.vms-toast-due > i { color: var(--due); }
.vms-toast-title { font-weight: 600; }
.vms-toast ul { margin: 4px 0 0; padding-left: 18px; color: var(--ink-muted); font-size: 13px; list-style: disc; }
.vms-toast-close { border: 0; background: transparent; color: var(--ink-muted); cursor: pointer; width: 24px; height: 24px; border-radius: var(--radius-md); }
.vms-toast-close:hover { background: var(--surface-sunken); color: var(--ink); }

/* ---------- Shell: sidebar ---------- */
.vms-rail { background: var(--rail) !important; color: var(--rail-ink); border-right: 1px solid var(--line); }
.vms-rail-brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: var(--rail-ink); }
.vms-rail-mark { width: 32px; height: 32px; border-radius: var(--radius-md); background: var(--rail-accent); color: var(--on-brand); display: grid; place-items: center; font-size: 11px; font-weight: 800; letter-spacing: .02em; flex: none; }
.vms-rail-name { font-size: 15px; font-weight: 700; line-height: 18px; color: var(--rail-ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vms-rail-sub { font-size: 12px; line-height: 16px; color: var(--rail-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vms-rail-sec { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--rail-muted); padding: 18px 12px 6px; }
.vms-rail-link { position: relative; display: flex; align-items: center; gap: 10px; height: 36px; padding: 0 12px; border-radius: var(--radius-md); color: var(--rail-ink); text-decoration: none; font-size: 14px; font-weight: 500; transition: background-color .12s, color .12s; }
.vms-rail-link > i { width: 18px; text-align: center; font-size: 14px; color: var(--rail-muted); }
.vms-rail-link:hover { background: var(--rail-hover); }
.vms-rail-link[aria-current="page"] { background: var(--rail-active); color: var(--rail-accent); font-weight: 600; }
.vms-rail-link[aria-current="page"] > i { color: var(--rail-accent); }
.vms-rail-link[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--rail-accent); }
.vms-rail-link .vms-count { margin-left: auto; background: var(--rail-accent); color: var(--on-brand); height: 18px; min-width: 18px; font-size: 11px; }
.vms-rail-user { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-top: 1px solid var(--line); }
.vms-avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 13px; background: var(--brand-soft); color: var(--brand); flex: none; }

/* ---------- Shell: top bar & page header ---------- */
.vms-topbar { background: var(--surface) !important; border-bottom: 1px solid var(--line); }
.vms-iconbtn { position: relative; display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-md); border: 0; background: transparent; color: var(--ink-muted); cursor: pointer; }
.vms-iconbtn:hover { background: var(--surface-sunken); color: var(--ink); }
.vms-iconbtn .vms-badge { position: absolute; top: 4px; right: 3px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--overdue); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; line-height: 1; }
.vms-menu { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); box-shadow: var(--shadow-overlay); overflow: hidden; }
.vms-menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 14px; font-size: 14px; color: var(--ink); text-decoration: none; background: transparent; border: 0; cursor: pointer; text-align: left; }
.vms-menu-item:hover { background: var(--surface-sunken); }
.vms-crumbs { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-muted); min-width: 0; }
.vms-crumbs a { color: var(--ink-muted); text-decoration: none; }
.vms-crumbs a:hover { color: var(--ink); text-decoration: underline; }
.vms-pagehead { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-4); }
.vms-pagehead h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -.01em; color: var(--ink); text-wrap: balance; }
.vms-pagehead p { margin: 2px 0 0; color: var(--ink-muted); font-size: 14px; }
.vms-pagehead-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* ---------- Page structure (used by migrated views) ---------- */
.vms-page-title { margin: 0; font-size: 24px !important; line-height: 32px !important; font-weight: 700 !important; letter-spacing: -.01em; color: var(--ink) !important; text-wrap: balance; }
.vms-section-title { margin: 0; font-size: 16px !important; line-height: 24px !important; font-weight: 600 !important; color: var(--ink) !important; }
.vms-subhead { font-size: 11px !important; line-height: 16px; font-weight: 600 !important; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-muted) !important; }
.vms-pad { padding: var(--space-5); }
.vms-pad-sm { padding: var(--space-4); }
@media (max-width: 640px) { .vms-pad { padding: var(--space-4); } }
a.vms-card { display: block; color: inherit; text-decoration: none; transition: border-color .12s; }
a.vms-card:hover { border-color: var(--line-strong); }
.vms-inset { background: var(--surface-sunken); border: 1px solid var(--line); border-radius: var(--radius-md); }
.vms-icon-box { width: 40px; height: 40px; border-radius: var(--radius-md); display: inline-grid; place-items: center; flex: none; background: var(--brand-soft); color: var(--brand); }
.vms-icon-box svg { width: 20px !important; height: 20px !important; color: currentColor !important; }
.vms-icon-box i { font-size: 17px !important; color: currentColor !important; }
.vms-icon-box.vms-tone-paid { background: var(--paid-soft); color: var(--paid); }
.vms-icon-box.vms-tone-due { background: var(--due-soft); color: var(--due); }
.vms-icon-box.vms-tone-overdue { background: var(--overdue-soft); color: var(--overdue); }
.vms-icon-box.vms-tone-promised { background: var(--promised-soft); color: var(--promised); }
.vms-icon-box.vms-tone-info { background: var(--info-soft); color: var(--info); }
.vms-icon-box.vms-tone-neutral { background: var(--neutral-soft); color: var(--ink-muted); }

/* Form bits */
.vms-form-label { display: block; margin-bottom: 6px; font-size: 13px !important; line-height: 18px; font-weight: 600 !important; color: var(--ink) !important; }
textarea.vms-input { height: auto; min-height: 76px; padding: 8px 12px; line-height: 20px; resize: vertical; }
select.vms-input[multiple] { height: auto; padding: 6px; }
.vms-input:disabled, .vms-input[readonly] { background: var(--surface-sunken); color: var(--ink-muted); }
.vms-file { display: block; width: 100%; box-sizing: border-box; font: inherit; font-size: 13px; color: var(--ink-muted); background: var(--surface); border: 1px dashed var(--line-strong); border-radius: var(--radius-md); padding: 5px; cursor: pointer; }
.vms-file::file-selector-button { font: inherit; font-size: 13px; font-weight: 600; margin-right: 10px; padding: 6px 12px; border: 0; border-radius: var(--radius-sm); background: var(--brand-soft); color: var(--brand); cursor: pointer; }
.vms-file:hover::file-selector-button { background: #dce6f8; }
.vms-iconbtn-outline { border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink); }
.vms-btn-block { display: flex; width: 100%; }
.vms-btn > svg { width: 16px; height: 16px; margin: 0 !important; flex: none; }
.vms-btn > i { margin: 0 !important; }

/* Tables built from legacy markup: cells may still carry old text utilities */
.vms-table td .text-sm { font-size: 14px; }
.vms-table th.text-center, .vms-table td.text-center { text-align: center; }
.vms-table th.text-right, .vms-table td.text-right { text-align: right; }

/* ---------- Token utilities ----------
   The staff app gets these from its Tailwind config; the customer portal and QR
   pages load Tailwind without it, so they are defined here too. */
.text-ink { color: var(--ink); }
.text-muted { color: var(--ink-muted); }
.text-brand { color: var(--brand); }
.text-paid { color: var(--paid); }
.text-due { color: var(--due); }
.text-overdue { color: var(--overdue); }
.text-promised { color: var(--promised); }
.bg-ground { background-color: var(--ground); }
.bg-surface { background-color: var(--surface); }
.bg-sunken, .hover\:bg-sunken:hover { background-color: var(--surface-sunken); }
.border-line { border-color: var(--line); }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}

/* ==========================================================================
   Third-party widgets: Select2, intl-tel-input, Flatpickr
   ========================================================================== */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    background-color: var(--surface) !important;
    border: 1px solid var(--line-strong) !important;
    border-radius: var(--vms-select2-radius, var(--radius-md)) !important;
}
.select2-container--default .select2-selection--single {
    height: var(--vms-select2-height, 38px) !important;
    padding: 0 var(--vms-select2-pad-x, 12px) !important;
    font-size: var(--vms-select2-font-size, inherit);
    display: flex !important;
    align-items: center !important;
}
.select2-container--default.select2-container--focus .select2-selection,
.select2-container--default.select2-container--open .select2-selection { border-color: var(--brand) !important; outline: 2px solid var(--focus); outline-offset: -1px; }
.select2-container--default .select2-selection--single .select2-selection__rendered { color: var(--ink) !important; line-height: normal !important; padding-left: 0 !important; padding-right: 20px !important; flex: 1 1 auto; }
.select2-container--default .select2-selection--single .select2-selection__placeholder { color: var(--ink-muted) !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: 100% !important; top: 0 !important; }
.select2-dropdown { background-color: var(--surface) !important; border: 1px solid var(--line) !important; border-radius: var(--radius-md) !important; box-shadow: var(--shadow-overlay); }
.select2-search--dropdown .select2-search__field { background-color: var(--surface) !important; border: 1px solid var(--line-strong) !important; color: var(--ink) !important; border-radius: var(--radius-md) !important; }
.select2-container--default .select2-results__option { color: var(--ink) !important; background-color: var(--surface) !important; }
.select2-container--default .select2-results__option[aria-selected="true"],
.select2-container--default .select2-results__option--selected { background-color: var(--brand-soft) !important; color: var(--ink) !important; }
.select2-container--default .select2-results__option--highlighted,
.select2-container--default .select2-results__option--highlighted[aria-selected],
.select2-container--default .select2-results__option--highlighted[aria-selected="true"] { background-color: var(--brand) !important; color: var(--on-brand) !important; }

.iti { width: 100%; }
.iti__selected-flag { background-color: var(--surface-sunken) !important; border-right: 1px solid var(--line) !important; }
.iti__selected-flag:hover { background-color: var(--neutral-soft) !important; }
.iti__country-list { background-color: var(--surface) !important; border: 1px solid var(--line) !important; box-shadow: var(--shadow-overlay); }
.iti__country { color: var(--ink) !important; padding: 8px 12px; }
.iti__country:hover, .iti__country.iti__highlight { background-color: var(--brand-soft) !important; }
.iti__divider { border-bottom: 1px solid var(--line) !important; }
.iti__search-input { background-color: var(--surface) !important; border: 1px solid var(--line-strong) !important; color: var(--ink) !important; }
.iti__dial-code { color: var(--ink-muted) !important; }

.flatpickr-input[type="text"] { background-color: var(--surface); border: 1px solid var(--line-strong); color: var(--ink); border-radius: var(--radius-md); padding: 0.5rem 0.75rem; width: 100%; font-size: 0.875rem; line-height: 1.5; }
.flatpickr-input[type="text"]:focus { outline: 2px solid var(--focus); outline-offset: -1px; border-color: var(--brand); }
.flatpickr-calendar { z-index: 9999 !important; font-family: var(--font-sans); }
.flatpickr-day.selected, .flatpickr-day.startRange, .flatpickr-day.endRange,
.flatpickr-day.selected.inRange, .flatpickr-day.startRange.inRange, .flatpickr-day.endRange.inRange { background: var(--brand) !important; border-color: var(--brand) !important; color: var(--on-brand) !important; }
.flatpickr-day.today { border-color: var(--brand) !important; }

/* ==========================================================================
   Compatibility layer for views not yet migrated to the design system.
   <html> always carries .light-mode (the app has one theme); these rules map
   the dark-era utility classes onto the tokens. Delete a rule once no view
   uses the class it targets.
   ========================================================================== */
html.light-mode body { background-color: var(--ground) !important; color: var(--ink) !important; background-image: none !important; }

/* Radius: one card radius */
html.light-mode .rounded-xl, html.light-mode .rounded-2xl { border-radius: var(--radius-lg) !important; }

/* Surfaces */
html.light-mode .bg-slate-950 { background-color: var(--ground) !important; }
html.light-mode .bg-slate-900 { background-color: var(--surface) !important; }
html.light-mode .bg-slate-800 { background-color: var(--surface) !important; }
html.light-mode .bg-slate-700 { background-color: var(--neutral-soft) !important; }
html.light-mode .bg-slate-600 { background-color: var(--neutral-soft) !important; }
html.light-mode .hover\:bg-slate-800:hover,
html.light-mode .hover\:bg-slate-700:hover,
html.light-mode .hover\:bg-slate-600:hover { background-color: var(--surface-sunken) !important; }
html.light-mode .bg-slate-900\/30, html.light-mode .bg-slate-900\/50, html.light-mode .bg-slate-900\/60,
html.light-mode .bg-slate-800\/30, html.light-mode .bg-slate-800\/40, html.light-mode .bg-slate-800\/50, html.light-mode .bg-slate-800\/60,
html.light-mode .hover\:bg-slate-800\/40:hover { background-color: var(--surface-sunken) !important; }
html.light-mode .bg-slate-900\/70, html.light-mode .bg-slate-900\/80, html.light-mode .bg-slate-900\/95 { background-color: var(--surface) !important; }
html.light-mode .bg-slate-700\/30, html.light-mode .bg-slate-700\/50, html.light-mode .bg-slate-700\/60,
html.light-mode .bg-slate-500\/15, html.light-mode .bg-slate-500\/20, html.light-mode .bg-slate-600\/20 { background-color: var(--neutral-soft) !important; }
html.light-mode .hover\:bg-slate-700\/20:hover, html.light-mode .hover\:bg-slate-700\/30:hover,
html.light-mode .hover\:bg-slate-700\/50:hover { background-color: var(--surface-sunken) !important; }

/* Cards: hairline + faint shadow, no lift */
html.light-mode .rounded-xl.border.border-slate-700, html.light-mode .rounded-2xl.border.border-slate-700,
html.light-mode .rounded-lg.border.border-slate-700, html.light-mode .rounded-xl.border.border-slate-600,
html.light-mode .rounded-lg.border.border-slate-600 { border-color: var(--line) !important; box-shadow: var(--shadow-card); }
html.light-mode .rounded-xl.border:hover { transform: none; }

/* Gradients → flat surfaces */
html.light-mode .bg-gradient-to-br.from-slate-800, html.light-mode .bg-gradient-to-br.from-slate-900, html.light-mode .bg-gradient-to-br.from-slate-950,
html.light-mode .bg-gradient-to-r.from-slate-800, html.light-mode .bg-gradient-to-r.from-slate-900, html.light-mode .bg-gradient-to-r.from-slate-950 { background-image: none !important; background-color: var(--surface) !important; }
html.light-mode .bg-gradient-to-br.via-blue-950 { background-image: none !important; background-color: var(--ground) !important; }
html.light-mode .bg-clip-text.text-transparent { background-image: none !important; color: var(--ink) !important; -webkit-text-fill-color: currentColor; }
/* Solid accent gradients (hero cards, icon tiles, primary buttons) → brand */
html.light-mode [class*="bg-gradient-to-"][class*="from-blue-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-indigo-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-cyan-"] { background-image: none !important; background-color: var(--brand) !important; }
html.light-mode [class*="bg-gradient-to-"][class*="from-green-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-emerald-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-teal-"] { background-image: none !important; background-color: var(--paid) !important; }
html.light-mode [class*="bg-gradient-to-"][class*="from-red-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-rose-"] { background-image: none !important; background-color: var(--overdue) !important; }
html.light-mode [class*="bg-gradient-to-"][class*="from-amber-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-yellow-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-orange-"] { background-image: none !important; background-color: var(--due) !important; }
html.light-mode [class*="bg-gradient-to-"][class*="from-purple-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-pink-"],
html.light-mode [class*="bg-gradient-to-"][class*="from-violet-"] { background-image: none !important; background-color: var(--promised) !important; }
html.light-mode [class*="shadow-blue-"], html.light-mode [class*="shadow-green-"], html.light-mode [class*="shadow-purple-"],
html.light-mode [class*="shadow-red-"], html.light-mode [class*="shadow-amber-"] { --tw-shadow-color: transparent !important; box-shadow: var(--shadow-card) !important; }

/* Text */
html.light-mode .text-white { color: var(--ink) !important; }
html.light-mode .text-slate-100, html.light-mode .text-slate-200 { color: var(--ink) !important; }
html.light-mode .text-slate-300, html.light-mode .text-slate-400 { color: var(--ink-muted) !important; }
html.light-mode .text-slate-500 { color: var(--ink-muted) !important; }
html.light-mode .text-slate-600 { color: #9aa5b4 !important; }
html.light-mode .hover\:text-white:hover { color: var(--ink) !important; }
html.light-mode .placeholder-slate-400::placeholder, html.light-mode .placeholder-slate-500::placeholder { color: #8a95a5 !important; }

/* Solid colour fills: keep white text on them, and map to tokens */
html.light-mode .bg-blue-500, html.light-mode .bg-blue-600, html.light-mode .bg-blue-700, html.light-mode .bg-indigo-600, html.light-mode .bg-primary-600 { background-color: var(--brand) !important; }
html.light-mode .hover\:bg-blue-700:hover, html.light-mode .hover\:bg-blue-600:hover, html.light-mode .hover\:bg-blue-800:hover, html.light-mode .hover\:bg-indigo-700:hover { background-color: var(--brand-hover) !important; }
html.light-mode .bg-green-500, html.light-mode .bg-green-600, html.light-mode .bg-emerald-500, html.light-mode .bg-emerald-600 { background-color: var(--paid) !important; }
html.light-mode .hover\:bg-green-700:hover, html.light-mode .hover\:bg-emerald-700:hover { background-color: #11531f !important; }
html.light-mode .bg-red-500, html.light-mode .bg-red-600 { background-color: var(--overdue) !important; }
html.light-mode .hover\:bg-red-700:hover { background-color: #8f1c13 !important; }
html.light-mode .bg-amber-500, html.light-mode .bg-amber-600, html.light-mode .bg-yellow-500, html.light-mode .bg-yellow-600, html.light-mode .bg-orange-500, html.light-mode .bg-orange-600 { background-color: var(--due) !important; }
html.light-mode .hover\:bg-amber-700:hover, html.light-mode .hover\:bg-yellow-700:hover, html.light-mode .hover\:bg-orange-700:hover { background-color: #6f3b00 !important; }
html.light-mode .bg-purple-500, html.light-mode .bg-purple-600, html.light-mode .bg-pink-500, html.light-mode .bg-pink-600 { background-color: var(--promised) !important; }
html.light-mode .hover\:bg-purple-700:hover, html.light-mode .hover\:bg-pink-700:hover { background-color: #4a3287 !important; }

html.light-mode .text-white[class*="bg-blue-5"], html.light-mode .text-white[class*="bg-blue-6"], html.light-mode .text-white[class*="bg-blue-7"],
html.light-mode .text-white[class*="bg-indigo-"], html.light-mode .text-white[class*="bg-primary-"],
html.light-mode .text-white[class*="bg-green-5"], html.light-mode .text-white[class*="bg-green-6"], html.light-mode .text-white[class*="bg-green-7"],
html.light-mode .text-white[class*="bg-emerald-5"], html.light-mode .text-white[class*="bg-emerald-6"],
html.light-mode .text-white[class*="bg-red-5"], html.light-mode .text-white[class*="bg-red-6"], html.light-mode .text-white[class*="bg-red-7"],
html.light-mode .text-white[class*="bg-rose-5"], html.light-mode .text-white[class*="bg-rose-6"],
html.light-mode .text-white[class*="bg-amber-5"], html.light-mode .text-white[class*="bg-amber-6"], html.light-mode .text-white[class*="bg-amber-7"],
html.light-mode .text-white[class*="bg-yellow-5"], html.light-mode .text-white[class*="bg-yellow-6"],
html.light-mode .text-white[class*="bg-orange-5"], html.light-mode .text-white[class*="bg-orange-6"],
html.light-mode .text-white[class*="bg-purple-5"], html.light-mode .text-white[class*="bg-purple-6"], html.light-mode .text-white[class*="bg-purple-7"],
html.light-mode .text-white[class*="bg-pink-5"], html.light-mode .text-white[class*="bg-pink-6"],
html.light-mode .text-white[class*="bg-teal-"], html.light-mode .text-white[class*="bg-cyan-"],
html.light-mode .text-white[class*="from-blue-"], html.light-mode .text-white[class*="from-indigo-"], html.light-mode .text-white[class*="from-cyan-"], html.light-mode .text-white[class*="from-green-"], html.light-mode .text-white[class*="from-emerald-"], html.light-mode .text-white[class*="from-teal-"], html.light-mode .text-white[class*="from-red-"], html.light-mode .text-white[class*="from-rose-"], html.light-mode .text-white[class*="from-amber-"], html.light-mode .text-white[class*="from-yellow-"], html.light-mode .text-white[class*="from-orange-"], html.light-mode .text-white[class*="from-purple-"], html.light-mode .text-white[class*="from-pink-"], html.light-mode .text-white[class*="from-violet-"],
html.light-mode [class*="bg-blue-5"] .text-white, html.light-mode [class*="bg-blue-6"] .text-white, html.light-mode [class*="bg-blue-7"] .text-white,
html.light-mode [class*="bg-green-5"] .text-white, html.light-mode [class*="bg-green-6"] .text-white,
html.light-mode [class*="bg-emerald-5"] .text-white, html.light-mode [class*="bg-emerald-6"] .text-white,
html.light-mode [class*="bg-red-5"] .text-white, html.light-mode [class*="bg-red-6"] .text-white,
html.light-mode [class*="bg-amber-5"] .text-white, html.light-mode [class*="bg-amber-6"] .text-white,
html.light-mode [class*="bg-yellow-5"] .text-white, html.light-mode [class*="bg-yellow-6"] .text-white,
html.light-mode [class*="bg-orange-5"] .text-white, html.light-mode [class*="bg-orange-6"] .text-white,
html.light-mode [class*="bg-purple-5"] .text-white, html.light-mode [class*="bg-purple-6"] .text-white,
html.light-mode [class*="bg-pink-5"] .text-white, html.light-mode [class*="bg-pink-6"] .text-white,
html.light-mode [class*="bg-indigo-"] .text-white, html.light-mode [class*="bg-teal-"] .text-white,
html.light-mode [class*="from-blue-"] .text-white, html.light-mode [class*="from-indigo-"] .text-white, html.light-mode [class*="from-cyan-"] .text-white, html.light-mode [class*="from-green-"] .text-white, html.light-mode [class*="from-emerald-"] .text-white, html.light-mode [class*="from-teal-"] .text-white, html.light-mode [class*="from-red-"] .text-white, html.light-mode [class*="from-rose-"] .text-white, html.light-mode [class*="from-amber-"] .text-white, html.light-mode [class*="from-yellow-"] .text-white, html.light-mode [class*="from-orange-"] .text-white, html.light-mode [class*="from-purple-"] .text-white, html.light-mode [class*="from-pink-"] .text-white, html.light-mode [class*="from-violet-"] .text-white { color: #ffffff !important; }
html.light-mode [class*="from-blue-"] .text-slate-100, html.light-mode [class*="from-blue-"] .text-slate-200, html.light-mode [class*="from-blue-"] .text-slate-300, html.light-mode [class*="from-blue-"] .text-slate-400, html.light-mode [class*="from-indigo-"] .text-slate-100, html.light-mode [class*="from-indigo-"] .text-slate-200, html.light-mode [class*="from-indigo-"] .text-slate-300, html.light-mode [class*="from-indigo-"] .text-slate-400, html.light-mode [class*="from-cyan-"] .text-slate-100, html.light-mode [class*="from-cyan-"] .text-slate-200, html.light-mode [class*="from-cyan-"] .text-slate-300, html.light-mode [class*="from-cyan-"] .text-slate-400, html.light-mode [class*="from-green-"] .text-slate-100, html.light-mode [class*="from-green-"] .text-slate-200, html.light-mode [class*="from-green-"] .text-slate-300, html.light-mode [class*="from-green-"] .text-slate-400, html.light-mode [class*="from-emerald-"] .text-slate-100, html.light-mode [class*="from-emerald-"] .text-slate-200, html.light-mode [class*="from-emerald-"] .text-slate-300, html.light-mode [class*="from-emerald-"] .text-slate-400, html.light-mode [class*="from-teal-"] .text-slate-100, html.light-mode [class*="from-teal-"] .text-slate-200, html.light-mode [class*="from-teal-"] .text-slate-300, html.light-mode [class*="from-teal-"] .text-slate-400, html.light-mode [class*="from-red-"] .text-slate-100, html.light-mode [class*="from-red-"] .text-slate-200, html.light-mode [class*="from-red-"] .text-slate-300, html.light-mode [class*="from-red-"] .text-slate-400, html.light-mode [class*="from-rose-"] .text-slate-100, html.light-mode [class*="from-rose-"] .text-slate-200, html.light-mode [class*="from-rose-"] .text-slate-300, html.light-mode [class*="from-rose-"] .text-slate-400, html.light-mode [class*="from-amber-"] .text-slate-100, html.light-mode [class*="from-amber-"] .text-slate-200, html.light-mode [class*="from-amber-"] .text-slate-300, html.light-mode [class*="from-amber-"] .text-slate-400, html.light-mode [class*="from-yellow-"] .text-slate-100, html.light-mode [class*="from-yellow-"] .text-slate-200, html.light-mode [class*="from-yellow-"] .text-slate-300, html.light-mode [class*="from-yellow-"] .text-slate-400, html.light-mode [class*="from-orange-"] .text-slate-100, html.light-mode [class*="from-orange-"] .text-slate-200, html.light-mode [class*="from-orange-"] .text-slate-300, html.light-mode [class*="from-orange-"] .text-slate-400, html.light-mode [class*="from-purple-"] .text-slate-100, html.light-mode [class*="from-purple-"] .text-slate-200, html.light-mode [class*="from-purple-"] .text-slate-300, html.light-mode [class*="from-purple-"] .text-slate-400, html.light-mode [class*="from-pink-"] .text-slate-100, html.light-mode [class*="from-pink-"] .text-slate-200, html.light-mode [class*="from-pink-"] .text-slate-300, html.light-mode [class*="from-pink-"] .text-slate-400, html.light-mode [class*="from-violet-"] .text-slate-100, html.light-mode [class*="from-violet-"] .text-slate-200, html.light-mode [class*="from-violet-"] .text-slate-300, html.light-mode [class*="from-violet-"] .text-slate-400,
html.light-mode .bg-blue-600 .text-slate-100, html.light-mode .bg-blue-600 .text-slate-200,
html.light-mode .bg-blue-600 .text-slate-300 { color: rgba(255, 255, 255, 0.85) !important; }
/* …but not on an opacity tint (bg-amber-500/10): those render near-white. */
html.light-mode [class*="bg-blue-400/"] .text-white, html.light-mode [class*="bg-blue-500/"] .text-white, html.light-mode [class*="bg-blue-600/"] .text-white,
html.light-mode [class*="bg-green-400/"] .text-white, html.light-mode [class*="bg-green-500/"] .text-white, html.light-mode [class*="bg-green-600/"] .text-white,
html.light-mode [class*="bg-emerald-500/"] .text-white, html.light-mode [class*="bg-emerald-600/"] .text-white,
html.light-mode [class*="bg-red-400/"] .text-white, html.light-mode [class*="bg-red-500/"] .text-white, html.light-mode [class*="bg-red-600/"] .text-white,
html.light-mode [class*="bg-amber-400/"] .text-white, html.light-mode [class*="bg-amber-500/"] .text-white, html.light-mode [class*="bg-amber-600/"] .text-white,
html.light-mode [class*="bg-yellow-400/"] .text-white, html.light-mode [class*="bg-yellow-500/"] .text-white, html.light-mode [class*="bg-yellow-600/"] .text-white,
html.light-mode [class*="bg-orange-500/"] .text-white, html.light-mode [class*="bg-orange-600/"] .text-white,
html.light-mode [class*="bg-purple-400/"] .text-white, html.light-mode [class*="bg-purple-500/"] .text-white, html.light-mode [class*="bg-purple-600/"] .text-white,
html.light-mode [class*="bg-pink-500/"] .text-white, html.light-mode [class*="bg-pink-600/"] .text-white,
html.light-mode [class*="bg-indigo-500/"] .text-white, html.light-mode [class*="bg-teal-500/"] .text-white, html.light-mode [class*="bg-cyan-500/"] .text-white,
html.light-mode [class*="bg-slate-400/"] .text-white, html.light-mode [class*="bg-slate-500/"] .text-white, html.light-mode [class*="bg-slate-600/"] .text-white { color: var(--ink) !important; }

/* …same for an element that is itself a tint and carries text-white
   (selected choice cards: "bg-blue-600/20 text-white"). */
html.light-mode .text-white:is([class*="bg-blue-500/"], [class*="bg-blue-600/"], [class*="bg-green-500/"], [class*="bg-green-600/"], [class*="bg-emerald-500/"], [class*="bg-emerald-600/"], [class*="bg-red-500/"], [class*="bg-red-600/"], [class*="bg-amber-500/"], [class*="bg-amber-600/"], [class*="bg-yellow-500/"], [class*="bg-yellow-600/"], [class*="bg-purple-500/"], [class*="bg-purple-600/"], [class*="bg-orange-500/"], [class*="bg-pink-500/"], [class*="bg-indigo-500/"], [class*="bg-slate-500/"], [class*="bg-slate-600/"]):not(.bg-blue-500):not(.bg-blue-600):not(.bg-green-600):not(.bg-red-600):not(.bg-amber-600):not(.bg-purple-600) { color: var(--ink) !important; }

/* Tints (badges, icon boxes, alert panels) → tone soft grounds */
html.light-mode [class*="bg-green-500/"], html.light-mode [class*="bg-green-600/"], html.light-mode [class*="bg-emerald-500/"], html.light-mode [class*="bg-emerald-600/"] { background-color: var(--paid-soft) !important; }
html.light-mode [class*="bg-yellow-500/"], html.light-mode [class*="bg-yellow-600/"], html.light-mode [class*="bg-amber-500/"], html.light-mode [class*="bg-amber-600/"], html.light-mode [class*="bg-orange-500/"], html.light-mode [class*="bg-orange-600/"] { background-color: var(--due-soft) !important; }
html.light-mode [class*="bg-red-500/"], html.light-mode [class*="bg-red-600/"], html.light-mode [class*="bg-rose-500/"] { background-color: var(--overdue-soft) !important; }
html.light-mode [class*="bg-purple-500/"], html.light-mode [class*="bg-purple-600/"], html.light-mode [class*="bg-pink-500/"], html.light-mode [class*="bg-violet-500/"] { background-color: var(--promised-soft) !important; }
html.light-mode [class*="bg-blue-500/"], html.light-mode [class*="bg-blue-600/"], html.light-mode [class*="bg-indigo-500/"], html.light-mode [class*="bg-primary-500/"] { background-color: var(--brand-soft) !important; }
html.light-mode [class*="bg-teal-500/"], html.light-mode [class*="bg-cyan-500/"] { background-color: var(--info-soft) !important; }

html.light-mode .text-green-300, html.light-mode .text-green-400, html.light-mode .text-green-500, html.light-mode .text-emerald-300, html.light-mode .text-emerald-400, html.light-mode .text-emerald-500 { color: var(--paid) !important; }
html.light-mode .text-yellow-300, html.light-mode .text-yellow-400, html.light-mode .text-yellow-500, html.light-mode .text-amber-300, html.light-mode .text-amber-400, html.light-mode .text-amber-500, html.light-mode .text-orange-300, html.light-mode .text-orange-400 { color: var(--due) !important; }
/* The same pale ambers with an opacity (text-amber-400/80 and the like) are
   dimmer still, and the rule above does not reach them: on white they all but
   vanish. They take the full "due" ink too — the fade was only for dark mode. */
html.light-mode [class*="text-yellow-200/"], html.light-mode [class*="text-yellow-300/"], html.light-mode [class*="text-yellow-400/"], html.light-mode [class*="text-amber-300/"], html.light-mode [class*="text-amber-400/"], html.light-mode [class*="text-orange-300/"], html.light-mode [class*="text-orange-400/"] { color: var(--due) !important; }
html.light-mode .text-red-300, html.light-mode .text-red-400, html.light-mode .text-red-500, html.light-mode .text-rose-400 { color: var(--overdue) !important; }
html.light-mode .text-purple-300, html.light-mode .text-purple-400, html.light-mode .text-pink-300, html.light-mode .text-pink-400, html.light-mode .text-violet-400 { color: var(--promised) !important; }
html.light-mode .text-blue-300, html.light-mode .text-blue-400, html.light-mode .text-blue-500, html.light-mode .text-indigo-400, html.light-mode .text-primary-400 { color: var(--brand) !important; }
html.light-mode .text-teal-400, html.light-mode .text-cyan-400 { color: var(--info) !important; }
html.light-mode .hover\:text-blue-300:hover, html.light-mode .hover\:text-blue-400:hover { color: var(--brand-hover) !important; }
html.light-mode .hover\:text-red-300:hover, html.light-mode .hover\:text-red-400:hover { color: var(--overdue) !important; }
html.light-mode .hover\:text-green-300:hover, html.light-mode .hover\:text-green-400:hover { color: var(--paid) !important; }

/* Borders */
html.light-mode .border-slate-950, html.light-mode .border-slate-900, html.light-mode .border-slate-800,
html.light-mode .border-slate-700 { border-color: var(--line) !important; }
html.light-mode .border-slate-600, html.light-mode .border-slate-500 { border-color: var(--line-strong) !important; }
html.light-mode .divide-slate-700 > :not([hidden]) ~ :not([hidden]),
html.light-mode .divide-slate-800 > :not([hidden]) ~ :not([hidden]),
html.light-mode .divide-slate-700\/50 > :not([hidden]) ~ :not([hidden]) { border-color: var(--line) !important; }
html.light-mode [class*="border-blue-500"], html.light-mode [class*="border-blue-600"] { border-color: #b9c9ea !important; }
html.light-mode [class*="border-green-500"], html.light-mode [class*="border-emerald-500"] { border-color: #b7dcc1 !important; }
html.light-mode [class*="border-yellow-500"], html.light-mode [class*="border-yellow-600"], html.light-mode [class*="border-amber-500"], html.light-mode [class*="border-orange-500"] { border-color: #f1dcb4 !important; }
html.light-mode [class*="border-red-500"], html.light-mode [class*="border-red-600"] { border-color: #f1b8b1 !important; }
html.light-mode [class*="border-purple-500"], html.light-mode [class*="border-pink-500"] { border-color: #d6cbef !important; }
html.light-mode .border-red-500 { border-color: var(--overdue) !important; }

/* Tables */
html.light-mode thead.bg-slate-950, html.light-mode thead.bg-slate-900, html.light-mode thead.bg-slate-900\/50,
html.light-mode thead.bg-slate-900\/30, html.light-mode thead.bg-slate-900\/60, html.light-mode thead.bg-slate-800\/50,
html.light-mode thead.bg-slate-800\/30, html.light-mode thead.bg-slate-800 { background-color: var(--surface-sunken) !important; border-bottom: 1px solid var(--line) !important; }
html.light-mode thead th { color: var(--ink-muted) !important; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; font-size: 11px !important; }
html.light-mode table .px-6.py-4 { padding-top: 12px !important; padding-bottom: 12px !important; }
html.light-mode tbody tr:hover { background-color: var(--surface-sunken) !important; }

/* Form controls */
html.light-mode input.bg-slate-900, html.light-mode input.bg-slate-800, html.light-mode input.bg-slate-950, html.light-mode input.bg-slate-700,
html.light-mode select.bg-slate-900, html.light-mode select.bg-slate-800, html.light-mode select.bg-slate-950, html.light-mode select.bg-slate-700,
html.light-mode textarea.bg-slate-900, html.light-mode textarea.bg-slate-800, html.light-mode textarea.bg-slate-950, html.light-mode textarea.bg-slate-700 {
    background-color: var(--surface) !important; color: var(--ink) !important; border-color: var(--line-strong) !important;
}
html.light-mode input:focus, html.light-mode select:focus, html.light-mode textarea:focus {
    border-color: var(--brand) !important; box-shadow: 0 0 0 3px rgba(29, 78, 168, 0.15) !important; --tw-ring-color: transparent !important;
}
html.light-mode input[type="checkbox"], html.light-mode input[type="radio"] { accent-color: var(--brand); }

/* Neutral buttons */
html.light-mode button.bg-slate-700, html.light-mode a.bg-slate-700, html.light-mode button.bg-slate-600, html.light-mode a.bg-slate-600 {
    background-color: var(--surface) !important; color: var(--ink) !important; border: 1px solid var(--line-strong) !important;
}
html.light-mode button.bg-slate-700:hover, html.light-mode a.bg-slate-700:hover, html.light-mode button.bg-slate-600:hover, html.light-mode a.bg-slate-600:hover { background-color: var(--surface-sunken) !important; }

/* Action buttons: one accent. Solid green / amber / purple / orange buttons
   were per-module colours; as actions they all take the brand. Red stays for
   destructive actions. */
html.light-mode :is(a, button, input[type="submit"]):is(.bg-green-500, .bg-green-600, .bg-emerald-500, .bg-emerald-600, .bg-yellow-500, .bg-yellow-600, .bg-amber-500, .bg-amber-600, .bg-orange-500, .bg-orange-600, .bg-purple-500, .bg-purple-600, .bg-pink-500, .bg-pink-600, .bg-indigo-600, .bg-teal-600),
html.light-mode :is(a, button, input[type="submit"])[class*="bg-gradient-to-"]:is([class*="from-green-"], [class*="from-emerald-"], [class*="from-yellow-"], [class*="from-amber-"], [class*="from-orange-"], [class*="from-purple-"], [class*="from-pink-"], [class*="from-teal-"]):not([class*="/10"]):not([class*="/20"]) {
    background-image: none !important; background-color: var(--brand) !important; color: var(--on-brand) !important; border-color: var(--brand) !important;
}
html.light-mode :is(a, button, input[type="submit"]):is(.bg-green-500, .bg-green-600, .bg-emerald-500, .bg-emerald-600, .bg-yellow-500, .bg-yellow-600, .bg-amber-500, .bg-amber-600, .bg-orange-500, .bg-orange-600, .bg-purple-500, .bg-purple-600, .bg-pink-500, .bg-pink-600, .bg-indigo-600, .bg-teal-600):hover { background-color: var(--brand-hover) !important; }
html.light-mode :is(a, button):is(.bg-green-500, .bg-green-600, .bg-emerald-600, .bg-yellow-600, .bg-amber-600, .bg-orange-600, .bg-purple-600, .bg-pink-600) :is(i, span, .text-white) { color: var(--on-brand) !important; }

/* Soft gradient tints (from-green-500/10 …) are panels, not fills */
html.light-mode [class*="bg-gradient-to-"][class*="from-green-500/"], html.light-mode [class*="bg-gradient-to-"][class*="from-emerald-500/"] { background-image: none !important; background-color: var(--paid-soft) !important; }
html.light-mode [class*="bg-gradient-to-"][class*="from-yellow-500/"], html.light-mode [class*="bg-gradient-to-"][class*="from-amber-500/"], html.light-mode [class*="bg-gradient-to-"][class*="from-orange-500/"] { background-image: none !important; background-color: var(--due-soft) !important; }
html.light-mode [class*="bg-gradient-to-"][class*="from-red-500/"] { background-image: none !important; background-color: var(--overdue-soft) !important; }
html.light-mode [class*="bg-gradient-to-"][class*="from-blue-500/"], html.light-mode [class*="bg-gradient-to-"][class*="from-indigo-500/"] { background-image: none !important; background-color: var(--brand-soft) !important; }
html.light-mode [class*="bg-gradient-to-"][class*="from-purple-500/"] { background-image: none !important; background-color: var(--promised-soft) !important; }

html.light-mode [class*="bg-gradient-to-"][class*="/10"] .text-white, html.light-mode [class*="bg-gradient-to-"][class*="/20"] .text-white { color: var(--ink) !important; }

/* Coloured hero cards and card header bands → white surfaces. Buttons (small
   padding) keep their fill; only padded blocks are neutralised. The figure
   keeps the card's tone, the icon box takes the tone's soft ground. */
html.light-mode :not(button)[class*="bg-gradient-to-"]:not([class*="from-slate"]):not([class*="/10"]):not([class*="/20"]):is(.p-5, .p-6, .p-8) {
    background-image: none !important; background-color: var(--surface) !important;
    border: 1px solid var(--line) !important; box-shadow: var(--shadow-card) !important; color: var(--ink) !important;
}
html.light-mode div[class*="bg-gradient-to-"]:not([class*="from-slate"]):not([class*="/10"]):not([class*="/20"]):is(.px-6.py-4, .px-6.py-3, .px-5.py-4, .px-4.py-3) {
    background-image: none !important; background-color: var(--surface) !important;
    border-bottom: 1px solid var(--line) !important; color: var(--ink) !important;
}
html.light-mode [class*="bg-gradient-to-"]:not([class*="from-slate"]):is(.p-5, .p-6, .p-8, div.px-6.py-4, div.px-6.py-3, div.px-5.py-4, div.px-4.py-3):not(button) :is(.text-white, h2, h3, h4) { color: var(--ink) !important; }
html.light-mode [class*="bg-gradient-to-"]:not([class*="from-slate"]):is(.p-5, .p-6, .p-8, div.px-6.py-4, div.px-6.py-3, div.px-5.py-4, div.px-4.py-3):not(button) :is(.text-blue-100, .text-blue-200, .text-green-100, .text-green-200, .text-emerald-100, .text-red-100, .text-purple-100, .text-pink-100, .text-yellow-100, .text-amber-100, .text-indigo-100, .text-white\/80, .text-white\/70, .text-white\/60, .opacity-80, .opacity-75, .opacity-90) { color: var(--ink-muted) !important; opacity: 1 !important; }
html.light-mode [class*="bg-gradient-to-"]:not([class*="from-slate"]):is(.p-5, .p-6, .p-8) :is([class*="bg-white/"]) { background-color: var(--brand-soft) !important; color: var(--brand) !important; }
html.light-mode [class*="bg-gradient-to-"]:not([class*="from-slate"]):is(.p-5, .p-6, .p-8) :is([class*="bg-white/"]) :is(i, .text-white) { color: var(--brand) !important; }
html.light-mode [class*="bg-gradient-to-"]:is([class*="from-green-"], [class*="from-emerald-"]):is(.p-5, .p-6, .p-8) :is([class*="bg-white/"], [class*="bg-white/"] i, [class*="bg-white/"] .text-white) { background-color: var(--paid-soft) !important; color: var(--paid) !important; }
html.light-mode [class*="bg-gradient-to-"]:is([class*="from-red-"], [class*="from-rose-"]):is(.p-5, .p-6, .p-8) :is([class*="bg-white/"], [class*="bg-white/"] i, [class*="bg-white/"] .text-white) { background-color: var(--overdue-soft) !important; color: var(--overdue) !important; }
html.light-mode [class*="bg-gradient-to-"]:is([class*="from-amber-"], [class*="from-yellow-"], [class*="from-orange-"]):is(.p-5, .p-6, .p-8) :is([class*="bg-white/"], [class*="bg-white/"] i, [class*="bg-white/"] .text-white) { background-color: var(--due-soft) !important; color: var(--due) !important; }
html.light-mode [class*="bg-gradient-to-"]:is([class*="from-purple-"], [class*="from-pink-"], [class*="from-indigo-"]):is(.p-5, .p-6, .p-8) :is([class*="bg-white/"], [class*="bg-white/"] i, [class*="bg-white/"] .text-white) { background-color: var(--promised-soft) !important; color: var(--promised) !important; }
html.light-mode [class*="bg-gradient-to-"]:is([class*="from-green-"], [class*="from-emerald-"]):is(.p-5, .p-6, .p-8) :is(.text-2xl, .text-3xl, .text-4xl) { color: var(--paid) !important; }
html.light-mode [class*="bg-gradient-to-"]:is([class*="from-red-"], [class*="from-rose-"]):is(.p-5, .p-6, .p-8) :is(.text-2xl, .text-3xl, .text-4xl) { color: var(--overdue) !important; }
html.light-mode [class*="bg-gradient-to-"]:is([class*="from-amber-"], [class*="from-yellow-"], [class*="from-orange-"]):is(.p-5, .p-6, .p-8) :is(.text-2xl, .text-3xl, .text-4xl) { color: var(--due) !important; }
html.light-mode [class*="bg-gradient-to-"]:is([class*="from-purple-"], [class*="from-pink-"]):is(.p-5, .p-6, .p-8) :is(.text-2xl, .text-3xl, .text-4xl) { color: var(--promised) !important; }

/* Page and section headings: one scale */
html.light-mode main h1.text-3xl, html.light-mode main h1.text-4xl, html.light-mode main h1.text-2xl { font-size: 24px !important; line-height: 32px !important; letter-spacing: -0.01em; font-weight: 700; }
html.light-mode main h2.text-2xl, html.light-mode main h2.text-xl { font-size: 18px !important; line-height: 26px !important; font-weight: 600; }
html.light-mode main :is(h2, h3).text-lg { font-size: 16px !important; line-height: 24px !important; font-weight: 600; }

/* Elevation: cards sit flat; only floating things get the overlay shadow */
html.light-mode .shadow-lg:not(.absolute):not(.fixed), html.light-mode .shadow-md:not(.absolute):not(.fixed) { box-shadow: var(--shadow-card) !important; }
html.light-mode .hover\:shadow-lg:hover, html.light-mode .hover\:shadow-xl:hover { box-shadow: var(--shadow-card) !important; }
html.light-mode [class*="hover:scale-"]:hover, html.light-mode [class*="hover:-translate-y"]:hover { transform: none !important; }

/* Overlays */
html.light-mode .bg-black\/60, html.light-mode .bg-black\/50, html.light-mode .bg-black.bg-opacity-50 { background-color: var(--scrim) !important; }
html.light-mode :is(.absolute, .fixed):is(.shadow-xl, .shadow-2xl, .shadow-lg) { box-shadow: var(--shadow-overlay) !important; }
html.light-mode :not(.absolute):not(.fixed):is(.shadow-xl, .shadow-2xl) { box-shadow: var(--shadow-card) !important; }

/* Stat figures inside migrated cards */
.vms-stat-value { font-size: 26px !important; line-height: 32px !important; font-weight: 700 !important; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.vms-stat-value:not([class*="text-"]) { color: var(--ink); }

/* Selectable rows / choice cards (a button or link wrapping content) */
.vms-select-card { display: block; width: 100%; box-sizing: border-box; text-align: left; padding: 12px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); color: var(--ink); cursor: pointer; font: inherit; transition: border-color .12s, background-color .12s; }
.vms-select-card:hover { border-color: var(--line-strong); background: var(--surface-sunken); }
.vms-select-card.border-blue-500, .vms-select-card[aria-pressed="true"], .vms-select-card[aria-selected="true"] { border-color: var(--brand) !important; box-shadow: 0 0 0 1px var(--brand); background: var(--brand-soft); }
