/* ==========================================================================
   Broli S&OP Portal — design tokens and layout. Sober, dense, management-grade.
   Group colours (Beetle Heritage): burgundy #961B1E, charcoal #4D4D4D, warm white.
   The burgundy is kept for the brand chrome (menu, buttons, links); status colours stay separate, with icon + label.
   Chart colours: fixed categorical order; status colours reserved and always paired with an icon + label.
   ========================================================================== */
:root {
  color-scheme: light;
  --brand-950: #1c1c1e; --brand-900: #2b2b2d; --brand-800: #4d4d4d; --brand-600: #961b1e; --brand-700: #7a1518; --accent: #961b1e; --accent-hover: #7a1518; --accent-soft: rgba(150,27,30,.09);
  --page: #f5f4f2; --surface: #ffffff; --surface-2: #faf9f7; --surface-3: #efedea;
  --text: #111418; --text-secondary: #4b5058; --text-muted: #5f646b;
  /* Text on an accent background (primary buttons): dark on the light accents of the dark themes (F-16). */
  --on-accent: #ffffff; --on-brand: #ffffff;
  --border: #e2e4e8; --border-strong: #cfd3d9; --grid: #eceef1; --axis: #c8ccd2;
  --tooltip-bg: #111418; --tooltip-ink: #ffffff;
  --series-1: #961b1e; --series-2: #4d4d4d; --series-3: #c8962e; --series-4: #2a7f8a; --series-5: #d97b7d; --series-6: #8f8f93; --series-7: #5b4a8a; --series-8: #e0a458;
  --good: #0ca30c; --good-ink: #006300; --good-bg: #e8f6e8;
  --warning: #fab219; --warning-ink: #8a5a00; --warning-bg: #fff5dc;
  --serious: #ec835a; --serious-ink: #a0421b; --serious-bg: #fdeee7;
  --critical: #d03b3b; --critical-ink: #b02626; --critical-bg: #fbe9e9;
  --excess: #6c5ccf; --excess-ink: #4a3aa7; --excess-bg: #efedfb;
  --neutral-bg: #eef0f3;
  --radius: 10px; --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-title: Futura, "Century Gothic", "Jost", "Avenir Next", var(--font);
  --sidebar-w: 232px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --accent: #e0575a; --accent-hover: #ea7678; --accent-soft: rgba(224,87,90,.14);
    --page: #0d0f12; --surface: #17191d; --surface-2: #1d2025; --surface-3: #252930;
    --text: #f2f3f5; --text-secondary: #c3c6cc; --text-muted: #9a9fa7; --on-accent: #111418;
    --border: #2a2e35; --border-strong: #3a3f47; --grid: #25282e; --axis: #3a3f47;
    --tooltip-bg: #f2f3f5; --tooltip-ink: #111418;
    --series-1: #e0575a; --series-2: #b4b4b8; --series-3: #d9a940; --series-4: #3fa3b0; --series-5: #f0a0a2; --series-6: #7a7a80; --series-7: #9085e9; --series-8: #e8b46e;
    --good-ink: #3ecf3e; --good-bg: #13301a; --warning-ink: #fab219; --warning-bg: #332812; --serious-ink: #f09a78; --serious-bg: #3a2219;
    --critical-ink: #f07070; --critical-bg: #3a1a1a; --excess-ink: #a79df0; --excess-bg: #25213d; --neutral-bg: #252930;
  }
}
:root[data-theme="dark"], :root[data-theme="night"], :root[data-theme="graphite"] {
  color-scheme: dark;
  --accent: #e0575a; --accent-hover: #ea7678; --accent-soft: rgba(224,87,90,.14);
  --page: #0d0f12; --surface: #17191d; --surface-2: #1d2025; --surface-3: #252930;
  --text: #f2f3f5; --text-secondary: #c3c6cc; --text-muted: #9a9fa7; --on-accent: #111418;
  --border: #2a2e35; --border-strong: #3a3f47; --grid: #25282e; --axis: #3a3f47;
  --tooltip-bg: #f2f3f5; --tooltip-ink: #111418;
  --series-1: #e0575a; --series-2: #b4b4b8; --series-3: #d9a940; --series-4: #3fa3b0; --series-5: #f0a0a2; --series-6: #7a7a80; --series-7: #9085e9; --series-8: #e8b46e;
  --good-ink: #3ecf3e; --good-bg: #13301a; --warning-ink: #fab219; --warning-bg: #332812; --serious-ink: #f09a78; --serious-bg: #3a2219;
  --critical-ink: #f07070; --critical-bg: #3a1a1a; --excess-ink: #a79df0; --excess-bg: #25213d; --neutral-bg: #252930;
}

/* ---------- Colour themes (menu utilisateur › Thème) ----------
   "Système" follows the computer (Beetle Heritage light or dark). Every theme only changes the chrome (menu, accent, pages,
   first chart series); status colours (critical, watch, good, excess) never change, so they always read the same. */
