/* 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);
    padding: 0 1.5rem;
    min-height: 3.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 .hint {
    color: var(--fg-muted);
    font-size: .8rem;
}

/* ─── header branding (MWS) ───────────────────────────────────────────
 * OrgaCard logo on the far left, the app-name badge centered between it
 * and the tab strip. The badge's margin-left:auto pairs with
 * nav.tabs's own margin-left:auto to split the free space either side of
 * the badge, so it lands roughly centered while the tabs stay right.
 * Both inherit the header's vertical centering (align-items: center).
 * LMS keeps the .title-block/h1 header above and never renders these. */
header .brand {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex: 0 0 auto;
}
header .brand-logo {
    height: 30px;
    width: auto;
    display: block;
}
header .app-name {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-left: auto;      /* pairs with nav.tabs margin-left:auto to center */
    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 */
    margin-left: auto;
}
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 */
}
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;
    align-self: center;
}
.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;
    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;
}
.page-header .hint {
    color: var(--fg-muted);
    font-size: .85rem;
}
.page-header code {
    background: var(--code-bg);
    padding: .05em .35em;
    border-radius: 3px;
    font-size: .85em;
}

.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;
}

.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); }

/* ─── 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; }
    .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; }
    header   { flex-direction: column; align-items: stretch; min-height: 0; padding: .6rem 1.5rem; gap: .5rem; }
    nav.tabs { margin-left: 0; 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; }
}

/* ─── 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 ───────────────────────────────────────── */
/* Six-widget composite arranged like the legacy reporting workbook:
 * row 1 = donut + daily line, row 2 = hourly stack + two KPI panels.
 * The filter sidebar shares the .page grid with .overview-grid so the
 * vertical extent matches the rest of the dashboard family. */
.lms-overview > .overview-grid {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 0;
    min-width: 0;
}
.overview-row {
    display: grid;
    gap: 1rem;
    flex: 1 1 0;
    min-height: 280px;
}
/* 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); }

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

/* KPI text block above the small line charts (Verspätung, Dauer). */
.lms-overview .kpi-block {
    padding: .15rem 0 .35rem 0;
}
.lms-overview .kpi-line {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--fg);
    line-height: 1.1;
}
.lms-overview .kpi-sub {
    font-size: .75rem;
    color: var(--fg-muted);
    margin-top: .15rem;
}

/* 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;
}

/* Below ~1100 px the row grid collapses to a stacked single-column
 * layout so the cards stay readable on narrow viewports. The filter
 * sidebar moves above the content via the existing media query. */
@media (max-width: 1100px) {
    .lms-overview > .overview-grid { grid-row: auto; }
    .overview-row-1,
    .overview-row-2 {
        grid-template-columns: 1fr;
    }
    .overview-row { min-height: 0; }
    .lms-overview .card { height: 320px; }
}
