/* ═══════════════════════════════════════════════════════════════════════
   BankBoek — Material Design 3 roles, one brand palette

   There is ONE colour scheme for the whole system: the landing page's
   (emerald #0A5C36 on a pale green canvas, mint borders, white cards).
   Every company, every industry and the admin app use it. The values below
   are the single source; nothing else in the system writes a colour of its
   own (UiGuideSourceTests / BrandPaletteTests enforce that, and that the
   admin app's copy and MudBlazor's palette say the same thing).

   Role names follow Material Design 3 so existing var(--md-sys-color-*)
   uses keep working; the values are the brand's, not generated from a seed.
   Change a colour here, then in the admin app.css copy and the two
   MudTheme blocks in App.razor — the tests tell you if one is missed.

   The legacy --c-* tokens are kept as aliases onto the roles so existing
   selectors keep working. New code should use --md-sys-color-* directly.
   ═══════════════════════════════════════════════════════════════════════ */
:root {
    /* Primary — the brand emerald. The top bar is solid primary-container. */
    --md-sys-color-primary: #0a5c36;
    --md-sys-color-on-primary: #ffffff;
    --md-sys-color-primary-container: #0a5c36;
    --md-sys-color-on-primary-container: #ffffff;

    /* Secondary — the lighter green, with the mint tint for chips and selection */
    --md-sys-color-secondary: #1a7a4a;
    --md-sys-color-on-secondary: #ffffff;
    --md-sys-color-secondary-container: #d8f3dc;
    --md-sys-color-on-secondary-container: #073d25;

    /* Tertiary — informational blue (Info alerts, links to detail) */
    --md-sys-color-tertiary: #1976d2;
    --md-sys-color-on-tertiary: #ffffff;
    --md-sys-color-tertiary-container: #e3f0fd;
    --md-sys-color-on-tertiary-container: #0d47a1;

    /* Error */
    --md-sys-color-error: #ba1a1a;
    --md-sys-color-on-error: #ffffff;
    --md-sys-color-error-container: #ffdad6;
    --md-sys-color-on-error-container: #93000a;

    /* Success (extended role — not in the M3 spec) */
    --md-sys-color-success: #1a7a4a;
    --md-sys-color-on-success: #ffffff;
    --md-sys-color-success-container: #d8f3dc;
    --md-sys-color-on-success-container: #073d25;

    /* Warning (extended role — not in the M3 spec) */
    --md-sys-color-warning: #855300;
    --md-sys-color-on-warning: #ffffff;
    --md-sys-color-warning-container: #f59e0b;
    --md-sys-color-on-warning-container: #613b00;

    /* Surfaces — pale green canvas, white cards */
    --md-sys-color-background: #f8fbf2;
    --md-sys-color-on-background: #2d3436;
    --md-sys-color-surface: #f8fbf2;
    --md-sys-color-on-surface: #2d3436;
    --md-sys-color-surface-variant: #e8f5e9;
    --md-sys-color-on-surface-variant: #636e72;
    --md-sys-color-surface-dim: #e8f5e9;
    --md-sys-color-surface-bright: #f8fbf2;
    --md-sys-color-surface-container-lowest: #ffffff;
    --md-sys-color-surface-container-low: #ffffff;
    --md-sys-color-surface-container: #f4fdf7;
    --md-sys-color-surface-container-high: #f0fbf4;
    --md-sys-color-surface-container-highest: #e8f5e9;

    /* Outlines */
    --md-sys-color-outline: #adb5bd;
    --md-sys-color-outline-variant: #d8f3dc;

    /* Inverse */
    --md-sys-color-inverse-surface: #1b263b;
    --md-sys-color-inverse-on-surface: #f4fdf7;
    --md-sys-color-inverse-primary: #8dd6a6;

    /* Utility */
    --md-sys-color-shadow: #000000;
    --md-sys-color-scrim: #000000;
    --md-sys-color-surface-tint: #0a5c36;

    /* ── Shape scale ─────────────────────────────────────────────────── */
    --md-sys-shape-corner-none:        0px;
    --md-sys-shape-corner-extra-small: 4px;
    --md-sys-shape-corner-small:       8px;
    --md-sys-shape-corner-medium:      12px;   /* cards */
    --md-sys-shape-corner-large:       16px;
    --md-sys-shape-corner-extra-large: 28px;   /* dialogs */
    --md-sys-shape-corner-full:        9999px; /* pill buttons, chips */

    /* ── Type scale ──────────────────────────────────────────────────── */
    --md-sys-typescale-display-large:    400 57px/64px var(--md-ref-typeface-brand);
    --md-sys-typescale-display-medium:   400 45px/52px var(--md-ref-typeface-brand);
    --md-sys-typescale-display-small:    400 36px/44px var(--md-ref-typeface-brand);
    --md-sys-typescale-headline-large:   400 32px/40px var(--md-ref-typeface-brand);
    --md-sys-typescale-headline-medium:  400 28px/36px var(--md-ref-typeface-brand);
    --md-sys-typescale-headline-small:   400 24px/32px var(--md-ref-typeface-brand);
    --md-sys-typescale-title-large:      400 22px/28px var(--md-ref-typeface-brand);
    --md-sys-typescale-title-medium:     500 16px/24px var(--md-ref-typeface-plain);
    --md-sys-typescale-title-small:      500 14px/20px var(--md-ref-typeface-plain);
    --md-sys-typescale-body-large:       400 16px/24px var(--md-ref-typeface-plain);
    --md-sys-typescale-body-medium:      400 14px/20px var(--md-ref-typeface-plain);
    --md-sys-typescale-body-small:       400 12px/16px var(--md-ref-typeface-plain);
    --md-sys-typescale-label-large:      500 14px/20px var(--md-ref-typeface-plain);
    --md-sys-typescale-label-medium:     500 12px/16px var(--md-ref-typeface-plain);
    --md-sys-typescale-label-small:      500 11px/16px var(--md-ref-typeface-plain);

    --md-ref-typeface-brand: 'Inter', 'Segoe UI', Helvetica, Arial, sans-serif;
    --md-ref-typeface-plain: 'Inter', 'Segoe UI', Helvetica, Arial, sans-serif;

    /* ── State layer opacities ───────────────────────────────────────── */
    --md-sys-state-hover-opacity:    0.08;
    --md-sys-state-focus-opacity:    0.10;
    --md-sys-state-pressed-opacity:  0.12;
    --md-sys-state-dragged-opacity:  0.16;

    /* ── Elevation ───────────────────────────────────────────────────── */
    --md-sys-elevation-level0: none;
    --md-sys-elevation-level1: 0 1px 2px rgba(0,0,0,.30), 0 1px 3px 1px rgba(0,0,0,.15);
    --md-sys-elevation-level2: 0 1px 2px rgba(0,0,0,.30), 0 2px 6px 2px rgba(0,0,0,.15);
    --md-sys-elevation-level3: 0 4px 8px 3px rgba(0,0,0,.15), 0 1px 3px rgba(0,0,0,.30);

    /* ── Legacy --c-* tokens, now aliases onto the M3 roles ──────────── */
    --c-primary:       var(--md-sys-color-primary);
    --c-on-primary:    var(--md-sys-color-on-primary);
    --c-primary-dark:  #073d25;
    --c-primary-light: #1a7a4a;
    --c-secondary:     var(--md-sys-color-secondary);
    /* --c-mint was a light tint behind dark text. Under a fidelity scheme
       primary-container holds the seed itself (dark, for the emerald brand),
       so the light-tint role is secondary-container. Always pair it with
       --c-on-mint; never put --c-primary on --c-mint. */
    --c-mint:          var(--md-sys-color-secondary-container);
    --c-on-mint:       var(--md-sys-color-on-secondary-container);

    --c-bg:            var(--md-sys-color-surface);
    --c-bg-card:       var(--md-sys-color-surface-container-low);
    --c-bg-raised:     var(--md-sys-color-surface-container-high);
    --c-surface:       var(--md-sys-color-surface-container-lowest);

    --c-text:          var(--md-sys-color-on-surface);
    --c-text-muted:    var(--md-sys-color-on-surface-variant);
    /* Dim text: readable on white (the landing's #adb5bd is not, for text) */
    --c-text-dim:      #78848a;

    --c-border:        var(--md-sys-color-outline-variant);
    --c-border-strong: var(--md-sys-color-outline);

    /* Landing-page shades with no M3 role of their own */
    --c-mist:          #e8f5e9;   /* alternate section / hover wash */
    --c-tint:          #f4fdf7;   /* faint panel tint */
    --c-line:          #f0f7f2;   /* hairline between rows */
    --c-faint:         #b2bec3;   /* placeholder / disabled glyphs */
    --c-footer:        #1b263b;   /* footer navy */

    --c-accent:        var(--md-sys-color-primary);
    --c-success:       var(--md-sys-color-success);
    --c-warn:          var(--md-sys-color-warning);
    --c-danger:        var(--md-sys-color-error);

    /* ── MudBlazor palette bridge — drives every Mud component ────────── */
    /* !important is load-bearing: MudThemeProvider injects a runtime
       <style> block into <head> AFTER this stylesheet, so without it the
       C# palette wins and Mud components ignore the loaded theme. */
    --mud-palette-primary: #0a5c36 !important;
    --mud-palette-primary-rgb: 10,92,54 !important;
    --mud-palette-primary-text: #ffffff !important;
    --mud-palette-primary-darken: #073d25 !important;
    --mud-palette-primary-lighten: #1a7a4a !important;
    --mud-palette-primary-hover: rgba(10,92,54, 0.08) !important;
    --mud-palette-secondary: #1a7a4a !important;
    --mud-palette-secondary-rgb: 26,122,74 !important;
    --mud-palette-secondary-text: #ffffff !important;
    --mud-palette-tertiary: #1976d2 !important;
    --mud-palette-tertiary-rgb: 25,118,210 !important;
    --mud-palette-tertiary-text: #ffffff !important;
    --mud-palette-background: #f8fbf2 !important;
    --mud-palette-background-gray: #f4fdf7 !important;
    --mud-palette-surface: #ffffff !important;
    --mud-palette-appbar-background: #0a5c36 !important;
    --mud-palette-appbar-text: #ffffff !important;
    --mud-palette-drawer-background: #ffffff !important;
    --mud-palette-drawer-text: #636e72 !important;
    --mud-palette-drawer-icon: #636e72 !important;
    --mud-palette-text-primary: #2d3436 !important;
    --mud-palette-text-secondary: #636e72 !important;
    --mud-palette-text-disabled: rgba(45,52,54, 0.38) !important;
    --mud-palette-action-default: #636e72 !important;
    --mud-palette-action-disabled: rgba(45,52,54, 0.38) !important;
    --mud-palette-action-disabled-background: rgba(45,52,54, 0.12) !important;
    --mud-palette-divider: #d8f3dc !important;
    --mud-palette-divider-light: rgba(216,243,220, 0.6) !important;
    --mud-palette-lines-default: #d8f3dc !important;
    --mud-palette-lines-inputs: #adb5bd !important;
    --mud-palette-table-lines: #d8f3dc !important;
    --mud-palette-table-striped: #f4fdf7 !important;
    --mud-palette-table-hover: rgba(10,92,54, 0.06) !important;
    --mud-palette-error: #ba1a1a !important;
    --mud-palette-error-rgb: 186,26,26 !important;
    --mud-palette-error-text: #ffffff !important;
    --mud-palette-error-hover: rgba(186,26,26, 0.08) !important;
    --mud-palette-success: #1a7a4a !important;
    --mud-palette-success-rgb: 26,122,74 !important;
    --mud-palette-success-text: #ffffff !important;
    --mud-palette-success-hover: rgba(26,122,74, 0.08) !important;
    --mud-palette-warning: #855300 !important;
    --mud-palette-warning-rgb: 133,83,0 !important;
    --mud-palette-warning-text: #ffffff !important;
    --mud-palette-warning-hover: rgba(133,83,0, 0.08) !important;
    --mud-palette-info: #1976d2 !important;
    --mud-palette-info-rgb: 25,118,210 !important;
    --mud-palette-info-text: #ffffff !important;
    --mud-palette-info-hover: rgba(25,118,210, 0.08) !important;

    /* Legacy radii, mapped onto the shape scale */
    --radius-sm:  var(--md-sys-shape-corner-small);
    --radius-md:  var(--md-sys-shape-corner-medium);
    --radius-lg:  var(--md-sys-shape-corner-medium);
    --radius:     var(--md-sys-shape-corner-medium);
}

