/*
 * core_tokens.css - the shared design values of the platform.
 *
 * =====================================================================
 * WHAT THIS FILE IS
 * =====================================================================
 * The ONE source for colour, spacing, radius, shadow and type.
 * Loaded globally in `templates/base_generic.html`, BEFORE style.css and
 * before `{% block extra_css %}` - every file after it can read it.
 *
 * It also carries the dark mode: `:root[data-theme="dark"]` resets the
 * BASE values; all derived names follow on their own, because CSS resolves
 * variables only when they are used.
 *
 * =====================================================================
 * WHY IT WAS REBUILT ON 09.11.2026
 * =====================================================================
 * Measured on 09.11.2026 over all 346 own CSS files:
 *
 *     4 818 uses of var(--...)
 *     1 525 of them pointed to names that existed NOWHERE
 *       1 419 fell back to their built-in hex value
 *         106 had no effect at all (no fallback, rule invalid)
 *
 * The apps reached for `--primary-color`, `--border-color`, `--text-muted`.
 * The old version of this file defined the same things under other names
 * (`--color-primary`, ...). So no colour could be changed centrally, even
 * though var() was used everywhere.
 *
 * NOW the names that are USED are the main names. The old `--color-*`
 * stay as references, so the 84 templates that already include this file
 * keep working unchanged.
 *
 * =====================================================================
 * THE PALETTE - DECIDED, NOT GUESSED
 * =====================================================================
 * Decision (Pierre, 09.11.2026): ONE platform palette. Where a name was used
 * with several fallback values, the most frequent one platform-wide wins;
 * the other places change visibly. Counted over all CSS files:
 *
 *     Blue    #007bff 1126x   (vs. #0d6efd 414x, #3b82f6 ~95x)
 *     Grey    #6c757d 1658x
 *     Ground  #f8f9fa  940x   (vs. #f9fafb 44x, #f3f4f6 50x)
 *     Border  #dee2e6  806x   (vs. #e5e7eb, #d1d5db, #e0e0e0)
 *     light   #e9ecef  692x
 *     Text    #495057  525x / #212529 286x
 *     Red     #dc3545  463x
 *     Green   #198754         (NOT the more frequent #28a745 - see below)
 *     Amber   #ffc107  224x   (vs. #f59e0b 37x, #fd7e14 44x)
 *     Info    #117a8b         (NOT the more frequent #17a2b8 - see below)
 *
 * TWO EXCEPTIONS TO "THE MOST FREQUENT WINS" - calculated on 09.11.2026:
 *   In their frequent variant green and teal carry NO readable white text:
 *   #28a745 only 3.13 and #17a2b8 only 3.04 (AA needs 4.5). Both were like
 *   that before the token layer. So the darker variant that carries white
 *   was chosen: #198754 = 4.53 (used 130x in the codebase, and in the
 *   approved plan) and #117a8b = 5.02.
 *
 * TWO GREYS FOR "HOVER" STAY - on purpose:
 *   --hover-bg         #f8f9fa  row on a white surface
 *   --hover-bg-strong  #f0f0f0  row on an already grey surface (#f8f9fa)
 * Pulling both to #f8f9fa would make the second kind INVISIBLE.
 *
 * =====================================================================
 * TWO ROLES FOR ACCENT COLOURS
 * =====================================================================
 * A lightened blue is good as text and bad as a fill. Measured
 * (WCAG contrast against the dark card #1e1e1e or white text on it):
 *
 *     #4da3ff as text on #1e1e1e         = 6.3   good
 *     white text on #4da3ff              = 2.6   unreadable
 *     #007bff as fill, white text        = 4.0   as in light mode today
 *
 * Therefore:
 *     --primary-color   fill (buttons, progress) - carries white text
 *     --primary-ink     text, links, icons on a surface
 *                     The reference surface is NOT white but #f0f0f0
 *                     (--hover-bg-strong): on a slightly grey card
 *                     #198754 reached only 3.98 on 10.11.2026, measured
 *                     67 times on the QMS badges. The difference to
 *                     white is five RGB units.
 * In light mode both are equal (nothing changes), in dark mode they are not.
 *
 * =====================================================================
 * WHAT DOES NOT BELONG HERE
 * =====================================================================
 * Module-specific names (--tel-*, --sm-*, --mail-*, --tasks-*, --cal-*, ...)
 * stay in their modules. This file only knows what more than one module
 * needs.
 */

