/* =============================================================================================
   TimeView theme layer — everything that must load AFTER the Syncfusion theme stylesheet.

   Served from TSO.TimeView.Shared.Components as _content/TSO.TimeView.Shared.Components/tv-theme.css.
   Hosts load: tv-tokens.css -> Syncfusion bootstrap5.3(-dark).css -> tv-theme.css -> host css.
   Contents: brand-primary override of the --color-sf-primary family, dark/high-contrast fallback
   keyed on body[data-theme], e-icons colour inheritance, scrollbars, html/body base, element
   defaults (links, focus ring), the .tv-btn hierarchy, and shell z-index plumbing for
   SfSidebar/SfDialog. Hosts MUST set body[data-theme="light|dark"] before first paint.
   ============================================================================================= */

/* TvDialog's HeaderContent slot. Syncfusion colours every header descendant itself (".e-dlg-header *"
   in bootstrap5.3.css), so the band foreground the slot sets (see .tv-dialog-header below) would not
   reach its children (seen live: a user card stayed dark on the band). This hands colour back to
   inheritance at the same (0,1,0) specificity and sits FIRST in this file on purpose: it beats only
   the Syncfusion theme loaded before it, while every later rule of equal weight still wins — a status
   chip (.tv-status-text, further down) keeps its colour. Moving it below such a rule breaks that. */
:where(.e-dlg-container.tv-dialog > .e-dialog) .tv-dialog-header * {
    color: inherit;
}

/* Theme overrides for Syncfusion components - loaded last to ensure highest specificity */

/* Fix for Syncfusion e-icons to inherit theme colors instead of staying black */
/* This file is loaded AFTER all other CSS including Syncfusion themes */

/* Force all e-icons to inherit color from parent */
.e-icons,
.e-icons::before,
.e-icons::after {
    color: inherit !important;
}

/* More specific selectors to ensure they apply in TreeView context */
.e-treeview .e-icons,
.e-treeview .e-icons::before,
.e-treeview .e-icons::after {
    color: inherit !important;
}

/* Ensure all icon types inherit color */
span.e-icons,
span.e-icons::before,
div.e-icons,
div.e-icons::before,
i.e-icons,
i.e-icons::before {
    color: inherit !important;
}

/* For any SVG-based icons */
.e-icons svg,
.e-icons svg path {
    fill: currentColor !important;
}

/* Override any hardcoded colors in Syncfusion's CSS */
.e-treeview .e-text-content .e-icons,
.e-treeview .e-text-content .e-icons::before {
    color: inherit !important;
}

/* Fix for parent items with children (those with expand/collapse icons) */
.e-treeview .e-list-item .e-icons.e-icon-collapsible,
.e-treeview .e-list-item .e-icons.e-icon-expandable,
.e-treeview .e-list-item .e-icons.e-icon-collapsible::before,
.e-treeview .e-list-item .e-icons.e-icon-expandable::before {
    color: inherit !important;
}

/* TreeView specific overrides */
.e-treeview .e-list-item .e-text-content div.e-list-icon.e-icons,
.e-treeview .e-list-item .e-text-content div.e-list-icon.e-icons::before {
    color: inherit !important;
}

/* Hover and active states - let JavaScript handle colors dynamically */
.e-treeview .e-list-item.e-hover .e-text-content div.e-list-icon.e-icons,
.e-treeview .e-list-item.e-hover .e-text-content div.e-list-icon.e-icons::before,
.e-treeview .e-list-item.e-active .e-text-content div.e-list-icon.e-icons,
.e-treeview .e-list-item.e-active .e-text-content div.e-list-icon.e-icons::before {
    color: inherit !important;
}

/* =========================================================================
   Scrollbar Theme Support - Light and Dark Themes
   ========================================================================= */

/* Scrollbar colours are derived from the element's own foreground, so they track whichever
   Syncfusion theme is active without a per-theme branch. The previous light/dark pair hardcoded
   eight greys and had no high-contrast case at all. */
:root {
    /* Scrollbar track (background) */
    --scrollbar-track-color: var(--tv-surface-alt);
    /* Scrollbar thumb (the draggable part) */
    --scrollbar-thumb-color: color-mix(in srgb, currentColor 30%, transparent);
    /* Scrollbar thumb on hover */
    --scrollbar-thumb-hover-color: color-mix(in srgb, currentColor 45%, transparent);
    /* Scrollbar thumb when active/dragging */
    --scrollbar-thumb-active-color: color-mix(in srgb, currentColor 60%, transparent);
}

/* Base body styles. The surface and text colour come from the active Syncfusion theme rather
   than a hardcoded light pair plus a dark override. */
html, body {
    margin: 0;
    padding: 0;
    background-color: var(--tv-body-bg);
    color: var(--tv-body-fg);
}

/* The high-contrast theme ships **no** --color-sf-* custom properties at all (verified: zero
   definitions in highcontrast.css), and App.razor collapses it onto data-theme="dark". Without
   this branch every --color-sf-* above resolves to its light fallback, so a dark theme renders
   dark widgets on a light canvas.

   This is not a hand-rolled dark palette — the values still read the theme where it publishes
   one, so bootstrap5.3-dark continues to win with its own --color-sf-* values. Only the
   *fallback* differs, which is the one thing data-theme can still tell us.

   The selector must resolve on **html**, not body, for two reasons — App.razor sets data-theme
   on body, hence :has():
     1. A custom property is substituted at computed-value time on the element that declares it.
        The aliases above (--color-bg-surface: var(--tv-surface), :93) are declared at :root, so
        they are resolved once on html and descendants inherit the already-substituted result.
        Overriding --tv-surface on body therefore could not reach them, and AiChat's panels
        rendered white on a dark canvas.
     2. html's background is what propagates to the page canvas. A background set only on body
        paints the body box, leaving a light rim under high contrast. */