/* ── Base typography ─────────────────────────────────────────────────────── */
/* M3 body-medium. The spec's default reading size is body-large (16px), but
   this is a dense financial grid — 14px is the M3 "compact" reading of the
   same scale and keeps table rows on screen. */
html, body {
    font: var(--md-sys-typescale-body-medium);
    background: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    -webkit-font-smoothing: antialiased;
}

/* ── Material Symbols ────────────────────────────────────────────────────── */
/* Google's font stylesheet already declares .material-symbols-outlined; this
   only pins the variable axes. M3 uses outlined (FILL 0) for resting icons and
   fills them on the active/selected state. */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
    vertical-align: middle;
}
.side-nav-link.active > .material-symbols-outlined,
.mud-nav-link.active  > .material-symbols-outlined {
    font-variation-settings: 'FILL' 1, 'wght' 500, 'GRAD' 0, 'opsz' 24;
}

/* Tabular numerals for all ledger / financial figures */
.mud-table td,
.mud-table th,
.num,
[class*="amount"],
[class*="balance"],
[class*="total"],
[class*="price"],
[class*="quantity"] {
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* ── Page header ─────────────────────────────────────────────────────────── */
.page-header {
    margin-bottom: 24px;
}
.page-header__title {
    font: var(--md-sys-typescale-headline-small);
    color: var(--md-sys-color-on-surface);
}
.page-header__sub {
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
    margin-top: 4px;
}

/* ── Loading / empty states ──────────────────────────────────────────────── */
.loading-pulse {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--md-sys-color-on-surface-variant);
    font: var(--md-sys-typescale-body-medium);
    padding: 32px 0;
}
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--md-sys-color-on-surface-variant);
}
.empty-state__icon  { font-size: 40px; margin-bottom: 12px; }
.empty-state__title { font: var(--md-sys-typescale-title-medium); color: var(--md-sys-color-on-surface); margin-bottom: 4px; }
.empty-state__sub   { font: var(--md-sys-typescale-body-medium); }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.detail-card {
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 16px;
}
.detail-card__title {
    font: var(--md-sys-typescale-label-medium);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 12px;
}
.detail-row {
    display: flex;
    gap: 12px;
    padding: 6px 0;
    border-bottom: 1px solid var(--md-sys-color-outline-variant);
    font: var(--md-sys-typescale-body-medium);
    align-items: flex-start;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { flex: 0 0 160px; color: var(--md-sys-color-on-surface-variant); font: var(--md-sys-typescale-body-small); }
.detail-value { flex: 1; color: var(--md-sys-color-on-surface); word-break: break-word; }

/* ── Capture summary (quote / order / invoice totals) ────────────────────── */
/* These panels reuse .detail-row, but its 160px label is sized for a detail
   page and leaves almost nothing for the amount in a 280px totals panel. The
   amount then wraps — and because en-ZA groups thousands with a space, and
   .detail-value breaks on word boundaries, it breaks in the middle of a number
   ("R 851 6 / 00,00"). Here the label gives way instead, and the amount is
   never broken. The panel's min-width is a floor, so it grows to fit. */
.capture-summary .detail-label { flex: 1 1 auto; }
.capture-summary .detail-value {
    flex: 0 0 auto;
    text-align: right;
    white-space: nowrap;
    word-break: normal;
}

/* ── Stat cards ──────────────────────────────────────────────────────────── */
.stat-card {
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 20px 24px;
}
.stat-card__label {
    font: var(--md-sys-typescale-label-medium);
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 8px;
}
.stat-card__value {
    font: var(--md-sys-typescale-headline-medium);
    color: var(--md-sys-color-on-surface);
    font-variant-numeric: tabular-nums;
    font-feature-settings: "tnum" 1;
}

/* ── Equal-height grid cards ─────────────────────────────────────────────── */
/* MudItem becomes a flex column so child cards stretch to full row height    */
.mud-grid-item {
    display: flex;
    flex-direction: column;
}
.mud-grid-item > .stat-card,
.mud-grid-item > .dash-tile,
.mud-grid-item > .detail-card {
    flex: 1;
    box-sizing: border-box;
}

/* ── Hybrid sidebar nav links ────────────────────────────────────────────── */
/* M3 navigation item: pill-shaped active indicator, state layer on hover.    */
.side-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    font: var(--md-sys-typescale-label-large);
    color: var(--md-sys-color-on-surface-variant);
    text-decoration: none;
    border-radius: var(--md-sys-shape-corner-full);
    margin: 2px 8px;
    transition: background .12s, color .12s;
    cursor: pointer;
}
.side-nav-link:hover {
    background: color-mix(in srgb, var(--md-sys-color-on-surface) calc(var(--md-sys-state-hover-opacity) * 100%), transparent);
    color: var(--md-sys-color-on-surface);
    text-decoration: none;
}
.side-nav-link:active {
    background: color-mix(in srgb, var(--md-sys-color-on-surface) calc(var(--md-sys-state-pressed-opacity) * 100%), transparent);
}
.side-nav-link.active {
    color: var(--md-sys-color-on-secondary-container);
    background: var(--md-sys-color-secondary-container);
    font-weight: 600;
}
.side-nav-icon {
    font-size: 18px;
    color: inherit;
    flex-shrink: 0;
}

