/* Readable text in both themes (2026-10-22). Loaded after coreui.min.css and the page's own stylesheet by every layout
 * (the signed-in sidebar and the sign-in pages), so it wins on equal specificity.
 *
 * Found by measuring the contrast of every visible text on every page in light, dark-by-system and dark-by-pick
 * (WCAG: 4.5:1, 3:1 for large text). The causes:
 *  - CoreUI's dark palette keeps the light theme's emphasis and subtle colours: text-*-emphasis was near-black on the
 *    dark page, bg-*-subtle badges stayed pale under white text, primary turned CoreUI's own purple, and secondary
 *    outline buttons stayed #6b7785 (3.3:1 on the dark cards);
 *  - the dark sidebar's section titles at 38 % white;
 *  - status colours made for bars (bright green, amber) also used as text on white;
 *  - text-warning (#f9b115) as text on white.
 * The theme itself now lives on both attributes, data-coreui-theme and data-bs-theme (fit/theme-init.js, color-modes.js).
 */

/* ---- dark: CoreUI tokens ----------------------------------------------------------------------------------- */
[data-coreui-theme=dark] {
    --cui-primary: #C6A790; /* the brand's copper (2026-11-29): 7.8:1 on the night page */
    --cui-primary-rgb: 198, 167, 144;
    --cui-link-color: #C6A790;
    --cui-link-color-rgb: 198, 167, 144;
    --cui-link-hover-color: #D9C2B0;
    --cui-link-hover-color-rgb: 217, 194, 176;
    --cui-success: #43c06b;
    --cui-success-rgb: 67, 192, 107;
    --cui-danger: #f07373;
    --cui-danger-rgb: 240, 115, 115;
    --cui-tertiary-color: rgba(245, 242, 237, 0.62);

    /* Text on the dark page: light tints. */
    --cui-primary-text-emphasis: #D9C2B0;
    --cui-secondary-text-emphasis: #D4CCD0;
    --cui-success-text-emphasis: #7fdca0;
    --cui-info-text-emphasis: #7fd9f0;
    --cui-warning-text-emphasis: #ffd56b;
    --cui-danger-text-emphasis: #f5a3a3;
    --cui-light-text-emphasis: #f3f4f7;
    --cui-dark-text-emphasis: #E3DDE0;

    /* Subtle surfaces on the dark page: dark tints, so the emphasis text above reads on them. */
    --cui-primary-bg-subtle: #392D35;
    --cui-secondary-bg-subtle: #30272D;
    --cui-success-bg-subtle: #10301d;
    --cui-info-bg-subtle: #0b2f3a;
    --cui-warning-bg-subtle: #3a2c06;
    --cui-danger-bg-subtle: #3d1519;
    --cui-light-bg-subtle: #30272D;
    --cui-dark-bg-subtle: #1D181C;
    --cui-primary-border-subtle: #675351;
    --cui-secondary-border-subtle: #574A52;
    --cui-success-border-subtle: #1d6b3a;
    --cui-info-border-subtle: #0e6a80;
    --cui-warning-border-subtle: #8a6a10;
    --cui-danger-border-subtle: #8a2a33;
}

/* Solid primary surfaces (step dots, bg-primary chips): copper, with ink text (css/fit/brand.css; 2026-11-28, they were a
 * deep blue that carried white text). */
[data-coreui-theme=dark] .bg-primary {
    background-color: #C6A790 !important;
}

/* ---- dark: outline buttons ---------------------------------------------------------------------------------- */
[data-coreui-theme=dark] .btn-outline-primary {
    --cui-btn-color: #C6A790;
    --cui-btn-border-color: #C6A790;
    --cui-btn-hover-color: #292126;
    --cui-btn-hover-bg: #C6A790;
    --cui-btn-hover-border-color: #C6A790;
    --cui-btn-active-color: #292126;
    --cui-btn-active-bg: #B1927C;
    --cui-btn-active-border-color: #B1927C;
    --cui-btn-disabled-color: #C6A790;
    --cui-btn-disabled-border-color: #C6A790;
}
[data-coreui-theme=dark] .btn-outline-secondary {
    --cui-btn-color: #b4bdc8;
    --cui-btn-border-color: #5d6878;
    --cui-btn-hover-color: #fff;
    --cui-btn-hover-bg: #4d5767;
    --cui-btn-hover-border-color: #5d6878;
    --cui-btn-active-color: #fff;
    --cui-btn-active-bg: #4d5767;
    --cui-btn-active-border-color: #5d6878;
    --cui-btn-disabled-color: #8a94a1;
    --cui-btn-disabled-border-color: #4d5767;
}
[data-coreui-theme=dark] .btn-outline-success {
    --cui-btn-color: #43c06b;
    --cui-btn-border-color: #43c06b;
    --cui-btn-active-bg: #1f7a3d;
    --cui-btn-active-border-color: #1f7a3d;
    --cui-btn-active-color: #fff;
}
[data-coreui-theme=dark] .btn-outline-danger {
    --cui-btn-color: #f07373;
    --cui-btn-border-color: #f07373;
    --cui-btn-active-bg: #b83a3a;
    --cui-btn-active-border-color: #b83a3a;
    --cui-btn-active-color: #fff;
}
[data-coreui-theme=dark] .dropdown-menu {
    --cui-dropdown-header-color: #aab3c5;
}