:root[data-theme="ocean"] {
  --brand-900: #0f2a47; --brand-800: #163a61; --brand-600: #1d5fa8; --accent: #1d5fa8; --accent-hover: #174c87; --accent-soft: rgba(29,95,168,.1);
  --page: #f2f5f9; --surface-2: #f7f9fc; --surface-3: #e9eef5; --series-1: #1d5fa8; --series-2: #4d5b6b; --series-3: #2a9d8f; --series-4: #e0a458;
}
:root[data-theme="forest"] {
  --brand-900: #1d3327; --brand-800: #2c4a39; --brand-600: #2e7d4f; --accent: #2e7d4f; --accent-hover: #24643f; --accent-soft: rgba(46,125,79,.1);
  --page: #f3f6f2; --surface-2: #f8faf7; --surface-3: #e8eee6; --series-1: #2e7d4f; --series-2: #5b6b5e; --series-3: #b98a2f; --series-4: #3f7fa6;
}
:root[data-theme="sand"] {
  --brand-900: #3b2f25; --brand-800: #5a4636; --brand-600: #a24c22; --accent: #a24c22; --accent-hover: #873e1a; --accent-soft: rgba(181,88,43,.1);
  --page: #f7f3ec; --surface-2: #fbf8f3; --surface-3: #efe8dc; --series-1: #b5582b; --series-2: #6b5d50; --series-3: #c8962e; --series-4: #4f7f7a;
}
:root[data-theme="lavender"] {
  --brand-900: #2a2340; --brand-800: #3e3460; --brand-600: #6a4fb3; --accent: #6a4fb3; --accent-hover: #563f95; --accent-soft: rgba(106,79,179,.1);
  --page: #f5f3f9; --surface-2: #f9f8fc; --surface-3: #ece8f4; --series-1: #6a4fb3; --series-2: #5c5670; --series-3: #d08a3f; --series-4: #2f8f9d;
}
:root[data-theme="slate"] {
  --brand-900: #1f2328; --brand-800: #353b43; --brand-600: #3d4f63; --accent: #3d5a80; --accent-hover: #2f4764; --accent-soft: rgba(61,90,128,.1);
  --page: #f3f4f6; --surface-2: #f8f9fa; --surface-3: #eceef1; --series-1: #3d5a80; --series-2: #7a8491; --series-3: #c08a3e; --series-4: #3f8f7a;
}
:root[data-theme="night"] {
  --brand-900: #0b1426; --brand-800: #16233d; --brand-600: #4c8dff; --on-brand: #0b1426; --accent: #6fa3ff; --accent-hover: #8fb8ff; --accent-soft: rgba(111,163,255,.15);
  --page: #0a0f1a; --surface: #111a2b; --surface-2: #162134; --surface-3: #1d2a40; --border: #22304a; --border-strong: #2f4060; --grid: #1c2840; --axis: #2f4060;
  --series-1: #6fa3ff; --series-2: #9aa7bd; --series-3: #e0b25a; --series-4: #4fc3b0;
}
:root[data-theme="graphite"] {
  --brand-900: #121212; --brand-800: #2a2a2a; --brand-600: #d99a2b; --on-brand: #121212; --accent: #e3a93b; --accent-hover: #f0be62; --accent-soft: rgba(227,169,59,.15);
  --page: #0e0e0e; --surface: #181818; --surface-2: #1f1f1f; --surface-3: #282828; --border: #2e2e2e; --border-strong: #3d3d3d; --grid: #262626; --axis: #3d3d3d;
  --series-1: #e3a93b; --series-2: #a8a8a8; --series-3: #5fb3c4; --series-4: #d9776b;
}
/* High contrast: black text on white, strong borders, dark accent; for bright rooms, projectors and low vision. */
:root[data-theme="contrast"] {
  --brand-900: #000000; --brand-800: #1a1a1a; --brand-600: #0033aa; --accent: #0033aa; --accent-hover: #002280; --accent-soft: rgba(0,51,170,.12);
  --page: #ffffff; --surface: #ffffff; --surface-2: #ffffff; --surface-3: #f0f0f0; --text: #000000; --text-secondary: #1a1a1a; --text-muted: #333333;
  --border: #595959; --border-strong: #000000; --grid: #bdbdbd; --axis: #000000;
  --series-1: #0033aa; --series-2: #000000; --series-3: #b35900; --series-4: #007a5a;
}
:root[data-theme="contrast"] .nav a, :root[data-theme="contrast"] .nav .nav-group, :root[data-theme="contrast"] .nav .nav-sub a { color: #ffffff; }
:root[data-theme="contrast"] table.data td, :root[data-theme="contrast"] table.data th { border-color: #8c8c8c; }

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; line-height: 1.45; color: var(--text); background: var(--page); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-family: var(--font-title); font-size: 22px; font-weight: 650; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; font-weight: 620; margin: 0; }
h3 { font-size: 13px; font-weight: 600; margin: 0; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.nowrap { white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar { background: var(--brand-900); color: #e4e2df; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; z-index: 30; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px 16px 12px; background: var(--surface); color: var(--text); border-bottom: 1px solid var(--border); font-weight: 700; letter-spacing: .01em; position: relative; }
.brand-logo { width: 150px; }
.brand small { display: block; font-family: var(--font-title); font-weight: 600; color: var(--accent); font-size: 11px; letter-spacing: .12em; text-transform: uppercase; }
.brand-mark { width: 30px; height: 30px; border-radius: 8px; background: #fff url("brand/mark.png") center / auto 24px no-repeat; }
.nav { padding: 10px 8px 20px; display: flex; flex-direction: column; gap: 1px; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #a19d98; padding: 14px 12px 6px; }
.nav a, .nav .nav-disabled { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 7px; color: #e4e2df; font-size: 13.5px; text-decoration: none; }
.nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav a.active { background: var(--brand-600); color: var(--on-brand); font-weight: 600; }
.nav .ico { width: 18px; text-align: center; opacity: .9; font-size: 14px; }
.nav .nav-disabled { color: #6f86a2; cursor: default; }
.nav .nav-group { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: 0; border-radius: 7px; background: none; color: #e4e2df; font: inherit; font-size: 13.5px; text-align: left; cursor: pointer; }
.nav .nav-group:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav .nav-group.active { color: #fff; font-weight: 600; }
.nav .nav-group:focus-visible { outline: 2px solid #e0575a; outline-offset: -2px; }
.nav .nav-group .chev { margin-left: auto; transition: transform .15s; opacity: .7; }
.nav .nav-group.open .chev { transform: rotate(90deg); }
.nav .nav-sub { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 6px 21px; padding-left: 8px; border-left: 1px solid rgba(255,255,255,.14); }
.nav .nav-sub a { padding: 6px 10px; font-size: 12.8px; color: #cfccc8; }
.nav .badge-phase { margin-left: auto; font-size: 10px; border: 1px solid #3f5a7a; border-radius: 10px; padding: 0 6px; color: #8ba2bd; }
.sidebar-foot { margin-top: auto; padding: 12px 18px; font-size: 11px; color: #a19d98; border-top: 1px solid rgba(255,255,255,.08); }

.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 56px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 14px; padding: 0 20px; position: sticky; top: 0; z-index: 25; }
.topbar .title { font-family: var(--font-title); font-weight: 650; white-space: nowrap; }
.topbar .spacer { flex: 1; }
.icon-btn { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; height: 34px; min-width: 34px; padding: 0 10px; cursor: pointer; color: var(--text-secondary); display: inline-flex; align-items: center; gap: 6px; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu-btn { display: none; }
.user-chip { display: flex; align-items: center; gap: 10px; position: relative; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-800); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 13px; }
.user-chip .who { line-height: 1.15; font-size: 12.5px; }
.user-chip .who b { display: block; font-size: 13px; }
/* Above the click-away backdrop (z-index 65), and scrollable on a short screen so every item stays reachable. */
.dropdown { position: absolute; top: calc(100% + 6px); right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); min-width: 220px; padding: 6px; z-index: 70;
            max-height: calc(100vh - 72px); overflow-y: auto; overscroll-behavior: contain; }
.dropdown button, .dropdown a { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 8px 10px; border-radius: 6px; cursor: pointer; color: var(--text); font-size: 13px; }
.dropdown button:hover, .dropdown a:hover { background: var(--surface-2); text-decoration: none; }

.demo-banner { background: repeating-linear-gradient(135deg, #fff3cd, #fff3cd 12px, #ffeeba 12px, #ffeeba 24px); color: #6b4e00; font-size: 12.5px; padding: 6px 20px; border-bottom: 1px solid #f1d58a; display: flex; gap: 10px; align-items: center; }
:root[data-theme="dark"] .demo-banner { background: #332812; color: #fab219; border-color: #4a3a18; }
.demo-banner b { letter-spacing: .08em; }
.content { padding: 18px 20px 40px; max-width: 1680px; width: 100%; }

/* ---------- Search ---------- */
.search { position: relative; flex: 0 1 420px; }
.search input { width: 100%; height: 36px; border: 1px solid var(--border); background: var(--surface-2); border-radius: 8px; padding: 0 12px 0 34px; }
.search input:focus { background: var(--surface); border-color: var(--accent); outline: none; box-shadow: 0 0 0 3px var(--accent-soft); }
.search .glyph { position: absolute; left: 11px; top: 8px; color: var(--text-muted); }
.search-results { position: absolute; top: 42px; left: 0; right: 0; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); max-height: 440px; overflow-y: auto; z-index: 60; padding: 6px; }
.search-results button { display: flex; gap: 10px; align-items: baseline; width: 100%; text-align: left; border: 0; background: none; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.search-results button:hover, .search-results button.sel { background: var(--surface-2); }
.search-results .type { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); width: 62px; flex: none; }
.search-results .sub { color: var(--text-muted); font-size: 12px; }

/* ---------- Filter bar ---------- */
.filterbar { background: var(--surface); border-bottom: 1px solid var(--border); padding: 8px 20px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; position: sticky; top: 56px; z-index: 20; }
.filterbar .phone-toggle { display: none; }
@media (max-width: 760px) { .filterbar .phone-toggle { display: inline-flex; } }
.filterbar .lbl { font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-right: 2px; }
.fsel { position: relative; }
.fsel > button { height: 32px; border: 1px solid var(--border); background: var(--surface); border-radius: 7px; padding: 0 10px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); white-space: nowrap; }
.fsel > button:hover { border-color: var(--border-strong); color: var(--text); }
.fsel > button.on { border-color: var(--accent); background: var(--accent-soft); color: var(--text); font-weight: 600; }
.fsel .count { background: var(--accent); color: var(--on-accent); border-radius: 10px; padding: 0 6px; font-size: 11px; }
.fsel .caret { font-size: 9px; opacity: .6; }
.fpanel { position: absolute; top: 36px; left: 0; min-width: 250px; max-width: 340px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow-lg); z-index: 70; padding: 8px; }
.fpanel input[type=search] { width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; margin-bottom: 6px; background: var(--surface-2); }
.fpanel .opts { max-height: 300px; overflow-y: auto; }
.fpanel label { display: flex; gap: 8px; align-items: center; padding: 6px 6px; border-radius: 5px; cursor: pointer; font-size: 13px; }
.fpanel label:hover { background: var(--surface-2); }
.fpanel .grp { font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; padding: 8px 6px 2px; }
.fpanel .actions { display: flex; justify-content: space-between; border-top: 1px solid var(--border); margin-top: 6px; padding-top: 6px; }
.fpanel .actions button { background: none; border: 0; color: var(--accent); cursor: pointer; font-size: 12.5px; padding: 4px 6px; }
.months { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; }
.months button { border: 1px solid var(--border); background: var(--surface); border-radius: 6px; padding: 6px 0; cursor: pointer; font-size: 12.5px; }
.months button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 4px; background: var(--surface-3); border-radius: 14px; padding: 2px 4px 2px 10px; font-size: 12px; color: var(--text-secondary); }
.chip b { color: var(--text); font-weight: 600; }
.chip button { border: 0; background: none; cursor: pointer; color: var(--text-muted); font-size: 13px; line-height: 1; padding: 2px 5px; border-radius: 10px; }
.chip button:hover { background: var(--border); color: var(--text); }
.reset { border: 0; background: none; color: var(--critical-ink); cursor: pointer; font-size: 12.5px; font-weight: 600; }
.period-pill { margin-left: auto; font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.period-pill b { color: var(--text); }
.fresh-pill { font-size: 12.5px; color: var(--text-secondary); white-space: nowrap; }
.fresh-pill b { color: var(--text); font-weight: 600; }
.fresh-late { font-size: 12.5px; font-weight: 600; color: var(--warning-ink, var(--critical-ink)); white-space: nowrap; text-decoration: none; }
a.fresh-late:hover { text-decoration: underline; }
.readiness-body { display: flex; gap: 24px; align-items: center; flex-wrap: wrap; }
.readiness-total { display: flex; flex-direction: column; align-items: center; min-width: 110px; }
.readiness-total b { font-size: 34px; line-height: 1; }
.readiness-total span { color: var(--text-muted); font-size: 12px; }
.readiness-parts { flex: 1; min-width: 260px; display: grid; gap: 10px; }
.readiness-part { color: inherit; text-decoration: none; display: grid; gap: 4px; }
.readiness-part .l { font-size: 13px; }
.readiness-part .bar { height: 8px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.readiness-part .bar span { display: block; height: 100%; }
.readiness-part .bar .good { background: var(--good, #2e7d4f); } .readiness-part .bar .watch { background: var(--warning, #fab219); }
.readiness-part .bar .bad { background: var(--critical, #b42318); } .readiness-part .bar .none { background: transparent; }
.readiness-rule { font-size: 11.5px; padding: 0 16px 12px; margin: 0; }
.filtered-pill { font-size: 12.5px; font-weight: 600; color: var(--accent); white-space: nowrap; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 150; display: flex; align-items: center; gap: 10px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--accent); border-radius: 8px;
  padding: 10px 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18); font-size: 13px; max-width: calc(100vw - 32px); }
@media print { .toast { display: none; } }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head .q { color: var(--text-secondary); margin-top: 4px; font-size: 13.5px; }
.fav-toggle { border: 0; background: none; cursor: pointer; font-size: 20px; line-height: 1; color: var(--text-muted); padding: 0 4px; vertical-align: middle; }
.fav-toggle:hover, .fav-toggle.on { color: var(--accent); }
.nav a.fav .fav-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media print { .fav-toggle { display: none; } }
.page-head .q::before { content: "? "; color: var(--accent); font-weight: 700; }
.crumbs { font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
.crumbs a { color: var(--text-muted); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Cards & KPI ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px 0; }
.card-head .hint { font-size: 12px; color: var(--text-muted); }
.card-body { padding: 12px 16px 16px; }
.card-body.flush { padding: 0; }
.grid { display: grid; gap: 14px; }
.g-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g-32 { grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); }
.mb { margin-bottom: 14px; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.kpis.k4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis.k6 { grid-template-columns: repeat(6, minmax(0, 1fr)); }
.kpi { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 12px 16px; box-shadow: var(--shadow); text-align: left; cursor: default; overflow: hidden; min-height: 108px; display: flex; flex-direction: column; }
button.kpi { cursor: pointer; font: inherit; color: inherit; width: 100%; }
button.kpi:hover { border-color: var(--border-strong); box-shadow: 0 4px 14px rgba(16,24,40,.12); transform: translateY(-1px); }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--border); }
.kpi.good::before { background: var(--good); } .kpi.watch::before { background: var(--warning); } .kpi.bad::before { background: var(--critical); }
.kpi .k-title { font-size: 11.5px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; color: var(--text-secondary); display: flex; justify-content: space-between; gap: 6px; }
.kpi .k-title .go { color: var(--text-muted); font-weight: 400; }
.kpi .k-value { font-size: 28px; font-weight: 680; letter-spacing: -.02em; margin-top: 6px; line-height: 1.1; }
.kpi .k-value .u { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-left: 4px; letter-spacing: 0; }
.kpi .k-delta { font-size: 12px; margin-top: 4px; font-weight: 600; }
.kpi .k-delta .vs { font-weight: 400; color: var(--text-muted); }
.up-good, .down-good { color: var(--good-ink); } .up-bad, .down-bad { color: var(--critical-ink); } .flat { color: var(--text-muted); }
.kpi .k-sub { font-size: 12px; color: var(--text-muted); margin-top: auto; padding-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi .k-state { position: absolute; right: 12px; top: 34px; font-size: 11px; }

/* ---------- Status badges (colour + icon + label) ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; border-radius: 12px; padding: 1px 9px 1px 7px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge .i { font-size: 10px; }
.st-critical { background: var(--critical-bg); color: var(--critical-ink); }
.st-serious { background: var(--serious-bg); color: var(--serious-ink); }
.st-warning { background: var(--warning-bg); color: var(--warning-ink); }
.st-good { background: var(--good-bg); color: var(--good-ink); }
.st-excess { background: var(--excess-bg); color: var(--excess-ink); }
.st-neutral { background: var(--neutral-bg); color: var(--text-secondary); }

/* ---------- Tabs & buttons ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); padding: 0 12px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; cursor: pointer; color: var(--text-secondary); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13px; }
.tabs button:hover { color: var(--text); }
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.tabs .n { background: var(--surface-3); border-radius: 10px; padding: 0 6px; font-size: 11px; margin-left: 4px; color: var(--text-secondary); }
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 550; font-size: 13px; color: var(--text); white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--critical-ink); border-color: var(--critical-bg); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; padding: 0; font: inherit; text-align: left; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Tables ---------- */
.table-tools { display: flex; gap: 10px; align-items: center; padding: 10px 12px; flex-wrap: wrap; }
.table-tools input[type=search] { height: 32px; border: 1px solid var(--border); border-radius: 7px; padding: 0 10px; min-width: 240px; background: var(--surface-2); }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th { position: sticky; top: 0; background: var(--surface-2); text-align: left; font-weight: 600; color: var(--text-secondary); font-size: 11.5px; text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data th.num { text-align: right; }
table.data th.sortable { cursor: pointer; user-select: none; }
table.data th.sortable:hover { color: var(--text); }
table.data th .arrow { color: var(--accent); margin-left: 2px; }
table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr.click { cursor: pointer; }
table.data tr.click:hover td { background: var(--surface-2); }
table.data td .sub { display: block; color: var(--text-muted); font-size: 11.5px; }
table.data td.code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; padding: 10px 12px; font-size: 12.5px; color: var(--text-secondary); flex-wrap: wrap; }
.pager select { height: 28px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.empty { padding: 36px 16px; text-align: center; color: var(--text-muted); }
.bar-cell { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.bar-cell .track { display: block; flex: none; width: 60px; height: 6px; background: var(--surface-3); border-radius: 3px; overflow: hidden; }
.bar-cell .fill { display: block; height: 100%; border-radius: 3px; }

/* ---------- Charts ---------- */
.chart { position: relative; width: 100%; }
.chart canvas { display: block; }
.chart-note { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }

/* ---------- Loading & errors ---------- */
.skeleton { background: linear-gradient(90deg, var(--surface-3) 25%, var(--surface-2) 50%, var(--surface-3) 75%); background-size: 400% 100%; animation: sk 1.3s ease infinite; border-radius: 8px; }
@keyframes sk { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }
.alert { border-radius: 8px; padding: 10px 14px; margin-bottom: 14px; font-size: 13px; display: flex; gap: 10px; align-items: flex-start; }
.alert.error { background: var(--critical-bg); color: var(--critical-ink); }
.alert.warn { background: var(--warning-bg); color: var(--warning-ink); }
.alert.ok { background: var(--good-bg); color: var(--good-ink); }
.alert.info { background: var(--surface-3); color: var(--text-secondary); }
.loading-bar { position: fixed; top: 0; left: 0; right: 0; height: 2px; z-index: 100; background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 200% 100%; animation: sk 1s linear infinite; }
.splash { min-height: 100vh; display: grid; place-items: center; color: var(--text-muted); }

/* ---------- Forms & modal ---------- */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form .full { grid-column: 1 / -1; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.field input, .field select, .field textarea { width: 100%; height: 36px; border: 1px solid var(--border-strong); border-radius: 7px; padding: 0 10px; background: var(--surface); }
.field textarea { height: auto; min-height: 70px; padding: 8px 10px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.field .help { font-size: 11.5px; color: var(--text-muted); margin-top: 3px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.modal-back { position: fixed; inset: 0; background: rgba(10, 20, 35, .45); display: grid; place-items: center; z-index: 200; padding: 16px; }
.modal { background: var(--surface); border-radius: 12px; box-shadow: var(--shadow-lg); width: min(720px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--border); }

/* ---------- Product detail ---------- */
.actions-panel { border-left: 4px solid var(--accent); }
.action-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); align-items: flex-start; }
.action-item:last-child { border-bottom: 0; }
.action-item .sev { flex: none; margin-top: 1px; }
.action-item b { display: block; margin-bottom: 2px; }
.action-item p { margin: 0; color: var(--text-secondary); font-size: 13px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 0; }
.facts div { padding: 10px 16px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.facts span { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.facts b { font-size: 15px; }

/* ---------- Login ---------- */
.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr 1fr; background: var(--page); }
.login-hero { position: relative; background: color-mix(in srgb, var(--accent) 7%, var(--surface)); border-right: 1px solid var(--border); color: var(--text); padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.login-hero h1 { font-size: 34px; color: var(--accent); margin-top: 40px; line-height: 1.15; }
.login-hero p { color: var(--text-secondary); max-width: 460px; font-size: 15px; }
.login-hero ul { color: var(--text); padding-left: 18px; line-height: 1.9; }
.login-form { display: grid; place-items: center; padding: 32px; }
.login-form form { width: min(360px, 100%); display: grid; gap: 14px; }
.login-form .field input { height: 42px; }
.login-form .btn { height: 42px; justify-content: center; }

/* ---------- Upload ---------- */
.dropzone { border: 2px dashed var(--border-strong); border-radius: 10px; padding: 22px; text-align: center; color: var(--text-secondary); background: var(--surface-2); }
.steps { display: flex; gap: 6px; flex-wrap: wrap; font-size: 12.5px; margin-bottom: 12px; }
.steps span { padding: 4px 10px; border-radius: 12px; background: var(--surface-3); color: var(--text-muted); }
.steps span.on { background: var(--accent); color: var(--on-accent); }
.steps span.done { background: var(--good-bg); color: var(--good-ink); }
.perm-grid td, .perm-grid th { text-align: center; }
.perm-grid td:first-child, .perm-grid th:first-child { text-align: left; }

/* ---------- Meeting / TV mode ---------- */
.shell.meeting { grid-template-columns: 1fr; }
.shell.meeting .sidebar { display: none; }
.shell.meeting .content { max-width: none; }
.shell.meeting { font-size: 15.5px; }
.shell.meeting .kpi .k-value { font-size: 34px; }

/* ---------- Responsive ---------- */
@media (max-width: 1400px) { .kpis { grid-template-columns: repeat(5, minmax(0, 1fr)); } .kpi .k-value { font-size: 24px; } .facts { grid-template-columns: repeat(2, minmax(0,1fr)); } }
@media (max-width: 1180px) {
  .kpis, .kpis.k6 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .g-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-32 { grid-template-columns: 1fr; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .nav-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 29; }
  .menu-btn { display: inline-flex; }
  .user-chip .who { display: none; }
}
@media (max-width: 760px) {
  .kpis, .kpis.k4, .kpis.k6 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filterbar:not(.phone-open) > :not(.lbl):not(.phone-toggle):not(.chips) { display: none; }
  .filterbar { position: static; padding: 8px 12px; }
  .dropdown.notif-panel { position: fixed; top: 58px; left: 8px; right: 8px; width: auto; max-height: calc(100vh - 80px); }
  .g-2, .g-3 { grid-template-columns: 1fr; }
  .content { padding: 14px 12px 32px; }
  .login-page { grid-template-columns: 1fr; } .login-hero { display: none; }
  .topbar .title { display: none; }
  .form { grid-template-columns: 1fr; }
  .period-pill { margin-left: 0; }
}

/* ---------- Print: page content only ---------- */
@media print {
  .sidebar, .topbar, .filterbar, .toolbar, .table-tools, .pager, .demo-banner button, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .card, .kpi { box-shadow: none; break-inside: avoid; }
  .content { padding: 0; max-width: none; }
}

#blazor-error-ui { background: var(--critical-bg); color: var(--critical-ink); bottom: 0; box-shadow: 0 -1px 2px rgba(0,0,0,.2); 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; }
.backdrop { position: fixed; inset: 0; z-index: 65; background: transparent; }
/* Dense analytical tables (many numeric columns): wrapping headers, tighter cells. */
table.data.dense { font-size: 12.5px; }
table.data.dense th { white-space: normal; padding: 7px 7px; font-size: 11px; line-height: 1.25; vertical-align: bottom; }
table.data.dense td { padding: 7px 7px; }
table.data.dense td .badge { padding: 1px 7px 1px 5px; font-size: 11.5px; }
.flags { display: flex; flex-wrap: wrap; gap: 3px; max-width: 170px; }
/* ---------- Notifications ---------- */
.bell-count { position: absolute; top: -5px; right: -6px; background: var(--critical); color: #fff; border-radius: 10px; font-size: 10.5px; font-weight: 700; padding: 0 5px; line-height: 17px; }
.notif-panel { width: min(420px, 92vw); max-height: 520px; overflow-y: auto; padding: 0; }
.notif-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); }
.dropdown button.notif { display: flex; gap: 10px; align-items: flex-start; padding: 10px 14px; border-radius: 0; border-bottom: 1px solid var(--border); }
.notif-row { display: flex; align-items: flex-start; gap: 6px; border-bottom: 1px solid var(--border); padding-right: 10px; }
.notif-row.unread { background: var(--accent-soft); }
.dropdown .notif-row > button.notif { flex: 1; min-width: 0; width: auto; border-bottom: 0; background: none; }
.dropdown .notif-row > button.notif-act { flex: none; width: auto; margin-top: 10px; white-space: nowrap; border: 1px solid var(--border); padding: 4px 8px; }
.notif-head span { display: flex; gap: 6px; align-items: center; }
.dropdown .notif-head .link-btn, .dropdown .notif-tabs button { width: auto; display: inline-block; }
.notif-tabs { display: flex; gap: 4px; padding: 6px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 41px; background: var(--surface); z-index: 1; }
.notif-tabs button { border: 0; background: none; padding: 5px 10px; border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--text-secondary); }
.notif-tabs button.on { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.notif-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.notif-msg { color: var(--text-secondary); font-size: 12.5px; white-space: pre-line; max-height: 5.8em; overflow: hidden; }
/* ---------- Meeting view ---------- */
.meeting-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.meeting-grid .card h2 a { color: inherit; }
.m-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; padding: 10px 16px 4px; }
.m-kpi { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; }
.m-kpi.good { border-color: var(--good); } .m-kpi.watch { border-color: var(--warning); } .m-kpi.bad { border-color: var(--critical); }
.m-kpi .l { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.m-kpi .v { font-size: 20px; font-weight: 680; }
.m-kpi .s { font-size: 11.5px; color: var(--text-muted); }
.m-items { list-style: none; margin: 0; padding: 4px 16px 12px; }
.m-items li { padding: 7px 0; border-top: 1px solid var(--border); display: flex; gap: 8px; align-items: flex-start; font-size: 13px; }
.m-items li .d { display: block; color: var(--text-muted); font-size: 12px; }
.decisions li { font-size: 14px; }
@media (max-width: 1180px) { .meeting-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 760px) { .meeting-grid { grid-template-columns: 1fr; } }
/* Checkboxes and radios keep their natural size inside form fields. */
.field input[type=checkbox], .field input[type=radio] { width: auto; height: auto; padding: 0; box-shadow: none; accent-color: var(--accent); }
.field label.check { display: flex; font-weight: 500; color: var(--text); margin: 0; }
.chips label.check.chip { cursor: pointer; }

/* Reporting follow-up: weekly calendar of expected reports. */
.cal-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.cal-day { border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); padding: 8px 10px; min-width: 0; }
.cal-day h3 { margin: 0 0 6px; font-size: 13px; display: flex; justify-content: space-between; gap: 6px; }
.cal-day h3 span { color: var(--text-muted); font-weight: 400; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-item { display: flex; gap: 8px; align-items: flex-start; padding: 6px 0; border-top: 1px solid var(--border); font-size: 12.5px; }
.cal-item .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; margin-top: 4px; background: var(--text-muted); }
.cal-item .dot.st-good { background: var(--good); } .cal-item .dot.st-warning { background: var(--warning); }
.cal-item .dot.st-serious { background: var(--serious); } .cal-item .dot.st-critical { background: var(--critical); }
.cal-item b { display: block; font-weight: 600; }
.cal-item .sub { display: block; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--text-secondary); }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.legend .dot-l { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }

/* ---------- Department workspaces ---------- */
.ws-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; grid-auto-flow: row dense; }
.ws-grid > .card { margin: 0; min-width: 0; }
.ws-grid > .wide { grid-column: 1 / -1; }
.card-head h2 .count { display: inline-block; margin-left: 6px; padding: 0 7px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: 11px; font-weight: 600; color: var(--text-muted); vertical-align: 2px; }
.card-sub { padding: 2px 16px 0; font-size: 12px; color: var(--text-muted); }
.ws-pick { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; }
@media (max-width: 1180px) { .ws-grid { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar .title, .hide-sm { display: none; }
  .search { flex: 1 1 auto; min-width: 0; }
  /* The state badge flows under the title instead of covering long titles. */
  .kpi .k-state { position: static; align-self: flex-start; margin-top: 6px; }
  .kpi { min-height: 0; }
  /* Wide tables scroll sideways with readable columns rather than squeezing every column. */
  .table-wrap > table.data { min-width: 780px; }
}

/* ---------- Stock by warehouse (matrix) ---------- */
.wh-matrix th.sticky, .wh-matrix td.sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); min-width: 220px; box-shadow: 1px 0 0 var(--border); }
.wh-matrix thead th.sticky, .wh-matrix tfoot th.sticky { z-index: 2; }
.wh-matrix tbody tr:hover td.sticky { background: var(--surface-2); }
.wh-matrix tfoot th { border-top: 2px solid var(--border); background: var(--surface-2); font-weight: 650; }
.wh-matrix tfoot th.num { text-align: right; }
.wh-matrix td.num.muted { color: var(--text-muted); }

/* Back link above each page title */
.back-link { display: inline-flex; align-items: center; gap: 4px; margin: 0 0 4px; padding: 2px 8px 2px 4px; border: 0; border-radius: 6px;
             background: none; color: var(--accent); font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.back-link:hover { background: var(--surface-2); }
@media print { .back-link { display: none; } }

/* Help assistant */
.assistant-fab { position: fixed; right: 20px; bottom: 20px; z-index: 90; display: inline-flex; align-items: center; gap: 6px; height: 44px; padding: 0 18px;
                 border: 0; border-radius: 22px; background: var(--accent); color: var(--on-accent); font: inherit; font-weight: 650; box-shadow: var(--shadow-lg); cursor: pointer; }
.assistant-fab:hover { background: #2168bd; }
.assistant { position: fixed; right: 20px; bottom: 20px; z-index: 90; width: 460px; max-width: calc(100vw - 32px); height: min(620px, calc(100vh - 110px));
             display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; }
.assistant header { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.assistant header > div { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.assistant header .muted { font-size: 11.5px; color: var(--text-muted); }
.assistant header .icon-btn { height: 30px; min-width: 30px; padding: 0 8px; }
.assistant-log { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.assistant .msg { max-width: 92%; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.45; overflow-wrap: anywhere; }
.assistant .msg.user { align-self: flex-end; background: var(--accent); color: var(--on-accent); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.assistant .msg.bot { align-self: flex-start; background: var(--surface-3); color: var(--text); border-bottom-left-radius: 4px; }
.assistant .msg.bot p { margin: 0 0 6px; } .assistant .msg.bot p:last-child { margin-bottom: 0; }
.assistant .msg.bot ul, .assistant .msg.bot ol { margin: 4px 0 6px; padding-left: 20px; }
.assistant .msg.bot li { margin: 2px 0; }
.assistant .msg.bot a { color: var(--accent); font-weight: 600; }
.assistant .msg.bot code { font-size: 12px; background: var(--surface); padding: 0 4px; border-radius: 4px; }
.assistant .msg.typing { display: inline-flex; gap: 4px; padding: 12px 14px; }
.assistant .msg.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: assistant-dot 1s infinite ease-in-out; }
.assistant .msg.typing span:nth-child(2) { animation-delay: .15s; } .assistant .msg.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes assistant-dot { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }
.assistant .msg.bot.wide { max-width: 100%; width: 100%; }
.assistant-data { overflow-wrap: normal; margin-top: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.assistant-data-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.assistant-data-head .muted, .assistant-data .small { font-size: 11.5px; color: var(--text-muted); }
.assistant-data .table-wrap { overflow-x: auto; margin: 4px -8px 0; }
.assistant-data table.data { font-size: 12px; min-width: 100%; }
.assistant-data table.data th, .assistant-data table.data td { padding: 5px 8px; }
.assistant-data .empty { padding: 8px 0; color: var(--text-muted); font-size: 12.5px; }
.assistant-more { display: inline-block; margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.assistant-suggestions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
.assistant-suggestions button { border: 1px solid var(--border-strong); background: var(--surface); color: var(--accent); border-radius: 16px; padding: 5px 12px;
                                font: inherit; font-size: 12.8px; text-align: left; cursor: pointer; }
.assistant-suggestions button:hover { background: var(--surface-2); }
.assistant-input { display: flex; gap: 8px; padding: 10px 12px 6px; border-top: 1px solid var(--border); }
.assistant-input textarea { flex: 1; resize: none; border: 1px solid var(--border-strong); border-radius: 8px; padding: 7px 9px; font: inherit; font-size: 13.5px;
                            background: var(--surface); color: var(--text); }
.assistant-input .btn { align-self: flex-end; }
.assistant-note { padding: 0 12px 10px; font-size: 11px; color: var(--text-muted); }
.shell.meeting ~ .assistant-fab, .shell.meeting ~ .assistant { display: none; }
@media (max-width: 760px) {
  .assistant-fab { right: 14px; bottom: 14px; height: 44px; width: 44px; padding: 0; justify-content: center; }
  .assistant-fab span { display: none; }
  .assistant { right: 0; bottom: 0; width: 100vw; max-width: none; height: 85vh; border-radius: 14px 14px 0 0; }
}
@media print { .assistant-fab, .assistant { display: none; } }

/* Operational reports: as many tiles as the report has, text values allowed. */
.kpis.ops-kpis { grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.ops-kpis .kpi { min-height: 96px; }
.ops-kpis .k-value { font-size: 24px; overflow-wrap: anywhere; }
.ops-table td { min-width: 84px; }
.ops-table td:last-child { min-width: 220px; }
.ops-kpis .k-value.long { font-size: 18px; }
table.data tr.detail td { background: var(--surface-2); }
ul.parents { margin: 6px 0 0; padding-left: 18px; columns: 2; column-gap: 32px; font-size: 12.5px; }
@media (max-width: 720px) { ul.parents { columns: 1; } }
table.data th .sub { display: block; font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-muted); }
.sales-range { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.sales-range input[type=date] { margin-left: 6px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; }
.sales-range .quick { display: flex; flex-wrap: wrap; gap: 6px; }

/* English display: hidden until the first translation pass (at most 2,5 s). */
html.i18n-pending body { visibility: hidden; }
.lang-switch { display: flex; gap: 6px; justify-content: center; margin-top: 18px; }
.lang-switch { align-items: center; }
.lang-switch select, .menu-field select { border: 1px solid var(--border-strong); border-radius: 6px; padding: 4px 8px; background: var(--surface); color: var(--text); font: inherit; font-size: 13px; }
.menu-field { display: grid; gap: 3px; padding: 6px 10px; }
.menu-field label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.menu-field select { width: 100%; }

/* ---------- Right-to-left (Arabic) ---------- */
[dir="rtl"] .nav .nav-sub { margin: 2px 21px 6px 0; padding-left: 0; padding-right: 8px; border-left: 0; border-right: 1px solid rgba(255,255,255,.14); }
[dir="rtl"] .nav .nav-group .chev { margin-left: 0; margin-right: auto; transform: scaleX(-1); }
[dir="rtl"] .nav .nav-group.open .chev { transform: rotate(90deg); }
[dir="rtl"] .kpi .k-title .go { transform: scaleX(-1); }
[dir="rtl"] .dropdown { right: auto; left: 0; }
[dir="rtl"] .period-pill { margin-left: 0; margin-right: auto; }
[dir="rtl"] .has-tip::after { margin-left: 0; margin-right: 4px; }
[dir="rtl"] table.data th, [dir="rtl"] table.data td { text-align: right; }
[dir="rtl"] table.data th.num, [dir="rtl"] table.data td.num, [dir="rtl"] .num { text-align: left; }
[dir="rtl"] .assistant-fab, [dir="rtl"] .assistant { right: auto; left: 20px; }
[dir="rtl"] .dropdown button, [dir="rtl"] .dropdown a { text-align: right; }

/* ---------- Group identity (Beetle Heritage) ---------- */
.login-logo { width: 240px; }
/* Logo en deux calques (partie rouge, partie grise) colorés par le thème. */
.logo { display: block; position: relative; aspect-ratio: 284 / 108; height: auto; }
.logo::before, .logo::after { content: ""; position: absolute; inset: 0; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; }
.logo::before { --m: url("brand/logo-red.png"); background: var(--accent); }
.logo::after { --m: url("brand/logo-grey.png"); background: var(--text-secondary); }
.login-hero .login-app { font-family: var(--font-title); color: var(--accent); letter-spacing: .12em; text-transform: uppercase; font-size: 12px; font-weight: 600; margin-top: 8px; }
.login-hero li::marker { color: var(--accent); }
.login-hero small { color: var(--text-muted); }
.login-form form { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow); }
.login-prefs { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }
.login-prefs .lang-switch { margin-top: 0; }
.nav a.active { background: var(--accent); }
.nav .nav-group.active .ico { color: #fff; } .nav a.active .ico { color: var(--on-brand); }
a.brand, a.brand:hover { text-decoration: none; }

/* ---------- ⓘ explanations ---------- */
.has-tip::after { content: "ⓘ"; margin-left: 4px; font-size: 11px; font-weight: 400; color: var(--text-muted); cursor: help; text-transform: none; letter-spacing: 0; }
.kpi .k-title .has-tip::after { font-size: 12px; }
.sop-tip { position: fixed; z-index: 200; display: none; max-width: 340px; padding: 8px 10px; border-radius: 8px; background: var(--tooltip-bg); color: var(--tooltip-ink);
           font-size: 12.5px; line-height: 1.45; font-weight: 400; text-transform: none; letter-spacing: 0; box-shadow: var(--shadow-lg); pointer-events: none; }
.has-tip::after { cursor: pointer; }
.sop-panel { position: fixed; z-index: 210; width: min(380px, calc(100vw - 16px)); padding: 10px 12px 8px; border-radius: 10px; background: var(--surface);
  color: var(--text); border: 1px solid var(--border); border-top: 3px solid var(--accent); box-shadow: var(--shadow-lg); font-size: 13px; line-height: 1.5;
  font-weight: 400; text-transform: none; letter-spacing: 0; }
.sop-panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
.sop-panel p { margin: 0 0 6px; }
.sop-panel .sop-panel-src { color: var(--text-muted); font-size: 12px; }
@media print { .has-tip::after, .sop-tip, .sop-panel { display: none !important; } }

/* Semoulerie */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px 14px; align-items: end; }
.form-grid .field { margin: 0; }
tr.row-alert td { background: var(--critical-bg); }
tr.total td { border-top: 2px solid var(--border-strong, var(--border)); }
.sub.neg { color: var(--critical-ink); font-weight: 600; }
.fill-list { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 6px; }
.fill-item { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