/* ── MudBlazor overrides ─────────────────────────────────────────────────── */

/* Buttons — M3 pill shape, no gradients, tonal/filled variants */
.mud-button-root {
    border-radius: var(--md-sys-shape-corner-full) !important;
    box-shadow: none !important;
    background-image: none !important;
    font: var(--md-sys-typescale-label-large) !important;
    letter-spacing: .01em;
    text-transform: none;
    padding-inline: 24px;
}
.mud-button-filled.mud-button-filled-primary {
    background-color: var(--md-sys-color-primary) !important;
    color: var(--md-sys-color-on-primary) !important;
    border: none !important;
}
/* State layers: M3 composites the layer over the container rather than
   swapping to a darker colour. */
.mud-button-filled.mud-button-filled-primary:hover {
    background-image: linear-gradient(
        color-mix(in srgb, var(--md-sys-color-on-primary) calc(var(--md-sys-state-hover-opacity) * 100%), transparent) 0 0) !important;
    box-shadow: var(--md-sys-elevation-level1) !important;
}
.mud-button-filled.mud-button-filled-primary:active {
    background-image: linear-gradient(
        color-mix(in srgb, var(--md-sys-color-on-primary) calc(var(--md-sys-state-pressed-opacity) * 100%), transparent) 0 0) !important;
}
.mud-button-outlined {
    border-color: var(--md-sys-color-outline) !important;
    color: var(--md-sys-color-primary) !important;
}
.mud-button-outlined:hover,
.mud-button-text:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) calc(var(--md-sys-state-hover-opacity) * 100%), transparent) !important;
}
.mud-button-outlined:active,
.mud-button-text:active {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) calc(var(--md-sys-state-pressed-opacity) * 100%), transparent) !important;
}

