/* MWS Dashboards — shell + per-dashboard styles. Vanilla CSS; tiny enough
 * that splitting by file isn't worth the import overhead. */

/* Color tokens.
 *
 * theme.js sets <html data-theme="light|dark"> on load; the
 * [data-theme="dark"] block below overrides the light defaults.
 * Browser `color-scheme` is also set so native UI (scrollbars, form
 * controls) follows along without us styling them explicitly. */
:root {
    --fg:           #1a2330;
    --fg-muted:     #5b6675;
    /* MWS-Gelb: the page background takes the MWS ivory so the dashboards
     * sit homogeneously alongside the MWS app (which uses this cream behind
     * its white content cards). Cards themselves stay white (--card-bg). */
    --bg:           #fcffef;
    --card-bg:      #fff;
    --border:       #e3e6ea;
    --accent:       #144263;   /* oc-blue-dark */
    --accent-light: #66b3da;   /* oc-blue-light */
    --accent-soft:  #e7eff9;   /* oc-blue-lighter */
    --status-ok:    #34a853;
    --status-err:   #ea4335;
    --status-warn:  #fbbc04;
    --warn-soft:    #fff8e1;
    --warn-border:  #f6cf6a;
    /* Per-Einkaufsartikel badge tints — distinct semantics:
     *  allergen → red/rose (warning)
     *  customer → teal/blue (informational identifier) */
    --allergen-bg:     #fde7e9;
    --allergen-border: #d97a82;
    --allergen-fg:     #9b2c33;
    --customer-bg:     #e2f0ec;
    --customer-border: #6ba893;
    --customer-fg:     #1f5e4d;
    --code-bg:      #eef0f3;
    --accent-fg:    #fff;
    --accent-hover: #19557d;   /* oc-blue */
    --bg-soft:      #fafbfc;
    /* App-name badge in the header — mirrors the MWS app bar's centered
     * application box (white icon + name on oc-blue-dark). */
    --app-box-bg:   #144263;
    --app-box-fg:   #fff;
    /* Loading-overlay backdrop — light washes white, dark washes navy so
     * the page underneath dims instead of glowing. */
    --overlay-backdrop: rgba(255, 255, 255, .3);
    color-scheme: light;
}

:root[data-theme="dark"] {
    --fg:           #e1e6ed;
    --fg-muted:     #9fb0c4;
    /* Dark chrome experiment: base the dark theme on the official
     * oc-blue-dark-background (#1b354c) so it reads as OrgaCard navy rather
     * than neutral slate. The dominant surface (cards / header / table —
     * ~90% of the page) takes the official #1b354c so that navy is what you
     * actually see; the page canvas behind them is one step lighter (#21415d)
     * so the cards read as recessed panels. Revert this commit to restore the
     * previous near-black slate dark theme. */
    --bg:           #21415d;
    --card-bg:      #1b354c;   /* oc-blue-dark-background — the ~90% surface */
    --border:       #33506d;
    --accent:       #4a86ad;
    --accent-light: #b7d3e6;
    --accent-soft:  #274563;
    --status-ok:    #5cbe6f;
    --status-err:   #ef6f63;
    --status-warn:  #f0c252;
    --warn-soft:    #3a2f1c;
    --warn-border:  #8a6e2d;
    --allergen-bg:     #3a1e22;
    --allergen-border: #8a484f;
    --allergen-fg:     #f0a3a8;
    --customer-bg:     #1d2f2a;
    --customer-border: #4a8473;
    --customer-fg:     #9bd0bc;
    --code-bg:      #24435f;
    --accent-fg:    #0f141b;
    --accent-hover: #5e9bc3;
    --bg-soft:      #1e3a54;
    /* On the dark chrome the badge takes oc-blue (a touch brighter than
     * oc-blue-dark) so it still separates from the surrounding navy. */
    --app-box-bg:   #19557d;
    --app-box-fg:   #fff;
    --overlay-backdrop: rgba(9, 20, 32, .45);
    color-scheme: dark;
}

* { box-sizing: border-box; }

/* One unified focus ring across every interactive element. :focus-visible
 * means it only paints on keyboard nav, not on mouse clicks — keeps the
 * UI quiet for pointer users while keyboard users always know where they
 * are. Components that already paint their own focus state can override
 * with a more specific selector. */
:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    background: var(--bg);
    color: var(--fg);
    font: 14px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
}
/* Flex column on the body lets header + footer claim their natural
 * heights and gives <main> the remaining vertical real estate. */
body {
    display: flex;
    flex-direction: column;
}

/* ─── shell chrome ────────────────────────────────────────────────────── */

header {
    display: flex;
    /* Branding (logo, title, app-name badge, toggle) is vertically centered
     * in a fixed-height bar; only the tab strip opts out to flex-end so the
     * active tab still meets the header's bottom border and reads as
     * connected to the content below. Symmetric vertical padding (none, the
     * min-height does the work) keeps equal space above and below the logo
     * and badge. */
    align-items: center;
    gap: 1.5rem;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    --header-row-height: 3.5rem;   /* the bar's height, and its first row's */
    min-height: var(--header-row-height);
    /* A tab strip too wide to sit beside the branding wraps, whole, onto a
     * second row of its own; its tabs never wrap among themselves (see
     * nav.tabs). The theme toggle takes no part in that: it is pinned to the
     * first row (see .theme-toggle), and the right padding keeps its room
     * free, so in one row the tabs end where the toggle begins and in two
     * the toggle stays where it was. */
    flex-wrap: wrap;
    /* Only the tab strip feels this: alone on a second row it has no auto
     * margin to hold it, so it moves right. On a row shared with the
     * app-name badge, the badge's auto margins take the free space first.
     * `safe` keeps a strip wider than its row from overflowing the left
     * edge, where it would be cut off: it starts at the left padding
     * instead and runs on into the toggle's room, which is empty on the
     * second row. A browser without `safe` keeps the line above it. */
    justify-content: flex-end;
    justify-content: safe flex-end;
    row-gap: 0;          /* the second row sits right under the first */
    flex-shrink: 0;      /* a flex item of the body: it must not give up the second row */
    position: relative;
    --theme-toggle-room: 6rem;   /* at least the toggle's own width */
    padding: 0 calc(1.5rem + var(--theme-toggle-room) + 1.5rem) 0 1.5rem;
}
header .title-block {
    display: flex;
    flex-direction: column;
    gap: .15rem;
}
header h1 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--accent);
    font-weight: 700;
}

/* ─── header branding (MWS + LMS) ─────────────────────────────────────
 * OrgaCard logo on the far left, the app-name badge (app icon + name)
 * centered between it and what follows. The badge's auto margins on both
 * sides split the free space of its row either side of it: in one row it
 * lands centered between the logo and the tab strip, which stays right; when
 * the tab strip has wrapped onto a row of its own (see header), centered
 * between the logo and the theme toggle, and the tabs stay right.
 * Both inherit the header's vertical centering (align-items: center). Both
 * apps render this same structure. */
header .brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex: 0 0 auto;
    /* The bar's own height, so the first row keeps it when the tab strip
     * wraps below — that row is the one the theme toggle is centred in. */
    height: var(--header-row-height);
}
header .brand-logo {
    height: 30px;
    width: auto;
    display: block;
}
header .app-name {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;      /* both sides auto: centered in its row (see above) */
    margin-right: auto;
    padding: .3rem .75rem;
    background: var(--app-box-bg);
    color: var(--app-box-fg);
    border-radius: 6px;
    flex: 0 0 auto;
}
header .app-name-icon {
    height: 30px;
    width: auto;
    display: block;
    flex: 0 0 auto;
}
header .app-name-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
header .app-name-title {
    font-weight: 700;
    font-size: .95rem;
}
header .app-name-sub {
    font-size: .72rem;
    opacity: .85;
    font-weight: 500;
}

nav.tabs {
    display: flex;
    gap: .25rem;
    align-items: stretch;
    align-self: flex-end;   /* pin the tab strip to the bar's bottom edge */
}
nav.tabs a {
    display: block;
    padding: .5rem 1rem;
    color: var(--fg-muted);
    text-decoration: none;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 6px 6px 0 0;
    font-weight: 500;
    margin-bottom: -1px; /* sit on top of the header bottom border */
    /* A label never breaks inside a tab: a strip that no longer fits wraps
     * onto a row of its own instead (see header). */
    white-space: nowrap;
}
nav.tabs a:hover {
    background: var(--accent-soft);
    color: var(--fg);
}
nav.tabs a.active {
    background: var(--bg);
    color: var(--accent);
    border-color: var(--border);
    border-bottom: 1px solid var(--bg);
}

/* Theme toggle — segmented control of three icon buttons (Hell, Auto,
 * Dunkel). Sits at the far right of the header, separated from the tab
 * strip. The active state mirrors the saved preference, not the
 * computed theme — Auto is a meta-state independent of the effective
 * light/dark resolution. */
.theme-toggle {
    display: flex;
    border: 1px solid var(--border);
    border-radius: 6px;
    overflow: hidden;
    /* Pinned to the middle of the header's first row rather than placed in
     * its flex flow, so a tab strip wrapping onto a second row cannot take
     * it along. The room it needs is held free by the header's right
     * padding. */
    position: absolute;
    right: 1.5rem;
    top: calc(var(--header-row-height) / 2);
    transform: translateY(-50%);
}
.theme-toggle .theme-btn {
    background: var(--card-bg);
    color: var(--fg-muted);
    border: none;
    padding: .35rem .55rem;
    font-size: .85rem;
    cursor: pointer;
    min-width: 1.9rem;
    line-height: 1;
}
.theme-toggle .theme-btn + .theme-btn {
    border-left: 1px solid var(--border);
}
.theme-toggle .theme-btn:hover {
    background: var(--accent-soft);
    color: var(--fg);
}
.theme-toggle .theme-btn.active {
    background: var(--accent);
    color: var(--accent-fg);
}

main {
    flex: 1 1 auto;
    min-height: 0;            /* allow children to shrink in flex layout */
    padding: 1rem 1.5rem;
    overflow: hidden;          /* per-section scroll instead of page scroll */
}