:root:has(body[data-theme="dark"]) {
    --tv-body-bg: color-mix(in srgb, var(--color-sf-content-bg-color, #1e1e1e) 96%, #000000);
    --tv-body-fg: var(--color-sf-content-text-color, #e0e0e0);
    --tv-surface: var(--color-sf-content-bg-color, #1e1e1e);
}

/* =========================================================================
   Brand primary — the Syncfusion "primary" is the TimeSolutions blue
   =========================================================================
   Every primary button, link, selected row, active nav item, focus ring and progress fill in
   the app takes its colour from the theme's --color-sf-primary family. Redefining that family
   here, in the one stylesheet that loads *after* the theme (see App.razor: the theme <link> is
   inserted immediately before this file), rebrands all of them at once. Components keep reading
   the theme's variable names; only what those names resolve to has changed. The app-level
   --palette-accent / --tv-accent alias --color-sf-primary, so they follow for free.

   Why the whole family and not just --color-sf-primary: bootstrap5.3.css does NOT derive its
   hover/pressed/light/lighter/dark/darker values from --color-sf-primary — each is a literal
   (#0b5ed7, #86b7fe, #cfe2ff, …). Override only the base and every hover flips back to Bootstrap
   blue. The derived values below are color-mix()ed from the chosen brand hue so the family stays
   internally consistent and the hue is still written down exactly once, in app.css. Four more
   variables outside the family (-content-bg-color-selected, -flyout-bg-color-pressed,
   -border-focus, -border-selected) are the same literal blue and are re-pointed at the end.

   Why BLUE, measured against white and the dark canvas #212529:

                              fill vs canvas    white text on fill   as link text
       light  --brand-blue          5.74               5.74               5.74   ✓ AA
       light  --brand-darkblue     11.98              11.98              11.98
       dark   --brand-blue          2.69               5.74               —  (links use -darker: 7.68)
       dark   --brand-darkblue      1.29                —                 1.29   ✗ invisible

   The "as link text" column is the hue itself; the links actually render in the -darker text
   tint in both themes (--tv-accent-text: 7.91 light, 7.68 dark), see the a, .btn-link rule.

   DARKBLUE is the flagship colour but disappears on the dark canvas, and running two hues meant
   the app looked like a different brand per theme. BLUE clears AA as fill and text in light and
   carries white labels in dark, so it is the one primary for both. (Its dark fill-vs-canvas
   contrast of 2.69 is below the 3:1 component floor — accepted for the label contrast; Bootstrap's
   own dark primary sits at 3.43 / 4.50.) To change the brand primary later, change the one
   --tv-brand-primary line; nothing else references a hue.

   --color-sf-primary-shadow is an "r, g, b" triplet the theme feeds into rgba(); it cannot be
   derived with color-mix(), so it is the one place the hue is repeated, in a different notation.
   Keep it in step with --tv-brand-primary above it.

   The dark branch keys on data-theme like the block above, so highcontrast (which ships no
   --color-sf-* at all) also receives these values — meaning components' var(--color-sf-primary,
   #hex) fallbacks now resolve to brand blue there rather than to Bootstrap blue. Intended. */
:root {
    --tv-brand-primary: var(--brand-blue);
    --tv-brand-primary-shadow: 23, 104, 178;

    --color-sf-primary: var(--tv-brand-primary);
    --color-sf-primary-text-color: var(--brand-white);
    --color-sf-primary-shadow: var(--tv-brand-primary-shadow);

    /* Hover darkens, pressed darkens further — the same direction the theme takes. */
    --color-sf-primary-bg-color-hover:     color-mix(in srgb, var(--tv-brand-primary) 85%, black);
    --color-sf-primary-border-color-hover: color-mix(in srgb, var(--tv-brand-primary) 80%, black);
    --color-sf-primary-bg-color-pressed:     color-mix(in srgb, var(--tv-brand-primary) 75%, black);
    --color-sf-primary-border-color-pressed: color-mix(in srgb, var(--tv-brand-primary) 75%, black);
    --color-sf-primary-bg-color-disabled:    color-mix(in srgb, var(--tv-brand-primary) 65%, transparent);

    /* Tints, in the theme's own roles: -light is the soft border/outline (was #86b7fe),
       -lighter the selected/expanded wash (was #cfe2ff), -dark a mid fill, -darker the text that
       sits on the -lighter wash (was #052c65). Mixed toward the content surface rather than a
       fixed white so the wash sits on whatever the theme's panel colour is. */
    --color-sf-primary-light:   color-mix(in srgb, var(--tv-brand-primary) 45%, var(--color-sf-content-bg-color, white));
    --color-sf-primary-lighter: color-mix(in srgb, var(--tv-brand-primary) 15%, var(--color-sf-content-bg-color, white));
    --color-sf-primary-dark:    color-mix(in srgb, var(--tv-brand-primary) 90%, black);
    --color-sf-primary-darker:  color-mix(in srgb, var(--tv-brand-primary) 80%, black);

    /* Four siblings outside the -primary family are ALSO hardcoded Bootstrap blue in the theme
       (#0d6efd / #86b7fe) and drive the selected row in TreeView/ListView (the nav menu), the
       pressed flyout item, and the focus/selected input border. Left alone they stay Bootstrap
       blue next to a brand-blue primary — the mismatch the nav menu showed. */
    --color-sf-content-bg-color-selected: var(--tv-brand-primary);
    --color-sf-flyout-bg-color-pressed:   var(--tv-brand-primary);
    --color-sf-border-focus:    var(--color-sf-primary-light);
    --color-sf-border-selected: var(--color-sf-primary-light);
}

:root:has(body[data-theme="dark"]) {
    /* Same hue; only the tint roles invert. On a dark surface "darker" is the theme's *text* tint
       (was #6ea8fe): it must get lighter, not darker, to stay legible. 45 % toward white measures
       7.68 against #212529. */
    --color-sf-primary-lighter: color-mix(in srgb, var(--tv-brand-primary) 18%, var(--color-sf-content-bg-color, #212529));
    --color-sf-primary-darker:  color-mix(in srgb, var(--tv-brand-primary) 45%, white);
}

/* Modern browsers (Chrome, Edge, Safari, Opera) - Webkit scrollbars */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);
}

*::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

*::-webkit-scrollbar-track {
    background: var(--scrollbar-track-color);
}

*::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb-color);
    border-radius: 6px;
    border: 2px solid var(--scrollbar-track-color);
    /* The track token is a translucent color-mix, so without padding-box the thumb's own
       background paints through its border and the 2px inset pill gap disappears. */
    background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover-color);
}

*::-webkit-scrollbar-thumb:active {
    background-color: var(--scrollbar-thumb-active-color);
}

/* Scrollbar corner (where horizontal and vertical scrollbars meet) */
*::-webkit-scrollbar-corner {
    background: var(--scrollbar-track-color);
}

/* Firefox - Standard scrollbar-color property */
* {
    scrollbar-color: var(--scrollbar-thumb-color) var(--scrollbar-track-color);
}

/* Specific styling for Syncfusion components with scrollable content */
.e-dialog .e-dlg-content::-webkit-scrollbar,
.e-popup::-webkit-scrollbar,
.time-registration-container::-webkit-scrollbar,
.e-content::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

.e-dialog .e-dlg-content::-webkit-scrollbar-track,
.e-popup::-webkit-scrollbar-track,
.time-registration-container::-webkit-scrollbar-track,
.e-content::-webkit-scrollbar-track {
    background: var(--scrollbar-track-color);
}

.e-dialog .e-dlg-content::-webkit-scrollbar-thumb,
.e-popup::-webkit-scrollbar-thumb,
.time-registration-container::-webkit-scrollbar-thumb,
.e-content::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb-color);
    border-radius: 6px;
    border: 2px solid var(--scrollbar-track-color);
    background-clip: padding-box;
}