/* Icon buttons — circular, with a state layer */
.mud-icon-button {
    border-radius: var(--md-sys-shape-corner-full) !important;
}
.mud-icon-button:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface-variant) calc(var(--md-sys-state-hover-opacity) * 100%), transparent) !important;
}

/* Cards, dialogs, menus — M3 shape scale */
.mud-card,
.mud-paper {
    border-radius: var(--md-sys-shape-corner-medium);
    background-color: var(--md-sys-color-surface-container-low);
}
.mud-dialog {
    border-radius: var(--md-sys-shape-corner-extra-large) !important;
    background-color: var(--md-sys-color-surface-container-high) !important;
}
.mud-dialog-title { font: var(--md-sys-typescale-headline-small); }
.mud-popover, .mud-menu-list {
    border-radius: var(--md-sys-shape-corner-extra-small);
    background-color: var(--md-sys-color-surface-container);
}
.mud-list-item:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) calc(var(--md-sys-state-hover-opacity) * 100%), transparent) !important;
}

/* Text fields — M3 outlined corner is extra-small. The border element is a
   <fieldset class="mud-input-outlined-border"> rendered as a SIBLING of
   .mud-input-outlined, not a descendant, so it must not be nested here.
   It also needs the small radius explicitly: MudBlazor's 12px
   DefaultBorderRadius rounds the fieldset so hard that the notch the floating
   label sits in no longer lines up. */