/* =====================================================================
   1. BASE VALUES - light. Only these are reset in dark mode.
   ===================================================================== */
:root {
    color-scheme: light;

    /* ---- Surfaces --------------------------------------------------- */
    --surface:            #ffffff;   /* card, dialog, input field        */
    --surface-sunken:     #f8f9fa;   /* page ground, table head          */
    --surface-raised:     #ffffff;   /* above the card (dropdown)        */
    --surface-tertiary:   #e9ecef;   /* third level, progress track      */
    --hover-bg:           #f8f9fa;   /* hover on a white surface         */
    --hover-bg-strong:    #f0f0f0;   /* hover on a grey surface          */
    --overlay-bg:         rgba(0, 0, 0, 0.5);   /* behind the dialog     */

    /* ---- Borders ---------------------------------------------------- */
    --border-color:       #dee2e6;   /* default border                   */
    --border-light:       #e9ecef;   /* separators in lists              */
    --border-strong:      #ced4da;   /* form fields                      */

    /* ---- Controls: their own calculation ----------------------------
       A border around an input is not text, but not decoration either:
       WCAG 1.4.11 requires 3.0 against the surface for controls.
       #ced4da (Bootstrap) reaches 1.49 on white, #e9ecef 1.19 - on
       10.11.2026 that was exactly the report "on pages with forms I no
       longer see the fields". They were there; nobody could see them.
       --border-strong stays for separators; whoever outlines a CONTROL
       uses --input-border.                                             */
    --input-border:       #909499;   /* 3.05 on #ffffff                  */
    --input-border-hover: #6c757d;   /* 4.69 - hover/active              */
    --switch-off:         #6c757d;   /* switch OFF, 4.69 on #ffffff      */

    /* ---- Text on a FIXED coloured surface ------------------------------
       --text-on-accent flips with the COMPANY colour: if it is light, the
       text turns black. That is right on the accent surface and wrong
       everywhere else - on a brand badge (#0078d4), a fixed gradient
       (#667eea -> #764ba2) or a dark speech bubble (#333) white stays the
       only readable colour, whatever the company. On 10.11.2026, 87 such
       rules used --text-on-accent.
       This value NEVER changes - neither with the theme nor with the
       company. That is why it lives only here.                         */
    --on-brand:           #ffffff;

    /* Text in <code>. #e83e8c (Bootstrap) reaches only 3.62 on #f8f9fa;
       the log pages show 54 keys per page in it.                        */
    --code-ink:           #ba3270;   /* 4.52 on #f0f0f0 */

    /* ---- Surfaces that do NOT turn with the theme ----------------------
       A dark speech bubble and a cancelled symbol should stay dark in
       both themes. Until 10.11.2026 they read --heading-color or
       --text-body: in dark mode those are light values, and the bubble
       became white on white (measured 1.1, 16 times on /tenant/users/). */
    --surface-inverse:    #343a40;   /* white on it: 10.6               */

    /* The swatches of the theme picker SHOW a theme - they do not
       follow it. They live here and nowhere else.                      */
    --swatch-light:       #ffffff;
    --swatch-light-2:     #f8f9fa;
    --swatch-dark:        #1e1e1e;
    --swatch-dark-2:      #343a40;

    /* Violet. The palette had none, and the QMS process types needed a
       third tone next to blue and green. Before, the literal #553c9a
       sat on --primary-light there: in dark mode violet on dark red,
       contrast 1.8.                                                 */
    --violet-bg:          #ede7f6;
    --violet-text:        #4527a0;   /* 8.47 on --violet-bg */

    /* ---- Text ------------------------------------------------------- */
    --heading-color:      #2c3e50;   /* headings                         */
    --text-color:         #212529;   /* main text                        */
    --text-body:          #495057;   /* body text                        */
    --text-muted:         #646c74;   /* secondary text, 4.68 on #f0f0f0  */
        /* #6c757d reaches only 4.45 on --surface-sunken (#f8f9fa) and so
           just fails AA - measured about 240 times over 373 pages in the
           LIGHT theme on 10.11.2026. #69727a reaches 4.65 and is 5 RGB
           units away: the difference cannot be seen, the readability can.
           The dark value (#9aa1aa, 6.4 on #1e1e1e) is unchanged. */
    --text-faint:         #adb5bd;   /* placeholder, disabled            */
        /* Pale ON PURPOSE: 2.1 on white, 3.6 on the dark surface. Enough
           for a placeholder and greyed-out things, NOT for text meant to
           be read. On 10.11.2026, 9 button labels used it ("expand all") -
           they now read --text-muted. The other 101 places really are
           placeholders and hints. */
    --text-on-accent:     #ffffff;   /* text on the ACCENT - flips with the company colour */

    /* ---- Text on the FIXED palette colours --------------------------
     * Not the same as --text-on-accent: that one flips with the company
     * colour (amber needs black text). These five surfaces are the same in
     * every company and both themes, so is their text.
     * Calculated by WCAG, not by convention:
     *   #6c757d  white 4.69  black 4.48
     *   #198754  white 4.53  black 4.63
     *   #dc3545  white 4.53  black 4.64
     *   #ffc107  white 1.63  black 12.88   <- black is REQUIRED here
     *   #117a8b  white 5.02
     */
    --on-secondary:       #ffffff;
    --on-success:         #ffffff;
    --on-danger:          #ffffff;
    --on-info:            #ffffff;

    /* ---- Accent ----------------------------------------------------- */
    --primary-color:      #007bff;   /* fill                             */
    --primary-ink:        #0069d9;   /* text/link, 4.58 on #f0f0f0       */
    --primary-hover:      #0056b3;
    --primary-dark:       #0056b3;
    --primary-light:      #e7f1ff;   /* soft tint as background          */
    --primary-focus:      rgba(0, 123, 255, 0.25);  /* focus ring        */
    --primary-rgb:        0, 123, 255;   /* the same colour as channels */
        /* For shadows and veils that bring their OWN opacity:
           rgba(var(--primary-rgb), 0.1). A finished rgba token like
           --primary-focus has a fixed opacity and would make all 143 focus
           rings equally strong - their alpha values range from 0.1 to
           0.35. The default is the same as before, so nothing changes for
           companies on the default. */
    --primary-border:     #007bff;   /* focus border, blue outlines      */
        /* A border is not text, but it must be SEEN: WCAG 1.4.11 requires
           3.0 against the surface. #80bdff had 1.97 - below any threshold
           of perception. The 504 rules that draw a border with
           --primary-color reached 3.98 with #007bff; the border tone is now
           the same value, so NOTHING changes for a company on the
           defaults. Only a light brand colour gets a darkened version with
           the same hue via settingsdesign/design.py. */
    --primary-text:       #004085;   /* text ON --primary-light          */
    --secondary-color:    #6c757d;
    --secondary-dark:     #545b62;

    /* ---- States ----------------------------------------------------- */
    --success-color:      #198754;   /* carries white text: 4.53 (#28a745 only 3.13) */
    --success-ink:        #167a4c;   /* 4.70 on #f0f0f0 */
    --success-dark:       #155724;
    --success-text:       #155724;   /* text IN the green notice strip */
    --success-bg:         #d4edda;
    --success-border:     #c3e6cb;

    --warning-color:      #ffc107;
    --warning-ink:        #856404;   /* amber as TEXT is light          */
    --warning-hover:      #ffca2c;
    --on-warning:         #000000;   /* text on amber - black in BOTH themes */
    --warning-dark:       #856404;
    --warning-bg:         #fff3cd;
    --warning-border:     #ffeeba;

    --danger-color:       #dc3545;
    --danger-ink:         #c6303e;   /* 4.73 on #f0f0f0 */
    --danger-dark:        #c82333;
    --danger-text:        #721c24;   /* text IN the red notice strip */
    --danger-bg:          #f8d7da;
    --danger-border:      #f5c6cb;

    --info-color:         #117a8b;   /* carries white text: 5.02 (#17a2b8 only 3.04) */
    --info-ink:           #107484;   /* 4.78 on #f0f0f0 */
    --info-dark:          #138496;
    --info-text:          #0c5460;   /* text IN the blue notice strip */
    --info-bg:            #d1ecf1;
    --info-border:        #bee5eb;

    /* ---- Navigation: dark in BOTH themes ---------------------------
     * The side menu of this platform has always been dark (#1e1e1e), even
     * when the content is light. So it does NOT follow the surfaces above
     * but has its own values. In dark mode it gets a shade deeper - exactly
     * what two @media(prefers-color-scheme) blocks in style.css did until
     * 09.11.2026, only tied to the operating system instead of the
     * platform setting.
     */
    --nav-bg:             #1e1e1e;   /* .side-menu            */
    --nav-bar-bg:         #282828;   /* .navbar               */
    --nav-submenu-bg:     rgba(0, 0, 0, 0.2);
    --nav-subsubmenu-bg:  rgba(0, 0, 0, 0.3);
    --nav-text:           #ffffff;
    --nav-text-1:         #cccccc;   /* first level           */
    --nav-text-2:         #aaaaaa;   /* second level, buttons */
    --nav-text-3:         #999999;   /* third level           */
    --nav-hover-bg:       rgba(255, 255, 255, 0.1);
    --nav-accent:         var(--primary-color);   /* FILL in the menu   */
    /* TEXT and BORDER in the menu. The side menu is dark in BOTH themes
       (#1e1e1e) - so the accent colour as text always needs the lightened
       version there, not the theme's. #b51a00 on #1e1e1e reaches 2.3;
       #4da3ff reaches 6.3.                                             */
    --nav-accent-ink:     #4da3ff;
    --nav-accent-hover:   #0056b3;
    --nav-scroll-track:   #1e1e1e;
    --nav-scroll-thumb:   #444444;
    --nav-scroll-hover:   #555555;
    --nav-border:         #333333;   /* border in the dark dropdown     */
    --nav-border-soft:    #2a2a2a;
    --nav-tooltip-bg:     #333333;
    --nav-market:         #52c41a;   /* marketplace entry     */
    --nav-market-hover:   #73d13d;

    /* ---- Shadows ------------------------------------------------------
       Every shadow carries a hairline (0 0 0 1px). In light mode it is
       almost invisible; in dark mode it is the ONLY thing separating a
       card from the ground - a black blur on black ground shows nothing.
       So the separation belongs in the token, not on every card.       */
    /* ---- Disabled -------------------------------------------------------
       "Greyed out" means opacity here, and opacity pulls EVERYTHING towards
       the ground: text, border, fill. 0.55 is calculated, not guessed -
       --text-color still reaches 3.7 and --input-border 1.8 on white, in
       dark mode 3.4 and 2.0 on #1e1e1e. Disabled does not mean unreadable. */
    --disabled-opacity:   0.55;

    --shadow-ring:        rgba(0, 0, 0, 0.08);
    --shadow-sm:          0 1px 2px rgba(0, 0, 0, 0.05), 0 0 0 1px var(--shadow-ring);
    --shadow-md:          0 2px 8px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--shadow-ring);
    --shadow-lg:          0 8px 24px rgba(0, 0, 0, 0.12), 0 0 0 1px var(--shadow-ring);
    --shadow-xl:          0 20px 60px rgba(0, 0, 0, 0.30), 0 0 0 1px var(--shadow-ring);

    /* =================================================================
       2. DERIVED NAMES - nothing is decided here, only referenced.
       They follow the dark mode on their own.
       ================================================================= */

    /* Surfaces, as the apps name them */
    --bg-primary:          var(--surface);
    --bg-secondary:        var(--surface-sunken);
    --bg-tertiary:         var(--surface-tertiary);
    --bg-light:            var(--surface-sunken);
    --bg-card:             var(--surface);
    --bg-subtle:           var(--surface-sunken);
    --bg-hover:            var(--hover-bg);
    --surface-alt:         var(--surface-sunken);
    --surface-hover:       var(--hover-bg);
    --card-bg:             var(--surface);
    --card-bg-alt:         var(--surface-sunken);
    --card-header-bg:      var(--surface-sunken);
    --header-bg:           var(--surface-sunken);
    --background-color:    var(--surface);
    --light-background:    var(--surface-sunken);
    --input-bg:            var(--surface);
    --optgroup-bg:         var(--surface-sunken);
    --avatar-bg:           var(--surface-tertiary);
    --progress-bg:         var(--surface-tertiary);
    --table-header-bg:     var(--surface-sunken);
    --table-hover-bg:      var(--hover-bg);
    --filter-row-bg:       var(--surface-sunken);
    --filter-row-hover-bg: var(--surface);
    --cal-bg-sidebar:      var(--surface-sunken);

    /* Borders */
    --border:              var(--border-color);
    --border-color-light:  var(--border-light);
    --bs-border-color:     var(--border-color);

    /* Text */
    --text-primary:        var(--text-color);
    --text-secondary:      var(--text-body);
    --text-muted-strong:   var(--text-body);
    --text-muted-dark:     var(--text-faint);
    --text-color-dark:     var(--text-color);
    --bs-secondary-color:  var(--text-body);
    --badge-color:         var(--text-muted);
    --indicator-color:     var(--text-muted);
    --cat-color:           var(--text-muted);   /* set per row by JS */
    --core-text:           var(--text-color);
    --core-text-muted:     var(--text-muted);
    --core-border:         var(--border-color);
    --core-bg-muted:       var(--surface-sunken);
    --core-bg-card:        var(--surface);
    --core-primary:        var(--primary-color);
    --core-warn:           var(--warning-dark);
    --core-danger:         var(--danger-color);

    /* Accent */
    --bs-primary:          var(--primary-color);
    --bs-tertiary-bg:      var(--surface-sunken);
    --primary-bg:          var(--primary-light);
    --primary-color-light: var(--primary-light);
    --secondary-bg:        var(--surface-sunken);
    --filter-tag-bg:       var(--primary-light);
    --filter-tag-hover-bg: #d0e7ff;
    --filter-tag-border:   #b6d4fe;
    --chip-color:          var(--border-color);
    --trn-cover:           var(--primary-color);
    --dep-subject-color:   var(--primary-color);
    --cal-switch-color:    var(--primary-color);
    --cal-danger:          var(--danger-color);
    --mail-accent:         var(--primary-color);
    --ebo-color:           var(--primary-color);
    --project-color:       var(--primary-color);
    --tpl-color:           var(--primary-color);
    --cert-accent-default: var(--primary-color);

    /* States, short names */
    --success:             var(--success-color);
    --success-light:       var(--success-bg);
    --success-hover:       var(--success-dark);
    --warning:             var(--warning-color);
    --warning-light:       var(--warning-bg);
    --warning-text:        var(--warning-dark);
    --danger:              var(--danger-color);
    --info:                var(--info-color);

    /* =================================================================
       3. OLD NAMES OF THIS FILE (before 09.11.2026) - 84 templates use
       them. They stay so nothing breaks there.
       ================================================================= */
    --color-surface:         var(--surface);
    --color-surface-sunken:  var(--surface-sunken);
    --color-surface-raised:  var(--surface-raised);
    --color-surface-hover:   var(--hover-bg-strong);
    --color-surface-muted:   var(--surface-sunken);
    --color-bg-secondary:    var(--surface-sunken);
    --color-bg-subtle:       var(--surface-sunken);
    --color-bg-hover:        var(--hover-bg);
    --color-border:          var(--border-color);
    --color-border-subtle:   var(--border-light);
    --color-border-light:    var(--border-light);
    --color-border-strong:   var(--border-strong);
    --color-text:            var(--text-color);
    --color-text-primary:    var(--text-color);
    --color-text-body:       var(--text-body);
    --color-text-secondary:  var(--text-body);
    --color-text-muted:      var(--text-muted);
    --color-text-faint:      var(--text-faint);
    --color-text-heading:    var(--heading-color);
    --color-text-on-accent:  var(--text-on-accent);
    --color-text-warning:    var(--warning-dark);
    --color-warning-text:    var(--warning-dark);   /* fuhrpark.css spells it this way round */
    --color-primary:         var(--primary-color);
    --color-primary-hover:   var(--primary-hover);
    --color-success:         var(--success-color);
    --color-warning:         var(--warning-color);
    --color-danger:          var(--danger-color);
    --color-info:            var(--info-color);
    --color-warning-bg:      var(--warning-bg);
    --color-danger-bg:       var(--danger-bg);
    /* The three "other blues" of the 02.10.2026 version. Decided on
       09.11.2026: there is ONE blue. The names stay as references so
       nothing breaks, but point to the same value. */
    --color-primary-bs5:     var(--primary-color);
    --color-primary-tw:      var(--primary-color);
    --color-primary-tw-dark: var(--primary-hover);

    /* =================================================================
       4. NO COLOURS - spacing, radius, type. Untouched by the theme.
       ================================================================= */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 12px;
    --space-lg: 16px;
    --space-xl: 24px;
    --space-2:  0.5rem;      /* used, was defined nowhere */
    --space-3:  1rem;

    --radius-sm:   4px;
    --radius-md:   6px;
    --radius-lg:   8px;
    --radius-pill: 999px;
    --radius-control: var(--radius-lg);  /* fields, dropdowns, menus - like the buttons (14.11.2026) */
    --border-radius:  var(--radius-md);   /* 0.375rem = 6px, as used */
    --core-radius:    var(--radius-md);
    --core-radius-sm: var(--radius-sm);

    --font-size-sm:   0.8125rem;   /* 13px, form-text  */
    --font-size-base: 0.875rem;    /* 14px, default    */
    --font-size-lg:   1rem;
    --font-weight-medium:   500;
    --font-weight-semibold: 600;
    --font-family: 'Roboto', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'SFMono-Regular', Menlo, Consolas, monospace;
    --bs-font-monospace: var(--font-mono);

    --sidebar-width: 250px;        /* style.css: .side-menu, DO NOT CHANGE */

    --table-row-height: 40px;
    --table-head-bg:    var(--surface-sunken);
    --table-row-hover:  var(--hover-bg);
    --table-border:     var(--border-light);

    /* Values set PER ELEMENT with style.setProperty. Only the initial
       value lives here, so the rule is valid until something is set. */
    --ring-angle: 0deg;
    --trn-progress: 0%;
    --dev-progress: 0%;
    --upload-progress: 0%;
    --of-frame-h: calc(100vh - 260px);
}