.e-dialog .e-dlg-content::-webkit-scrollbar-thumb:hover,
.e-popup::-webkit-scrollbar-thumb:hover,
.time-registration-container::-webkit-scrollbar-thumb:hover,
.e-content::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-thumb-hover-color);
}

.e-dialog .e-dlg-content::-webkit-scrollbar-thumb:active,
.e-popup::-webkit-scrollbar-thumb:active,
.time-registration-container::-webkit-scrollbar-thumb:active,
.e-content::-webkit-scrollbar-thumb:active {
    background-color: var(--scrollbar-thumb-active-color);
}

/* High contrast mode support for scrollbars */
@media (prefers-contrast: high) {
    *::-webkit-scrollbar-thumb {
        border: 3px solid transparent;
        background-clip: padding-box;
    }
}

/* Forced colors mode (Windows High Contrast) */
@media (forced-colors: active) {
    *::-webkit-scrollbar {
        color-scheme: light dark;
    }
    *::-webkit-scrollbar-track {
        background: Canvas;
    }
    *::-webkit-scrollbar-thumb {
        background: ButtonText;
        border-color: Canvas;
    }
    *::-webkit-scrollbar-thumb:hover,
    *::-webkit-scrollbar-thumb:active {
        background: Highlight;
    }
}

/* =========================================================================
   Sidebar fix — preserve position:fixed inside pushed content
   =========================================================================
   Syncfusion SfSidebar adds .e-content-animation to the pushed content area
   and may apply a CSS transform for the push animation. Any CSS transform on
   an ancestor creates a new containing block for position:fixed descendants,
   making them behave like position:absolute and scroll with the page.
   Resetting to transform:none here restores correct fixed-positioning behavior
   while the margin-based push animation continues to work.
   ========================================================================= */
.e-content-animation {
    transform: none !important;
}

/* Element defaults and the two-tone focus ring. Bootstrap's own stylesheet is not loaded in the
   BFF, so links and .btn-primary must be stated here or fall back to browser blue; in hosts that
   do load Bootstrap these simply re-point it at the accent token. */
html, body {
    font-family: var(--tv-font-sans);
}

/* Bootstrap's own stylesheet is not loaded (see App.razor), so these few element
   defaults have to be stated here or links fall back to the browser's default blue.
   They previously carried the stock template's hardcoded light-theme hex values,
   which stayed light-blue on the dark and high-contrast themes; they now track the
   accent token instead.
   A link is accent used as *text*, so it takes --tv-accent-text, not the --tv-accent fill:
   the fill is 2.69:1 on the dark canvas, under the 4.5:1 text minimum, while the text tint
   measures 7.91 on white and 7.68 on #212529. Anything that paints an anchor as a button or
   on an accent fill sets its own colour with a class selector, which outranks this one. */
a, .btn-link {
    color: var(--tv-accent-text);
}

.btn-primary {
    color: var(--tv-on-accent);
    background-color: var(--tv-accent);
    border-color: var(--tv-accent);
}

/* The inner white ring was invisible against a dark panel, leaving a single-colour
   halo instead of the intended two-tone focus indicator. currentColor's inverse is
   not available in CSS, so the surface token supplies the separating ring. */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
    box-shadow: 0 0 0 0.1rem var(--tv-focus-ring-inner), 0 0 0 0.25rem var(--tv-focus-ring);
}

/* The layout markup carried Bootstrap's `px-2` for its horizontal gutter, but the Bootstrap
   stylesheet is not loaded (its <link> is commented out in App.razor), so that class resolved to
   nothing and every page — the full-bleed entity grids most visibly — ran edge-to-edge. The
   gutter is owned here instead, via the shared token. */
.content {
    padding-top: var(--tv-content-top-gap);
    padding-inline: var(--tv-page-gutter);
}