footer {
    flex: 0 0 auto;
    /* Pin the status line to the bottom edge of the viewport. On the wide
     * layout this changes nothing — `main` clips its overflow, so the page
     * never scrolls and the footer already sits at the bottom. It earns its
     * keep on the narrow layout, where the media query below hands `main`
     * back to overflow:visible and the page starts scrolling; that same
     * media query unclamps the body height, without which this sticky has
     * no room to travel. The opaque background is what keeps the scrolling
     * content from showing through. */
    position: sticky;
    bottom: 0;
    padding: .65rem 1.5rem;
    color: var(--fg-muted);
    font-size: .95rem;
    border-top: 1px solid var(--border);
    background: var(--card-bg);
}
/* Status line is the "lade …" / "N Treffer" feedback at the bottom-
 * left. Bumped from .8rem to a comfortable 1rem and made bold +
 * higher-contrast colours on customer request — the previous size
 * blended into the chrome and a user scanning the table for results
 * had no peripheral signal that a fetch was in progress. */
.status        { color: var(--fg);         font-weight: 600; font-size: 1rem; }
.status.ok     { color: var(--status-ok);  font-weight: 600; }
.status.error  { color: var(--status-err); font-weight: 600; }
.status.loading{ color: var(--status-warn);font-weight: 600; }
/* Reserve one line for the footer status so the chrome keeps a constant
 * height: without this the empty (loaded) state collapses the inline span
 * to 0 while "lade …" is a full text line, and the footer jumps. */
#status { display: block; min-height: 1lh; }

.empty {
    color: var(--fg-muted);
    text-align: center;
    padding: 4rem 1rem;
}

/* Full-page replacement shown by shell.js when /api/* returns 401.
   Deliberately minimal — body is wiped, no header, no navigation.
   Users return to MWS to re-mint a session. */
.auth-required {
    max-width: 32rem;
    margin: 6rem auto;
    padding: 0 1rem;
    color: var(--fg);
}
.auth-required h1 {
    font-size: 1.5rem;
    margin: 0 0 .75rem;
}
.auth-required p {
    color: var(--fg-muted);
    line-height: 1.5;
}

/* ─── loading overlay ─────────────────────────────────────────────────
 * Fullscreen spinner ported from the MWS/LMS Angular frontends
 * (@orgacard/theme loading-overlay.scss): the OrgaCard logo abstracted
 * to pure CSS — orange dot, grey arc spinning backwards, oc-blue arc
 * spinning forwards. The circle colors are brand constants and stay
 * identical in both themes; only the backdrop follows the theme.
 * Markup lives in two places with the same classes: shell.js builds the
 * runtime overlay, each app's index.html carries a static copy
 * (.init-loading-overlay) that bridges the gap until the shell boots. */
.loading-overlay {
    position: fixed;
    inset: 0;
    /* One step below #oc-auth-overlay (9999, auth.css): the LMS tenant/
     * system picker appears while the init splash is still up and must
     * stay clickable above it. */
    z-index: 9990;
    opacity: 1;
    /* shell.js fades the init splash out by setting opacity 0, then
     * removes the node once this transition has finished. */
    transition: opacity .3s;
}
.loading-overlay[hidden] { display: none; }
.loading-overlay .app-splash-screen {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    background: var(--overlay-backdrop);
    backdrop-filter: blur(2px);
}
.loading-overlay .loading-container {
    position: relative;
    width: 94px;
    height: 94px;
    overflow: visible;
}
.loading-overlay .circle {
    position: absolute;
    top: 50%;
    left: 50%;
    border-radius: 50%;
}
.loading-overlay .circle1 {
    width: 38px;
    height: 38px;
    background-color: rgb(243, 148, 0);
    transform: translate(-50%, -50%);
}
.loading-overlay .circle2 {
    width: 66px;
    height: 66px;
    border: 9px solid transparent;
    border-top-color: rgb(166, 168, 169);
    transform: translate(-50%, -50%) rotate(45deg);
    animation: oc-spin 3s infinite linear reverse;
}
.loading-overlay .circle3 {
    width: 96px;
    height: 96px;
    border: 11px solid transparent;
    border-top-color: rgb(0, 124, 193);
    transform: translate(-50%, -50%) rotate(45deg);
    animation: oc-spin 4s infinite linear;
}
/* The Angular original declares two identical keyframes (spin1/spin2);
 * collapsed to one here — the arcs still differ via duration/direction. */
@keyframes oc-spin {
    from { transform: translate(-50%, -50%) rotate(45deg); }
    to   { transform: translate(-50%, -50%) rotate(405deg); }
}

/* ─── per-dashboard primitives ────────────────────────────────────────── */

.page {
    display: grid;
    /* minmax(0, 1fr) — without the explicit 0 floor, the chart column
     * inherits min-content from the ECharts canvas inside (which has
     * stale inline width attributes between resize()s). That floor
     * pushes the 280 px sidebar past the page's right edge, where
     * `main { overflow: hidden }` clips it. The 0 lets the column
     * actually shrink and the sidebar stay anchored. */
    grid-template-columns: minmax(0, 1fr) 280px;
    grid-template-rows: auto 1fr;  /* header row natural, charts/filters fill */
    height: 100%;
    gap: 1rem;
    min-height: 0;
}

.page-header {
    grid-column: 1 / -1;
    grid-row: 1;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
}
.page-header h2 {
    margin: 0 0 .1em 0;
    color: var(--accent);
    font-size: 1.15rem;
}
.page-header .color-by {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    gap: .2rem;
    font-size: .8rem;
    color: var(--fg-muted);
}
/* Label-less select (e.g. Preisbasis): drop it to the bottom so it lines up
   with the neighbouring select that still carries a caption above it. */
.page-header .color-by.basis {
    align-self: flex-end;
}
.page-header .color-by.basis + .color-by {
    margin-left: 0;
}
.page-header .color-by select {
    font: inherit;
    padding: .35rem .5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--fg);
    min-width: 160px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    /* Flex column so the .chart inside can flex:1 and fill remaining space. */
    display: flex;
    flex-direction: column;
    min-height: 0;
    /* As a grid item, default min-width is `auto` (= min-content), which
     * inherits the ECharts canvas's last-rendered width. That refuses
     * to shrink, so when the viewport narrows, the card overflows its
     * cell instead of compressing — and the sidebar drops off the page.
     * min-width: 0 lets the cell take whatever width the grid gives. */
    min-width: 0;
}
.card h3 {
    margin: 0 0 .75rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
    flex: 0 0 auto;
}

.charts {
    grid-column: 1;
    grid-row: 2;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    min-height: 0;
    /* Let the grid container shrink below its children's min-content
     * (the canvas widths). Otherwise it would push past the page's
     * right edge and clip the sidebar. */
    min-width: 0;
}
.chart {
    width: 100%;
    flex: 1 1 auto;
    min-height: 280px;  /* floor so the chart stays usable on shorter screens */
    /* Same min-width: 0 reasoning as on .card — without it the flex
     * item floors at the canvas's intrinsic width and refuses to
     * shrink with its container. */
    min-width: 0;
}
/* KPI text block between a card's heading and its chart: one headline number
 * with a subordinate line under it. It keeps its height (`flex: 0 0 auto`) so
 * the chart below takes the rest of the card rather than squeezing the text. */
.kpi-block {
    flex: 0 0 auto;
    padding: .15rem 0 .35rem 0;
}
/* Two KPIs in one block, for a card that measures two populations instead of
 * one. They sit side by side so neither reads as a footnote of the other.
 * Each takes an equal share of the width the card has, so the second one
 * starts at the same place whatever the first one reads — "—" and
 * "ø -59,5 Std" are the same column. Below two shares of `minmax` the track
 * count drops to one and they stack instead of squeezing. */
.kpi-block-split {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
    gap: 0 1.5rem;
}
.kpi-line {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--fg);
    line-height: 1.1;
}
.kpi-sub {
    font-size: .75rem;
    color: var(--fg-muted);
    margin-top: .15rem;
}

.filters {
    grid-column: 2;
    grid-row: 2;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    /* Scroll the sidebar independently when filters + legend are taller
     * than the viewport. Charts beside it keep their full height. */
    overflow-y: auto;
    min-height: 0;
}
.filters h3 {
    margin: 0 0 .25rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
}
.filters label {
    display: flex;
    flex-direction: column;
    gap: .25rem;
    font-size: .85rem;
    color: var(--fg-muted);
}
.filters select,
.filters input {
    font: inherit;
    padding: .4rem .5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--fg);
}
/* Range filter (von / bis) — two compact number inputs side by side
 * with a hint line below showing the data's actual min/max. */
.filters fieldset.range-filter {
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: .35rem .6rem .5rem;
    margin: 0;
    color: var(--fg-muted);
    font-size: .85rem;
}
.filters fieldset.range-filter legend {
    padding: 0 .35rem;
    font-size: .8rem;
}
.filters fieldset.range-filter .range-row {
    display: flex;
    gap: .5rem;
}
.filters fieldset.range-filter .range-row label {
    flex: 1;
}
.filters fieldset.range-filter input[type="number"] {
    width: 100%;
    padding: .25rem .35rem;
}
.filters fieldset.range-filter .range-hint {
    margin-top: .35rem;
    font-size: .72rem;
    opacity: .8;
}
/* Portionspreis distribution strip — inline SVG painted by the
 * dashboard JS from the server-supplied 20-bin histogram. Bars
 * inside the active von/bis range get the accent fill; bars
 * outside fade to muted. Stretches to the fieldset width via
 * preserveAspectRatio="none" on the <svg>. */
.filters fieldset.range-filter .price-histogram {
    display: block;
    width: 100%;
    height: 44px;
    margin: .25rem 0 .5rem;
    background: var(--bg-soft);
    border-radius: 3px;
}
.filters fieldset.range-filter .price-bin {
    fill: var(--fg-muted);
    opacity: .35;
}
.filters fieldset.range-filter .price-bin.in-range {
    fill: var(--accent);
    opacity: .9;
}
/* Checkbox-style filter rows: row layout instead of stacked, native
 * checkbox sizing instead of the padded input look above. */
.filters label.checkbox-filter {
    flex-direction: row;
    align-items: center;
    gap: .5rem;
    cursor: pointer;
}
.filters label.checkbox-filter input[type="checkbox"] {
    padding: 0;
    margin: 0;
    width: 1rem;
    height: 1rem;
    flex: 0 0 auto;
    cursor: pointer;
}

