/* ==========================================================================
   LoanAcre UI
   The Oven's design language (ported from Champions Haven's ch-ui.css).
   Loaded after theme.min.css on every page. Light and dark share the same
   rules; only the tokens change.

   The colours here are the neutral LoanAcre brand (brands/vault). A client's
   brand pack overrides the brand tokens (accent, navy, status colours,
   chart series, gradient) from public/assets/brand/tokens.css, which
   `php spark brand:install` generates and the page loads after this file.
   Keep these values in step with brands/vault/brand.php (a test checks).
   ========================================================================== */

/* ---------- tokens ---------- */
:root,
[data-bs-theme="light"] {
    color-scheme: light;
    --ch-bg: #f2f4f7;
    --ch-surface: #ffffff;
    --ch-surface-2: #f8f9fb;
    --ch-line: #e3e7ee;
    --ch-line-strong: #cfd5e0;
    --ch-text: #0b0f19;
    --ch-text-2: #4b5468;
    --ch-text-3: #6f788b;
    --ch-accent: #2d4bd1;
    --ch-accent-rgb: 45, 75, 209;
    --ch-accent-soft: #eaeefc;
    --ch-accent-ink: #2239a8;
    --ch-navy: #0f1424;
    --ch-navy-rgb: 15, 20, 36;
    --ch-ok: #0e7a50;   --ch-ok-soft: #e2f4ec;
    --ch-warn: #a35200; --ch-warn-soft: #fff1e0;
    /* Chart fills need a brighter orange than warning text, which is dark for contrast. */
    --ch-chart-warn: #f29d0b;
    --ch-bad: #c8203f;  --ch-bad-soft: #fde8ec;
    --ch-info: #6a3fd0; --ch-info-soft: #efe9fc;
    --ch-hover: #f5f7fa;
    --ch-on-accent: #ffffff;
    /* Chart series from the brand palette. */
    --ch-series-1: #e0a100;
    --ch-series-2: #2d4bd1;
    --ch-series-3: #0f9f8f;
    --ch-shadow-pop: 0 6px 20px rgba(8, 11, 18, 0.07);
    --ch-shadow-bar: 0 10px 18px -16px rgba(8, 11, 18, 0.35);
    --ch-backdrop: #080b12;
    --ch-radius: 16px;
    --ch-radius-sm: 10px;
    /* Buttons, inputs and other controls: rounded corners, not pills. */
    --ch-radius-control: 10px;
    --ch-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    /* The signature gradient: used once per screen, to guide the eye. */
    --ch-gradient: linear-gradient(90deg, #ffd76a 0%, #f5b301 40%, #d98a00 75%, #a35f00 100%);
}

[data-bs-theme="dark"] {
    color-scheme: dark;
    --ch-bg: #080b12;
    --ch-surface: #0f131d;
    --ch-surface-2: #131826;
    --ch-line: #1f2535;
    --ch-line-strong: #2b3348;
    --ch-text: #f2f4f7;
    --ch-text-2: #b3bbcc;
    --ch-text-3: #848ca0;
    --ch-accent: #5b74ff;
    --ch-accent-rgb: 91, 116, 255;
    --ch-accent-soft: rgba(91, 116, 255, 0.16);
    --ch-accent-ink: #b3bfff;
    --ch-navy: #0f1424;
    --ch-navy-rgb: 15, 20, 36;
    --ch-ok: #43c58b;   --ch-ok-soft: rgba(67, 197, 139, 0.14);
    --ch-warn: #ffab52; --ch-warn-soft: rgba(255, 171, 82, 0.14);
    --ch-chart-warn: #ffb547;
    --ch-bad: #ff6b81;  --ch-bad-soft: rgba(255, 107, 129, 0.14);
    --ch-info: #b59bff; --ch-info-soft: rgba(181, 155, 255, 0.14);
    --ch-hover: #151b2a;
    --ch-on-accent: #ffffff;
    --ch-series-1: #f2b733;
    --ch-series-2: #7d8fff;
    --ch-series-3: #2cc6b4;
    --ch-shadow-pop: 0 10px 30px rgba(0, 0, 0, 0.5);
    --ch-shadow-bar: 0 10px 18px -16px rgba(0, 0, 0, 0.8);
    --ch-backdrop: #000000;
}

/* Bootstrap reads its own variables; point them at the tokens. */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
    --bs-body-font-family: var(--ch-font);
    --bs-font-sans-serif: var(--ch-font);
    --bs-body-bg: var(--ch-surface);
    --bs-body-bg-rgb: 255, 255, 255;
    --bs-body-color: var(--ch-text);
    --bs-emphasis-color: var(--ch-text);
    --bs-heading-color: var(--ch-text);
    --bs-secondary-color: var(--ch-text-2);
    --bs-tertiary-color: var(--ch-text-3);
    --bs-secondary-bg: var(--ch-surface-2);
    --bs-tertiary-bg: var(--ch-bg);
    --bs-border-color: var(--ch-line);
    --bs-border-color-translucent: var(--ch-line);
    --bs-primary: var(--ch-accent);
    --bs-primary-rgb: var(--ch-accent-rgb);
    --bs-primary-text-emphasis: var(--ch-accent-ink);
    --bs-primary-bg-subtle: var(--ch-accent-soft);
    --bs-primary-border-subtle: var(--ch-accent-soft);
    --bs-link-color: var(--ch-accent);
    --bs-link-color-rgb: var(--ch-accent-rgb);
    --bs-link-hover-color: var(--ch-accent-ink);
    --bs-border-radius: var(--ch-radius-sm);
    --bs-border-radius-sm: 8px;
    --bs-border-radius-lg: var(--ch-radius);
    --bs-border-radius-xl: var(--ch-radius);
    --bs-border-radius-2xl: 20px;
    --bs-box-shadow: var(--ch-shadow-pop);
    --bs-box-shadow-sm: none;
    --bs-dark: var(--ch-navy);
    --bs-dark-rgb: var(--ch-navy-rgb);
    --bs-gray-900: var(--ch-text);
    --bs-gray-800: var(--ch-text);
    --bs-gray-700: var(--ch-text-2);
    --bs-gray-600: var(--ch-text-3);
    --bs-light: var(--ch-surface-2);
}

[data-bs-theme="dark"] {
    --bs-body-bg-rgb: 15, 19, 29;
    --bs-white: var(--ch-surface);
    --bs-white-rgb: 15, 19, 29;
    --bs-light-rgb: 19, 24, 38;
    --bs-dark: var(--ch-text);
    --bs-dark-rgb: 242, 244, 247;
    --bs-gray-100: var(--ch-surface-2);
    --bs-gray-200: var(--ch-line);
    --bs-gray-300: var(--ch-line-strong);
    --bs-gray-400: var(--ch-text-3);
    --bs-gray-500: var(--ch-text-3);
}

/* ---------- base ---------- */
body {
    font-family: var(--ch-font);
    background: var(--ch-bg);
    color: var(--ch-text);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6,
.h1, .h2, .h3, .h4, .h5, .h6 {
    color: var(--ch-text);
    letter-spacing: -0.01em;
}

.text-muted,
.text-secondary,
.text-body-secondary {
    color: var(--ch-text-3) !important;
}

.text-primary { color: var(--ch-accent) !important; }
.text-success { color: var(--ch-ok) !important; }
.text-warning { color: var(--ch-warn) !important; }
.text-danger { color: var(--ch-bad) !important; }
.text-info { color: var(--ch-info) !important; }

.bg-body-tertiary,
.bg-light-subtle { background-color: var(--ch-bg) !important; }

hr { border-color: var(--ch-line); opacity: 1; }

/* ---------- cards ---------- */
.card {
    --bs-card-bg: var(--ch-surface);
    --bs-card-color: var(--ch-text);
    --bs-card-title-color: var(--ch-text);
    --bs-card-cap-bg: transparent;
    --bs-card-border-color: var(--ch-line);
    --bs-card-border-radius: var(--ch-radius);
    --bs-card-inner-border-radius: calc(var(--ch-radius) - 1px);
    --bs-card-spacer-y: 18px;
    --bs-card-spacer-x: 20px;
    --bs-card-cap-padding-y: 16px;
    --bs-card-cap-padding-x: 20px;
}

/* Surface cards get the reference's hairline frame. Image, overlay, dark
   and transparent cards on the public site keep their own treatment. */
.card:not(.bg-transparent):not(.rounded-0):not(.bg-dark):not(.bg-primary):not([style*="background-image"]) {
    --bs-card-border-width: 1px;
    border: 1px solid var(--ch-line) !important;
}

.card.shadow,
.card.shadow-sm,
.card .shadow-sm,
.card.shadow-lg {
    box-shadow: none !important;
}

.card > .card-header,
.card > .card-footer {
    background: transparent;
    border-color: var(--ch-line);
}

.card > .card-header:not(.border-bottom) {
    border-bottom: 0;
    padding-bottom: 0;
}

.card > .card-header h5,
.card > .card-header h6,
.card > .card-header .card-title,
.card-body > h5.card-title,
.ch-card-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ch-text);
    margin: 0;
    letter-spacing: 0;
}

/* A title at the top of a card body keeps a gap above what follows it. */
.card-body > h5.card-title { margin-bottom: 14px; }

.card > .card-header.border-bottom {
    padding-bottom: 14px;
}

/* A card whose only job is to hold a table: no inner padding, table edge to edge. */
.card.ch-pad-0 > .card-body,
.card > .card-body.p-0 {
    padding: 0;
}

.ch-card-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 12px;
}

.ch-card-sub {
    color: var(--ch-text-3);
    font-size: 12px;
    font-weight: 400;
}

/* ---------- tiles ---------- */
.ch-tile {
    display: flex;
    flex-direction: column;
    gap: 4px;
    height: 100%;
    background: var(--ch-surface);
    border: 1px solid var(--ch-line);
    border-radius: var(--ch-radius);
    padding: 18px 20px;
    color: var(--ch-text);
    text-decoration: none;
    min-width: 0;
}

a.ch-tile:hover {
    border-color: var(--ch-line-strong);
    color: var(--ch-text);
}

.ch-tile .ch-tile-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--ch-text-2);
    font-size: 12.5px;
    font-weight: 500;
}

.ch-tile .ch-tile-label i {
    color: var(--ch-text-3);
    font-size: 14px;
}

.ch-tile .ch-tile-value {
    font-size: 30px;
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.ch-tile .ch-tile-sub {
    margin-top: 4px;
    font-size: 15px;
    font-weight: 600;
    color: var(--ch-text-2);
    font-variant-numeric: tabular-nums;
}

.ch-tile .ch-tile-value.accent { color: var(--ch-accent-ink); }
.ch-tile .ch-tile-value.bad { color: var(--ch-bad); }

.ch-tile .ch-tile-value--text {
    font-size: 20px;
    line-height: 1.25;
    padding: 5px 0 2px;
}

/* One row of tiles on wide screens, two columns below that (never 3 + 1). */
.ch-tiles {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (min-width: 1100px) {
    .ch-tiles {
        grid-auto-flow: column;
        grid-auto-columns: minmax(0, 1fr);
        grid-template-columns: none;
    }
}

.ch-tile .ch-tile-hint {
    color: var(--ch-text-3);
    font-size: 12px;
}

.ch-tile .ch-tile-hint .badge { margin-right: 4px; }
.ch-tile .ch-tile-hint a { white-space: nowrap; }

.ch-quick-title { font-size: 13.5px; font-weight: 600; color: var(--ch-text); }
.ch-quick-sub { font-size: 12px; color: var(--ch-text-3); }
a.ch-tile.flex-row > i { flex: none; }

/* ---------- tables ---------- */
.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ch-text);
    --bs-table-border-color: var(--ch-line);
    --bs-table-hover-bg: var(--ch-hover);
    --bs-table-hover-color: var(--ch-text);
    --bs-table-striped-bg: var(--ch-hover);
    --bs-table-striped-color: var(--ch-text);
    --bs-table-active-bg: var(--ch-accent-soft);
    font-size: 13px;
    margin-bottom: 0;
}

.table > thead,
.table .table-light,
.table > thead.table-light {
    --bs-table-bg: transparent;
    --bs-table-color: var(--ch-text-3);
    --bs-table-border-color: var(--ch-line);
    --bs-table-striped-bg: transparent;
    --bs-table-hover-bg: transparent;
}