/* =====================================================================
   5. DARK - only the base values of section 1. Everything derived follows.
   Surfaces derived from the side menu: .side-menu has always been
   #1e1e1e, so the dark palette is no invention but what has always been
   dark in this platform.
   Contrasts measured (WCAG), see the head of this file.
   ===================================================================== */
:root[data-theme="dark"] {
    color-scheme: dark;

    --surface:            #1e1e1e;
    --surface-sunken:     #141416;
    --surface-raised:     #262629;
    --surface-tertiary:   #2a2a2e;
    --hover-bg:           #26262a;
    --hover-bg-strong:    #303036;
    --overlay-bg:         rgba(0, 0, 0, 0.7);

    --border-color:       #343438;
    --border-light:       #2a2a2e;
    --border-strong:      #46464d;
    --violet-bg:          #241a3a;
    --violet-text:        #b39ddb;   /* 6.83 on --violet-bg */
    --input-border:       #74747a;   /* 3.25 on #262629 */
    --input-border-hover: #9aa1aa;
    --switch-off:         #8b9198;   /* 5.24 on #1e1e1e */
    --code-ink:           #f08cb8;

    --heading-color:      #f2f2f3;   /* 14.9 on the card */
    --text-color:         #e4e4e7;   /* 13.1 */
    --text-body:          #c7c9ce;   /* 10.1 */
    --text-muted:         #9aa1aa;   /*  6.4 */
    --text-faint:         #71757c;   /*  3.6 - placeholders only */
    --text-on-accent:     #ffffff;

    --primary-color:      #007bff;   /* fill stays, carries white text */
    --primary-ink:        #4da3ff;   /*  6.3 as text */
    --primary-hover:      #3d97ff;
    --primary-dark:       #0062cc;
    --primary-light:      #15304d;
    --primary-focus:      rgba(77, 163, 255, 0.35);
    --primary-border:     #3570a8;   /* 3.20 on #1e1e1e (#2a5a8c was 2.33) */
    --primary-text:       #9ecbff;
    --secondary-color:    #6c757d;   /* stays: carries white text as in light mode */
    --secondary-dark:     #545b62;

    --success-color:      #198754;
    --success-ink:        #4ec977;   /*  7.9 */
    --success-dark:       #4ec977;
    --success-text:       #4ec977;
    --success-bg:         #12301c;
    --success-border:     #1e4a2c;

    --warning-color:      #ffc107;
    --warning-ink:        #ffcd39;   /* 10.2 */
    --warning-dark:       #ffcd39;
    --warning-bg:         #3a2f0b;
    --warning-border:     #574715;

    --danger-color:       #dc3545;
    --danger-ink:         #f4707d;   /*  5.9 */
    --danger-dark:        #f4707d;
    --danger-text:        #f4707d;
    --danger-bg:          #3a1418;
    --danger-border:      #5a2027;

    --info-color:         #117a8b;
    --info-ink:           #3ec8dd;   /*  8.3 */
    --info-dark:          #3ec8dd;
    --info-text:          #3ec8dd;
    --info-bg:            #0d2a30;
    --info-border:        #14434d;

    --nav-bg:             #1a1a1a;
    --nav-border:         #2e2e32;
    --nav-border-soft:    #242428;
    --nav-submenu-bg:     rgba(0, 0, 0, 0.3);
    --nav-subsubmenu-bg:  rgba(0, 0, 0, 0.4);
    --nav-market:         #73d13d;
    --nav-market-hover:   #95de64;

    /* On a dark ground a soft shadow does not show; it must be deeper.
       And deeper is not enough: the hairline makes the separation. */
    --disabled-opacity:   0.55;
    --shadow-ring:        #3a3a42;
    --shadow-sm:          0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--shadow-ring);
    --shadow-md:          0 2px 8px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--shadow-ring);
    --shadow-lg:          0 8px 24px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--shadow-ring);
    --shadow-xl:          0 20px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--shadow-ring);

    /* Two derived values that do not follow from the base values in dark mode */
    --filter-tag-hover-bg: #1b3a5c;
    --filter-tag-border:   #2a5a8c;
}