/* ---- light ------------------------------------------------------------------------------------------------- */
.btn-outline-secondary {
    --cui-btn-color: #56606d;
    --cui-btn-active-bg: #565f6b;
    --cui-btn-active-border-color: #565f6b;
}
:root:not([data-coreui-theme=dark]) .btn-outline-success {
    --cui-btn-color: #177a35;
    --cui-btn-border-color: #177a35;
    --cui-btn-active-bg: #177a35;
    --cui-btn-active-border-color: #177a35;
}
:root:not([data-coreui-theme=dark]) {
    --cui-secondary-bg-subtle: #e2e5e9;
}
.dropdown-menu {
    --cui-dropdown-header-color: #56627a;
}
:root:not([data-coreui-theme=dark]) .text-warning {
    color: #9a5b06 !important;
}
:root:not([data-coreui-theme=dark]) .text-success {
    color: #177a35 !important;
}
:root:not([data-coreui-theme=dark]) .text-danger {
    color: #c43c3c !important;
}

/* ---- both ------------------------------------------------------------------------------------------------- */
/* The sidebar is dark in both themes: its section titles at 60 % white instead of 38 %. */
.sidebar-dark .sidebar-nav .nav-title {
    color: rgba(255, 255, 255, 0.6);
}

/* Solid status surfaces under white text: shades deep enough for it in both themes (CoreUI's #1b9e3e and #6b7785
 * carried white at 3.5:1 and 3.4:1, and the lighter dark-theme success above would drop it to 2.3:1). */
.bg-success {
    background-color: #1d7a3a !important;
}
.bg-danger {
    background-color: #b83a3a !important;
}
.bg-secondary {
    background-color: #565f6b !important;
}
.pagination {
    --cui-pagination-active-bg: #C6A790; /* copper with ink text, as css/fit/brand.css fills the primary (2026-11-28) */
    --cui-pagination-active-border-color: #C6A790;
    --cui-pagination-active-color: #292126;
}
:root:not([data-coreui-theme=dark]) .btn-outline-danger {
    --cui-btn-color: #c43c3c;
    --cui-btn-border-color: #c43c3c;
}

/* A muted line inside a selected toggle button follows the button's text, not the page's muted colour. */
.btn-check:checked + .btn .text-body-secondary {
    color: inherit !important;
    opacity: 0.85;
}

/* A status colour made for a bar (#22C55E, #F59E0B, …) shown as text: the same hue, darkened on a light page and
 * lightened on a dark one. Templates set --fit-status instead of color. */
.fit-status-text {
    color: color-mix(in srgb, var(--fit-status, currentColor) 62%, #000);
}
[data-coreui-theme=dark] .fit-status-text {
    color: color-mix(in srgb, var(--fit-status, currentColor) 70%, #fff);
}

/* A category glyph on its own colour's pale tint (yellow on pale yellow was 1.8:1): a deeper shade of the same hue on
 * a light page, a slightly lighter one on a dark page, so the icon keeps its category colour and reaches 3:1. */
.fit-glyph {
    color: color-mix(in srgb, var(--fit-glyph, currentColor) 70%, #000);
}
[data-coreui-theme=dark] .fit-glyph {
    color: color-mix(in srgb, var(--fit-glyph, currentColor) 82%, #fff);
}
/* The picked icon in the category form: a light frame instead of the solid grey that hid a coloured glyph. */
#category-icon-picker .btn-check:checked + .btn {
    background-color: var(--cui-tertiary-bg);
    border: 2px solid var(--cui-primary);
}

/* An ended budget, a dormant savings goal, a closed account or a paused recurring transaction: drained of colour rather than faded, so its text stays readable. */
[data-fit-dormant=true] {
    filter: saturate(0.25);
}