.table > thead th,
.table > thead td {
    font-weight: 600;
    color: var(--ch-text-3);
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
    background-color: transparent;
    border-top: 0;
    border-bottom: 1px solid var(--ch-line);
    padding-top: 10px;
    padding-bottom: 10px;
}

.table > tbody > tr > * {
    border-bottom-color: var(--ch-line);
    padding-top: 10px;
    padding-bottom: 10px;
    vertical-align: middle;
}

.table > tbody > tr:last-child > * {
    border-bottom-width: 0;
}

.table:not(.table-bordered) > :not(caption) > * > *:first-child { padding-left: 16px; }
.table:not(.table-bordered) > :not(caption) > * > *:last-child { padding-right: 16px; }

/* Outside a card a table sits in its own frame; inside a card the card is the frame. */
.table-responsive:not(:has(.table-bordered)) {
    border: 1px solid var(--ch-line);
    border-radius: var(--ch-radius);
    background: var(--ch-surface);
}

.card .table-responsive,
.modal .table-responsive {
    border: 0 !important;
    border-radius: 0;
    background: transparent;
}

.table-bordered {
    --bs-table-border-color: var(--ch-line);
}

/* ---------- buttons ---------- */
.btn {
    --bs-btn-border-radius: var(--ch-radius-control);
    --bs-btn-font-weight: 500;
    --bs-btn-font-size: 13px;
    --bs-btn-padding-y: 7px;
    --bs-btn-padding-x: 14px;
    --bs-btn-focus-box-shadow: 0 0 0 3px var(--ch-accent-soft);
    border-radius: var(--ch-radius-control);
    letter-spacing: 0;
    box-shadow: none;
}

.btn-sm,
.btn-group-sm > .btn {
    --bs-btn-padding-y: 5px;
    --bs-btn-padding-x: 11px;
    --bs-btn-font-size: 12.5px;
    border-radius: var(--ch-radius-control);
}

.btn-lg,
.btn-group-lg > .btn {
    --bs-btn-padding-y: 10px;
    --bs-btn-padding-x: 20px;
    --bs-btn-font-size: 15px;
    border-radius: var(--ch-radius-control);
}

.btn-xs { border-radius: var(--ch-radius-control); }

/* One button shape everywhere, whatever rounded-* class a view asked for. */
.btn[class*="rounded-"]:not(.rounded-0):not(.rounded-circle) {
    border-radius: var(--ch-radius-control) !important;
}

.btn-primary {
    --bs-btn-bg: var(--ch-accent);
    --bs-btn-border-color: var(--ch-accent);
    --bs-btn-color: var(--ch-on-accent);
    --bs-btn-hover-bg: var(--ch-accent-ink);
    --bs-btn-hover-border-color: var(--ch-accent-ink);
    --bs-btn-hover-color: var(--ch-on-accent);
    --bs-btn-active-bg: var(--ch-accent-ink);
    --bs-btn-active-border-color: var(--ch-accent-ink);
    --bs-btn-disabled-bg: var(--ch-accent);
    --bs-btn-disabled-border-color: var(--ch-accent);
}

[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: var(--ch-on-accent);
    --bs-btn-hover-bg: var(--ch-accent-ink);
    --bs-btn-hover-border-color: var(--ch-accent-ink);
    --bs-btn-hover-color: var(--ch-on-accent);
    --bs-btn-active-bg: var(--ch-accent-ink);
    --bs-btn-active-color: var(--ch-on-accent);
}

/* Neutral buttons: the reference's surface pill with an accent hover. */
.btn-light,
.btn-white,
.btn-secondary,
.btn-outline-secondary,
.btn-outline-light,
.btn-outline-dark {
    --bs-btn-bg: var(--ch-surface);
    --bs-btn-color: var(--ch-text);
    --bs-btn-border-color: var(--ch-line-strong);
    --bs-btn-hover-bg: var(--ch-surface);
    --bs-btn-hover-color: var(--ch-accent-ink);
    --bs-btn-hover-border-color: var(--ch-accent);
    --bs-btn-active-bg: var(--ch-accent-soft);
    --bs-btn-active-color: var(--ch-accent-ink);
    --bs-btn-active-border-color: var(--ch-accent);
    --bs-btn-disabled-bg: var(--ch-surface);
    --bs-btn-disabled-color: var(--ch-text-3);
    --bs-btn-disabled-border-color: var(--ch-line);
    background: var(--bs-btn-bg);
    border-color: var(--bs-btn-border-color);
    color: var(--bs-btn-color);
}

.btn-light:hover, .btn-white:hover, .btn-secondary:hover,
.btn-outline-secondary:hover, .btn-outline-light:hover, .btn-outline-dark:hover {
    background: var(--bs-btn-hover-bg);
    border-color: var(--bs-btn-hover-border-color);
    color: var(--bs-btn-hover-color);
}

.btn-outline-primary {
    --bs-btn-color: var(--ch-accent-ink);
    --bs-btn-border-color: var(--ch-line-strong);
    --bs-btn-bg: var(--ch-surface);
    --bs-btn-hover-bg: var(--ch-accent-soft);
    --bs-btn-hover-color: var(--ch-accent-ink);
    --bs-btn-hover-border-color: var(--ch-accent);
    --bs-btn-active-bg: var(--ch-accent-soft);
    --bs-btn-active-color: var(--ch-accent-ink);
    --bs-btn-active-border-color: var(--ch-accent);
}

.btn-outline-success,
.btn-outline-danger,
.btn-outline-warning,
.btn-outline-info {
    --bs-btn-bg: var(--ch-surface);
    --bs-btn-border-color: var(--ch-line-strong);
}

.btn-outline-success { --bs-btn-color: var(--ch-ok); --bs-btn-hover-bg: var(--ch-ok-soft); --bs-btn-hover-color: var(--ch-ok); --bs-btn-hover-border-color: var(--ch-ok); --bs-btn-active-bg: var(--ch-ok-soft); --bs-btn-active-color: var(--ch-ok); }
.btn-outline-danger { --bs-btn-color: var(--ch-bad); --bs-btn-hover-bg: var(--ch-bad-soft); --bs-btn-hover-color: var(--ch-bad); --bs-btn-hover-border-color: var(--ch-bad); --bs-btn-active-bg: var(--ch-bad-soft); --bs-btn-active-color: var(--ch-bad); }
.btn-outline-warning { --bs-btn-color: var(--ch-warn); --bs-btn-hover-bg: var(--ch-warn-soft); --bs-btn-hover-color: var(--ch-warn); --bs-btn-hover-border-color: var(--ch-warn); --bs-btn-active-bg: var(--ch-warn-soft); --bs-btn-active-color: var(--ch-warn); }
.btn-outline-info { --bs-btn-color: var(--ch-info); --bs-btn-hover-bg: var(--ch-info-soft); --bs-btn-hover-color: var(--ch-info); --bs-btn-hover-border-color: var(--ch-info); --bs-btn-active-bg: var(--ch-info-soft); --bs-btn-active-color: var(--ch-info); }

/* Ink button: the strongest neutral action. Inverts with the theme. */
.btn-dark {
    --bs-btn-bg: var(--ch-text);
    --bs-btn-border-color: var(--ch-text);
    --bs-btn-color: var(--ch-surface);
    --bs-btn-hover-bg: var(--ch-accent-ink);
    --bs-btn-hover-border-color: var(--ch-accent-ink);
    --bs-btn-hover-color: var(--ch-on-accent);
    --bs-btn-active-bg: var(--ch-accent-ink);
    --bs-btn-active-border-color: var(--ch-accent-ink);
    --bs-btn-disabled-bg: var(--ch-text-3);
    --bs-btn-disabled-border-color: var(--ch-text-3);
    --bs-btn-disabled-color: var(--ch-surface);
    background: var(--bs-btn-bg);
    border-color: var(--bs-btn-border-color);
    color: var(--bs-btn-color);
}

[data-bs-theme="dark"] .btn-dark {
    --bs-btn-hover-bg: var(--ch-accent);
    --bs-btn-hover-border-color: var(--ch-accent);
    --bs-btn-hover-color: var(--ch-on-accent);
}

/* Inside the app, green/amber/cyan outlines carried no meaning (Edit, View,
   Register...), so they read as the neutral pill. Red keeps its warning. */
.ch-main .btn-outline-info,
.ch-main .btn-outline-success,
.ch-main .btn-outline-warning {
    --bs-btn-bg: var(--ch-surface);
    --bs-btn-color: var(--ch-text);
    --bs-btn-border-color: var(--ch-line-strong);
    --bs-btn-hover-bg: var(--ch-surface);
    --bs-btn-hover-color: var(--ch-accent-ink);
    --bs-btn-hover-border-color: var(--ch-accent);
    --bs-btn-active-bg: var(--ch-accent-soft);
    --bs-btn-active-color: var(--ch-accent-ink);
    --bs-btn-active-border-color: var(--ch-accent);
    --bs-btn-disabled-color: var(--ch-text-3);
    --bs-btn-disabled-border-color: var(--ch-line);
}

.btn-success { --bs-btn-bg: var(--ch-ok); --bs-btn-border-color: var(--ch-ok); --bs-btn-hover-bg: var(--ch-ok); --bs-btn-hover-border-color: var(--ch-ok); --bs-btn-color: var(--ch-on-accent); --bs-btn-hover-color: var(--ch-on-accent); }
.btn-danger { --bs-btn-bg: var(--ch-bad); --bs-btn-border-color: var(--ch-bad); --bs-btn-hover-bg: var(--ch-bad); --bs-btn-hover-border-color: var(--ch-bad); --bs-btn-color: var(--ch-on-accent); --bs-btn-hover-color: var(--ch-on-accent); }
.btn-success:hover, .btn-danger:hover { filter: brightness(0.94); }

/* Theme "soft" buttons map onto the soft/ink pairs. */
.btn-primary-soft { color: var(--ch-accent-ink); background-color: var(--ch-accent-soft); border-color: transparent; }
.btn-primary-soft:hover, .btn-primary-soft:focus, .btn-primary-soft:active { color: var(--ch-on-accent); background-color: var(--ch-accent); }
.btn-success-soft { color: var(--ch-ok); background-color: var(--ch-ok-soft); border-color: transparent; }
.btn-danger-soft { color: var(--ch-bad); background-color: var(--ch-bad-soft); border-color: transparent; }
.btn-warning-soft { color: var(--ch-warn); background-color: var(--ch-warn-soft); border-color: transparent; }
.btn-info-soft { color: var(--ch-info); background-color: var(--ch-info-soft); border-color: transparent; }

.btn-link { --bs-btn-color: var(--ch-accent); --bs-btn-hover-color: var(--ch-accent-ink); }

.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--ch-text-2);
}

.btn-ghost:hover { background: var(--ch-bg); color: var(--ch-text); }

/* Round icon buttons, like the reference modal close button. */
.ch-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--ch-text-2);
    font-size: 16px;
    position: relative;
}

.ch-icon-btn:hover,
.ch-icon-btn[aria-expanded="true"] {
    background: var(--ch-bg);
    color: var(--ch-text);
}

.btn-close { border-radius: 50%; }
[data-bs-theme="dark"] .btn-close { filter: invert(1) grayscale(100%) brightness(200%); }

/* ---------- forms ---------- */
.form-control,
.form-select {
    background-color: var(--ch-surface);
    border: 1px solid var(--ch-line-strong);
    border-radius: var(--ch-radius-control);
    color: var(--ch-text);
    font-size: 13.5px;
    padding: 7px 14px;
    box-shadow: none;
}

.form-select {
    padding-right: 2.5rem;
}

.form-control-sm,
.form-select-sm {
    font-size: 12.5px;
    padding-top: 5px;
    padding-bottom: 5px;
}

.form-select-sm { padding-right: 2.25rem; }
.form-select-lg { padding-right: 3rem; }

textarea.form-control,
select.form-select[multiple],
select.form-select[size]:not([size="1"]),
.form-floating > .form-control,
.form-floating > .form-select {
    border-radius: var(--ch-radius-sm);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--ch-accent);
    box-shadow: 0 0 0 3px var(--ch-accent-soft);
    background-color: var(--ch-surface);
    color: var(--ch-text);
}