/* =====================================================================
   6. AUTOMATIC - whoever chose nothing (or "auto") follows the operating
   system. `:not([data-theme="light"])` is the switch for it: whoever
   explicitly chose LIGHT stays light, even if their system is dark.
   ===================================================================== */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        color-scheme: dark;

        --surface:            #1e1e1e;
        --surface-sunken:     #141416;
        --surface-raised:     #262629;
        --surface-tertiary:   #2a2a2e;
        --hover-bg:           #26262a;
        --hover-bg-strong:    #303036;
        --overlay-bg:         rgba(0, 0, 0, 0.7);

        --border-color:       #343438;
        --border-light:       #2a2a2e;
        --border-strong:      #46464d;
        --violet-bg:          #241a3a;
        --violet-text:        #b39ddb;
        --input-border:       #74747a;
        --input-border-hover: #9aa1aa;
        --switch-off:         #8b9198;
        --code-ink:           #f08cb8;

        --heading-color:      #f2f2f3;
        --text-color:         #e4e4e7;
        --text-body:          #c7c9ce;
        --text-muted:         #9aa1aa;
        --text-faint:         #71757c;
        --text-on-accent:     #ffffff;

        --primary-color:      #007bff;
        --primary-ink:        #4da3ff;
        --primary-hover:      #3d97ff;
        --primary-dark:       #0062cc;
        --primary-light:      #15304d;
        --primary-focus:      rgba(77, 163, 255, 0.35);
        --primary-border:     #3570a8;   /* 3.20 on #1e1e1e (#2a5a8c was 2.33) */
        --primary-text:       #9ecbff;
        --secondary-color:    #6c757d;
        --secondary-dark:     #545b62;

        --success-color:      #198754;
        --success-ink:        #4ec977;
        --success-dark:       #4ec977;
        --success-text:       #4ec977;
        --success-bg:         #12301c;
        --success-border:     #1e4a2c;

        --warning-color:      #ffc107;
        --warning-ink:        #ffcd39;
        --warning-dark:       #ffcd39;
        --warning-bg:         #3a2f0b;
        --warning-border:     #574715;

        --danger-color:       #dc3545;
        --danger-ink:         #f4707d;
        --danger-dark:        #f4707d;
        --danger-text:        #f4707d;
        --danger-bg:          #3a1418;
        --danger-border:      #5a2027;

        --info-color:         #117a8b;
        --info-ink:           #3ec8dd;
        --info-dark:          #3ec8dd;
        --info-text:          #3ec8dd;
        --info-bg:            #0d2a30;
        --info-border:        #14434d;

        --nav-bg:             #1a1a1a;
        --nav-border:         #2e2e32;
        --nav-border-soft:    #242428;
        --nav-submenu-bg:     rgba(0, 0, 0, 0.3);
        --nav-subsubmenu-bg:  rgba(0, 0, 0, 0.4);
        --nav-market:         #73d13d;
        --nav-market-hover:   #95de64;

        --disabled-opacity:   0.55;
        --shadow-ring:        #3a3a42;
        --shadow-sm:          0 1px 2px rgba(0, 0, 0, 0.5), 0 0 0 1px var(--shadow-ring);
        --shadow-md:          0 2px 8px rgba(0, 0, 0, 0.55), 0 0 0 1px var(--shadow-ring);
        --shadow-lg:          0 8px 24px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--shadow-ring);
        --shadow-xl:          0 20px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--shadow-ring);

        --filter-tag-hover-bg: #1b3a5c;
        --filter-tag-border:   #2a5a8c;
    }
}