/* ─── MultiSelect widget ──────────────────────────────────────────────── */
.ms { position: relative; }
.ms-details > summary {
    list-style: none;
    cursor: pointer;
    padding: .4rem .5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--fg);
    display: flex;
    align-items: center;
    user-select: none;
    font-size: .85rem;
}
.ms-details > summary::-webkit-details-marker { display: none; }
.ms-details > summary::after {
    content: '▾';
    margin-left: auto;
    color: var(--fg-muted);
    font-size: .8em;
}
.ms-details[open] > summary {
    border-color: var(--accent);
    background: var(--accent-soft);
}
.ms-summary.has-selection { color: var(--accent); font-weight: 500; }
.ms-panel {
    position: absolute;
    z-index: 20;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 14px rgba(20, 35, 60, .12);
    padding: .5rem;
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
/* When the toggle sits low in the viewport the widget flips upward, so the
 * popover anchors to the summary's top edge instead of its bottom. */
.ms-panel.ms-panel-up {
    top: auto;
    bottom: calc(100% + 4px);
    box-shadow: 0 -6px 14px rgba(20, 35, 60, .12);
}
/* Empty-state notice shown in place of the list when no options match. */
.ms-empty {
    padding: .6rem .4rem;
    text-align: center;
    color: var(--fg-muted);
    font-size: .85rem;
    border: 1px dashed var(--border);
    border-radius: 4px;
    background: var(--bg-soft);
}
.ms-search { padding: .3rem .5rem !important; font-size: .85rem; }
.ms-list {
    overflow-y: auto;
    max-height: 220px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-soft);
}
/* .ms-row is a <label>, and `.filters label` (specificity 0,1,1) sets
 * flex-direction:column to stack a filter's title above its input. We need
 * to beat that specificity here — `label.ms-row` is (0,1,1) too and wins
 * by virtue of being later in the stylesheet. */
label.ms-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .4rem;
    padding: .2rem .4rem;
    font-size: .85rem;
    color: var(--fg);
    cursor: pointer;
}
label.ms-row:hover { background: var(--accent-soft); }
label.ms-row input[type=checkbox],
label.ms-row input[type=radio] { flex: 0 0 auto; margin: 0; }
label.ms-row span {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.ms-actions { display: flex; justify-content: flex-end; }
.ms-actions button {
    margin: 0;
    padding: .25rem .55rem;
    background: transparent;
    color: var(--fg-muted);
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: .8rem;
    cursor: pointer;
}
.ms-actions button:hover {
    background: var(--accent-soft);
    color: var(--accent);
}

/* Scoped to specific filter-bar buttons only — a bare `.filters
 * button` would also style every MultiSelect Clear button inside the
 * sidebar, then `.ms-actions button` needed !important to fight back.
 * Keying off the data-action attribute frees us from the specificity
 * arms race without touching the markup. */
.filters button[data-action="reload"],
.filters button[data-action="reset"] {
    margin-top: .5rem;
    padding: .5rem .75rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: .85rem;
}
/* Reload = primary action (solid) — the user's "I want to see fresh
 * data" instinct. Reset = secondary (outline) since it discards work. */
.filters button[data-action="reload"] {
    border: 1px solid var(--accent);
    background: var(--accent);
    color: var(--accent-fg);
}
.filters button[data-action="reload"]:hover { background: var(--accent-hover); }
.filters button[data-action="reset"] {
    border: 1px solid var(--accent);
    background: transparent;
    color: var(--accent);
}
.filters button[data-action="reset"]:hover { background: var(--accent-soft); }

/* ─── InfoPanel widget ────────────────────────────────────────────────── */
/* The ⓘ next to a dashboard title, and the panel it floats over the
 * content. The host is the positioning context, and it wraps icon AND
 * panel so the pointer can travel from one to the other without the
 * hover ending. */
.ip {
    /* Gap between the icon and the panel. It is used twice: the panel is
     * pushed away by it, and the panel's ::before bridge reaches back by the
     * same amount so the pointer can cross the gap without leaving the host.
     * Without that bridge a slow move onto the panel fires mouseleave and
     * closes it just as the reader arrives — measured, not theoretical. The
     * two values MUST stay equal, hence one variable instead of two numbers. */
    --ip-gap: 6px;
    position: relative;
    display: inline-flex;
    vertical-align: middle;
}
/* The `display` above would otherwise beat the UA `[hidden] { display: none }`
 * rule, so the widget's own `hostEl.hidden` for the empty state would leave a
 * visible but dead ⓘ behind. Same re-assertion as `.legend[hidden]` below. */
.ip[hidden] { display: none; }
.ip-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--fg-muted);
    cursor: pointer;   /* same affordance as every other button in the shell */
}
.ip-toggle:hover,
.ip-toggle[aria-expanded="true"] { color: var(--accent); }
/* Icon size lives here rather than in the SVG's width/height attributes,
 * so it can be tuned without touching the widget's markup constant. The
 * viewBox scales the strokes with it. */
.ip-toggle svg {
    width: 30px;
    height: 30px;
}
/* Above the cards and above the filter popovers, below the loading
 * overlay. Where the panel actually lands is position()'s
 * job, not this rule's: it flips the panel above the icon and scrolls its
 * entries so that it stays inside the dashboard area and above the status
 * line. Note that `main { overflow: hidden }` is only half the reason —
 * the narrow layout hands `main` back to `overflow: visible` and the
 * widget still keeps the panel off the sticky footer. */
.ip-panel {
    position: absolute;
    z-index: 30;
    top: calc(100% + var(--ip-gap));
    left: 0;
    width: max-content;
    max-width: min(770px, 80vw);
    background: var(--card-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 14px rgba(20, 35, 60, .18);
    padding: .6rem .7rem;
    /* Base size = the dashboard title the ⓘ sits under, so the entry
     * labels below match that heading. The prose steps down from it. */
    font-size: 1.15rem;
    line-height: 1.45;
    font-weight: 400;   /* the icon may sit inside an <h2> — don't inherit bold */
    text-align: left;
    white-space: normal;
}
.ip-panel.ip-panel-up {
    top: auto;
    bottom: calc(100% + var(--ip-gap));
    box-shadow: 0 -6px 14px rgba(20, 35, 60, .18);
}
/* The hover bridge: a descendant of the panel, so the host still counts as
 * hovered while the pointer is in the gap. It covers ONLY the gap and never
 * the panel's own area — a positioned pseudo-element paints above the in-flow
 * text of the same stacking context, so it also wins the hit-testing against
 * it. An earlier version spanned the whole panel and cost exactly that: the
 * prose could not be selected and a link inside would have been click-dead,
 * against the promise info-panel.js makes. Keep it a strip. Invisible — it
 * paints nothing. */
.ip-panel::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: calc(-1 * var(--ip-gap));
    height: var(--ip-gap);
}
/* Flipped above the icon: the gap, and with it the bridge, sits below. */
.ip-panel.ip-panel-up::before {
    top: auto;
    bottom: calc(-1 * var(--ip-gap));
}
/* Anchored to the icon's right edge instead of its left, for an icon
 * close enough to the viewport edge that the panel would overflow. */
.ip-panel.ip-panel-right {
    left: auto;
    right: 0;
}
.ip-title {
    font-weight: 600;
    color: var(--accent);
    margin-bottom: .25rem;
}
/* pre-line on the text-bearing elements, not on the panel: a `\n` in a
 * caller's string becomes a real line break, while the panel's own indented
 * markup keeps collapsing — on the container it would show up as blank
 * lines above the first entry. Runs of spaces still collapse either way. */
.ip-intro {
    margin: 0;
    color: var(--fg-muted);
    font-size: 1rem;   /* prose sits a step below the labels */
    white-space: pre-line;
}
/* Only spaced when it actually follows something — an intro-less panel
 * shouldn't open with a gap. */
.ip-intro:not([hidden]) + .ip-entries:not(:empty),
.ip-title:not([hidden]) + .ip-intro[hidden] + .ip-entries:not(:empty) {
    margin-top: .5rem;
}
.ip-entries {
    display: flex;
    flex-direction: column;
    /* The one part of the panel that scrolls. The max-height comes from
     * position() in info-panel.js, not from here: it is whatever room is
     * left between the icon and the edge of the dashboard area, so a long
     * panel stops on the same line as the cards instead of running into the
     * footer. Same split as `.it-tip`, whose geometry is likewise written
     * by its widget while everything else lives in this sheet — and unlike
     * `.ms-list`/`.legend-rows`, which cap themselves at a constant.
     * `auto` keeps the bar away until the clamp bites.
     *
     * Scrolling the entries rather than the whole panel has two reasons:
     * the title stays readable while the reader travels, and the hover
     * bridge `.ip-panel::before` — which sits OUTSIDE the panel's box, in
     * the gap — would be clipped away by an overflow on `.ip-panel`
     * itself, taking the pointer's path to the panel with it. */
    overflow-y: auto;
    /* Naming overflow-x is what settles it: `auto` on one axis computes the
     * `visible` on the other to `auto` too, and the entry text is
     * `pre-line`, which does not break an oversized token. A word wider
     * than the panel would then add a horizontal bar that eats from the
     * clamped height position() just measured. Nothing here is meant to be
     * reachable sideways. */
    overflow-x: hidden;
    /* Keeps the prose off the scrollbar, same as `.legend-rows`. It does
     * NOT reserve the bar's gutter — a classic bar takes that from the
     * content box whatever the padding is, so the text does rewrap a little
     * when the bar appears. Harmless: position() has already written the
     * max-height by then, so a rewrap costs scrolling distance, never
     * height. `scrollbar-gutter: stable` would prevent the rewrap and was
     * turned down for it — a gutter reserved on every panel, including the
     * ones that never scroll, for a reflow nobody can see happen. */
    padding-right: 4px;
}
/* One box per non-empty group. The rule is on the *following* sibling, so
 * the first group never gets a line above it and a group left empty draws
 * no line at all (the widget emits no box for it). */
.ip-group {
    display: flex;
    flex-direction: column;
    gap: .4rem;
}
.ip-group + .ip-group {
    margin-top: .5rem;
    padding-top: .5rem;
    border-top: 1px solid var(--border);
}
.ip-entry {
    display: flex;
    flex-direction: column;
    gap: .05rem;
}
/* Label keeps the panel's base size (= the dashboard title); the text
 * under it steps down, so each entry reads heading-then-prose. */
.ip-entry-label {
    font-weight: 600;
    white-space: pre-line;
}
.ip-entry-text {
    color: var(--fg-muted);
    font-size: 1rem;
    white-space: pre-line;
}
/* `pre-line` keeps the soft-wrap opportunities a text already has but
 * invents none, so a token longer than the panel — a URL, a hyphen-free
 * compound — sticks out of all three of these. Breaking it is the cure.
 * `.ip-entries` and its `overflow-x: hidden` would only hide the symptom,
 * and would not even do that for the intro, which sits outside that box. */