.form-control::placeholder { color: var(--ch-text-3); }

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
    background-color: var(--ch-bg);
    color: var(--ch-text-2);
}

.form-control[type="file"] { padding: 5px 8px; }

.form-label,
.col-form-label {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--ch-text-2);
    margin-bottom: 6px;
}

.form-text { color: var(--ch-text-3); font-size: 12px; }

.input-group-text {
    background: var(--ch-bg);
    border-color: var(--ch-line-strong);
    color: var(--ch-text-2);
    border-radius: var(--ch-radius-control);
    font-size: 13px;
}

.form-check-input {
    border-color: var(--ch-line-strong);
    background-color: var(--ch-surface);
}

.form-check-input:checked {
    background-color: var(--ch-accent);
    border-color: var(--ch-accent);
}

.form-check-input:focus {
    border-color: var(--ch-accent);
    box-shadow: 0 0 0 3px var(--ch-accent-soft);
}

/* Search + filter bar. */
.ch-search-filter-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 0.5rem;
    flex: 1 1 12rem;
    max-width: 20rem;
    min-width: 0;
}

.btn.ch-filter-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0.4rem 0.8rem;
    font-size: 0.8125rem;
    line-height: 1;
    box-sizing: border-box;
    overflow: visible;
}

.ch-filter-toggle-count {
    position: absolute;
    top: -0.35rem;
    right: -0.35rem;
    min-width: 1.1rem;
    height: 1.1rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--ch-accent);
    color: var(--ch-on-accent);
    font-size: 0.65rem;
    font-weight: 600;
    line-height: 1.1rem;
    text-align: center;
}

.ch-filter-date { width: 100%; }

@media (max-width: 991.98px) {
    .ch-filter-offcanvas .form-select,
    .ch-filter-offcanvas .ch-filter-date,
    .ch-filter-offcanvas .form-control {
        width: 100%;
        max-width: 100%;
        flex: 1 1 auto;
    }
}

@media (min-width: 992px) {
    .ch-filter-date {
        width: 9.75rem;
        flex: 0 0 9.75rem;
    }
}

/* ---------- badges ---------- */
.badge {
    --ch-badge-bg: var(--ch-bg);
    --ch-badge-fg: var(--ch-text-2);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: 0;
    white-space: nowrap;
    vertical-align: middle;
}

/* Status badges carry the reference's leading dot. Counters pinned to a
   corner, badges with their own icon, and empty indicator dots do not. */
.badge:not(.position-absolute):not(:has(> i)):not(:empty)::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex: none;
}

.badge.bg-success, .badge.text-bg-success, .badge.bg-success-subtle { background-color: var(--ch-ok-soft) !important; color: var(--ch-ok) !important; }
.badge.bg-warning, .badge.text-bg-warning, .badge.bg-warning-subtle { background-color: var(--ch-warn-soft) !important; color: var(--ch-warn) !important; }
.badge.bg-danger, .badge.text-bg-danger, .badge.bg-danger-subtle { background-color: var(--ch-bad-soft) !important; color: var(--ch-bad) !important; }
.badge.bg-info, .badge.text-bg-info, .badge.bg-info-subtle { background-color: var(--ch-info-soft) !important; color: var(--ch-info) !important; }
.badge.bg-primary, .badge.text-bg-primary, .badge.bg-primary-subtle { background-color: var(--ch-accent-soft) !important; color: var(--ch-accent-ink) !important; }
.badge.bg-secondary, .badge.text-bg-secondary, .badge.bg-light, .badge.text-bg-light,
.badge.bg-secondary-subtle, .badge.bg-dark, .badge.text-bg-dark { background-color: var(--ch-bg) !important; color: var(--ch-text-2) !important; }