/* Reset margin added by Syncfusion e-icon-left on icon-only buttons using MDI */
.e-icon-btn.e-btn .e-btn-icon.mdi {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* TvButton visual hierarchy. The Secondary variant is an outline: transparent bg, theme-aware
   text/icon/border, primary colour on hover. Primary (.e-primary) and Danger (.e-danger) keep the
   Syncfusion solid fill, so they are excluded here — an unscoped rule with !important silently
   turned every IsPrimary button in the app into an outline. :where() keeps the exclusion at zero
   specificity so the scoped .tv-btn-colored overrides in TvButton.razor.css still win. */
.e-btn.tv-btn:where(:not(.e-primary, .e-danger)) {
    background-color: transparent !important;
    border: 1px solid var(--color-sf-content-text-color) !important;
    color: var(--color-sf-content-text-color) !important;
}

.e-btn.tv-btn .e-btn-icon {
    color: inherit !important;
}

/* Hover, focus and press recolour the outline: the border takes the accent fill, the label its text
   tint, because the fill as a label is 2.69:1 on the dark canvas (2.49 on the :active wash). */
.e-btn.tv-btn:where(:not(.e-primary, .e-danger)):hover,
.e-btn.tv-btn:where(:not(.e-primary, .e-danger)):focus {
    background-color: transparent !important;
    border-color: var(--color-sf-primary) !important;
    color: var(--tv-accent-text) !important;
}

.e-btn.tv-btn:where(:not(.e-primary, .e-danger)):active {
    background-color: color-mix(in srgb, var(--color-sf-primary) 10%, transparent) !important;
    border-color: var(--color-sf-primary) !important;
    color: var(--tv-accent-text) !important;
}

/* A pressed toggle (TvButton Pressed="true", #1177): the outline doubled to 2px, heavier text and a
   faint accent wash. A Secondary button already has a 1px border in the text colour, so the accent border
   the planning shell gives its flat toggles (#1174) would have made the pressed one the FAINTER outline
   (2.01:1 on the dark theme, against 9.78:1 for the unpressed ones beside it). Width and weight carry
   the state without colour; the wash is the third, colour-only cue. The inset shadow draws the second
   pixel without moving the layout, and yields to the focus ring rather than hiding it. After :active so
   a pressed toggle stays marked while it is being clicked off. Disabled wins: TvButton.razor.css fades
   it, so a toggle that cannot be used never reads as the one that is on. The wash is !important only
   because the Secondary base, :hover and :active rules above set background-color !important; without
   it the pressed toggle would lose its wash to them. Selected toggles use their own solid fill. */
:where(.tv-btn-root:not(.tv-btn-selected)) .e-btn.tv-btn:where(:not(.e-primary, .e-danger))[aria-pressed="true"] {
    background-color: color-mix(in srgb, var(--palette-accent, hotpink) 14%, transparent) !important;
    font-weight: 600;
}

:where(.tv-btn-root:not(.tv-btn-selected)) .e-btn.tv-btn:where(:not(.e-primary, .e-danger))[aria-pressed="true"]:not(:focus-visible) {
    box-shadow: inset 0 0 0 1px currentColor;
}

/* Tertiary variant: the outline without its border. At rest it is fully transparent by design
   (dismiss/cancel/low-stakes toggle), but it still needs a hover/active background tint — without
   one it reads as plain text, not a button, since the Secondary outline's hover/active recolouring
   alone isn't enough affordance once the border is gone. The tint is skipped for a Selected toggle
   (aria-pressed="true") so hovering/pressing the currently-selected preset doesn't visually wash
   out its --tv-accent fill from TvButton.razor.css. */
.e-btn.tv-btn.e-btn-borderless {
    border: none !important;
}

.e-btn.tv-btn.e-btn-borderless:hover,
.e-btn.tv-btn.e-btn-borderless:focus {
    border: none !important;
}

.e-btn.tv-btn.e-btn-borderless:active {
    border: none !important;
}

.e-btn.tv-btn.e-btn-borderless:not([aria-pressed="true"]):hover,
.e-btn.tv-btn.e-btn-borderless:not([aria-pressed="true"]):focus {
    background-color: color-mix(in srgb, var(--color-sf-primary) 6%, transparent) !important;
}

.e-btn.tv-btn.e-btn-borderless:not([aria-pressed="true"]):active {
    background-color: color-mix(in srgb, var(--color-sf-primary) 10%, transparent) !important;
}

/* =========================================================================
   Main-layout sidebar z-index — must render above the sticky TopBar
   (z-index: 1000) on mobile where sidebar type is Over.
   Scope this override to the layout container to avoid affecting other
   Syncfusion sidebars.
   ========================================================================= */
#contentContainer .e-sidebar {
    z-index: var(--tv-z-sidebar) !important;
}

/* =========================================================================
   Modal dialogs must clear the app chrome. Syncfusion computes a dialog
   z-index of 1000 and writes it inline, which loses to the sidebar override
   directly above — so a modal renders behind the navigation menu.

   Only the container is lifted, never the overlay or the dialog itself:
   Syncfusion sets the overlay to exactly one below the dialog, and since
   both are children of the container, raising the container carries them up
   as a stacking context with that relative order intact. Overriding the
   inner two as well collapses the gap and the overlay covers the dialog,
   which presents as an unresponsive, greyed-out modal.
   !important is unavoidable here: nothing else outranks an inline style.
   ========================================================================= */
.e-dlg-container {
    z-index: var(--tv-z-dialog, 1100) !important;
}

/* The error dialog clears everything, including the toasts and any dialog that raised it — an
   exception must never be reported behind the screen that caused it. The selector targets the
   *container*, because the rule above is a blanket !important that a ZIndex on the SfDialog
   itself cannot beat. Same invariant as above: lift the container only. */
.e-dlg-container:has(.error-dialog) {
    z-index: var(--tv-z-error-dialog, 1400) !important;
}

/* =========================================================================
   Native data tables (.tv-table).
   One shared density for every plain <table> of figures, so the copies in
   each component stop drifting apart. A component adds its own BEM modifiers
   (sticky name column, right-aligned figures, depth indents) on top, and
   never restyles the th/td base padding or borders.
   ========================================================================= */
.tv-table {
    border-collapse: collapse;
    width: 100%;
}