.ip-intro,
.ip-entry-label,
.ip-entry-text { overflow-wrap: break-word; }

/* ─── InfoTip widget ──────────────────────────────────────────────────── */
/* The bubble the widget shows on hover. Same look as the InfoPanel — card
 * background, hairline, shadow — one size down, because it carries values
 * rather than prose. */
/* Only a host with content reacts to the mouse: info-tip.js sets the class
 * with the text and drops it again when the text goes away. */
.it-host-armed { cursor: pointer; }
/* `fixed`, and a child of <body>: as a descendant of its host the bubble was
 * clipped by every ancestor that scrolls. `left`/`top` are written by the
 * widget, which measures the host on each open — left-aligned to it, pulled
 * back or flipped up only when the window would cut it off.
 *
 * Above the cards and the filter popovers, below the loading overlay. */
.it-tip {
    position: fixed;
    z-index: 30;
    left: 0;
    top: 0;
    width: max-content;
    max-width: min(20rem, 70vw);
    background: var(--card-bg);
    color: var(--fg);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 6px 14px rgba(20, 35, 60, .18);
    padding: .4rem .55rem;
    font-size: .8rem;
    font-weight: 400;
    line-height: 1.45;
    text-align: left;
    /* The newlines a caller passes are the line breaks it gets. */
    white-space: pre-line;
    font-variant-numeric: tabular-nums;
    /* The pointer must not be able to hover the bubble itself: it sits over
     * its own host, so hovering it would leave and re-enter the host in a
     * loop. Nothing in a tip is clickable or selectable, so it gives up
     * hit-testing entirely. */
    pointer-events: none;
}
.it-tip[hidden] { display: none; }

/* ─── Sidebar legend ──────────────────────────────────────────────────── */
/* Shared legend used by both charts — replaces per-chart legends so the
 * bars get the full chart width. Each row is a clickable button; the
 * `.off` modifier dims it when the series is currently hidden. */
.legend {
    margin-top: .5rem;
    padding-top: .5rem;
    border-top: 1px dashed var(--border);
    display: flex;
    flex-direction: column;
    gap: .35rem;
}
/* The dashboard JS sets the `hidden` attribute when there's nothing to
 * distinguish — a single series, e.g. "Aufschlüsseln nach: Keine" (the
 * default at start). The `display: flex` above would otherwise override
 * the UA `[hidden] { display: none }` rule and leave an empty "Legende"
 * heading on screen, so re-assert it here. */
.legend[hidden] {
    display: none;
}
.legend h3 {
    margin: 0 0 .25rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
}
.legend-rows {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}
/* Shared layout for legend rows — works for both <div> (LMS Overview's
 * informational legend) and <button> (Einkaufswert's clickable
 * series-toggle legend). Button-only behaviors (hover background,
 * cursor, .off dim state) are scoped to button.legend-row below. */
.legend-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: .45rem;
    margin: 0;
    padding: .2rem .35rem;
    background: transparent;
    color: var(--fg);
    border: 1px solid transparent;
    border-radius: 4px;
    font-size: .82rem;
    text-align: left;
    width: 100%;
}
button.legend-row {
    cursor: pointer;
    /* Rapid clicks (the dblclick "solo" gesture) must not start a text
     * selection on the label. */
    user-select: none;
}
button.legend-row:hover {
    background: var(--accent-soft);
}
button.legend-row.off { opacity: .45; }
button.legend-row.off .legend-swatch {
    background-color: transparent !important;
    border: 1px solid var(--fg-muted);
}
/* The currently-hovered series (chart-side) mirrors here as bold +
 * a subtle background. Paired with scrollIntoView({block:'nearest'})
 * on the JS side so the active entry never disappears below the
 * fold when there are many series. */
button.legend-row.active {
    font-weight: 700;
    background: var(--accent-soft);
}
.legend-swatch {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    border-radius: 2px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .12);
}
.legend-label {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Middle breakpoint — viewport wide enough for a right-hand sidebar but
 * too narrow for two charts side-by-side with a comfortable 12-month
 * axis. Stack the two charts vertically inside their column and split
 * the available height between them (1fr 1fr) so they fill the viewport
 * without an inner scrollbar. Filter sidebar stays on the right. */
@media (max-width: 1700px) and (min-width: 1101px) {
    .charts {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
    /* Drop the usual 280 px floor: when the chart row is the constraint
     * (short viewport, two stacked rows), the floor would force overflow
     * and an inner scrollbar. The card's min-height: 0 already opts in
     * to shrink-to-fit; the chart just needs to follow suit. */
    .chart {
        min-height: 0;
    }
}

@media (max-width: 1100px) {
    /* On narrow viewports drop the chart "fill all the height" trick:
     * the page becomes naturally scrolling, each section takes its
     * intrinsic size. */
    main     { overflow: visible; }
    /* Let the body grow with that scrolling content instead of staying
     * clamped to one screenful. This is what makes the sticky footer above
     * work: a sticky element can only travel inside its containing block,
     * so with a body exactly one viewport tall the status line would stop
     * at the first screenful and scroll out of sight with everything else.
     * The min-height is what still pins the footer to the bottom edge when
     * a dashboard is shorter than the window — and it only does that while
     * `html` keeps the definite height it gets globally: a percentage
     * min-height against an auto-height parent resolves to zero, which
     * leaves a short page's status line floating in mid-screen. */
    body { height: auto; min-height: 100%; }
    .page    { height: auto; grid-template-columns: 1fr; grid-template-rows: none; }
    .page-header, .charts, .filters, .rezepturen-content { grid-column: 1; grid-row: auto; }
    .charts  { grid-template-columns: 1fr; overflow-y: visible; }
    .filters { order: -1; overflow-y: visible; }
    .chart   { height: 380px; flex: 0 0 auto; }
    .rezepturen-table-wrap { max-height: none; overflow: visible; }
    /* No wrapping when stacked: a wrapping column line is as wide as its
     * widest item, and an unwrappable tab strip wider than the viewport
     * would then set the width the toggle centres in. */
    header   { flex-direction: column; flex-wrap: nowrap; align-items: stretch; min-height: 0; padding: .6rem 1.5rem; gap: .5rem; }
    nav.tabs { align-self: stretch; }
    /* Stacked header: unwind the badge centering + bottom-pin so logo, badge
     * and tabs each sit at the start of their own row instead of drifting. */
    header .brand,
    header .app-name { align-self: flex-start; margin-left: 0; margin-right: 0; }
    /* Stacked, every part has a row of its own, so the toggle goes back into
     * the flow, centred under the tabs, and the logo needs no bar height. */
    header .brand { height: auto; }
    .theme-toggle { position: static; transform: none; align-self: center; }
}

/* ─── Card grid ─────────────────────────────────────────────────────── */
/* Rows of cards in the chart column of a .page, in place of .charts:
 *
 *   <section class="page …">
 *     <div class="page-header">…</div>
 *     <div class="card-grid">
 *       <div class="card-grid-row my-row-1">…cards…</div>
 *     </div>
 *     <aside class="filters">…</aside>
 *   </section>
 *
 * The grid sets the heights; a dashboard sets only the columns of its rows,
 * with a class of its own on the row (`.my-row-1 { grid-template-columns: … }`).
 * One class is enough: below ~1100 px the rule here that stacks the rows is
 * the more specific one and wins over it wherever either stands. */
.page > .card-grid {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    min-width: 0;
}
/* The row height, and the one number to turn up if the cards should get
 * taller: on a window tall enough for all rows they share the space, and below
 * that they hold this and the page scrolls. */
.card-grid-row {
    display: grid;
    gap: 1rem;
    flex: 1 1 0;
    min-height: 280px;
}

/* Without this the chart's own min-height floor (see .chart) outgrows the row
 * above, and every row ends up as tall as a card's content demands rather than
 * as tall as it was told to be.
 *
 * The basis is 0 rather than `auto` for the same reason, one step further in:
 * ECharts writes the size of each draw into the DOM, so with a content-based
 * basis every chart hands its PREVIOUS canvas to the row as a height to
 * respect. The row could then only ever grow, and a window made smaller
 * without a reload left the charts running out of their cards. At 0 the charts
 * take what the row gives them and nothing else — which is also what leaves a
 * chart with a KPI block above it shorter than its neighbours by exactly that
 * block. */
.card-grid .chart { flex: 1 1 0; min-height: 0; }

.card-grid .card h3 {
    margin: 0 0 .55rem 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--accent);
}
.card-grid .card h3 .subtle {
    color: var(--fg-muted);
    font-weight: 400;
    font-size: .85rem;
    margin-left: .25rem;
}

/* Below ~1100 px the rows collapse to one column and the grid hands scrolling
 * back to the page; stacked, the cards keep their reading order. */
@media (max-width: 1100px) {
    .page > .card-grid { grid-row: auto; }
    .card-grid > .card-grid-row {
        grid-template-columns: 1fr;
        flex: 0 0 auto;
        min-height: 0;
    }
    .card-grid .card { height: auto; }
    /* Height comes from the row in the wide layout; stacked, each card needs
     * one of its own, and it is the same one the stacking rule further up
     * gives every .chart — that rule sets it, but cannot reach through the
     * `flex-basis: 0` above, because a media query adds no specificity. Hence
     * the value again, and the basis back to `auto` so the height counts. */
    .card-grid .chart { flex: 0 0 auto; height: 380px; min-height: 0; }
}

/* ─── Rezepturen dashboard (table) ────────────────────────────────────── */
.rezepturen-content {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: .75rem;
    min-height: 0;
    min-width: 0;
}
.rezepturen-table-wrap {
    flex: 1 1 auto;
    overflow: auto;       /* both axes — table is wide and rows can exceed viewport */
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    min-height: 0;
}
.rezepturen-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
    /* Fixed layout pins column widths to the <colgroup> defs so the
     * colspan-6 drill-down row can't reflow the columns. Without it
     * the rows jump sideways every time a row expands or collapses. */
    table-layout: fixed;
}
.rezepturen-table .col-name        { width: auto;  }
.rezepturen-table .col-costcenters { width: 10rem; }
.rezepturen-table .col-status      { width: 7rem;  }
.rezepturen-table .col-version     { width: 5rem;  }
.rezepturen-table .col-date        { width: 7rem;  }
.rezepturen-table .col-catalog     { width: 12rem; }
.rezepturen-table .col-group       { width: 12rem; }
.rezepturen-table .col-price       { width: 8rem;  }
.rezepturen-table .price-cell      { text-align: right; font-variant-numeric: tabular-nums; }
/* ── Rechnungsprüfung: table-level styling ───────────────────────── */
.rechnungen .rezepturen-table .col-status        { width: 7rem;   }
/* Widths sized to fit the German header text without ellipsis:
 *   "Kostenstelle", "Lieferdatum", "Lieferschein", "Gesamt netto",
 *   "Gesamt brutto". The supplier column stays `auto` and absorbs
 *   the slack — long supplier names like "Chefs Culinar
 *   Vollsortiment" still ellipsize gracefully in their wider cell. */