/* Corner counters (notifications, filter counts) stay solid so they read at a glance. */
.badge.position-absolute.bg-danger { background-color: var(--ch-bad) !important; color: #fff !important; }
.badge.position-absolute.bg-primary { background-color: var(--ch-accent) !important; color: var(--ch-on-accent) !important; }

/* ---------- alerts / notes ---------- */
/* Prefixed with [data-bs-theme] to outrank the template's dark-mode alert colours. */
.alert {
    --bs-alert-border-radius: var(--ch-radius-sm);
    border: 0;
    font-size: 13px;
    padding: 12px 16px;
}

[data-bs-theme] .alert-primary, [data-bs-theme] .alert-info { --bs-alert-bg: var(--ch-accent-soft); --bs-alert-color: var(--ch-accent-ink); --bs-alert-link-color: var(--ch-accent-ink); }
[data-bs-theme] .alert-success { --bs-alert-bg: var(--ch-ok-soft); --bs-alert-color: var(--ch-ok); --bs-alert-link-color: var(--ch-ok); }
[data-bs-theme] .alert-warning { --bs-alert-bg: var(--ch-warn-soft); --bs-alert-color: var(--ch-warn); --bs-alert-link-color: var(--ch-warn); }
[data-bs-theme] .alert-danger { --bs-alert-bg: var(--ch-bad-soft); --bs-alert-color: var(--ch-bad); --bs-alert-link-color: var(--ch-bad); }
[data-bs-theme] .alert-secondary, [data-bs-theme] .alert-light { --bs-alert-bg: var(--ch-bg); --bs-alert-color: var(--ch-text-2); }
[data-bs-theme] :is(.alert-primary, .alert-info, .alert-success, .alert-warning, .alert-danger, .alert-secondary, .alert-light) {
    background-color: var(--bs-alert-bg);
    color: var(--bs-alert-color);
    border-color: transparent;
}

.alert .alert-heading,
.alert h5,
.alert h6 {
    color: inherit;
    font-size: 13.5px;
    font-weight: 600;
    letter-spacing: 0;
    margin-bottom: 6px;
}

/* App pages use the reference's compact type scale. */
.ch-main h1, .ch-main .h1 { font-size: 22px; }
.ch-main h2, .ch-main .h2 { font-size: 20px; }
.ch-main h3, .ch-main .h3 { font-size: 18px; }
.ch-main h4, .ch-main .h4 { font-size: 16px; }
.ch-main h5, .ch-main .h5 { font-size: 15px; }
.ch-main h6, .ch-main .h6 { font-size: 13.5px; }
.ch-main h1, .ch-main h2, .ch-main h3, .ch-main h4, .ch-main h5, .ch-main h6 { font-weight: 600; }
.ch-main .display-1, .ch-main .display-2, .ch-main .display-3,
.ch-main .display-4, .ch-main .display-5, .ch-main .display-6 { font-size: 28px; font-weight: 600; }

.form-check-label { padding-left: 4px; }

.ch-note {
    background: var(--ch-accent-soft);
    color: var(--ch-accent-ink);
    border-radius: var(--ch-radius-sm);
    padding: 10px 14px;
    font-size: 12.5px;
}

/* ---------- menus, modals, offcanvas ---------- */
.dropdown-menu {
    --bs-dropdown-bg: var(--ch-surface);
    --bs-dropdown-color: var(--ch-text);
    --bs-dropdown-border-color: var(--ch-line);
    --bs-dropdown-border-radius: 12px;
    --bs-dropdown-link-color: var(--ch-text);
    --bs-dropdown-link-hover-bg: var(--ch-bg);
    --bs-dropdown-link-hover-color: var(--ch-text);
    --bs-dropdown-link-active-bg: var(--ch-accent-soft);
    --bs-dropdown-link-active-color: var(--ch-accent-ink);
    --bs-dropdown-header-color: var(--ch-text-3);
    --bs-dropdown-divider-bg: var(--ch-line);
    --bs-dropdown-font-size: 13px;
    border: 1px solid var(--ch-line) !important;
    box-shadow: var(--ch-shadow-pop) !important;
    padding: 6px;
}

.dropdown-item {
    border-radius: 8px;
    padding: 7px 10px;
}

.dropdown-header {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

.modal {
    --bs-modal-bg: var(--ch-surface);
    --bs-modal-color: var(--ch-text);
    --bs-modal-border-color: var(--ch-line);
    --bs-modal-border-radius: 20px;
    --bs-modal-inner-border-radius: 19px;
    --bs-modal-header-border-color: var(--ch-line);
    --bs-modal-footer-border-color: var(--ch-line);
    --bs-modal-header-padding: 18px 24px 14px;
    --bs-modal-padding: 18px 24px 22px;
    --bs-modal-box-shadow: var(--ch-shadow-pop);
}

.modal-content { border: 1px solid var(--ch-line); }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-backdrop { --bs-backdrop-bg: var(--ch-backdrop); --bs-backdrop-opacity: 0.32; }

.offcanvas,
.offcanvas-lg,
.offcanvas-md,
.offcanvas-xl {
    --bs-offcanvas-bg: var(--ch-surface);
    --bs-offcanvas-color: var(--ch-text);
    --bs-offcanvas-border-color: var(--ch-line);
}

.toast {
    --bs-toast-bg: var(--ch-surface);
    --bs-toast-border-color: var(--ch-line);
    --bs-toast-border-radius: var(--ch-radius-sm);
}

/* ---------- navigation pieces ---------- */
.pagination {
    --bs-pagination-color: var(--ch-text-2);
    --bs-pagination-bg: var(--ch-surface);
    --bs-pagination-border-color: var(--ch-line-strong);
    --bs-pagination-hover-color: var(--ch-accent-ink);
    --bs-pagination-hover-bg: var(--ch-surface);
    --bs-pagination-hover-border-color: var(--ch-accent);
    --bs-pagination-focus-box-shadow: 0 0 0 3px var(--ch-accent-soft);
    --bs-pagination-active-color: var(--ch-accent-ink);
    --bs-pagination-active-bg: var(--ch-accent-soft);
    --bs-pagination-active-border-color: var(--ch-accent-soft);
    --bs-pagination-disabled-color: var(--ch-text-3);
    --bs-pagination-disabled-bg: var(--ch-surface);
    --bs-pagination-disabled-border-color: var(--ch-line);
    --bs-pagination-font-size: 12.5px;
    gap: 6px;
    flex-wrap: wrap;
}

.pagination .page-link {
    border-radius: var(--ch-radius-control) !important;
    min-width: 32px;
    text-align: center;
    padding: 5px 11px;
    margin: 0 !important;
}

.breadcrumb {
    --bs-breadcrumb-font-size: 12.5px;
    --bs-breadcrumb-item-active-color: var(--ch-text-3);
    --bs-breadcrumb-divider-color: var(--ch-text-3);
    margin-bottom: 0;
}

.breadcrumb a { color: var(--ch-text-2); text-decoration: none; }
.breadcrumb a:hover { color: var(--ch-accent-ink); }

.list-group {
    --bs-list-group-bg: var(--ch-surface);
    --bs-list-group-color: var(--ch-text);
    --bs-list-group-border-color: var(--ch-line);
    --bs-list-group-border-radius: var(--ch-radius-sm);
    --bs-list-group-action-hover-bg: var(--ch-hover);
    --bs-list-group-action-active-bg: var(--ch-accent-soft);
    --bs-list-group-active-bg: var(--ch-accent-soft);
    --bs-list-group-active-color: var(--ch-accent-ink);
    --bs-list-group-active-border-color: var(--ch-line);
}

/* Borderless lists are feature lists laid on whatever is behind them. */
.list-group-borderless {
    --bs-list-group-bg: transparent;
    --bs-list-group-border-color: transparent;
}

.nav-tabs {
    --bs-nav-tabs-border-color: var(--ch-line);
    --bs-nav-tabs-link-hover-border-color: transparent;
    --bs-nav-tabs-link-active-color: var(--ch-accent-ink);
    --bs-nav-tabs-link-active-bg: transparent;
    --bs-nav-tabs-link-active-border-color: transparent;
    gap: 4px;
}

.nav-tabs .nav-link {
    color: var(--ch-text-2);
    font-weight: 500;
    font-size: 13px;
    border: 0;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    padding: 9px 12px;
}

.nav-tabs .nav-link:hover { color: var(--ch-text); }

.nav-tabs .nav-link.active {
    color: var(--ch-accent-ink);
    border-bottom-color: var(--ch-accent);
    background: transparent;
}

/* nav-pills render as the reference's segmented control. */
.nav-pills:not(.flex-column) {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 3px;
    background: var(--ch-bg);
    border-radius: var(--ch-radius-control);
}

.nav-pills .nav-link {
    border-radius: calc(var(--ch-radius-control) - 3px);
    color: var(--ch-text-2);
    font-size: 12.5px;
    font-weight: 500;
    padding: 5px 12px;
    background: transparent;
}

.nav-pills .nav-link:hover { color: var(--ch-text); }

.nav-pills .nav-link.active,
.nav-pills .show > .nav-link {
    background: var(--ch-surface);
    color: var(--ch-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.nav-pills.flex-column .nav-link.active {
    background: var(--ch-accent-soft);
    color: var(--ch-accent-ink);
    box-shadow: none;
}

.progress {
    --bs-progress-bg: var(--ch-bg);
    --bs-progress-border-radius: 999px;
    --bs-progress-bar-bg: var(--ch-accent);
    height: 8px;
}

/* Icon circles used across dashboards (bg-* bg-opacity-10 rounded-circle). */
.bg-primary.bg-opacity-10 { background-color: var(--ch-accent-soft) !important; }

/* ---------- app shell (admin, portal, writer) ---------- */
.ch-shell {
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    grid-template-rows: 60px 1fr;
    min-height: 100vh;
    background: var(--ch-bg);
}

/* Bootstrap's .offcanvas-lg forces a transparent background on wide screens;
   the sidebar keeps the top bar's surface colour at every width. */
.ch-sidebar,
.ch-sidebar.offcanvas-lg {
    grid-row: 1 / span 2;
    background-color: var(--ch-surface) !important;
    border-right: 1px solid var(--ch-line);
}

@media (min-width: 992px) {
    /* The top bar sits on the page background, lined up with the top of the
       floating sidebar rather than a white band running into its corner. Once
       the page scrolls (vault-shell.js) it frosts, with a soft shadow instead of
       a hard line. */
    .ch-shell { grid-template-rows: 72px 1fr; }

    .ch-shell > .ch-topbar {
        padding-top: 12px;
        background: transparent;
        border-bottom-color: transparent;
        transition: background-color 0.2s ease, box-shadow 0.2s ease;
    }

    .ch-shell > .ch-topbar.is-scrolled {
        background: color-mix(in srgb, var(--ch-bg) 82%, transparent);
        -webkit-backdrop-filter: blur(10px);
        backdrop-filter: blur(10px);
        box-shadow: var(--ch-shadow-bar);
    }

    /* A floating card: inset from the window edges, rounded, lifted by a soft shadow. */
    .ch-sidebar,
    .ch-sidebar.offcanvas-lg {
        position: sticky;
        top: 12px;
        height: calc(100vh - 24px);
        margin: 12px 0 12px 12px;
        border: 1px solid var(--ch-line);
        border-radius: 18px;
        box-shadow: var(--ch-shadow-pop);
        overflow: hidden;
    }

    .ch-sidebar .offcanvas-body {
        display: flex;
        flex-direction: column;
        height: 100%;
        overflow-y: auto;
        padding: 18px 14px;
    }
}

.ch-sidebar .offcanvas-body {
    display: flex;
    flex-direction: column;
    padding: 18px 14px;
    scrollbar-width: thin;
}

.ch-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 8px 18px;
    color: var(--ch-text);
    text-decoration: none;
}

.ch-brand img { height: 42px; width: 42px; display: block; }

.ch-brand-name {
    font-size: 10.5px;
    font-weight: 600;
    color: var(--ch-accent-ink);
    background: var(--ch-accent-soft);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 999px;
}

.ch-sidebar .offcanvas-body { scrollbar-width: none; }
.ch-sidebar .offcanvas-body::-webkit-scrollbar { display: none; }

/* ---------- sidebar navigation ---------- */
.ch-nav { display: flex; flex-direction: column; gap: 6px; }

.ch-nav-section { display: flex; flex-direction: column; }
.ch-nav-section + .ch-nav-section { margin-top: 6px; padding-top: 8px; border-top: 1px solid var(--ch-line); }

/* Group headings: sentence case, and a button that folds the group away. */
.ch-nav-heading {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    width: 100%; margin: 0 0 2px; padding: 6px 12px;
    background: none; border: 0; border-radius: var(--ch-radius-sm);
    font-size: 12px; font-weight: 600; color: var(--ch-text-2); text-align: left; cursor: pointer;
}
.ch-nav-heading:hover { color: var(--ch-text); }
.ch-nav-heading > i { font-size: 11px; transition: transform 0.2s ease; }
.ch-nav-section.is-collapsed .ch-nav-heading > i { transform: rotate(-90deg); }

.ch-nav-items { display: flex; flex-direction: column; gap: 2px; }

.ch-nav-link {
    position: relative;
    display: flex; align-items: center; gap: 11px;
    width: 100%; padding: 8px 12px;
    border: 0; border-radius: var(--ch-radius-sm); background: none;
    color: var(--ch-text); font-weight: 500; font-size: 13.5px; line-height: 1.3;
    text-decoration: none; text-align: left; cursor: pointer;
    transition: background-color 0.15s ease, color 0.15s ease;
}
.ch-nav-link > i:first-child { width: 18px; font-size: 16px; text-align: center; flex: none; color: var(--ch-text-3); transition: color 0.15s ease; }
.ch-nav-label { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ch-nav-link:hover { background: var(--ch-surface-2); color: var(--ch-text); }
.ch-nav-link:hover > i:first-child { color: var(--ch-text-2); }
.ch-nav-link:focus-visible, .ch-nav-heading:focus-visible { outline: 2px solid var(--ch-accent); outline-offset: 1px; }

/* The current page: a tinted pill, bold text and its filled icon in the brand colour. */
.ch-nav-link.active { background: var(--ch-accent-soft); color: var(--ch-accent-ink); font-weight: 600; }
.ch-nav-link.active > i:first-child { color: var(--ch-accent); }
.ch-nav-parent.has-active > i:first-child { color: var(--ch-accent); }

.ch-nav-link.disabled { color: var(--ch-text-3); opacity: 0.7; cursor: not-allowed; }

/* Work waiting on someone: a small count in the brand colour. */
.ch-nav-badge {
    flex: none; min-width: 20px; height: 20px; padding: 0 6px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 999px; background: var(--ch-accent); color: var(--ch-on-accent);
    font-size: 11px; font-weight: 700; line-height: 1;
}
.ch-nav-link.active .ch-nav-badge { background: var(--ch-accent-ink); }

/* A sub-list. */
.ch-nav-caret { font-size: 11px; color: var(--ch-text-3); margin-left: auto; transition: transform 0.2s ease; }
.ch-nav-parent.is-open .ch-nav-caret { transform: rotate(90deg); }
.ch-nav-sub { display: flex; flex-direction: column; gap: 2px; margin: 2px 0 4px 20px; padding-left: 10px; border-left: 1px solid var(--ch-line); }
.ch-nav-sub[hidden] { display: none; }
.ch-nav-sub .ch-nav-link { font-size: 13px; padding: 7px 10px; }

.ch-sidebar-foot {
    margin-top: auto;
    padding: 12px;
    border-radius: var(--ch-radius-sm);
    background: var(--ch-surface-2);
    border: 1px solid var(--ch-line);
    color: var(--ch-text-3);
    font-size: 12px;
    line-height: 1.5;
}

.ch-sidebar-foot a { color: var(--ch-accent-ink); text-decoration: none; font-weight: 500; }

.ch-topbar {
    position: sticky;
    top: 0;
    z-index: 1020;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: var(--ch-surface);
    border-bottom: 1px solid var(--ch-line);
    padding: 0 28px;
    min-width: 0;
}

.ch-topbar-title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.ch-topbar h1 {
    font-size: 17px;
    font-weight: 600;
    margin: 0;
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ch-topbar h1 .sub {
    color: var(--ch-text-3);
    font-size: 12.5px;
    margin-left: 12px;
    font-weight: 400;
    letter-spacing: 0;
}

.ch-topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--ch-text-2);
    font-size: 12.5px;
    flex: none;
}

.ch-topbar .dropdown-menu { margin-top: 8px !important; }

.ch-user-btn {
    display: inline-flex;
    flex: none;
    align-items: center;
    gap: 8px;
    padding: 3px 10px 3px 3px;
    border: 1px solid var(--ch-line);
    /* The account button stays a pill, as in Champions Haven. */
    border-radius: 999px;
    background: var(--ch-surface);
    color: var(--ch-text);
    font-size: 13px;
    font-weight: 500;
}

.ch-user-btn:hover { border-color: var(--ch-line-strong); }

.ch-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ch-accent-soft);
    color: var(--ch-accent-ink);
    font-size: 12px;
    font-weight: 600;
    object-fit: cover;
    flex: none;
}

.ch-main {
    padding: 24px 28px 40px;
    min-width: 0;
}

.ch-main > .ch-page-meta {
    margin-bottom: 16px;
}

@media (max-width: 991.98px) {
    .ch-shell {
        grid-template-columns: minmax(0, 1fr);
    }

    .ch-sidebar {
        grid-row: auto;
        border-right: 0;
    }

    .ch-sidebar.offcanvas-lg { width: 272px; }

    .ch-topbar { padding: 0 16px; }
    .ch-topbar h1 .sub { display: none; }
    .ch-main { padding: 16px 16px 32px; }
}

.ch-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px 16px;
    margin-top: 32px;
    padding-top: 16px;
    border-top: 1px solid var(--ch-line);
    color: var(--ch-text-3);
    font-size: 12px;
}

.ch-footer-links { display: flex; gap: 16px; }
.ch-footer-links a { color: var(--ch-text-3); text-decoration: none; }
.ch-footer-links a:hover { color: var(--ch-accent-ink); }

/* Recent-activity menu in the admin top bar. */
.ch-activity-menu {
    width: 320px;
    max-height: min(70vh, 560px);
    overflow-y: auto;
}

.ch-activity-menu .dropdown-item h6 {
    font-size: 13px !important;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 1px;
}