/* =====================================================================
   7. PRINT - always light. An invoice, a dunning letter, a certificate
   must never come out of the printer dark, whatever is set.
   ===================================================================== */
@media print {
    :root,
    :root[data-theme="dark"] {
        color-scheme: light;

        --surface:          #ffffff;
        --surface-sunken:   #ffffff;
        --surface-raised:   #ffffff;
        --surface-tertiary: #e9ecef;
        --hover-bg:         #ffffff;
        --hover-bg-strong:  #ffffff;

        --border-color:     #dee2e6;
        --border-light:     #e9ecef;
        --border-strong:    #ced4da;
        --violet-bg:        #ede7f6;
        --violet-text:      #4527a0;
        --input-border:     #909499;
        --input-border-hover: #6c757d;
        --switch-off:       #6c757d;
        --code-ink:         #ba3270;

        --heading-color:    #000000;
        --text-color:       #000000;
        --text-body:        #212529;
        --text-muted:       #495057;
        --text-faint:       #6c757d;

        --primary-color:    #007bff;
        --primary-ink:      #0056b3;
        --primary-border:   #007bff;
        --primary-text:     #004085;
        --success-ink:      #155724;
        --warning-ink:      #856404;
        --danger-ink:       #a71d2a;
        --info-ink:         #117a8b;

        --disabled-opacity: 1;
        --shadow-ring: transparent;
        --shadow-sm: none;
        --shadow-md: none;
        --shadow-lg: none;
        --shadow-xl: none;
    }
}

/* =====================================================================
   8. LOGIN - always dark. Login, error and thank-you pages
   (auth_external.css) have no light theme; these values therefore do NOT
   switch on purpose. Approved by Pierre on 21.11.2026.
   Brand colour #c5023c as on rivus360.com, white on it 5.9 : 1.
   (The --ext-* names are used by static/css/auth_external.css.)
   ===================================================================== */
:root {
    --ext-grund:      #0f1014;
    --ext-flaeche:    #14161b;
    --ext-feld:       #0c0d10;
    --ext-rand:       #2a2e37;
    --ext-rand-hell:  #3a3f4b;
    --ext-text:       #e9ebef;
    --ext-leise:      #9ba2ae;
    --ext-marke:      #c5023c;
    --ext-marke-hell: #de1a54;
    --ext-fokus:      #ff6f97;
}