.rechnungen .rezepturen-table .col-cctr          { width: 8.5rem;  }
.rechnungen .rezepturen-table .col-kdnr          { width: 7rem;    }
.rechnungen .rezepturen-table .col-supplier      { width: auto;    }
.rechnungen .rezepturen-table .col-date          { width: 9rem;    }
.rechnungen .rezepturen-table .col-lieferschein  { width: 8rem;    }
.rechnungen .rezepturen-table .col-positions     { width: 4rem;    }
.rechnungen .rezepturen-table .col-amount        { width: 10rem;   }
/* Also let header text ellipsize so an oversized header doesn't break
 * the fixed layout; data cells already do this via the shared tbody rule.
 * Scoped with `>` to THIS table's own thead — the per-position drill-down
 * (.lf-pos-table) is nested inside a body cell of this table, and a plain
 * descendant selector would otherwise force nowrap+ellipsis onto its
 * headers too (they need to wrap, not truncate). */
.rechnungen .rezepturen-table > thead th {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Status pill — complete=green, uncomplete=amber, other=neutral. */
.status.status-complete   { background: var(--customer-bg); color: var(--customer-fg); }
.status.status-uncomplete { background: var(--warn-soft);   color: var(--warn-border); }
.status.status-other      { background: var(--code-bg);     color: var(--fg-muted); }

/* Date-range preset buttons — small inline pills under the von/bis. */
.filters .date-presets {
    display: flex;
    flex-wrap: wrap;
    gap: .25rem;
    margin-top: .35rem;
}
.filters .date-presets button {
    flex: 1 1 auto;
    padding: .2rem .35rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--fg-muted);
    border-radius: 3px;
    cursor: pointer;
    font-size: .72rem;
}
.filters .date-presets button:hover {
    background: var(--accent-soft);
    color: var(--accent);
    border-color: var(--accent);
}