.ch-activity-menu .dropdown-item small {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-menu .flex-grow-1 { min-width: 0; }

/* Initials/icon avatars (notification rows, people lists). The theme forces
   .avatar to inline-block !important, which beats Bootstrap's d-flex and
   leaves initials in the top-left corner; photo avatars keep the theme's. */
div.avatar:not(:has(> img)),
span.avatar:not(:has(> img)) {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: 600;
    line-height: 1;
    letter-spacing: 0.02em;
    text-align: center;
    flex: none;
}

div.avatar-sm:not(:has(> img)) { width: 36px !important; height: 36px !important; font-size: 12.5px; }
div.avatar-lg:not(:has(> img)) { width: 56px !important; height: 56px !important; font-size: 18px !important; }
div.avatar:not(.avatar-sm):not(.avatar-lg):not(:has(> img)) { font-size: 14px; }

.bg-primary-soft { background-color: var(--ch-accent-soft) !important; }
.bg-success-soft { background-color: var(--ch-ok-soft) !important; }
.bg-warning-soft { background-color: var(--ch-warn-soft) !important; }
.bg-danger-soft { background-color: var(--ch-bad-soft) !important; }
.bg-info-soft { background-color: var(--ch-info-soft) !important; }
.text-primary-soft { color: var(--ch-accent-ink) !important; }

/* ==========================================================================
   Page patterns
   ========================================================================== */

/* Stack of page blocks with even spacing (reference .stack). */
.ch-stack { display: flex; flex-direction: column; gap: 16px; }
.ch-stack > * { margin-bottom: 0 !important; }

/* Cards stacked in a grid column keep the page rhythm. */
.row > [class*="col"] > .card + .card,
.row > [class*="col"] > .card + section.card { margin-top: 16px; }

/* ---------- list card ---------- */
/* Sections used as cards carry no extra padding. */
section.card { padding: 0; }

.card.ch-list { overflow: hidden; }

.ch-list > .ch-card-head,
.ch-section > .ch-card-head,
.card > .ch-card-head {
    padding: 16px 20px 14px;
    margin: 0;
    align-items: center;
}

.ch-card-head .ch-card-title { font-size: 13.5px; }
.ch-card-head > div:first-child { min-width: 0; flex: 1 1 200px; }

@media (max-width: 767.98px) {
    .ch-card-head { flex-wrap: wrap; }
    .ch-card-head > div:first-child { flex: 1 1 100%; }
    .ch-card-head > .ch-toolbar { justify-content: flex-start; }
    .ch-search { flex-basis: 100%; max-width: none; }
    .ch-filters .ch-filters-end { margin-left: auto; }
}

.ch-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.ch-toolbar .btn,
.ch-toolbar .form-select,
.ch-toolbar .form-control { margin-bottom: 0; }

/* Head actions share one compact size, whatever size class the view asked for. */
.ch-card-head .ch-toolbar .btn,
.ch-detail-head .ch-toolbar .btn {
    --bs-btn-padding-y: 5px;
    --bs-btn-padding-x: 12px;
    --bs-btn-font-size: 12.5px;
}

.ch-toolbar .ch-pill-tabs { width: auto; }

.ch-list .ch-note,
.ch-list > .alert {
    margin: 0 20px 14px;
}

/* Body of a list card: filter strip, table and pager run edge to edge; any
   other block (notes, alerts, bulk-action bars, simple forms) is inset. */
.ch-list-body > :not(form):not(.table-responsive):not(.modal):not(script):not(style):not(input):not(.ch-pager):not(.ch-filters):not(.ch-filter-panel):not(.ch-bulk-bar) {
    margin: 14px 20px;
}

.ch-list-body > form:not(:has(.ch-filters)):not(.ch-filters) { margin: 14px 20px; }
.ch-list-body > form.ch-filters { margin: 0; }
.ch-list-body > form:not(.ch-filters) > :not(.ch-filters):not(.ch-filter-panel):not(input[type="hidden"]):not(script) { margin: 12px 20px; }
.ch-list-body > div:not(.ch-list-foot):has(> .ch-pager) { margin: 0 !important; padding: 0 !important; }
.ch-list-body > div:not(.ch-list-foot):has(> .ch-pager) > .ch-pager { width: 100%; }
.ch-list > .ch-card-head { border-bottom: 1px solid var(--ch-line); }
.ch-list .ch-filters { border-top: 0; }

/* Pager footer with a per-page picker beside it. */
.ch-list-foot {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    border-top: 1px solid var(--ch-line);
    margin: 0 !important;
}

.ch-list-foot .ch-pager { border-top: 0; padding: 0; flex: 1; justify-content: flex-end; }
.ch-list-foot .form-select { width: auto; font-size: 12.5px; padding-top: 5px; padding-bottom: 5px; }

/* A list card's summary band and its row of page-level actions. */
.ch-list-body > .ch-list-summary {
    margin: 0 !important;
    padding: 14px 20px;
    border-bottom: 1px solid var(--ch-line);
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
}

.ch-list-summary > div:first-child { grid-column: span 2; }

.ch-list-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.ch-list-actions .btn { margin-bottom: 0; }

/* Bulk selection bar that appears above a table. */
.ch-bulk-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 20px;
    background: var(--ch-accent-soft);
    color: var(--ch-accent-ink);
    font-size: 13px;
    border-bottom: 1px solid var(--ch-line);
}

.ch-bulk-bar.d-none { display: none !important; }
.ch-bulk-bar .btn { margin-bottom: 0; }

/* Segmented links in a card head (Events / Archived etc.). When there are
   more than fit (e.g. an event's categories on a phone) the strip scrolls
   sideways and can be swiped; ch-pill-tabs.js fades the edge that hides more. */
.ch-seg {
    display: inline-flex;
    max-width: 100%;
    padding: 3px;
    gap: 2px;
    background: var(--ch-bg);
    border: 1px solid var(--ch-line);
    border-radius: var(--ch-radius-control);
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scroll-behavior: smooth;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.ch-seg::-webkit-scrollbar { display: none; }
.ch-seg.is-clipped-end { -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent); }
.ch-seg.is-clipped-start { -webkit-mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to left, #000 calc(100% - 32px), transparent); }
.ch-seg.is-clipped-start.is-clipped-end { -webkit-mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to right, transparent, #000 32px, #000 calc(100% - 32px), transparent); }

/* A strip of tabs on its own row inside a list card, lined up with the card head. */
.ch-seg-row { padding: 12px 20px; border-bottom: 1px solid var(--ch-line); }

.ch-seg > li { list-style: none; display: flex; }
.ch-seg { margin: 0; list-style: none; }

.ch-seg > a,
.ch-seg > button,
.ch-seg > li > a,
.ch-seg > li > button {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 0;
    background: transparent;
    padding: 5px 12px;
    border-radius: calc(var(--ch-radius-control) - 3px);
    color: var(--ch-text-2);
    font-size: 12.5px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.ch-seg > a:hover,
.ch-seg > button:hover,
.ch-seg > li > a:hover,
.ch-seg > li > button:hover { color: var(--ch-text); }

.ch-seg > .is-active,
.ch-seg > .active,
.ch-seg > li > .is-active,
.ch-seg > li > .active {
    background: var(--ch-surface);
    color: var(--ch-text);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

[data-bs-theme="dark"] .ch-seg > .is-active,
[data-bs-theme="dark"] .ch-seg > .active,
[data-bs-theme="dark"] .ch-seg > li > .is-active,
[data-bs-theme="dark"] .ch-seg > li > .active { background: var(--ch-line-strong); box-shadow: none; }

.ch-seg .badge { padding: 1px 7px; font-size: 10.5px; }
.ch-seg .badge::before { display: none; }

/* ---------- filter strip ---------- */
.ch-filters {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    padding: 12px 20px;
    border-top: 1px solid var(--ch-line);
    border-bottom: 1px solid var(--ch-line);
    background: var(--ch-surface-2);
}

.ch-filters .ch-filters-end {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.ch-search {
    position: relative;
    flex: 1 1 220px;
    max-width: 340px;
    min-width: 0;
}

.ch-search > i {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--ch-text-3);
    font-size: 13px;
    pointer-events: none;
}

.ch-search .form-control {
    padding-left: 34px;
    font-size: 13px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.ch-filters .form-select,
.ch-filters .form-control:not(.ch-search .form-control) {
    width: auto;
    font-size: 12.5px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.btn.ch-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: auto;
    padding: 6px 12px;
    font-size: 12.5px;
    line-height: 1.4;
    overflow: visible;
}

.btn.ch-filter-toggle .ch-count {
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: var(--ch-accent);
    color: var(--ch-on-accent);
    font-size: 10.5px;
    font-weight: 600;
    line-height: 18px;
    text-align: center;
}

[data-bs-theme="dark"] .btn.ch-filter-toggle .ch-count { color: var(--ch-on-accent); }

.ch-filter-panel {
    border-bottom: 1px solid var(--ch-line);
    background: var(--ch-surface-2);
}

.ch-filter-panel-body {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    padding: 0 20px 14px;
    align-items: end;
}

.ch-filter-panel-body .form-select,
.ch-filter-panel-body .form-control {
    width: 100%;
    font-size: 12.5px;
    padding-top: 6px;
    padding-bottom: 6px;
}

.ch-filter-panel-body .form-select { padding-right: 2.25rem; }

.ch-filter-field > label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--ch-text-3);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0 0 4px 12px;
}

.ch-filter-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ch-filter-actions .btn { margin-bottom: 0; }

/* ---------- list table ---------- */
.ch-list .table-responsive,
.ch-section .table-responsive { border: 0; border-radius: 0; background: transparent; }

.ch-list .table > thead th,
.ch-list .table > tbody > tr > *,
.ch-section .table > thead th,
.ch-section .table > tbody > tr > * {
    padding-left: 12px;
    padding-right: 12px;
}

.ch-list .table > :not(caption) > * > *:first-child,
.ch-section .table > :not(caption) > * > *:first-child { padding-left: 20px; }

.ch-list .table > :not(caption) > * > *:last-child,
.ch-section .table > :not(caption) > * > *:last-child { padding-right: 20px; }

.ch-list .table > thead th { background: var(--ch-surface); }

.table .ch-primary,
.table a.ch-primary {
    font-weight: 600;
    color: var(--ch-text);
    text-decoration: none;
}

.table a.ch-primary:hover { color: var(--ch-accent-ink); }

.ch-dim,
.table .ch-sub {
    color: var(--ch-text-3);
    font-size: 12px;
}

.table .ch-sub { display: block; margin-top: 1px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table .ch-mono, .ch-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; }

.table tr.ch-row-click { cursor: pointer; }

.ch-empty-row td {
    color: var(--ch-text-3);
    text-align: center;
    padding: 36px 20px !important;
}

.ch-empty-row i { display: block; font-size: 22px; margin-bottom: 6px; opacity: 0.6; }

/* Row actions: quiet icon buttons that only show colour on hover. */
.ch-row-actions {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    flex-wrap: nowrap;
}

td:has(> .ch-row-actions) { text-align: right; width: 1%; white-space: nowrap; }

.ch-row-actions > .btn,
.ch-row-actions > form > .btn,
.ch-row-actions > .dropdown > .btn {
    --bs-btn-bg: transparent;
    --bs-btn-border-color: transparent;
    --bs-btn-color: var(--ch-text-2);
    --bs-btn-hover-bg: var(--ch-bg);
    --bs-btn-hover-border-color: transparent;
    --bs-btn-hover-color: var(--ch-text);
    --bs-btn-active-bg: var(--ch-line);
    --bs-btn-active-border-color: transparent;
    background: transparent;
    border-color: transparent;
    color: var(--ch-text-2);
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px !important;
    margin: 0;
    font-size: 14px;
}

.ch-row-actions > form { display: inline-flex; margin: 0; }

.ch-row-actions > .btn:hover,
.ch-row-actions > form > .btn:hover,
.ch-row-actions > .dropdown > .btn:hover { background: var(--ch-bg); color: var(--ch-text); }

.ch-row-actions .btn-outline-danger:hover,
.ch-row-actions .btn-danger:hover { color: var(--ch-bad); background: var(--ch-bad-soft); }

.ch-row-actions .btn-outline-success:hover,
.ch-row-actions .btn-success:hover { color: var(--ch-ok); background: var(--ch-ok-soft); }

.ch-row-actions .dropdown-toggle::after { display: none; }

.dropdown-item.text-danger:hover,
.dropdown-item.ch-danger:hover { background: var(--ch-bad-soft); color: var(--ch-bad) !important; }
.dropdown-item.ch-danger { color: var(--ch-bad); }

/* ---------- pager ---------- */
.ch-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    flex-wrap: wrap;
    padding: 10px 20px;
    border-top: 1px solid var(--ch-line);
    color: var(--ch-text-3);
    font-size: 12.5px;
}

.ch-pager-nav { display: flex; align-items: center; gap: 6px; }

.ch-pager-nav .btn {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    font-size: 12px;
}

.ch-pager-nav .btn.disabled { opacity: 0.45; }
.ch-pager-pos { font-variant-numeric: tabular-nums; color: var(--ch-text-2); padding: 0 4px; }

/* A pager rendered outside a list card still gets the strip look. */
.card-body > .ch-pager:last-child,
.ch-pager.ch-pager--bare { border-top: 0; padding-left: 0; padding-right: 0; }

/* ---------- detail view ---------- */
.ch-detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.ch-detail-title {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.015em;
    margin: 0;
}

.ch-detail-sub { color: var(--ch-text-3); font-size: 13px; margin-top: 2px; }

.ch-badges { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }

.ch-kv {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px 24px;
}

.ch-kv .k {
    color: var(--ch-text-3);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.ch-kv .v {
    font-weight: 500;
    margin-top: 3px;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.ch-kv .v.ch-dim { font-weight: 400; }
.ch-kv .span-all { grid-column: 1 / -1; }

.ch-section-title,
.ch-main .ch-section-title,
main .ch-section-title {
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ch-text-3);
    margin: 0 0 10px;
}

.ch-detail-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 12px;
    border: 1px solid var(--ch-line);
    flex: none;
}

.ch-stacked-bar {
    display: flex;
    height: 8px;
    border-radius: 999px;
    overflow: hidden;
    background: var(--ch-bg);
    gap: 2px;
}

.ch-stacked-bar > i { display: block; height: 100%; }
.ch-legend b { color: var(--ch-text); font-weight: 600; margin-left: 2px; }

.ch-category-list { display: flex; flex-direction: column; }

.ch-category-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 0;
    border-bottom: 1px solid var(--ch-line);
}

.ch-category-row:last-child { border-bottom: 0; padding-bottom: 0; }
.ch-category-row:first-child { padding-top: 0; }

.ch-swatch {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex: none;
}

.ch-logo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
}