.tv-table th,
.tv-table td {
    padding: var(--tv-space-1, 0.25rem) var(--tv-space-2, 0.5rem);
    border-bottom: 1px solid var(--tv-color-border, hotpink);
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.tv-table thead th {
    position: sticky;
    top: 0;
    font-weight: var(--tv-weight-strong, 600);
    background: var(--tv-surface, hotpink);
}

/* =========================================================================
   KPI tiles (.tv-kpi-row / .tv-kpi).
   One summary-figure tile for every row of headline numbers (planning's
   Totaler and Mit dashboard, #1404), so the copies stop drifting apart.
   The tiles sit on the content surface like the tables beside them, with
   compact padding because the value is the only large thing in a tile. A
   component adds its own modifiers (status tint, a ring, a split line).
   ========================================================================= */

/* Equal columns across the full width; below the minimum the row wraps. A
   row with more tiles lowers --tv-kpi-min-width rather than restyling the
   grid. min(100%, ...) keeps a narrow column from scrolling the page. */
.tv-kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--tv-kpi-min-width, 12rem)), 1fr));
    gap: var(--tv-space-3, 0.75rem);
}

.tv-kpi {
    display: flex;
    flex-direction: column;
    gap: var(--tv-space-1, 0.25rem);
    min-width: 0;
    padding: var(--tv-space-2, 0.5rem) var(--tv-space-3, 0.75rem);
    border: 1px solid var(--tv-color-border, hotpink);
    border-radius: var(--tv-default-border-radius, 0.5rem);
    background: var(--tv-surface, hotpink);
}

.tv-kpi-label {
    font-size: var(--tv-text-meta, 0.75rem);
    color: var(--tv-color-text-secondary, hotpink);
}

/* A baseline-aligned row that wraps, so a unit or a marker beside the figure
   drops below it in a narrow tile instead of overflowing. line-height 1.2
   keeps the metric size from adding the body's leading on top. */
.tv-kpi-value {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: var(--tv-space-2, 0.5rem);
    font-size: var(--tv-text-metric, 1.75rem);
    font-weight: var(--tv-weight-strong, 600);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* The unit after a figure ("timer"): body size and muted, as the figure is
   what the eye should land on. */
.tv-kpi-unit {
    font-size: var(--tv-text-body, 0.875rem);
    color: var(--tv-color-text-secondary, hotpink);
}

/* =========================================================================
   Sections (TvSection, #2559): one box of content, its regions flush.
   No content sits on the page canvas. One subject is one box; inside it the
   regions join with one shared border and no gap, only the outer corners
   rounded (the Kunder list's search row, grouping strip, grid and pager are
   one rectangle). A new subject is a new box, --tv-space-3 below, opened by
   the brand band - docs/design-system/README.md, Sections and boxes.
   Global, not scoped: the regions are other components a scoped rule cannot
   reach. No overflow clipping: toolbars inside open absolute flyouts.
   ========================================================================= */

.tv-section {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--tv-surface, hotpink);
    border: 1px solid var(--tv-color-border, hotpink);
    border-radius: var(--tv-default-border-radius, 0.5rem);
}

/* One border between neighbouring regions, never a gap. */
.tv-section > * + * {
    border-block-start: 1px solid var(--tv-color-border, hotpink);
}

/* The box does not clip, so the regions round their own outer corners; 1px less than the box so the
   curve sits inside its border. */
.tv-section > :first-child {
    border-start-start-radius: calc(var(--tv-default-border-radius, 0.5rem) - 1px);
    border-start-end-radius: calc(var(--tv-default-border-radius, 0.5rem) - 1px);
}

.tv-section > :last-child {
    border-end-start-radius: calc(var(--tv-default-border-radius, 0.5rem) - 1px);
    border-end-end-radius: calc(var(--tv-default-border-radius, 0.5rem) - 1px);
}

/* Boxes stack with the one rhythm. A parent that already lays its children out with a gap keeps it
   and leaves this class off. */
.tv-section-stack {
    display: flex;
    flex-direction: column;
    gap: var(--tv-space-3, 0.75rem);
    min-width: 0;
}

/* A Syncfusion grid inside a box is one of its regions, and the box is its frame: the grid's own outer
   border would draw a second line along the box's edge (seen live on Min planlægning, #2560). */
.tv-section .e-grid {
    border-width: 0;
}

/* The heading: the brand band on a page (Section bands), body size at strong weight. */
.tv-section__header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--tv-space-1, 0.25rem) var(--tv-space-2, 0.5rem);
    padding: var(--tv-space-2, 0.5rem) var(--tv-space-4, 1rem);
    background: var(--tv-form-section-header-surface, hotpink);
    color: var(--tv-form-section-header-fg, hotpink);
}

.tv-section__title {
    margin: 0;
    font-size: var(--tv-text-body, 0.875rem);
    font-weight: var(--tv-weight-strong, 600);
    color: inherit;
}

.tv-section__subtitle {
    font-size: var(--tv-text-meta, 0.75rem);
}

.tv-section__header-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--tv-space-2, 0.5rem);
    margin-inline-start: auto;
}

/* A borderless button on the band takes the band's foreground and darkening hover, as in the dialog
   header; !important because the TvButton rules set colour with !important. A Primary button keeps
   its fill - it would vanish into a band of the same blue, so put it in a row instead. */
.tv-section:not(.tv-section--window) > .tv-section__header .e-btn.e-btn-borderless {
    color: var(--tv-form-section-header-fg, hotpink) !important;
}

.tv-section:not(.tv-section--window) > .tv-section__header .e-btn.e-btn-borderless:hover,
.tv-section:not(.tv-section--window) > .tv-section__header .e-btn.e-btn-borderless:focus-visible {
    background: var(--tv-form-section-header-hover, hotpink) !important;
}

/* In a dialog or side panel the window title is already the band: the heading is a neutral strip. */
.tv-section--window > .tv-section__header {
    background: var(--tv-surface-alt, hotpink);
    color: inherit;
}

/* A padded region: a filter line, a banner, a toolbar, a pager. */
.tv-section__row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--tv-space-2, 0.5rem);
    min-width: 0;
    padding: var(--tv-space-2, 0.5rem) var(--tv-space-4, 1rem);
}