.mud-input-outlined-border {
    border-radius: var(--md-sys-shape-corner-extra-small) !important;
    border-color: var(--md-sys-color-outline);
}
/* The notch is a <legend> sized from its text at 0.75em of the INHERITED font
   size. MudBlazor assumes that inherits 16px, but our 14px body-medium base
   shrank it to 10.5px while the floating label still renders at 12px — so the
   label overran its gap. Pin the legend back to 12px to re-sync them. */
.mud-input.mud-input-outlined .mud-input-outlined-border legend,
.mud-input-outlined-border legend {
    font-size: 12px !important;
}

/* Tables — clean spreadsheet look on an M3 surface */
.mud-table-container {
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    overflow: hidden;
}
.mud-table-head .mud-table-cell {
    background: var(--md-sys-color-surface-container);
    color: var(--md-sys-color-on-surface-variant);
    font: var(--md-sys-typescale-label-medium);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-bottom: 1px solid var(--md-sys-color-outline-variant) !important;
}
.mud-table-body .mud-table-row:hover > .mud-table-cell {
    background: color-mix(in srgb, var(--md-sys-color-on-surface) calc(var(--md-sys-state-hover-opacity) * 100%), transparent);
}

/* Nav drawer active link — M3 pill indicator */
.mud-nav-link {
    border-radius: var(--md-sys-shape-corner-full) !important;
    font: var(--md-sys-typescale-label-large) !important;
}
.mud-nav-link:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) calc(var(--md-sys-state-hover-opacity) * 100%), transparent) !important;
}
.mud-nav-link.active {
    color: var(--md-sys-color-on-secondary-container) !important;
    background: var(--md-sys-color-secondary-container) !important;
}

/* Chips — M3 chips are fully rounded */
.mud-chip {
    border-radius: var(--md-sys-shape-corner-small) !important;
    font: var(--md-sys-typescale-label-large) !important;
}

/* ── Dashboard shared styles (dash-tile, pipeline, aged-buckets) ────────────── */

.dash-tile {
    background: var(--md-sys-color-surface-container-low);
    border: 1px solid var(--md-sys-color-outline-variant);
    border-radius: var(--md-sys-shape-corner-medium);
    padding: 32px 24px;
    text-align: center;
    cursor: pointer;
    transition: box-shadow .15s, background .15s;
    user-select: none;
    height: 100%;
    box-sizing: border-box;
}
.dash-tile:hover {
    background: color-mix(in srgb, var(--md-sys-color-primary) calc(var(--md-sys-state-hover-opacity) * 100%), var(--md-sys-color-surface-container-low));
    box-shadow: var(--md-sys-elevation-level1);
}
.dash-tile:active {
    background: color-mix(in srgb, var(--md-sys-color-primary) calc(var(--md-sys-state-pressed-opacity) * 100%), var(--md-sys-color-surface-container-low));
}
.dash-tile__icon {
    font-size: 40px;
    color: var(--md-sys-color-primary);
    display: block;
    margin-bottom: 12px;
}
.dash-tile__title {
    font: var(--md-sys-typescale-title-medium);
    color: var(--md-sys-color-on-surface);
    margin-bottom: 6px;
}
.dash-tile__sub {
    font: var(--md-sys-typescale-body-medium);
    color: var(--md-sys-color-on-surface-variant);
}

.aged-buckets {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr 1fr;
    gap: 8px;
    margin-top: 12px;
}
.aged-bucket__label {
    font: var(--md-sys-typescale-label-small);
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--md-sys-color-on-surface-variant);
    margin-bottom: 4px;
}
.aged-bucket__value {
    font: var(--md-sys-typescale-title-medium);
    color: var(--md-sys-color-on-surface);
    font-variant-numeric: tabular-nums;
}