.ch-logo-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    border: 1px solid var(--ch-line);
    border-radius: var(--ch-radius-sm);
    min-height: 92px;
    text-align: center;
    font-size: 12px;
    color: var(--ch-text-2);
}

.ch-logo-tile img { max-height: 44px; max-width: 100%; object-fit: contain; }

.ch-file-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--ch-bad-soft);
    color: var(--ch-bad);
    font-size: 18px;
    flex: none;
}

/* Detail pages written before the patterns: "muted small label over a value"
   pairs and uppercase section labels read as the key/value grid. */
.ch-main p.mb-1.text-muted.small {
    font-size: 11px !important;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ch-text-3) !important;
    margin-bottom: 3px !important;
}

.ch-main p.mb-1.text-muted.small + p.mb-0 { font-weight: 500; color: var(--ch-text); overflow-wrap: anywhere; }

.ch-main h6.text-uppercase.text-muted.fw-bold.small {
    font-size: 11.5px !important;
    font-weight: 600 !important;
    letter-spacing: 0.05em;
    color: var(--ch-text-3) !important;
}

/* "Label ... value" list rows (metadata, registration details). */
.list-group-item.d-flex.justify-content-between { gap: 16px; align-items: baseline; }
.list-group-item.d-flex.justify-content-between > .text-muted:first-child { flex: none; white-space: nowrap; font-size: 12.5px; }
.list-group-item.d-flex.justify-content-between > :last-child:not(:first-child) { text-align: right; min-width: 0; overflow-wrap: anywhere; }

/* ---------- form page ---------- */
.ch-form-section > .card-body { padding: 20px; }

.ch-form-section .ch-form-head { margin-bottom: 16px; }
.ch-form-section .ch-form-head h5 { font-size: 14px; font-weight: 600; margin: 0; }
.ch-form-section .ch-form-head p { color: var(--ch-text-3); font-size: 12.5px; margin: 2px 0 0; }

/* Floating save bar: stays in reach at the bottom of long forms. */
.ch-form-actions {
    position: sticky;
    bottom: 12px;
    z-index: 5;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
    padding: 10px 12px 10px 20px;
    background: color-mix(in srgb, var(--ch-surface) 94%, transparent);
    backdrop-filter: blur(8px);
    border: 1px solid var(--ch-line);
    border-radius: var(--ch-radius);
    box-shadow: var(--ch-shadow-pop);
}

.ch-form-actions .btn { margin-bottom: 0; }
/* Primary action sits last, where the eye ends up (markup order varies by view). */
.ch-form-actions .btn-primary,
.ch-form-actions .btn-success,
.ch-form-actions .btn-danger { order: 2; }
.ch-form-actions .ch-form-actions-start { margin-right: auto; color: var(--ch-text-3); font-size: 12.5px; }

/* ---------- chips ---------- */
.ch-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 6px 3px 10px;
    border-radius: 999px;
    background: var(--ch-accent-soft);
    color: var(--ch-accent-ink);
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
}

.ch-chip .bi-x { font-size: 14px; opacity: 0.7; }
.ch-chip:hover { color: var(--ch-accent-ink); }
.ch-chip:hover .bi-x { opacity: 1; }

/* ---------- charts ---------- */
.ch-chart {
    position: relative;
    width: 100%;
}

.ch-chart canvas { display: block; }

.ch-legend {
    display: flex;
    gap: 14px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--ch-text-2);
    margin-top: 10px;
}

.ch-legend i {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: -1px;
}

.ch-empty {
    color: var(--ch-text-3);
    padding: 28px 20px;
    text-align: center;
    font-size: 13px;
}

.ch-tip {
    position: absolute;
    pointer-events: none;
    background: var(--ch-surface);
    border: 1px solid var(--ch-line);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--ch-text);
    box-shadow: var(--ch-shadow-pop);
    white-space: nowrap;
    z-index: 5;
    transition: opacity 0.1s ease;
}

.ch-tip b { display: block; margin-bottom: 4px; font-weight: 600; }

/* ---------- auth ---------- */
/* The form sits straight on the page: the page takes the surface colour
   instead of framing the form in a card. */
body:has(.ch-auth-panel) { background: var(--ch-surface); }

.ch-auth-panel {
    width: 100%;
    max-width: 440px;
    margin: auto;
    background: transparent;
    border: 0;
    padding: 24px 20px;
}

.ch-auth-panel.ch-auth-panel--wide { max-width: 620px; }

.ch-auth-panel img.h-150px { height: 96px !important; }

.ch-auth-panel .form-floating > .form-control,
.ch-auth-panel .form-floating > .form-select {
    border-radius: var(--ch-radius-sm);
}

@media (max-width: 575.98px) {
    .ch-auth-panel { padding: 24px 8px; }
}

/* ---------------------------------------------------------------------------
   Dashboard greeting: the top row of a dashboard, not a card
   --------------------------------------------------------------------------- */
.ch-greeting {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "title icon"
        "line  icon"
        "meta  icon";
    align-items: center;
    column-gap: 24px;
    padding: 4px 4px 8px;
    margin-bottom: 16px;
}
.ch-greeting-title { grid-area: title; }
.ch-greeting-line { grid-area: line; justify-self: start; }
.ch-greeting-meta { grid-area: meta; }
.ch-greeting-icon { grid-area: icon; }
.ch-greeting .ch-greeting-title {
    margin: 0 0 8px;
    font-size: 2.25rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--ch-text);
}
.ch-greeting-name { color: var(--ch-accent); }
/* The line: a speech bubble tinted for the time of day, so it reads as
   something said to you rather than a subtitle. */