/* A toolbar or tab strip that should read as chrome rather than content. */
.tv-section__row--muted {
    background: var(--tv-surface-alt, hotpink);
}

/* One padded region holding content that keeps its own inner layout - a dialog's form or list
   (#2562) - rather than splitting it into rows. */
.tv-section__body {
    min-width: 0;
    padding: var(--tv-space-3, 0.75rem) var(--tv-space-4, 1rem);
}

/* A foot note or helper line under a table. */
.tv-section__note {
    padding: var(--tv-space-1, 0.25rem) var(--tv-space-4, 1rem);
    font-size: var(--tv-text-meta, 0.75rem);
    color: var(--tv-color-text-secondary, hotpink);
}

/* Side-by-side cells sharing a border. Each cell casts a 1px line on its start and top edge; the
   split clips at its own edge, so only the lines between cells show - in a row, and when the cells
   wrap into a column on a narrow screen. A shadow rather than a border, so no cell is a pixel
   narrower than its neighbour. Nothing in a cell opens an inline flyout, so the clip is safe. */
.tv-section__split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--tv-section-split-min, 32rem)), 1fr));
    overflow: hidden;
}

.tv-section__split > * {
    min-width: 0;
    box-shadow: -1px 0 0 var(--tv-color-border, hotpink), 0 -1px 0 var(--tv-color-border, hotpink);
}

/* TvDialog CanvasBody: the body is the page canvas, so the TvSections in it read as boxes, as on a
   page. Opt-in per dialog; every other dialog keeps its plain surface. */
.e-dlg-container.tv-dialog-canvas > .e-dialog > .e-dlg-content {
    background: var(--tv-body-bg, hotpink);
}

.e-dlg-container.tv-dialog-canvas > .e-dialog .tv-dialog-body {
    display: flex;
    flex-direction: column;
    gap: var(--tv-space-3, 0.75rem);
}

/* =========================================================================
   Status tones (.tv-indicator-*, .tv-approval-*, .tv-invoice-*, …).
   A status colour that is known at compile time is a class, not an inline
   style (docs/design-system/README.md, Status tones). A tone class is named
   tv- plus its Tier-2 token and only sets --tv-status-color; it paints
   nothing, because the same status is text on one screen and a border, a
   dot or a fill on the next. .tv-status-text paints the common case; any
   other use reads the property in the component's own rule.
   The C# helpers return these names (ValueTargetIndicatorDisplay.GetCssClass,
   TimeRegStatusColors.GetApprovalStateCssClass, InvoiceStatusDisplay.CssClass,
   PlanningLoadLevel.CssClass), and a test per helper holds every rule here to
   the var() its colour helper returns, so the two cannot drift.
   ========================================================================= */

/* Not inherited: a tone on a card must not colour a child that reads the property without a tone
   of its own (the uncoloured work-hours figure inside a toned approval card). Universal syntax keeps
   the value a token stream, so a token built on currentColor resolves on the element that paints. */
@property --tv-status-color {
    syntax: "*";
    inherits: false;
}

/* Text, and the glyphs inside it. No tone means no status, so the text keeps its own colour. */
.tv-status-text {
    color: var(--tv-status-color, currentColor);
}

/* TimeRegPeriodSummary.ValueTargetIndicator */
.tv-indicator-neutral { --tv-status-color: var(--indicator-neutral, hotpink); }
.tv-indicator-good { --tv-status-color: var(--indicator-good, hotpink); }
.tv-indicator-warning { --tv-status-color: var(--indicator-warning, hotpink); }
.tv-indicator-bad { --tv-status-color: var(--indicator-bad, hotpink); }

/* TimeRegApprovalStateEnum */
.tv-approval-draft { --tv-status-color: var(--approval-draft, hotpink); }
.tv-approval-employee-closed { --tv-status-color: var(--approval-employee-closed, hotpink); }
.tv-approval-management-approved { --tv-status-color: var(--approval-management-approved, hotpink); }
.tv-approval-management-denied { --tv-status-color: var(--approval-management-denied, hotpink); }

/* InvoiceStatus */
.tv-invoice-status-draft { --tv-status-color: var(--invoice-status-draft, hotpink); }
.tv-invoice-status-done { --tv-status-color: var(--invoice-status-done, hotpink); }
.tv-invoice-status-approved { --tv-status-color: var(--invoice-status-approved, hotpink); }
.tv-invoice-status-posted { --tv-status-color: var(--invoice-status-posted, hotpink); }
.tv-invoice-status-dispatched { --tv-status-color: var(--invoice-status-dispatched, hotpink); }
.tv-invoice-status-paid { --tv-status-color: var(--invoice-status-paid, hotpink); }
.tv-invoice-status-cancelled { --tv-status-color: var(--invoice-status-cancelled, hotpink); }

/* The invoicing dashboard's key figures (passed to DashboardKpiTile, so they cannot be scoped) */
.tv-invoice-aging-over-90 { --tv-status-color: var(--invoice-aging-over-90, hotpink); }
.tv-invoice-shortfall-negative { --tv-status-color: var(--invoice-shortfall-negative, hotpink); }
.tv-invoice-shortfall-positive { --tv-status-color: var(--invoice-shortfall-positive, hotpink); }

/* PlanningLoadBucket - the capacity cells, Totals, Find quickly and the legend */
.tv-planning-load-bar-spare { --tv-status-color: var(--planning-load-bar-spare, hotpink); }
.tv-planning-load-bar-spare-soft { --tv-status-color: var(--planning-load-bar-spare-soft, hotpink); }
.tv-planning-load-bar-mid { --tv-status-color: var(--planning-load-bar-mid, hotpink); }
.tv-planning-load-bar-over-soft { --tv-status-color: var(--planning-load-bar-over-soft, hotpink); }
.tv-planning-load-bar-over { --tv-status-color: var(--planning-load-bar-over, hotpink); }