.pipeline-scroll {
    overflow-x: auto;
    border-radius: var(--md-sys-shape-corner-medium);
    border: 1px solid var(--md-sys-color-outline-variant);
}
.pipeline-grid {
    display: grid;
    grid-template-columns: 64px repeat(4, 1fr);
    gap: 1px;
    background: var(--md-sys-color-outline-variant);
    min-width: 420px;
}
.pipeline-cell {
    background: var(--md-sys-color-surface-container-lowest);
    padding: 10px 8px;
}
.pipeline-cell--corner      { background: var(--md-sys-color-surface-container); }
.pipeline-cell--col-header  { background: var(--md-sys-color-surface-container); text-align: center; cursor: pointer; transition: background .12s; padding: 10px 6px; }
.pipeline-cell--col-header:hover { background: color-mix(in srgb, var(--md-sys-color-primary) calc(var(--md-sys-state-hover-opacity) * 100%), var(--md-sys-color-surface-container)); }
.pipeline-cell--row-label   { background: var(--md-sys-color-surface-container); display: flex; align-items: center; justify-content: flex-end; padding: 6px 8px; }
.pipeline-cell--data        { text-align: center; min-height: 54px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.pipeline-cell--link        { cursor: pointer; transition: background .12s; }
.pipeline-cell--link:hover  { background: color-mix(in srgb, var(--md-sys-color-primary) calc(var(--md-sys-state-hover-opacity) * 100%), var(--md-sys-color-surface-container-lowest)); }
.pipeline-col-icon          { font-size: 18px; color: var(--md-sys-color-primary); display: block; margin-bottom: 3px; }
.pipeline-col-label         { font: var(--md-sys-typescale-label-small); text-transform: uppercase; letter-spacing: .05em; color: var(--md-sys-color-on-surface-variant); }
.pipeline-col-sublabel      { font: var(--md-sys-typescale-label-small); font-size: 9px; text-transform: uppercase; letter-spacing: .04em; color: var(--md-sys-color-on-surface-variant); opacity: .75; }
.pipeline-row-label         { font: var(--md-sys-typescale-label-small); text-transform: uppercase; letter-spacing: .05em; color: var(--md-sys-color-on-surface-variant); white-space: nowrap; }
.pipeline-value             { font: var(--md-sys-typescale-title-small); color: var(--md-sys-color-on-surface); }
.pipeline-meta              { font: var(--md-sys-typescale-body-small); color: var(--md-sys-color-on-surface-variant); margin-top: 3px; }
.pipeline-empty             { font: var(--md-sys-typescale-body-medium); color: var(--md-sys-color-outline-variant); }

/* ── Error UI ─────────────────────────────────────────────────────────────── */
#blazor-error-ui {
    color-scheme: light only;
    background: var(--md-sys-color-warning-container);
    color: var(--md-sys-color-on-warning-container);
    bottom: 0;
    box-shadow: var(--md-sys-elevation-level2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: .6rem 1.25rem .7rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: .75rem; top: .5rem; }

/* ── Blazor load progress ─────────────────────────────────────────────────── */
.loading-progress {
    position: relative;
    display: block;
    width: 8rem;
    height: 8rem;
    margin: 20vh auto 1rem;
}
.loading-progress circle {
    fill: none;
    stroke: var(--md-sys-color-surface-container-highest);
    stroke-width: .6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}
.loading-progress circle:last-child {
    stroke: var(--md-sys-color-primary);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * .8), 500%;
    transition: stroke-dasharray .05s ease-in-out;
}
.loading-progress-text {
    position: absolute;
    text-align: center;
    font: var(--md-sys-typescale-title-medium);
    inset: calc(20vh + 3.25rem) 0 auto .2rem;
}
.loading-progress-text::after { content: var(--blazor-load-percentage-text, "Loading"); }

/* ── Line-item capture tables ──────────────────────────────────────────────────
   Imported invoice lines carry product names up to 255 characters. A select
   sizes itself to its content, so without a fixed table layout one long name
   pushes Qty, Unit Price and Line Total off the screen. The name truncates
   with an ellipsis instead; the full text is available in the open dropdown,
   where options wrap. */
.line-items-table table {
    table-layout: fixed;
    width: 100%;
}
.line-items-table td {
    overflow: hidden;
}
/* MudSelect shows the chosen option inside .mud-input-slot; clip it. */
.line-items-table .mud-select .mud-input-slot,
.line-items-table .mud-select .mud-input-root,
.line-items-table .mud-select input {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}

/* Select popovers render detached from their anchor, so they need their own
   cap: wrap long option text rather than growing a page-wide panel. */
.mud-popover {
    max-width: min(720px, 92vw);
}
.mud-popover .mud-list-item-text {
    white-space: normal;
    overflow-wrap: anywhere;
}

/* ── Break-even explorer ────────────────────────────────────────────────────
   Three columns on a wide screen — assumptions, the picture, the figures — and
   one stacked column below 1100px. Everything is built out of the existing
   tokens, so both themes and any brand seed are handled by the tokens alone. */

.be-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.be-layout {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 320px;
    gap: 16px;
    align-items: start;
}