/* Footer totals row — sticky-looking band at the bottom of the table. */
.rezepturen-table tfoot.lf-totals-foot td {
    border-top: 2px solid var(--border);
    padding: .55rem .65rem;
    background: var(--bg-soft);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.rezepturen-table tfoot.lf-totals-foot td.lf-totals-label {
    text-align: right;
    color: var(--fg-muted);
}

/* Position-level Reklamation icon (⚠) sits next to the Einkaufsartikel name. */
.lf-complaint-icon {
    color: var(--status-err);
    margin-right: .3rem;
    cursor: help;
}

/* ── Rechnungsprüfung: per-position table inside the drill-down ─────
 * Fixed-width columns so the numeric cells sit under the main row's
 * right-aligned price columns; the Einkaufsartikel name column takes
 * the remainder. The detail-row td override below also tightens its
 * left padding so the drill-down doesn't get pushed off to the right. */
.rechnungen tr.rec-detail-row td {
    padding: .35rem .65rem .65rem .65rem;
}
.lf-pos-table {
    width: 100%;
    border-collapse: collapse;
    font-size: .85rem;
    table-layout: fixed;
}
/* Every column EXCEPT the name gets an explicit width sized to its
 * widest VALUE (not its header — the long price headers wrap onto two
 * lines instead, see th.lf-price below). The name column carries no
 * width, so in table-layout:fixed it alone receives all remaining
 * space: article names get the room the price columns used to waste,
 * and the fixed columns can't be starved because they're, well, fixed.
 * (An earlier all-explicit variant let the browser spread the slack
 *  evenly across every column — 6rem-wide truncated names next to
 *  price columns full of dead air.)
 *   qty   → "440 Packungen" / "100 Kilogramm"
 *   price → Basispreis ("€ 200,0000")
 *   max   → value + the (±X % / ±X €) tag, e.g. "€ 12,5000 (±10 %)"
 *   wide  → "€ 1.036,45" under a two-line header
 * Each width = content + the doubled 1.3rem-per-side padding the value
 * cells carry (see the lf-qty/lf-price padding rule below). */
.lf-pos-table col.lf-col-qty        { width: 9.3rem;  }
.lf-pos-table col.lf-col-price      { width: 7.3rem;  }
.lf-pos-table col.lf-col-price-max  { width: 10.8rem; }
.lf-pos-table col.lf-col-price-wide { width: 8.8rem;  }
.lf-pos-table thead th {
    text-align: left;
    /* tighter horizontal padding than the .65rem body cells so the
     * wrapped two-line price headers break at their natural word
     * boundaries ("Preis nach | Lieferschein"). */
    padding: .35rem .5rem;
    border-bottom: 1px solid var(--border);
    color: var(--fg-muted);
    font-weight: 600;
    font-size: .75rem;
    /* Mixed one- and two-line headers: anchor them all to the same
     * baseline directly above the first data row. */
    vertical-align: bottom;
}
.lf-pos-table tbody td {
    padding: .35rem .65rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.lf-pos-table tbody tr:last-child td { border-bottom: none; }
.lf-pos-table th.lf-price,
.lf-pos-table td.lf-price {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
/* Values stay on one line (the columns are sized to fit them); the
 * long headers ("Maximal akzeptierter Preis", "Preis nach
 * Lieferschein", "Gesamt Position netto") wrap onto two lines instead
 * of dictating the column width. */
.lf-pos-table td.lf-price { white-space: nowrap; }
/* Double breathing room BETWEEN the value columns: 1.3rem per side
 * (2× the .65rem body default) on every quantity/price cell — the
 * name column keeps the default so it doesn't pay twice (it already
 * donates the width the wider value columns consume, see above). */
.lf-pos-table th.lf-qty,
.lf-pos-table td.lf-qty,
.lf-pos-table th.lf-price,
.lf-pos-table td.lf-price {
    padding-left: 1.3rem;
    padding-right: 1.3rem;
}
/* Liefermenge + Inhalt cells carry text + number ("10 Karton",
 * "150 Päckchen"). Right-aligning the values felt offset against
 * the short "Inhalt" header — long cell values reached well past
 * the header's left edge. Left-anchor instead so the header sits
 * directly above each row's leftmost character, matching the
 * Einkaufsartikel column's read direction. */
.lf-pos-table th.lf-qty,
.lf-pos-table td.lf-qty {
    text-align: left;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.lf-pos-table .lf-pi-name {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Paid-vs-expected colour coding on the Einzelpreis Basismengeneinheit cell.
 * Red = paid more (or position complained), green = paid less, neutral
 * for "ok" or "unknown". */
.lf-pos-table .lf-price.price-high {
    color: var(--status-err);
    font-weight: 600;
}
.lf-pos-table .lf-price.price-low {
    color: var(--status-ok);
    font-weight: 600;
}
.lf-pos-table .lf-price.price-unknown {
    color: var(--fg-muted);
    font-style: italic;
}

/* Lieferungen list: gesamt-netto/brutto cells right-aligned tabular */
.rezepturen-table .lf-price {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Portionspreis not computable — at least one Rezeptartikel has no
 * assigned Einkaufsartikel (with a price) under the active mandator
 * scope. We show a muted em-dash "—" with an explanatory hover instead
 * of an understated (and previously red) partial price. */
.rezepturen-table .price-cell.price-incomplete {
    cursor: help;
}
.rezepturen-table thead th {
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
    text-align: left;
    padding: .55rem .65rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--fg-muted);
    /* The first header sits inside an overflow:auto wrap; without
     * this border-image trick the bottom border vanishes once the
     * thead becomes "stuck" because sticky elements don't paint
     * their border over the scrolling rows. */
    box-shadow: 0 1px 0 var(--border);
    user-select: none;
}
.rezepturen-table thead th[data-sort-key] {
    cursor: pointer;
}
.rezepturen-table thead th[data-sort-key]:hover {
    color: var(--fg);
}
/* Arrow indicator appended via ::after so the column width doesn't
 * jump when sort changes — the empty pseudo always reserves a slot. */
.rezepturen-table thead th[data-sort-key]::after {
    content: '⇅';
    margin-left: .3rem;
    opacity: .25;
    font-size: .85em;
}
.rezepturen-table thead th.sorted { color: var(--accent); }
.rezepturen-table thead th.sorted.asc::after  { content: '↑'; opacity: 1; }
.rezepturen-table thead th.sorted.desc::after { content: '↓'; opacity: 1; }
.rezepturen-table tbody td {
    padding: .45rem .65rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.rezepturen-table tbody tr:hover { background: var(--accent-soft); }
/* Fixed col widths + long recipe names = truncate with ellipsis.
 * The full name is still readable via the row's drill-down. */
.rezepturen-table .rec-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rezepturen-table tbody td:not(.rec-detail-cell):not(.costcenters-cell) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Costcenters column flex-wraps inside its cell — the row grows
 * vertically rather than truncating, since the badges are the
 * point of the column. */
.rezepturen-table td.costcenters-cell {
    white-space: normal;
    line-height: 1.4;
}
.cust-badge {
    display: inline-block;
    margin: 0 .2rem .2rem 0;
    padding: 0 .35rem;
    border: 1px solid var(--customer-border);
    border-radius: 3px;
    background: var(--customer-bg);
    color: var(--customer-fg);
    font-size: .72rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    cursor: help;
}
.cc-badge {
    display: inline-block;
    margin: 0 .2rem .2rem 0;
    padding: 0 .35rem;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .72rem;
    cursor: help;
}
/* Declaration-state icon before the allergen list:
 *  ✓ = supplier answered yes/no for every allergen
 *  ? = some answered, some still unknown
 *  ✗ = supplier hasn't declared anything
 * Colors match status semantics: green/amber/red. */
.allergen-decl {
    display: inline-block;
    margin: 0 .35rem .2rem 0;
    width: 1rem;
    text-align: center;
    font-size: .85rem;
    font-weight: 600;
    cursor: help;
}
.allergen-decl.decl-complete { color: var(--status-ok); }
.allergen-decl.decl-partial  { color: var(--status-warn); }
.allergen-decl.decl-none     { color: var(--status-err); }

.allergen-badge {
    display: inline-block;
    margin: 0 .2rem .2rem 0;
    padding: 0 .3rem;
    border: 1px solid var(--allergen-border);
    border-radius: 3px;
    background: var(--allergen-bg);
    color: var(--allergen-fg);
    font-size: .72rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    cursor: help;
}
/* Trace ("kann Spuren von …") — amber/orange, distinct from the red
 * "contains" allergen badge so the two read differently at a glance. */
.allergen-badge.is-trace {
    border-color: var(--warn-border);
    background: var(--warn-soft);
    color: #8a6700;
}
:root[data-theme="dark"] .allergen-badge.is-trace {
    color: var(--status-warn);
}
.rezepturen-table .rec-num {
    display: inline-block;
    margin-right: .35rem;
    padding: 0 .35rem;
    border-radius: 3px;
    background: var(--code-bg);
    color: var(--fg-muted);
    font-size: .75rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.rezepturen-table .names-cell {
    max-width: 28rem;
    /* Don't wrap each ingredient name in the middle — wrap only at the
     * separators. The "+N" badge sits at the end. */
    white-space: normal;
    word-break: normal;
}
.rezepturen-table .names-cell .more {
    display: inline-block;
    margin-left: .25rem;
    padding: 0 .35rem;
    border-radius: 3px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .72rem;
    font-weight: 600;
}
.rezepturen-table .empty-row {
    padding: 2rem;
    text-align: center;
    color: var(--fg-muted);
}
.rezepturen-table .muted { color: var(--fg-muted); }
.rezepturen-table .status {
    display: inline-block;
    padding: .1rem .4rem;
    border-radius: 3px;
    font-size: .72rem;
    font-weight: 600;
}
/* Four-state status pill: freigegeben (released + valid) is green;
 * abgelaufen (was released, validity expired — can be re-released) is
 * orange; vollständig (complete draft, never released) is amber;
 * unvollständig (incomplete draft) is red to flag it clearly as needing
 * attention (per customer request). */
.rezepturen-table .status-freigegeben     { background: rgba(52,168,83,.15);  color: var(--status-ok); }
.rezepturen-table .status-abgelaufen      { background: rgba(217,119,6,.18);  color: #a04f00; }
.rezepturen-table .status-vollstaendig    { background: rgba(251,188,4,.18);  color: #8a6700; }
.rezepturen-table .status-unvollstaendig  { background: rgba(234,67,53,.15);  color: var(--status-err); }
:root[data-theme="dark"] .rezepturen-table .status-vollstaendig { color: var(--status-warn); }
:root[data-theme="dark"] .rezepturen-table .status-abgelaufen   { color: #f59f4a; }
.rezepturen-table .badge {
    display: inline-block;
    margin-left: .35rem;
    padding: .05rem .35rem;
    border-radius: 3px;
    font-size: .7rem;
    font-weight: 600;
}
.rezepturen-table .badge-teil   { background: var(--accent-soft); color: var(--accent); }
/* Grund and Teil are independent: a recipe can wear both badges
 * (a Grundrezeptur is also a Teilrezeptur if anyone references it).
 * Grund gets the warmer accent so it stands out from the Teil pill. */
.rezepturen-table .badge-grund  { background: var(--warn-soft); color: var(--warn-border); }
.rezepturen-table .badge-locked { background: transparent; }

/* Inline drill-down: each .rec-row is a clickable header; clicking
 * inserts a .rec-detail-row right after it with the ingredient
 * breakdown. The rec-toggle caret rotates to indicate state. */
.rezepturen-table tbody tr.rec-row { cursor: pointer; }
.rezepturen-table tbody tr.rec-row.expanded { background: var(--accent-soft); }
.rezepturen-table .rec-toggle {
    display: inline-block;
    width: 1rem;
    margin-right: .15rem;
    color: var(--fg-muted);
    transition: transform .12s ease;
}
.rezepturen-table tr.rec-row.expanded .rec-toggle {
    transform: rotate(90deg);
    color: var(--accent);
}
/* `> td` (direct child only) so the chunky 2rem/1rem padding lands on
 * the rec-detail wrapper cell, not on the inner lf-pos-table's td.lf-qty
 * and td.lf-price cells — those would otherwise inherit the same
 * left-pad and slide ~19px to the right of their headers (worst on the
 * Inhalt column, where the short German header sits noticeably left
 * of its much wider cell values). */
.rezepturen-table tr.rec-detail-row > td {
    background: var(--bg-soft);
    padding: .65rem 1rem .85rem 2rem;
    border-bottom: 1px solid var(--border);
}
.rec-detail-cell {
    /* TD is a table cell; the grid lives on the inner wrapper to dodge
     * browser quirks with display: grid on <td>. */
}
/* Single-column stack. Using grid (rather than plain flow) so the
 * structure stays consistent — easy to swap back to multi-column if
 * needed by changing grid-template-columns. */
.rec-detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .75rem;
}
.rec-detail-block {
    display: flex;
    flex-direction: column;
    gap: .15rem;
    break-inside: avoid;
}
/* Rezeptartikel without any linked Einkaufsartikel — flagged at all
 * times (not only when the filter toggle is on) so the user can spot
 * incomplete recipes at a glance. Mandator-aware: when a mandator
 * filter is active the highlight reflects that mandator's scope. */
.rec-detail-block.missing-purchaseitems {
    background: var(--warn-soft);
    border-left: 3px solid var(--warn-border);
    padding: .35rem .5rem;
    border-radius: 4px;
    margin-left: -.5rem;
}
.rec-detail-block.sub-recipe .ing-head {
    color: var(--accent);
    font-style: italic;
}
/* Sub-recipe block is collapsed by default; clicking the head
 * expands the nested ingredients inline. */
.rec-detail-block.sub-recipe .sub-recipe-head {
    cursor: pointer;
    user-select: none;
}
.rec-detail-block.sub-recipe .sub-recipe-head:hover {
    color: var(--accent-hover);
}
.rec-detail-block.sub-recipe .sub-toggle {
    display: inline-block;
    transition: transform .12s ease;
    color: var(--fg-muted);
}
.rec-detail-block.sub-recipe.expanded .sub-toggle {
    transform: rotate(90deg);
    color: var(--accent);
}
/* Nested body: indent + left accent so it visually nests under the
 * head. Works for arbitrary depth via the recursive renderDetail call. */
.rec-detail-block.sub-recipe .sub-recipe-body {
    margin-top: .35rem;
    margin-left: 1rem;
    padding-left: .75rem;
    border-left: 2px solid var(--accent-soft);
}
.rec-detail-block.sub-recipe .sub-recipe-body .rec-detail-grid {
    /* Tighter spacing inside a nested grid since indent already
     * separates it from the parent. */
    gap: .5rem;
}

/* "Wird verwendet in N Rezepturen" panel sits ABOVE the ingredient
 * grid in the expanded detail row. Mirrors the sub-recipe head visual
 * language (chevron + soft accent on hover) so it reads as the same
 * kind of inline lazy expand. Hidden entirely when used_in_count = 0
 * (renderUsedInPanel returns ''). */
.rec-used-in {
    margin-bottom: .6rem;
    padding: .35rem .5rem;
    background: var(--bg);
    border-left: 3px solid var(--accent-soft);
    border-radius: 3px;
}
.rec-used-in-head {
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    color: var(--accent);
}
.rec-used-in-head:hover { color: var(--accent-hover); }
.rec-used-in-toggle {
    display: inline-block;
    margin-right: .3rem;
    transition: transform .12s ease;
    color: var(--fg-muted);
}
.rec-used-in.expanded .rec-used-in-toggle {
    transform: rotate(90deg);
    color: var(--accent);
}
.rec-used-in-body { margin-top: .35rem; }
.rec-used-in-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: 1fr;
    gap: .15rem;
}
.rec-used-in-item {
    padding: .2rem .35rem;
    font-size: .85rem;
    display: flex;
    align-items: center;
    gap: .35rem;
}
.rec-used-in-item:hover { background: var(--bg-soft); }
.rec-used-in-depth {
    color: var(--fg-muted);
    font-family: var(--font-mono, monospace);
    font-size: .8rem;
    width: 2.5rem;
    display: inline-block;
    text-align: left;
}
.ing-head {
    font-weight: 500;
    font-size: .85rem;
}
/* Allergene "hochgezogen" auf den Rezeptartikel-Kopf: distinct union of
 * the allergen badges of all its Einkaufsartikel. */
.ing-head .ra-allergens {
    margin-left: .4rem;
    font-weight: 400;
}
.ing-purchaseitems {
    margin: 0;
    padding-left: 1.25rem;
    color: var(--fg-muted);
    font-size: .8rem;
}
/* Each Einkaufsartikel row stays on ONE line: name on the left
 * (truncating with ellipsis when long), badges right-aligned. No
 * wrap — badges never break to a second line. */
.ing-purchaseitems li {
    display: flex;
    align-items: center;
    gap: .5rem;
    flex-wrap: nowrap;
    margin: .15rem 0;
    min-width: 0;
}
.ing-purchaseitems .pi-name {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* Supplier shown in parentheses after the EKA name — de-emphasised. */
.pi-supplier {
    color: var(--fg-muted);
    font-weight: 400;
}
.ing-purchaseitems .pi-meta {
    display: inline-flex;
    flex-wrap: nowrap;
    gap: 0;
    align-items: center;
    margin-left: auto;
    flex: 0 0 auto;
}
.cust-badge.cust-more {
    font-style: italic;
    font-family: inherit;
}
/* Heart marker for is_favorite (is_default=1) purchaseitems. Pinned
 * to the same row as the name via inline-block. */
.pi-fav {
    color: #e2444a;
    margin-right: .3rem;
    font-size: .9em;
}
.ing-empty {
    color: var(--fg-muted);
    font-size: .8rem;
    font-style: italic;
    padding-left: 1.25rem;
}
.rec-detail-loading, .rec-detail-empty, .rec-detail-err {
    color: var(--fg-muted);
    font-style: italic;
    padding: .25rem 0;
}
.rec-detail-err { color: var(--status-err); }

.rezepturen-pager {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: .5rem 0;
}
.rezepturen-pager button {
    padding: .35rem .75rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--fg);
    border-radius: 4px;
    cursor: pointer;
    font-size: .85rem;
}
.rezepturen-pager button:hover:not([disabled]) { background: var(--accent-soft); }
.rezepturen-pager button[disabled] { opacity: .4; cursor: default; }
.rezepturen-pager .pager-info { color: var(--fg-muted); font-size: .85rem; }
.rezepturen-pager .pager-page-input {
    width: 4.5em;
    padding: .25rem .35rem;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--fg);
    border-radius: 4px;
    font-size: .85rem;
    text-align: center;
}

/* ─── LMS Übersicht dashboard ───────────────────────────────────────── */
/* A widget composite arranged like the legacy reporting workbook: the donut
 * beside the daily line, below them the hourly stack beside the KPI panels.
 * Rows and heights come from .card-grid; only the columns are set here. */
/* Row 1: narrow donut (1) + wider daily line (2). */
.overview-row-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
/* Row 2: wide hourly stack + two compact KPI cards. */
.overview-row-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); }

/* Filter sidebar overrides — the LMS Übersicht filters include native
 * date and select inputs alongside MultiSelects, so the sidebar
 * widens slightly and we restore typical native-control sizing. */
.lms-overview ~ .filters input[type="date"],
.lms-overview ~ .filters select {
    width: 100%;
    padding: .35rem .5rem;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--fg);
    font-size: .85rem;
}

/* ─── LMS Live View dashboard ───────────────────────────────────────── */
/* One moment, in two bands: the counters beside the expectation chart, then
 * the three transport views. Every selector below is new — nothing here
 * changes a rule another app reads. */
.lms-liveview > .liveview-grid {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    min-width: 0;
}
.liveview-row {
    display: grid;
    gap: 1rem;
    min-height: 0;
    min-width: 0;
}
/* Both bands share the height; the top one keeps a little more of it,
 * because its chart carries a full day's hours while the bottom row's cards
 * scroll. The min-heights are what stop either band from collapsing to its
 * axis labels on a short window. */
/* The chart gets the width, the counters only a column — its `minmax` floor
 * is what keeps the labels readable on a narrow window, where a share of the
 * band alone would fall below them. */
.liveview-row-top {
    grid-template-columns: minmax(9rem, 1fr) minmax(0, 4fr);
    flex: 1.1 1 0;
    min-height: 300px;
}
.liveview-row-bottom {
    grid-template-columns: minmax(12rem, 2fr) minmax(0, 9fr) minmax(0, 9fr);
    flex: 1 1 0;
    min-height: 300px;
}

.lms-liveview .card h3 {
    margin: 0 0 .55rem 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--accent);
}
.lms-liveview .card h3 .subtle { font-weight: 400; color: var(--fg-muted); }

/* ── the counter stack ── */
/* Two columns of three, filled column by column — `grid-auto-flow: column`
 * with three explicit rows, so the first three cells go down the left column
 * and the next three down the right one, which is the order the markup reads
 * in. Three rows instead of six is what makes the card fit without a
 * scrollbar. Padding moves from the card to the cells, so the hairlines
 * between them reach the card's edges.
 *
 * No `overflow` of its own, deliberately: the InfoTip bubbles of two of
 * these cells are wider than a cell and would be clipped by a scroll
 * container here. Three rows fit, so there is nothing left to scroll. */
.lms-liveview .liveview-kpis {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: repeat(3, minmax(0, 1fr));
    grid-auto-flow: column;
    padding: 0;
}
.lms-liveview .kpi-row {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .05rem;
    padding: .4rem .5rem;
    text-align: center;
    min-width: 0;
    border-top: 1px solid var(--border);
}
/* Separators follow the flow: no rule above a column's first cell, and a
 * vertical one down the left edge of the second column. */
.lms-liveview .kpi-row:nth-child(3n + 1) { border-top: 0; }
.lms-liveview .kpi-row:nth-child(n + 4)  { border-left: 1px solid var(--border); }
.lms-liveview .kpi-row-value {
    font-size: 1.45rem;
    font-weight: 600;
    line-height: 1.15;
    color: var(--fg);
    font-variant-numeric: tabular-nums;
}
/* Two columns in a narrow card leave a label about one word wide, so it wraps
 * rather than truncates — a counter whose name ends in "…" is unreadable,
 * three short lines are not. */
.lms-liveview .kpi-row-label {
    font-size: .72rem;
    font-weight: 600;
    line-height: 1.2;
    color: var(--accent);
}
/* The staffing delta rides inside the value line, at text size — it is a
 * comparison, not a second headline. */
.lms-liveview .kpi-delta {
    font-size: .8rem;
    font-weight: 600;
    color: var(--fg-muted);
    white-space: nowrap;
}

/* ── sidebar: the moment ── */
.lms-liveview .sidebar-block {
    margin-top: .5rem;
    padding-top: .5rem;
    border-top: 1px dashed var(--border);
}
.lms-liveview .sidebar-block h3 {
    margin: 0 0 .25rem 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--accent);
}
.lms-liveview .sidebar-value {
    font-size: .82rem;
    color: var(--fg-muted);
    font-variant-numeric: tabular-nums;
}

/* ── active-transport tiles ── */
.lms-liveview .liveview-tiles {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    overflow-y: auto;
    min-height: 0;
}
/* One row: the transport's number on the left, how long it has been running
 * on the right. Everything else is in the tile's InfoTip. */
.lms-liveview .transport-tile {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .5rem;
    /* The frame is the Auftragstyp: renderActive writes `border-color` per
     * tile from the shared palette, so the colour is data and the accent here
     * is only the fallback for a type the palette does not know. Thick enough
     * to read as a colour rather than as a hairline. */
    border: 3px solid var(--accent);
    border-radius: 4px;
    padding: .3rem .5rem;
    background: var(--card-bg);
    font-size: .82rem;
}
.lms-liveview .transport-elapsed {
    color: var(--fg-muted);
    font-variant-numeric: tabular-nums;
}
/* Never shrink: the transport number is the row's identity, and a flex row
 * would otherwise take the ellipsis out of it as readily as out of a place
 * name — leaving "#2…" beside two truncated places, which identifies
 * nothing. Only the places give way. */
.lms-liveview .transport-nr {
    flex: 0 0 auto;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--accent);
}

/* ── the Gantt ── */
/* One scroll area holding all three groups. The axis is a sibling ABOVE the
 * rows and stays put via position: sticky — which is the whole reason this
 * widget is DOM and not a canvas. */
.lms-liveview .gantt {
    /* One width for the label column, the axis offset and the now-line: all
     * three subtract exactly this, which is what puts them on one scale.
     * It holds the transport number alone — the only thing the axis names —
     * in the shortened head-and-tail form renderGantt writes, which is the
     * widest a label gets however long the underlying number is, plus the
     * label's own right padding. Every pixel here is one the bars do not
     * get, so it is cut to that form and not to the longest number the
     * field could hold. */
    --gantt-labels: 7rem;
    position: relative;
    /* The widget's own stacking context, and the reason it needs one: the axis
     * and the now-line below both carry a z-index, and they are meant to order
     * against each other and the bars — nothing further out. Without a context
     * here they get none of their own, because neither this box nor .gantt-body
     * makes one (both are positioned but z-index: auto, and overflow alone does
     * not count) and no ancestor up to the root does either. Their z-indexes
     * then resolve in the ROOT context, where any positive value outranks the
     * sticky footer's `auto` — so on the narrow layout, where the page scrolls
     * and this card travels under the status line, the line and the axis draw
     * across it. Isolating keeps the order inside intact and the widget as a
     * whole in document order, i.e. behind the chrome. */
    isolation: isolate;
    /* Rows scroll, the time axis never does: its width IS the container's,
     * every bar is a percentage of it and the end labels are pulled inwards.
     * So sideways scrolling here can only ever be an artefact — the now-line
     * is a zero-width box with a 1px border, and at the very end of the
     * window that border falls just past the edge. Naming overflow-x is what
     * settles it: `overflow-y: auto` alone leaves x at visible, which the
     * browser then computes to auto, and one stray pixel becomes a scroll
     * range. */
    overflow-x: hidden;
    overflow-y: auto;
    min-height: 0;
    flex: 1 1 auto;
}
.lms-liveview .gantt-axis {
    position: sticky;
    top: 0;
    z-index: 2;
    height: 1.35rem;
    margin-left: var(--gantt-labels);
    border-bottom: 1px solid var(--border);
    background: var(--card-bg);
}
/* The axis begins where the labels end, so its own background does too — and
 * a row scrolling underneath stays visible in that strip, its number riding
 * up into the hours. This covers it: a box exactly as wide as the label
 * column, butted against the axis's left edge.
 *
 * Painting BESIDE the axis rather than widening it. Dropping the margin would
 * be the obvious move and is the wrong one: the ticks are positioned in
 * percent against the axis box, so it would move them twice over — once by
 * shifting their origin leftwards, once by widening the rectangle those
 * percentages resolve against. Nothing here touches the box.
 *
 * The shadow continues the axis's bottom border, which this strip does not
 * inherit. It ends exactly at the left edge of `.gantt`, which clips
 * horizontally, so it costs no scrollbar. */
.lms-liveview .gantt-axis::before {
    content: "";
    position: absolute;
    top: 0;
    bottom: 0;
    right: 100%;
    width: var(--gantt-labels);
    background: var(--card-bg);
    box-shadow: 0 1px 0 var(--border);
}
.lms-liveview .gantt-tick,
.lms-liveview .gantt-now-head {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: .68rem;
    color: var(--fg-muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
.lms-liveview .gantt-now-head { color: var(--fg); font-weight: 600; }
.lms-liveview .gantt-body { position: relative; }

/* One scale for the whole widget.
 *
 * The axis, the bars and the now-line each place a time as a percentage, and
 * they agree only while all three measure it against the SAME rectangle: the
 * strip beginning where the label column ends and running to the right edge.
 *
 * Each reaches it differently — the axis by its margin, a bar through the
 * track that is whatever its row has left over, the now-line through the box
 * below. What holds them together is that the label column is the only thing
 * any of them subtracts. So the air between a label and what follows it sits
 * INSIDE the label, as padding, and the row carries no gap: a gap would fall
 * between label and track, shortening the bars' rectangle alone and sliding
 * every bar off the axis by its width. */
.lms-liveview .gantt-nowbox {
    position: absolute;
    top: 0;
    bottom: 0;
    left: var(--gantt-labels);
    right: 0;
    /* Positioned AND given a z-index, so the line inside is confined to this
     * box rather than escaping into the page's stacking order. */
    z-index: 1;
    pointer-events: none;
}
.lms-liveview .gantt-now {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 1px dashed var(--fg-muted);
}
.lms-liveview .gantt-row {
    display: flex;
    align-items: center;
    font-size: .78rem;
}
.lms-liveview .gantt-label {
    flex: 0 0 var(--gantt-labels);
    display: flex;
    gap: .3rem;
    /* The row's former gap, moved in here — see the one-scale note above. */
    padding-right: .5rem;
    overflow: hidden;
    white-space: nowrap;
    color: var(--fg);
}
.lms-liveview .gantt-label > span { overflow: hidden; text-overflow: ellipsis; }
/* The number wears its Auftragstyp's colour as a frame, the same way an
 * active transport's tile does — renderGantt writes `border-color` per row,
 * and the accent is the fallback for a type the palette does not know. */
.lms-liveview .gantt-nr {
    border: 3px solid var(--accent);
    border-radius: 4px;
    padding: 0 .3rem;
    line-height: 1.3;
}
.lms-liveview .gantt-track { position: relative; flex: 1 1 auto; height: 100%; }
.lms-liveview .gantt-bar {
    position: absolute;
    top: 20%;
    height: 60%;
    min-width: 2px;
    border-radius: 3px;
    background: var(--accent);
}
/* No planned end: the bar fades out rather than claiming a right edge. */
.lms-liveview .gantt-bar-openend {
    background: linear-gradient(to right, var(--accent), transparent);
    border-radius: 3px 0 0 3px;
}
.lms-liveview .gantt-group {
    margin: .35rem 0 .15rem 0;
    font-size: .72rem;
    font-weight: 600;
    color: var(--accent);
}
.lms-liveview .gantt-row-offaxis { opacity: .8; }
.lms-liveview .gantt-note {
    font-size: .7rem;
    color: var(--fg-muted);
    white-space: nowrap;
}

.lms-liveview .chart { flex: 1 1 auto; min-height: 0; }

/* Below the same breakpoint as the Übersicht the bands stack. The counter
 * stack re-flows into three columns there: six full-width rows above a chart
 * would push everything else off the first screen. */
@media (max-width: 1100px) {
    .lms-liveview > .liveview-grid { grid-row: auto; }
    .liveview-row-top,
    .liveview-row-bottom { grid-template-columns: 1fr; }
    .liveview-row { flex: 0 0 auto; min-height: 0; }
    .lms-liveview .card { height: auto; }
    /* Full width here, so the stack turns into two rows of three read across
     * — `grid-auto-flow: row` — and the separators turn with it. */
    .lms-liveview .liveview-kpis {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-template-rows: auto;
        grid-auto-flow: row;
    }
    .lms-liveview .kpi-row { border-top: 0; border-left: 1px solid var(--border); }
    .lms-liveview .kpi-row:nth-child(3n + 1) { border-left: 0; }
    .lms-liveview .kpi-row:nth-child(n + 4)  { border-top: 1px solid var(--border); }
    .lms-liveview .liveview-expected,
    .lms-liveview .liveview-hourly { min-height: 260px; }
}

/* ─── LMS Storno- und Abbruchsaufkommen dashboard ──────────────────────── */
/* The cards sit in rows: the outcome columns beside the reason ranking, then
 * the per-day and per-hour series, then the ladders. Together they no longer
 * fit a viewport, so this grid scrolls — the rows keep their height instead of
 * being squeezed to their axis labels.
 *
 * This stylesheet is shared by every app, so everything below is either a class
 * of this dashboard's own or scoped to `.lms-cancellations`. The inherited
 * rules redefined that way are `.chart`, `.card h3` and `.card[hidden]`; no
 * other reader of this file is affected. */
.lms-cancellations > .cancellations-grid {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    /* Room for the scrollbar, so its appearance doesn't nudge the cards. */
    padding-right: .35rem;
}
/* The row height, and the one number to turn up if the cards should get
 * taller: on a window tall enough for all of them the rows share the space,
 * and below that they hold this and the grid above scrolls.
 *
 * `flex-shrink: 0` with an `auto` basis is what lets a row grow PAST that
 * floor when its content asks for it — the reason ranking does, one axis row
 * per reason. Shrinking instead would fold those rows away again. */
.cancellations-row {
    display: grid;
    gap: 1rem;
    flex: 1 0 auto;
    min-height: 280px;
}
/* The top row pairs the narrow outcome columns with the wider reason
 * ranking; the rows below it split evenly. */
.cancellations-row-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.cancellations-row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
/* The last row splits evenly too, but by auto-fit rather than by two named
 * tracks: the Art filter hides one of the ladder cards, and auto-fit drops the
 * track with it so the survivor takes the full width instead of leaving a
 * hole. The `min(100%, …)` floor is what keeps a single card from being asked
 * for more width than the row has. */
.cancellations-row-3 {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
}
/* `.card` sets display:flex and thereby beats the UA's `[hidden]` rule at
 * equal specificity, so hiding one has to be said again here — otherwise the
 * card merely goes blank and keeps its place. Same re-assertion as `.ip` and
 * `.legend` further up. */
.lms-cancellations .card[hidden] { display: none; }

/* Without this the chart's own min-height floor (see .chart) outgrows the row
 * above, and every row ends up as tall as a card's content demands rather
 * than as tall as it was told to be.
 *
 * The basis is 0 rather than `auto` for the same reason, one step further in:
 * ECharts writes the size of each draw into the DOM, so with a content-based
 * basis every chart hands its PREVIOUS canvas to the row as a height to
 * respect. The row could then only ever grow — one card kept it open while
 * its neighbour was already asking for less. At 0 the charts take what the
 * row gives them and nothing else. */
.lms-cancellations .chart { flex: 1 1 0; min-height: 0; }
/* The exception, and the only card here that decides its own height: the
 * dashboard sets --reason-h from the number of reasons it has to draw
 * (REASON_ROW_PX each), and the row above grows with it. A height rather than
 * a min-height, so the box shrinks again when a filter leaves fewer reasons —
 * as a floor the previous draw's canvas would hold the card open. The basis
 * goes back to `auto` here, which now means that height and nothing else —
 * this is the one chart whose own number may push its row taller, and it
 * still stretches when the row has room to spare. */
.lms-cancellations .cancellations-reasons .chart {
    flex: 1 1 auto;
    height: var(--reason-h, auto);
}

.lms-cancellations .card h3 {
    margin: 0 0 .55rem 0;
    font-size: .95rem;
    font-weight: 600;
    color: var(--accent);
}
.lms-cancellations .card h3 .subtle {
    color: var(--fg-muted);
    font-weight: 400;
    font-size: .85rem;
    margin-left: .25rem;
}

/* Below ~1100 px the rows collapse to one column and the grid hands scrolling
 * back to the page. */
@media (max-width: 1100px) {
    .lms-cancellations > .cancellations-grid {
        grid-row: auto;
        overflow-y: visible;
        padding-right: 0;
    }
    .cancellations-row-1,
    .cancellations-row-2,
    .cancellations-row-3 { grid-template-columns: 1fr; }
    .cancellations-row { flex: 0 0 auto; min-height: 0; }
    .lms-cancellations .card { height: auto; }
    /* Height comes from the row in the wide layout; stacked, each card needs
     * one of its own, and it is the same one the other dashboards use here —
     * the shared rule further up sets it, but cannot reach through the
     * `flex-basis: 0` above, because a media query adds no specificity. Hence
     * the value again, and the basis back to `auto` so the height counts.
     * The reason card keeps whichever is larger: this height, or what its own
     * rows add up to. */
    .lms-cancellations .chart { flex: 0 0 auto; height: 380px; min-height: 0; }
    .lms-cancellations .cancellations-reasons .chart {
        height: max(380px, var(--reason-h, 0px));
    }
}

/* ─── LMS Transportaufkommen dashboard ──────────────────────────────── */
/* Two bands: the hourly stack across the full width, below it the weekday
 * stack beside the daily lines. Rows and heights come from .card-grid; only
 * the columns are set here. */
/* The hourly stack has the whole width: it carries the most columns of the
 * three and is the one that gets unreadable first when squeezed. */
.transportvolume-row-1 { grid-template-columns: minmax(0, 1fr); }
/* The smaller share for the weekday stack — seven columns at most — and the
 * larger one for the daily lines, which carry a point per day of the window.
 * Not the narrowest share that would fit its columns, though: the weekday
 * tooltip lists every Auftragstyp, and below this width it wraps. */
.transportvolume-row-2 { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }

/* ─── LMS Verspätungen dashboard ────────────────────────────────────── */
/* Two bands of two cards. The pairing is not free: the two cards with a DATE
 * axis sit in the same column, one above the other, and the columns are equal
 * — so the two axes line up and a spike stands in the same place on both. The
 * KPI blocks above those two charts are equally tall for the same reason, the
 * split one included. Below ~1100 px, where the rows stack, that alignment is
 * gone with the second column.
 *
 * Rows and heights come from .card-grid; only the columns are set here. One
 * template for both rows rather than a class per row: the alignment above is
 * what the equal columns are for, so the two cannot be set apart without
 * giving it up. */
.delays-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* ─── LMS Transportdauer dashboard ─────────────────────────────────── */
/* Two bands: the per-day and the per-hour card in halves across the top, the
 * ladder and the two unit cards in thirds underneath. Rows and heights come
 * from .card-grid; only the columns are set here. */
.transportduration-row-1 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.transportduration-row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1fr); }

/* ─── LMS Organisationseinheiten dashboard ─────────────────────────── */
/* The volume per start and per target unit across the top, the delay rate and
 * the delay duration per unit underneath. The delay cards are coupled
 * (organisationalunits.js) and replay a tooltip at the same cursor position on
 * each other, so their columns must stay equal: unequal widths would land it
 * on a different unit.
 *
 * Rows and heights come from .card-grid; only the columns are set here. */
.organisationalunits-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* ─── LMS Transportzeiten dashboard ─────────────────────────────────── */
/* The transports and the staff per day across the full width, below them the
 * utilisation beside the time on a job per employee. The bottom cards share
 * their day axis, so they share the row equally. Rows and heights come from
 * .card-grid; only the columns are set here. */
.transporttimes-row-1 { grid-template-columns: minmax(0, 1fr); }
.transporttimes-row-2 { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

/* ─── LMS Transportstrecken dashboard ───────────────────────────────── */
/* The distances per day beside the distance ladder across the top, the means
 * per transport beside the employees' part underneath. One template for both
 * rows, so the per-day cards above each other in the left column line up day
 * for day. Rows and heights come from .card-grid; only the columns are set
 * here. */
.transportroutes-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