/* =========================================================================
   Chart text
   Syncfusion writes `Roboto`/`Helvetica` as an SVG presentation attribute with no fallback and
   Roboto is not loaded, so on Windows every axis label, legend entry, data label and tooltip fell
   back to the browser's serif. A CSS declaration outranks a presentation attribute, so one rule
   here puts every chart in the app on the design-system stack. Tooltips render in their own
   `_tooltip` SVG outside the chart element, hence the id selectors.
   ========================================================================= */
.e-chart text,
.e-accumulationchart text,
[id$="_tooltip"] text,
[id$="_tooltip_svg"] text {
    font-family: var(--tv-font-sans);
}

/* =========================================================================
   TvDialog chrome (.e-dlg-container.tv-dialog > .e-dialog).
   Keyed on the container, not .e-dialog: when CssClass changes after the first
   render (Size switching, the merge wizard's preview step) SfDialog moves the
   new classes onto the container but strips them from .e-dialog itself, so a
   .e-dialog.tv-dialog rule stops matching. TvDialog is always modal, so the
   container always exists.
   Global rather than a scoped TvDialog.razor.css on purpose: SfDialog renders
   the header, content and footer containers itself, outside TvDialog's CSS
   scope, so a scoped rule could not reach them without ::deep on every
   selector. Everything is keyed on .tv-dialog so no other dialog changes
   (the error dialog and any dialog not yet on TvDialog keep Syncfusion's
   defaults). The Syncfusion containers are matched with > so a dialog nested
   inside a TvDialog body (the document editor's Font/Table dialogs in the merge
   preview) keeps its own chrome. Tokens only: spacing from --tv-space-*, title
   from --tv-text-section.
   ========================================================================= */
/* A dialog whose content changes height while it is open is pinned to the top (#1978): with
   DialogPositionData Y="top" the container lays it out from the top edge, so it grows and shrinks
   downward and nothing above a change moves. Syncfusion's centred container re-centres on every
   height change instead, which moved both edges by half and put the next click on another control.
   The gap keeps the pinned dialog off the window edge. */
.e-dlg-container.e-dlg-center-top.tv-dialog-pinned {
    box-sizing: border-box;
    padding-block-start: var(--tv-space-6, 2rem);
}

/* Syncfusion caps the dialog at the window height minus 20px, inline, as if it were centred; pinned
   below the gap, that ran the footer off the bottom of a 768px window (seen live: "Flyt" at 765px).
   The cap is the container's height less the same gap again, so the content scrolls instead.
   !important because the cap Syncfusion writes is an inline style. */
.e-dlg-container.e-dlg-center-top.tv-dialog-pinned > .e-dialog {
    max-height: calc(100% - var(--tv-space-6, 2rem)) !important;
}

/* The width is set here, not through SfDialog's Width: SfDialog appends "px" to a value that does
   not end in a unit it knows, turning var(--tv-dialog-md) into an invalid declaration the browser
   drops. !important because SfDialog still writes its default width inline. */
.e-dlg-container.tv-dialog-sm > .e-dialog { width: var(--tv-dialog-sm) !important; }
.e-dlg-container.tv-dialog-md > .e-dialog { width: var(--tv-dialog-md) !important; }
.e-dlg-container.tv-dialog-lg > .e-dialog { width: var(--tv-dialog-lg) !important; }
.e-dlg-container.tv-dialog-full > .e-dialog { width: var(--tv-dialog-full) !important; }

/* The header is the brand band TvFormShell paints its section headers and active tab with, so a
   dialog and the form inside it read as one branded frame. The same tokens, not a dialog-specific
   copy of the blue: each theme (dark, high contrast) redefines them once and both follow. The
   fill already separates header from body, so there is no bottom rule. */
.e-dlg-container.tv-dialog > .e-dialog > .e-dlg-header-content {
    padding: var(--tv-space-3) var(--tv-space-4);
    background: var(--tv-form-section-header-surface, hotpink);
    border-bottom: 0;
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.e-dlg-container.tv-dialog > .e-dialog > .e-dlg-header-content .e-dlg-header {
    font-size: var(--tv-text-section);
    font-weight: 600;
    color: var(--tv-form-section-header-fg, hotpink);
}

.e-dlg-container.tv-dialog > .e-dialog .tv-dialog-title {
    margin: 0;
    font-size: var(--tv-text-section);
    font-weight: 600;
    line-height: inherit;
    color: var(--tv-form-section-header-fg, hotpink);
}

/* TvDialog's HeaderContent slot: the title takes the slack and whatever the slot adds (a help
   button, a status chip) sits after it, before Syncfusion's close icon. The slot sets the band's
   foreground itself so plain text in it inherits it (seen live: the period closing wizard's
   period read dark grey on the blue band — the title is white only because it sets its own colour).
   It wraps (#2517): when the title and the slot do not fit on one line, the slot moves below the title.
   Without the wrap the title, a flex item with min-width 0, was squeezed instead and its text ran under
   the slot (seen live at 375px: "Luk tidsregistreringsperiode" in a 67px box under the wizard's period).
   A header that fits on one line is unchanged. */
.e-dlg-container.tv-dialog > .e-dialog .tv-dialog-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--tv-space-1) var(--tv-space-3);
    min-width: 0;
    /* The header box ends exactly where the close icon starts; a long user card ran up to it. */
    padding-inline-end: var(--tv-space-2);
    color: var(--tv-form-section-header-fg, hotpink);
}


/* A single word wider than the header (a Danish compound on a phone) breaks rather than running under
   the close icon. */
.e-dlg-container.tv-dialog > .e-dialog .tv-dialog-header > .tv-dialog-title {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
}

/* A button in the slot sits on the band like the close icon, so it takes the same foreground and
   the same darkening hover; a Tertiary button's own colours are for a light surface. !important
   because the TvButton rules above set colour with !important (seen live: the help icon rendered
   near-black on the blue band); this selector is more specific, so it wins inside the slot only. */