@media (max-width: 1100px) {
    .be-layout { grid-template-columns: minmax(0, 1fr); }
}

.be-panel {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 20px;
}

.be-panel__title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--c-text);
    margin-bottom: 12px;
}

/* The stage keeps a fixed aspect so the scene does not jump as figures change. */
.be-stage { padding: 12px; }

.be-scene {
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 340px;
    user-select: none;
}

/* ── Sliders ─────────────────────────────────────────────────────────────── */

.be-slider { margin-bottom: 18px; }

.be-slider__label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--c-text);
    margin-bottom: 6px;
}

.be-slider__unit {
    color: var(--c-text-muted);
    font-size: 0.75rem;
    white-space: nowrap;
}

.be-slider__row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.be-slider__range {
    flex: 1 1 auto;
    min-width: 0;
    accent-color: var(--c-primary);
}

.be-slider__number {
    flex: 0 0 92px;
    width: 92px;
    padding: 6px 8px;
    font: inherit;
    font-size: 0.85rem;
    text-align: right;
    color: var(--c-text);
    background: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm, 6px);
}

.be-slider__range:focus-visible,
.be-slider__number:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* ── Figures ─────────────────────────────────────────────────────────────── */

.be-figure { margin-bottom: 14px; }

.be-figure__label {
    font-size: 0.78rem;
    color: var(--c-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.be-figure__value {
    font-size: 1.35rem;
    font-weight: 600;
    color: var(--c-text);
    font-variant-numeric: tabular-nums;
}

.be-figure__value--lead { font-size: 1.75rem; }
.be-figure__none        { color: var(--c-text-dim); }
.be-figure__unit        { font-size: 0.78rem; color: var(--c-text-muted); }

.be-good { color: var(--c-success); }
.be-bad  { color: var(--c-danger); }

.be-note {
    font-size: 0.82rem;
    color: var(--c-text-muted);
    line-height: 1.45;
    margin: 8px 0 0;
}

/* ── Scenario legend ─────────────────────────────────────────────────────── */

.be-legend__row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 2px 0;
    font-size: 0.85rem;
}

.be-legend__swatch {
    flex: 0 0 12px;
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

.be-legend__name  { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.be-legend__value { flex: 0 0 auto; color: var(--c-text-muted); font-variant-numeric: tabular-nums; }

.be-save {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 12px;
}

.be-exports {
    display: flex;
    gap: 4px;
    margin-top: 12px;
    flex-wrap: wrap;
}

/* The spoken summary duplicates the picture, so it is available to a screen
   reader and to anyone who wants the sentence, without cluttering the layout. */
.be-sr-summary {
    margin-top: 16px;
    font-size: 0.85rem;
    color: var(--c-text-muted);
}

/* ── Contour view ────────────────────────────────────────────────────────── */

.be-contour { margin: 0; }

.be-contour__caption {
    font-size: 0.8rem;
    color: var(--c-text-muted);
    margin-top: 8px;
    line-height: 1.45;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */

.be-empty {
    background: var(--c-bg-card);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 48px 24px;
    text-align: center;
    max-width: 620px;
    margin: 0 auto;
}

.be-empty__icon  { font-size: 44px; color: var(--c-text-dim); }
.be-empty__title { font-size: 1.1rem; font-weight: 600; color: var(--c-text); margin-top: 8px; }
.be-empty__body  { color: var(--c-text-muted); line-height: 1.55; margin: 8px auto 20px; }

/* ── Setup screen ────────────────────────────────────────────────────────── */

.be-setup {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

@media (max-width: 1000px) {
    .be-setup { grid-template-columns: minmax(0, 1fr); }
}

.be-setup__item {
    display: flex;
    align-items: center;
    gap: 4px;
    border-radius: var(--radius-sm, 6px);
}

.be-setup__item--active { background: var(--c-mint); }
.be-setup__item--active .be-setup__name,
.be-setup__item--active .be-setup__meta { color: var(--c-on-mint); }

.be-setup__pick {
    flex: 1 1 auto;
    min-width: 0;
    text-align: left;
    background: none;
    border: 0;
    padding: 8px 10px;
    cursor: pointer;
    font: inherit;
}

.be-setup__name { display: block; color: var(--c-text); font-weight: 500; }
.be-setup__meta { display: block; color: var(--c-text-muted); font-size: 0.78rem; }

.be-setup__grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    align-items: start;
}

.be-setup__preview { color: var(--c-text-muted); font-style: italic; }

/* ── Account and product mapping ─────────────────────────────────────────── */

.be-map { margin-top: 16px; }

.be-map__head {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--c-text);
    margin-bottom: 6px;
}

.be-map__count { font-weight: 400; color: var(--c-text-muted); font-size: 0.78rem; }

.be-map__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 150px;
    overflow-y: auto;
    padding: 2px;
}

.be-chip {
    font: inherit;
    font-size: 0.78rem;
    padding: 4px 10px;
    border-radius: 999px;
    border: 1px solid var(--c-border);
    background: var(--c-surface);
    color: var(--c-text-muted);
    cursor: pointer;
}

.be-chip:hover { border-color: var(--c-border-strong); }

.be-chip--on {
    background: var(--c-mint);
    border-color: var(--c-primary);
    color: var(--c-on-mint);
    font-weight: 500;
}

.be-chip:focus-visible {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

/* ── Snackbar (Material Design 3) ───────────────────────────────────────────
   The application's one notification surface, mounted once in App.razor.

   Every colour is a token. The surface is the M3 inverse pair, which is what a
   snackbar is meant to sit on — a dark plate against a light page — and severity
   is carried by the leading icon and a hairline accent rather than by repainting
   the whole thing. That matters here because each industry theme redefines these
   roles: the snackbar follows the theme without knowing a thing about it. */

.snackbar-host {
    position: fixed;
    left: 24px;
    bottom: 16px;
    z-index: 1050;
    display: flex;
    pointer-events: none;               /* the empty host must not eat clicks */
}

.snackbar {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 12px;

    /* Width follows the text, up to the M3 maximum. */
    width: max-content;
    max-width: 560px;
    min-height: 48px;
    padding: 10px 12px 10px 16px;

    background: var(--md-sys-color-inverse-surface);
    color: var(--md-sys-color-inverse-on-surface);
    border-radius: var(--radius-sm, 4px);
    box-shadow: var(--md-sys-elevation-level3);

    /* Body medium, the M3 type role for snackbar text. */
    font-size: 14px;
    line-height: 1.43;
    letter-spacing: .25px;

    border-left: 4px solid var(--snackbar-accent, var(--md-sys-color-inverse-primary));
    animation: snackbar-enter 220ms cubic-bezier(.2, 0, 0, 1);
}

.snackbar--leaving {
    animation: snackbar-leave 200ms cubic-bezier(.4, 0, 1, 1) forwards;
}

@keyframes snackbar-enter {
    from { opacity: 0; transform: translateY(16px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes snackbar-leave {
    from { opacity: 1; }
    to   { opacity: 0; }
}

/* Someone who has asked for less motion still gets the notification, just without
   it sliding in. */
@media (prefers-reduced-motion: reduce) {
    .snackbar,
    .snackbar--leaving { animation: none; }
}

.snackbar__icon {
    flex: 0 0 auto;
    font-size: 20px;
    color: var(--snackbar-accent, var(--md-sys-color-inverse-primary));
}

.snackbar__text {
    flex: 1 1 auto;
    min-width: 0;

    /* Up to two lines, then elide — a snackbar is not the place for an essay. */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.snackbar__action {
    flex: 0 0 auto;
    font: inherit;
    font-weight: 600;
    letter-spacing: .1px;
    text-transform: uppercase;
    background: none;
    border: 0;
    padding: 8px;
    margin: -4px 0;
    border-radius: var(--radius-sm, 4px);
    cursor: pointer;
    color: var(--snackbar-accent, var(--md-sys-color-inverse-primary));
}

.snackbar__dismiss {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
    color: var(--md-sys-color-inverse-on-surface);
    opacity: .75;
}

.snackbar__dismiss .material-symbols-outlined { font-size: 18px; }

.snackbar__action:hover,
.snackbar__dismiss:hover { background: rgb(255 255 255 / .12); }

.snackbar__dismiss:hover { opacity: 1; }

.snackbar__action:focus-visible,
.snackbar__dismiss:focus-visible {
    outline: 2px solid var(--md-sys-color-inverse-primary);
    outline-offset: 2px;
}

/* ── Severity ───────────────────────────────────────────────────────────────
   Container roles, not the base ones: the base error/warning/success colours are
   sized for light surfaces and disappear against the inverse plate. */

.snackbar--info    { --snackbar-accent: var(--md-sys-color-inverse-primary); }
.snackbar--success { --snackbar-accent: var(--md-sys-color-on-success-container); }
.snackbar--warning { --snackbar-accent: var(--md-sys-color-warning-container); }
.snackbar--error   { --snackbar-accent: var(--md-sys-color-error-container); }

/* ── Small screens ──────────────────────────────────────────────────────────
   Bottom-centre and full width, so the text has somewhere to go. */

@media (max-width: 600px) {
    .snackbar-host {
        left: 8px;
        right: 8px;
        bottom: 8px;
        justify-content: center;
    }

    .snackbar { width: 100%; max-width: none; }
}

/* ── Intercompany loan timeline ───────────────────────────────────────────── */
.loan-timeline { list-style: none; padding: 0; margin: 0; }
.loan-timeline li {
    display: grid; grid-template-columns: 24px 1fr; gap: 12px; align-items: baseline;
    padding: 8px 0; border-bottom: 1px solid var(--c-border);
}
.loan-timeline li:last-child { border-bottom: none; }
.loan-timeline__dot { width: 12px; height: 12px; border-radius: 50%; background: var(--c-border); }
.loan-timeline__dot--done    { background: var(--md-sys-color-primary); }
.loan-timeline__dot--warning { background: var(--md-sys-color-error); }