.ch-greeting .ch-greeting-line {
    position: relative;
    display: inline-flex;
    align-items: flex-start;
    gap: 12px;
    margin: 6px 0 0;
    max-width: 68ch;
    padding: 12px 18px 12px 12px;
    border: 1px solid color-mix(in srgb, var(--ch-greeting-tone) 35%, transparent);
    border-radius: 4px 18px 18px 18px;
    background: color-mix(in srgb, var(--ch-greeting-tone) 12%, var(--ch-surface));
    font-size: 1.1875rem;
    font-weight: 500;
    line-height: 1.45;
    color: var(--ch-text);
    box-shadow: 0 6px 18px -10px color-mix(in srgb, var(--ch-greeting-tone) 60%, transparent);
    animation: ch-greeting-pop 0.5s cubic-bezier(0.2, 0.9, 0.3, 1.25) 0.15s both;
}
.ch-greeting-line-icon {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-top: -2px;
    border-radius: 50%;
    background: var(--ch-greeting-tone);
    color: #fff;
    font-size: 1rem;
    animation: ch-greeting-wiggle 0.7s ease-in-out 0.65s both;
}
.ch-greeting-line-text { padding-top: 2px; }
.ch-greeting-kicker {
    display: block;
    margin-bottom: 2px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: color-mix(in srgb, var(--ch-greeting-tone) 70%, var(--ch-text));
}
@keyframes ch-greeting-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: none; }
}
@keyframes ch-greeting-wiggle {
    0%, 100% { transform: rotate(0); }
    25% { transform: rotate(-14deg) scale(1.1); }
    50% { transform: rotate(10deg) scale(1.1); }
    75% { transform: rotate(-5deg); }
}
@media (prefers-reduced-motion: reduce) {
    .ch-greeting .ch-greeting-line,
    .ch-greeting-line-icon { animation: none; }
}
.ch-greeting-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px 14px;
    margin-top: 12px;
    font-size: 0.875rem;
    color: var(--ch-text-3);
}
.ch-greeting-meta a { text-decoration: none; }
.ch-greeting-meta i { margin-right: 4px; }
.ch-greeting-icon {
    flex: none;
    font-size: 5.25rem;
    line-height: 1;
    color: var(--ch-greeting-tone, var(--ch-accent));
}
.ch-greeting--morning   { --ch-greeting-tone: #f0a23a; }
.ch-greeting--afternoon { --ch-greeting-tone: var(--ch-chart-warn); }
.ch-greeting--evening   { --ch-greeting-tone: #e0703a; }
.ch-greeting--night     { --ch-greeting-tone: #6f7fd8; }
[data-bs-theme="dark"] .ch-greeting--night { --ch-greeting-tone: #a3b0f5; }
[data-bs-theme="dark"] .ch-greeting--evening { --ch-greeting-tone: #f0925f; }

@media (max-width: 575.98px) {
    /* The icon sits beside the heading only; the bubble gets the full width. */
    .ch-greeting {
        column-gap: 16px;
        grid-template-areas:
            "title icon"
            "line  line"
            "meta  meta";
    }
    .ch-greeting .ch-greeting-title { font-size: 1.75rem; margin-bottom: 4px; }
    .ch-greeting .ch-greeting-line { font-size: 1.0625rem; padding: 10px 14px 10px 10px; gap: 10px; }
    .ch-greeting-line-icon { width: 30px; height: 30px; font-size: 0.9rem; }
    .ch-greeting-icon { font-size: 3.5rem; }
}

/* ---------- list tables on phones (table.ch-stack-sm) ----------
   Below 768px each row becomes a small card with one "LABEL  value" line per
   cell, instead of a table that scrolls sideways. ch-table-stack.js copies
   the column headings onto the cells as data-label. */
@media (max-width: 767.98px) {
    .table-responsive:has(> .table.ch-stack-sm) { overflow: visible; }
    .table.ch-stack-sm > thead { display: none; }
    .table.ch-stack-sm,
    .table.ch-stack-sm > tbody,
    .table.ch-stack-sm > tbody > tr { display: block; width: 100%; }
    .table.ch-stack-sm > tbody > tr { padding: 12px 16px; border-bottom: 1px solid var(--ch-line); }
    .table.ch-stack-sm > tbody > tr:last-child { border-bottom: 0; }
    .table.ch-stack-sm > tbody > tr > td {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        gap: 6px 8px;
        min-width: 0;
        padding: 5px 0 !important;
        border: 0;
        white-space: normal;
        text-align: right;
        background: transparent;
    }
    .table.ch-stack-sm > tbody > tr > td::before {
        content: attr(data-label);
        flex: none;
        color: var(--ch-text-3);
        font-size: 11px;
        font-weight: 600;
        letter-spacing: .04em;
        text-transform: uppercase;
        text-align: left;
        margin-right: auto; /* label left, the cell's content gathered on the right */
    }
    .table.ch-stack-sm > tbody > tr > td[data-label=""]::before { content: none; }
    .table.ch-stack-sm > tbody > tr > td[data-label=""] { justify-content: flex-start; text-align: left; }
    .table.ch-stack-sm > tbody > tr > td.is-blank { display: none; }
}
/* Inline code (payment references, etc.) in the palette, not Bootstrap pink. */
code { color: var(--ch-accent-ink); }
/* ---------- button states, final say ----------
   The base theme colours hovered links and outline buttons with its own
   blues, some with !important. These rules outrank them so every button
   keeps readable text in every state and theme. */
html[data-bs-theme] .btn-primary {
    --bs-btn-color: var(--ch-on-accent) !important;
    --bs-btn-bg: var(--ch-accent) !important;
    --bs-btn-border-color: var(--ch-accent) !important;
    --bs-btn-hover-color: var(--ch-on-accent) !important;
    --bs-btn-hover-bg: var(--ch-accent-ink) !important;
    --bs-btn-hover-border-color: var(--ch-accent-ink) !important;
    --bs-btn-active-color: var(--ch-on-accent) !important;
    --bs-btn-active-bg: var(--ch-accent-ink) !important;
    --bs-btn-active-border-color: var(--ch-accent-ink) !important;
    --bs-btn-disabled-color: var(--ch-on-accent) !important;
    --bs-btn-disabled-bg: var(--ch-accent) !important;
    --bs-btn-disabled-border-color: var(--ch-accent) !important;
}

html[data-bs-theme] .btn-outline-primary {
    --bs-btn-color: var(--ch-accent-ink) !important;
    --bs-btn-bg: transparent !important;
    --bs-btn-border-color: var(--ch-line-strong) !important;
    --bs-btn-hover-color: var(--ch-accent-ink) !important;
    --bs-btn-hover-bg: var(--ch-accent-soft) !important;
    --bs-btn-hover-border-color: var(--ch-accent) !important;
    --bs-btn-active-color: var(--ch-accent-ink) !important;
    --bs-btn-active-bg: var(--ch-accent-soft) !important;
    --bs-btn-active-border-color: var(--ch-accent) !important;
}

/* Every button shows its own text colour, whatever hover rule targets links. */
html[data-bs-theme] .btn { color: var(--bs-btn-color) !important; }
html[data-bs-theme] .btn:hover,
html[data-bs-theme] .btn:focus-visible { color: var(--bs-btn-hover-color) !important; }
html[data-bs-theme] .btn:active,
html[data-bs-theme] .btn.active,
html[data-bs-theme] .btn.show { color: var(--bs-btn-active-color) !important; }
html[data-bs-theme] .btn:disabled,
html[data-bs-theme] .btn.disabled { color: var(--bs-btn-disabled-color, var(--bs-btn-color)) !important; }
html[data-bs-theme] .btn:hover i,
html[data-bs-theme] .btn:hover svg,
html[data-bs-theme] .btn:focus-visible i { color: inherit !important; fill: currentColor !important; }

html[data-bs-theme] .btn-danger-soft {
    --bs-btn-color: var(--ch-bad) !important;
    --bs-btn-bg: var(--ch-bad-soft) !important;
    --bs-btn-border-color: transparent !important;
    --bs-btn-hover-color: var(--ch-on-accent) !important;
    --bs-btn-hover-bg: var(--ch-bad) !important;
    --bs-btn-hover-border-color: var(--ch-bad) !important;
    --bs-btn-active-color: var(--ch-on-accent) !important;
    --bs-btn-active-bg: var(--ch-bad) !important;
    background-color: var(--bs-btn-bg) !important;
}
html[data-bs-theme] .btn-danger-soft:hover,
html[data-bs-theme] .btn-danger-soft:active { background-color: var(--bs-btn-hover-bg) !important; }

/* Chart legends: a line series shows as a short stroke; pie entries carry value and share. */
.ch-legend i.is-line { height: 3px !important; border-radius: 2px !important; width: 14px !important; }
.ch-legend--pie { flex-direction: column; align-items: stretch; gap: 6px; }
.ch-legend--pie span { display: flex; align-items: center; gap: 8px; }
.ch-legend--pie b { margin-left: auto; }
.ch-legend--pie small { color: var(--ch-text-3); min-width: 3.2em; text-align: right; }

/* Pagination, final say (same story as the buttons above). */
html[data-bs-theme] .pagination .page-link {
    color: var(--ch-text-2) !important;
    background-color: var(--ch-surface-2) !important;
    border-color: var(--ch-line) !important;
}
html[data-bs-theme] .pagination .page-link:hover,
html[data-bs-theme] .pagination .page-link:focus-visible {
    color: var(--ch-accent-ink) !important;
    background-color: var(--ch-accent-soft) !important;
    border-color: var(--ch-accent) !important;
}
html[data-bs-theme] .pagination .page-item.active .page-link,
html[data-bs-theme] .pagination .page-link.active,
html[data-bs-theme] .pagination .page-item.active .page-link:hover {
    color: var(--ch-on-accent) !important;
    background-color: var(--ch-accent) !important;
    border-color: var(--ch-accent) !important;
}
html[data-bs-theme] .pagination .page-item.disabled .page-link {
    color: var(--ch-text-3) !important;
    background-color: transparent !important;
}
html[data-bs-theme] .pagination .page-link:hover i,
html[data-bs-theme] .pagination .page-link:hover svg { color: inherit !important; fill: currentColor !important; }

/* Footer links are small; keep them at full text contrast. */
.ch-footer, .ch-footer-links a { color: var(--ch-text-2); }
.ch-footer-links a:hover { color: var(--ch-text); }
/* ---------- date fields ---------- */
/* Native date inputs (admin): themed picker chrome and a calendar icon in our ink. */
input.form-control[type="date"],
input.form-control[type="datetime-local"],
input.form-control[type="time"],
input.form-control[type="month"] { color-scheme: light; min-height: 38px; }
html[data-bs-theme="dark"] input.form-control[type="date"],
html[data-bs-theme="dark"] input.form-control[type="datetime-local"],
html[data-bs-theme="dark"] input.form-control[type="time"],
html[data-bs-theme="dark"] input.form-control[type="month"] { color-scheme: dark; }
input.form-control::-webkit-calendar-picker-indicator {
    cursor: pointer; opacity: .55; border-radius: 6px; padding: 3px; margin-right: -4px;
}
input.form-control::-webkit-calendar-picker-indicator:hover { opacity: 1; background-color: var(--ch-hover); }
input.form-control::-webkit-datetime-edit-fields-wrapper { padding: 0; }
/* Two tiles per row on phones: money values shrink with the screen so they stay inside the card. */
@media (max-width: 575.98px) {
    .ch-tile .ch-tile-value { font-size: clamp(19px, 5.6vw, 30px); }
}

/* A card that opens and closes (<details class="card ch-disclosure">). */
.ch-disclosure > summary { cursor: pointer; list-style: none; }
.ch-disclosure > summary::-webkit-details-marker { display: none; }
.ch-disclosure > summary .bi-chevron-down { color: var(--ch-text-3); transition: transform .15s ease; }
.ch-disclosure[open] > summary .bi-chevron-down { transform: rotate(180deg); }

/* ==========================================================================
   LoanAcre: brand pieces
   ========================================================================== */
/* The client's logo: the light-surface version in the light theme, the
   original artwork in the dark theme (partials/ui/brand_logo.php). */
img.vt-logo { display: block; height: auto; max-width: 100%; }
img.vt-logo.vt-logo--dark { display: none; }
[data-bs-theme="dark"] img.vt-logo.vt-logo--light { display: none; }
[data-bs-theme="dark"] img.vt-logo.vt-logo--dark { display: block; }
/* Until the brand is published, the client's name stands in for the logo. */
.vt-logo-text {
    display: block;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -.01em;
    line-height: 1.2;
    color: var(--ch-text);
}

/* Sidebar brand: the logo with the portal name beneath it. */
.ch-brand {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 8px 18px;
}
.ch-brand img.ch-brand-logo { width: 156px; height: auto; }
.ch-brand .ch-brand-name { margin-left: 2px; }

/* The signature gradient, once per screen: a hairline along the top of the
   sidebar card, and along the top of sign-in and public pages. */
.ch-sidebar::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 3px;
    background: var(--ch-gradient);
    z-index: 2;
}

.vt-auth-stripe {
    position: fixed;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--ch-gradient);
    z-index: 1030;
}

/* Top bar: today's date, quietly; the page brings its own heading. */
.ch-topbar-date {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ch-text-2);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}
.ch-topbar-date i { color: var(--ch-text-3); }
/* On phones the sidebar folds away, so the logo rides in the top bar. */
.ch-topbar-brand { display: block; width: 112px; }
@media (min-width: 576px) and (max-width: 991.98px) {
    .ch-topbar-brand { margin-right: 8px; }
}

/* The footer credit on every page. */
.vt-credit {
    margin: 0;
    color: var(--ch-text-3);
    font-size: 12px;
    letter-spacing: 0.01em;
}

/* ---------- sign-in pages ---------- */
body.vt-auth {
    background: var(--ch-surface);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.vt-auth-main {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    padding: 56px 0 24px;
}

.vt-auth-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 36px;
}

.vt-auth-logo { display: block; width: 190px; }

.vt-auth-title {
    font-size: 26px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin: 0 0 6px;
}

.vt-auth-lead {
    color: var(--ch-text-2);
    font-size: 14.5px;
    margin: 0 0 24px;
}

.vt-auth-alt {
    margin: 22px 0 0;
    color: var(--ch-text-2);
    text-align: center;
}

.vt-auth-icon {
    display: inline-grid;
    place-items: center;
    width: 52px;
    height: 52px;
    margin-bottom: 18px;
    border-radius: 50%;
    background: var(--ch-accent-soft);
    color: var(--ch-accent);
    font-size: 22px;
}

.vt-password-toggle {
    position: absolute;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    z-index: 5;
}

.vt-code-input {
    letter-spacing: 0.35em;
    font-weight: 600;
    text-align: center;
}

.vt-powered {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 40px 0 0;
    padding-top: 20px;
    border-top: 1px solid var(--ch-line);
    color: var(--ch-text-3);
    font-size: 12.5px;
}
.vt-powered img { width: 18px; height: auto; }
.vt-powered strong { color: var(--ch-text); font-weight: 600; }

.vt-auth-foot {
    flex: none;
    padding: 18px 20px 22px;
    text-align: center;
}

.ch-auth-panel .form-floating > label { color: var(--ch-text-3); }
.ch-auth-panel .btn-lg { --bs-btn-padding-y: 11px; font-weight: 600; }

/* ---------- public pages (intake forms) ---------- */
body.vt-public { background: var(--ch-bg); }

.vt-public-head {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 36px 16px 8px;
    text-align: center;
}
.vt-public-logo { width: 170px; }
.vt-public-title {
    color: var(--ch-text-2);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.vt-public-main { max-width: 1140px; padding-top: 20px; padding-bottom: 32px; }
.vt-public-foot {
    padding: 8px 16px 28px;
    text-align: center;
}

/* ==========================================================================
   Bridge: the base theme's dashboard components on the tokens
   ========================================================================== */
/* Pages bring their own <main class="main"><div class="content container-fluid">;
   inside the shell those are plain wrappers. */
.ch-main > .main,
.ch-main > main.main { padding: 0 !important; margin: 0; }
.ch-main .content.container-fluid,
.ch-main .content.container { padding: 0; max-width: none; }

/* Page header: the page's own title, description and actions. */
.page-header {
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 20px;
}
.page-header .breadcrumb { margin-bottom: 6px; }
.page-header-title,
.ch-main .page-header-title {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}
.page-header-text { color: var(--ch-text-3); font-size: 13.5px; margin-bottom: 0; }
.page-header-tabs { margin-bottom: 0; }

/* Card heads written with the base theme's classes. */
.card > .card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--ch-line);
}
.card > .card-header:not(.border-bottom) { border-bottom: 1px solid var(--ch-line); padding-bottom: 14px; }
.card-header-title,
.card > .card-header .card-header-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ch-text);
    margin: 0;
    letter-spacing: 0;
}
.card-header-content-between { gap: 12px; flex-wrap: wrap; }
.card-subtitle {
    display: block;
    color: var(--ch-text-3);
    font-size: 11.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
}
.card-text { color: var(--ch-text-2); }
.card-hover-shadow { transition: border-color 0.15s ease, box-shadow 0.15s ease; }
.card-hover-shadow:hover { box-shadow: var(--ch-shadow-pop) !important; border-color: var(--ch-line-strong) !important; }
.card .card-title.h2,
.card .h2.card-title { font-size: clamp(18px, 1.55vw, 24px); font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.card-footer { background: transparent; border-color: var(--ch-line); padding: 12px 20px; }
.text-cap { color: var(--ch-text-3); font-size: 11px; letter-spacing: 0.05em; }

/* Tables. */
.card .card-table > :not(caption) > * > * { padding-left: 12px; padding-right: 12px; }
.card .card-table > :not(caption) > * > *:first-child { padding-left: 20px; }
.card .card-table > :not(caption) > * > *:last-child { padding-right: 20px; }
.card .card-table > tbody > tr:first-child > td { padding-top: 12px; }
.card .card-table > tbody > tr:last-child > td { padding-bottom: 12px; }
.thead-light th,
.table .thead-light th { background-color: var(--ch-surface-2); }
.table-thead-bordered > :not(:last-child) > :last-child > * {
    border-top: 1px solid var(--ch-line);
    border-bottom: 1px solid var(--ch-line);
}
.card > .table-responsive:first-child .table-thead-bordered > thead > tr > *,
.card > .card-header + .table-responsive .table-thead-bordered > thead > tr > * { border-top: 0; }
.table-align-middle > :not(caption) > * > * { vertical-align: middle; }
.table-borderless.table-thead-bordered > tbody > tr > * { border-bottom: 1px solid var(--ch-line); }
.table-borderless.table-thead-bordered > tbody > tr:last-child > * { border-bottom: 0; }
.table-sm > :not(caption) > * > * { padding-top: 6px; padding-bottom: 6px; }

/* Soft backgrounds, alerts, buttons and avatars on the soft/ink pairs. */
.bg-soft-primary { background-color: var(--ch-accent-soft) !important; }
.bg-soft-success { background-color: var(--ch-ok-soft) !important; }
.bg-soft-warning { background-color: var(--ch-warn-soft) !important; }
.bg-soft-danger { background-color: var(--ch-bad-soft) !important; }
.bg-soft-info { background-color: var(--ch-info-soft) !important; }
.bg-soft-secondary,
.bg-soft-dark { background-color: var(--ch-bg) !important; }

.badge.bg-soft-primary { color: var(--ch-accent-ink) !important; }
.badge.bg-soft-success { color: var(--ch-ok) !important; }
.badge.bg-soft-warning { color: var(--ch-warn) !important; }
.badge.bg-soft-danger { color: var(--ch-bad) !important; }
.badge.bg-soft-info { color: var(--ch-info) !important; }
.badge.bg-soft-secondary,
.badge.bg-soft-dark { color: var(--ch-text-2) !important; }
.badge.text-white,
.badge.text-dark { color: inherit; }

[data-bs-theme] .alert-soft-primary { background-color: var(--ch-accent-soft); color: var(--ch-accent-ink); }
[data-bs-theme] .alert-soft-info { background-color: var(--ch-info-soft); color: var(--ch-info); }
[data-bs-theme] .alert-soft-success { background-color: var(--ch-ok-soft); color: var(--ch-ok); }
[data-bs-theme] .alert-soft-warning { background-color: var(--ch-warn-soft); color: var(--ch-warn); }
[data-bs-theme] .alert-soft-danger { background-color: var(--ch-bad-soft); color: var(--ch-bad); }
[data-bs-theme] .alert-soft-secondary,
[data-bs-theme] .alert-soft-dark { background-color: var(--ch-bg); color: var(--ch-text-2); }
[data-bs-theme] [class*="alert-soft-"] .alert-link { color: inherit; text-decoration: underline; }
[data-bs-theme] .alert-info { --bs-alert-bg: var(--ch-info-soft); --bs-alert-color: var(--ch-info); --bs-alert-link-color: var(--ch-info); }
.alert { border-radius: var(--ch-radius-sm); }

html[data-bs-theme] .btn-soft-primary { --bs-btn-color: var(--ch-accent-ink); --bs-btn-bg: var(--ch-accent-soft); --bs-btn-border-color: transparent; --bs-btn-hover-color: var(--ch-on-accent); --bs-btn-hover-bg: var(--ch-accent); --bs-btn-hover-border-color: var(--ch-accent); --bs-btn-active-color: var(--ch-on-accent); --bs-btn-active-bg: var(--ch-accent); background-color: var(--bs-btn-bg); border-color: transparent; }
html[data-bs-theme] .btn-soft-success { --bs-btn-color: var(--ch-ok); --bs-btn-bg: var(--ch-ok-soft); --bs-btn-border-color: transparent; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--ch-ok); --bs-btn-hover-border-color: var(--ch-ok); --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--ch-ok); background-color: var(--bs-btn-bg); border-color: transparent; }
html[data-bs-theme] .btn-soft-warning { --bs-btn-color: var(--ch-warn); --bs-btn-bg: var(--ch-warn-soft); --bs-btn-border-color: transparent; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--ch-warn); --bs-btn-hover-border-color: var(--ch-warn); --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--ch-warn); background-color: var(--bs-btn-bg); border-color: transparent; }
html[data-bs-theme] .btn-soft-danger { --bs-btn-color: var(--ch-bad); --bs-btn-bg: var(--ch-bad-soft); --bs-btn-border-color: transparent; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--ch-bad); --bs-btn-hover-border-color: var(--ch-bad); --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--ch-bad); background-color: var(--bs-btn-bg); border-color: transparent; }
html[data-bs-theme] .btn-soft-info { --bs-btn-color: var(--ch-info); --bs-btn-bg: var(--ch-info-soft); --bs-btn-border-color: transparent; --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--ch-info); --bs-btn-hover-border-color: var(--ch-info); background-color: var(--bs-btn-bg); border-color: transparent; }
html[data-bs-theme] .btn-soft-secondary { --bs-btn-color: var(--ch-text-2); --bs-btn-bg: var(--ch-bg); --bs-btn-border-color: transparent; --bs-btn-hover-color: var(--ch-text); --bs-btn-hover-bg: var(--ch-line); --bs-btn-hover-border-color: transparent; background-color: var(--bs-btn-bg); border-color: transparent; }
html[data-bs-theme] :is(.btn-soft-primary, .btn-soft-success, .btn-soft-warning, .btn-soft-danger, .btn-soft-info, .btn-soft-secondary):hover { background-color: var(--bs-btn-hover-bg); border-color: var(--bs-btn-hover-border-color); }