.e-dlg-container.tv-dialog > .e-dialog .tv-dialog-header .e-btn {
    color: var(--tv-form-section-header-fg, hotpink) !important;
}

.e-dlg-container.tv-dialog > .e-dialog .tv-dialog-header .e-btn:hover,
.e-dlg-container.tv-dialog > .e-dialog .tv-dialog-header .e-btn:focus-visible {
    background: var(--tv-form-section-header-hover, hotpink) !important;
}

/* The close icon sits on the band, so it takes the band's foreground. Hover darkens, never
   lightens, for the same reason as the form band: the white glyph must keep AA contrast. The
   colour goes on the button: the theme forces .e-icons to color: inherit !important. */
.e-dlg-container.tv-dialog > .e-dialog > .e-dlg-header-content .e-dlg-closeicon-btn {
    color: var(--tv-form-section-header-fg, hotpink);
}

.e-dlg-container.tv-dialog > .e-dialog > .e-dlg-header-content .e-dlg-closeicon-btn:hover,
.e-dlg-container.tv-dialog > .e-dialog > .e-dlg-header-content .e-dlg-closeicon-btn:focus-visible {
    background: var(--tv-form-section-header-hover, hotpink);
}

.e-dlg-container.tv-dialog > .e-dialog > .e-dlg-content {
    padding: var(--tv-space-4);
}

/* SidePanel (the slide-in filter/settings panel) carries the same brand band as TvDialog, so a
   panel and a dialog read as one family. Here rather than in SidePanel.razor.css: the dialog does
   not render inside the component's scoped markup, so a scoped rule never reaches it. */
/* Anchored to the viewport edge at full height, the panel has no use for the dialog's rounded
   frame: its light border and corner gaps showed as a white rim around the band. The shadow
   still sets it off from the page. */
.e-dlg-container.side-panel-dialog > .e-dialog {
    border: 0;
    border-radius: 0;
}

.e-dlg-container.side-panel-dialog > .e-dialog > .e-dlg-header-content {
    background: var(--tv-form-section-header-surface, hotpink);
    border-bottom: 0;
}

/* .side-panel-title is named too: a body-text colour on spans beats inheriting from the header. */
.e-dlg-container.side-panel-dialog > .e-dialog > .e-dlg-header-content .e-dlg-header,
.e-dlg-container.side-panel-dialog > .e-dialog > .e-dlg-header-content .side-panel-title {
    color: var(--tv-form-section-header-fg, hotpink);
}

.e-dlg-container.side-panel-dialog > .e-dialog > .e-dlg-header-content .e-dlg-closeicon-btn {
    color: var(--tv-form-section-header-fg, hotpink);
}

.e-dlg-container.side-panel-dialog > .e-dialog > .e-dlg-header-content .e-dlg-closeicon-btn:hover,
.e-dlg-container.side-panel-dialog > .e-dialog > .e-dlg-header-content .e-dlg-closeicon-btn:focus-visible {
    background: var(--tv-form-section-header-hover, hotpink);
}

/* Lets a body that must fill a fixed-height dialog (the merge preview editor) do so; with an auto
   height it resolves to auto, so ordinary dialogs are unaffected. */
.e-dlg-container.tv-dialog > .e-dialog .tv-dialog-body {
    height: 100%;
}

/* A field error in a dialog is a line of text under the field, not a box. Two global sheets meet
   on .validation-message: the BFF's validation-accessibility.css paints a tinted box with a 44px
   min-height (a touch-target size, though the message is not a control), and
   FormComponentsShared.css then shrinks the text to 12px without removing the box — so each field
   in a dialog grew a 60px panel, and in dark mode its red-on-dark-red text failed AA contrast.
   The warning glyph stays, so the error is not signalled by colour alone. The colour is the text
   variant, not the danger fill: the fill as 12px text was 3.41:1 on the dark dialog surface. */
.e-dlg-container.tv-dialog > .e-dialog .validation-message {
    display: flex;
    align-items: baseline;
    gap: var(--tv-space-1);
    min-height: 0;
    margin-top: var(--tv-space-1);
    padding: 0;
    border: 0;
    background: none;
    color: var(--indicator-bad-text, hotpink);
    font-size: var(--tv-text-meta);
    animation: none;
}

.e-dlg-container.tv-dialog > .e-dialog .validation-message::before {
    font-size: inherit;
}

/* The rule above outranks the forced-colors rules in validation-accessibility.css and
   FormComponentsShared.css, and validation-accessibility.css also sets forced-color-adjust: none,
   so without this a high-contrast user got the theme's red instead of the system text colour. */
@media (forced-colors: active) {
    .e-dlg-container.tv-dialog > .e-dialog .validation-message {
        color: CanvasText;
    }
}

.e-dlg-container.tv-dialog > .e-dialog > .e-footer-content {
    padding: var(--tv-space-3) var(--tv-space-4);
    border-top: 1px solid var(--tv-color-border);
}

/* SfDialog always emits the footer template, so a dialog without buttons would show an empty bar. */
.e-dlg-container.tv-dialog > .e-dialog > .e-footer-content:has(> .tv-dialog-footer:empty) {
    display: none;
}

/* Wraps rather than overflowing a phone-width dialog when a footer has three or four buttons
   (the time registration dialog: Cancel, Delete, Draft, Done). */
.e-dlg-container.tv-dialog > .e-dialog .tv-dialog-footer {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: var(--tv-space-2);
}

/* On a phone the footer stacks full-width buttons, Primary on top where the thumb is, rather than
   wrapping shrink-wrapped buttons into a row where Delete sits beside Cancel. One rule for every
   dialog, replacing the time registration form's own mobile button styling. */
@media (max-width: 47.99em) {
    .e-dlg-container.tv-dialog > .e-dialog .tv-dialog-footer {
        flex-direction: column-reverse;
        align-items: stretch;
    }

    .e-dlg-container.tv-dialog > .e-dialog .tv-dialog-footer .e-btn {
        width: 100%;
    }
}