html[data-bs-theme] .btn-ghost-secondary { --bs-btn-color: var(--ch-text-2); --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-hover-color: var(--ch-text); --bs-btn-hover-bg: var(--ch-bg); --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: var(--ch-line); background-color: transparent; }
html[data-bs-theme] .btn-ghost-danger { --bs-btn-color: var(--ch-bad); --bs-btn-bg: transparent; --bs-btn-border-color: transparent; --bs-btn-hover-color: var(--ch-bad); --bs-btn-hover-bg: var(--ch-bad-soft); --bs-btn-hover-border-color: transparent; --bs-btn-active-bg: var(--ch-bad-soft); background-color: transparent; }
html[data-bs-theme] :is(.btn-ghost-secondary, .btn-ghost-danger):hover { background-color: var(--bs-btn-hover-bg); }

html[data-bs-theme] .btn-warning { --bs-btn-color: #fff; --bs-btn-bg: var(--ch-chart-warn); --bs-btn-border-color: var(--ch-chart-warn); --bs-btn-hover-color: #fff; --bs-btn-hover-bg: var(--ch-warn); --bs-btn-hover-border-color: var(--ch-warn); --bs-btn-active-color: #fff; --bs-btn-active-bg: var(--ch-warn); }
html[data-bs-theme] .btn-success,
html[data-bs-theme] .btn-danger { --bs-btn-color: #fff; --bs-btn-hover-color: #fff; --bs-btn-active-color: #fff; }

.btn-white { --bs-btn-bg: var(--ch-surface); }
.btn-icon { display: inline-flex; align-items: center; justify-content: center; }

.avatar { border-radius: 50%; }
.avatar-initials { border-radius: 50%; }
.avatar-soft-primary .avatar-initials { background-color: var(--ch-accent-soft); color: var(--ch-accent-ink); }
.avatar-soft-success .avatar-initials { background-color: var(--ch-ok-soft); color: var(--ch-ok); }
.avatar-soft-warning .avatar-initials { background-color: var(--ch-warn-soft); color: var(--ch-warn); }
.avatar-soft-danger .avatar-initials { background-color: var(--ch-bad-soft); color: var(--ch-bad); }

/* Segmented control (the base theme's nav-segment). */
.nav-segment {
    background: var(--ch-bg);
    border-radius: var(--ch-radius-control);
    padding: 3px;
}
.nav-segment .nav-link {
    color: var(--ch-text-2);
    font-size: 12.5px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: calc(var(--ch-radius-control) - 3px);
}
.nav-segment .nav-link:hover { color: var(--ch-text); }
.nav-segment .nav-link.active { background: var(--ch-surface); color: var(--ch-text); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
[data-bs-theme="dark"] .nav-segment .nav-link.active { background: var(--ch-line-strong); box-shadow: none; }

/* Inputs the base theme draws itself. */
.input-group-merge { border: 0; border-radius: var(--ch-radius-control); overflow: visible; }
.input-group-merge .form-control { border-width: 1px; }
.form-label-link { font-size: 12.5px; font-weight: 500; }
.form-switch .form-check-input { border-radius: 2em; }
.form-control-lg, .form-select-lg { font-size: 15px; padding-top: 10px; padding-bottom: 10px; }
.form-floating > .form-control,
.form-floating > .form-select { height: calc(3.5rem + 2px); padding: 1.625rem 14px 0.625rem; }
.form-floating > label { padding: 1rem 14px; }
.required-indicator { color: var(--ch-bad); }

/* Tabs keep their pills but sit on the tokens. */
.nav-tabs { border-bottom: 1px solid var(--ch-line); }
.nav-tabs .nav-link { margin-bottom: -1px; }

/* Utility colours the base theme fixes in place. */
[data-bs-theme="dark"] .bg-white { background-color: var(--ch-surface) !important; }
[data-bs-theme="dark"] .bg-light { background-color: var(--ch-surface-2) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--ch-text) !important; }
[data-bs-theme="dark"] .text-body { color: var(--ch-text) !important; }
[data-bs-theme="dark"] .border,
[data-bs-theme="dark"] .border-top,
[data-bs-theme="dark"] .border-bottom,
[data-bs-theme="dark"] .border-start,
[data-bs-theme="dark"] .border-end { border-color: var(--ch-line) !important; }
.text-body { color: var(--ch-text) !important; }
.bg-light { background-color: var(--ch-surface-2) !important; }
.border-primary { border-color: var(--ch-accent) !important; }
.text-secondary { color: var(--ch-text-2) !important; }

/* Images with a light and a dark variant (payment gateway logos). */
[data-hs-theme-appearance="dark"] { display: none !important; }
[data-bs-theme="dark"] [data-hs-theme-appearance="dark"] { display: inline-block !important; }
[data-bs-theme="dark"] [data-hs-theme-appearance="default"] { display: none !important; }

/* Lists, modals and dropdowns in dark mode. */
.list-group-item { background-color: var(--bs-list-group-bg); color: var(--ch-text); border-color: var(--ch-line); }
.modal-content { background-color: var(--ch-surface); color: var(--ch-text); }
.modal-header, .modal-footer { border-color: var(--ch-line); }
.lms-modal-content { border: 1px solid var(--ch-line); box-shadow: var(--ch-shadow-pop); }
.dropdown-item { color: var(--ch-text); }
.dropdown-item:hover, .dropdown-item:focus { background-color: var(--ch-bg); color: var(--ch-text); }
.dropdown-divider { border-color: var(--ch-line); }

/* Native selects draw their chevron for a light surface; give dark mode a light one. */
[data-bs-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23b3bbcc' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}

/* Text the base theme paints a fixed dark grey; follow the theme instead. */
dt, dd, caption,
.breadcrumb, .breadcrumb .breadcrumb-item, .breadcrumb .breadcrumb-link,
.form-check-label, .form-control-plaintext, .accordion-button,
.blockquote-footer, .figure-caption, .table tr, .nav, .dropdown-item-icon, .list-group-icon {
    color: inherit;
}
dt { color: var(--ch-text-2); font-weight: 500; }
dd { color: var(--ch-text); }
.breadcrumb .breadcrumb-item.active { color: var(--ch-text-3); }
.breadcrumb .breadcrumb-item + .breadcrumb-item::before { color: var(--ch-text-3); }
.form-control-plaintext { color: var(--ch-text); }
.img-thumbnail { background-color: var(--ch-surface); border-color: var(--ch-line); }
.avatar:not(img) { background-color: transparent; }
kbd { background-color: var(--ch-navy); color: #fff; }

/* Wide tables scroll sideways inside their card with a slim scrollbar. */
.table-responsive { scrollbar-width: thin; scrollbar-color: var(--ch-line-strong) transparent; }

/* Empty-state rows ("No loans yet…") span the table and wrap like text. */
.table-nowrap > tbody > tr > td[colspan] { white-space: normal; }
