/* ---- themes: every colour comes from these tokens; picked in the header, saved per browser ---- */
/* Gleuhr Coral (default) */
:root, :root[data-theme="coral"] {
  color-scheme: light;
  --bg: #faf6f3; --surface: #ffffff; --surface-2: #fdf7f4; --border: #ecdfd9; --text: #2a211e;
  --muted: #84756f; --accent: #d75447; --accent-ink: #ffffff; --blue-bg: #fbeae6;
  --red: #b42318; --red-bg: #fdecea; --orange: #b45309; --orange-bg: #fdf0dc;
  --green: #12863f; --green-bg: #e5f6ec; --grey-bg: #f3ece8;
  --shadow: 0 1px 2px rgba(80, 40, 30, .07); --radius: 10px;
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --grid: rgba(42, 33, 30, .09);
}
:root[data-theme="ocean"] {
  color-scheme: light;
  --bg: #f4f7fb; --surface: #ffffff; --surface-2: #f7f9fc; --border: #dde5ee; --text: #16222e;
  --muted: #627284; --accent: #1f6fb2; --accent-ink: #ffffff; --blue-bg: #e2eef9;
  --red: #b42318; --red-bg: #fdecea; --orange: #b45309; --orange-bg: #fdf0dc;
  --green: #12863f; --green-bg: #e5f6ec; --grey-bg: #edf1f6;
  --shadow: 0 1px 2px rgba(20, 50, 80, .07);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --grid: rgba(22, 34, 46, .09);
}
:root[data-theme="sage"] {
  color-scheme: light;
  --bg: #f5f7f3; --surface: #ffffff; --surface-2: #f7f9f6; --border: #dfe7df; --text: #1d2620;
  --muted: #66746a; --accent: #3e7a5a; --accent-ink: #ffffff; --blue-bg: #e3efe7;
  --red: #b42318; --red-bg: #fdecea; --orange: #b45309; --orange-bg: #fdf0dc;
  --green: #12863f; --green-bg: #e5f6ec; --grey-bg: #edf2ed;
  --shadow: 0 1px 2px rgba(30, 60, 40, .07);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --grid: rgba(29, 38, 32, .09);
}
:root[data-theme="slate"] {
  color-scheme: light;
  --bg: #f4f5f7; --surface: #ffffff; --surface-2: #f8f9fb; --border: #e3e6ea; --text: #1d2330;
  --muted: #667085; --accent: #2f5bea; --accent-ink: #ffffff; --blue-bg: #e8eefe;
  --red: #d92d20; --red-bg: #fdecea; --orange: #dc6803; --orange-bg: #fef0e1;
  --green: #12863f; --green-bg: #e5f6ec; --grey-bg: #eef0f3;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100; --s5: #e87ba4; --grid: rgba(29, 35, 48, .09);
}
:root[data-theme="midnight"] {
  color-scheme: dark;
  --bg: #14171c; --surface: #1c2027; --surface-2: #232831; --border: #2e343d; --text: #ebe7e4;
  --muted: #9aa2ad; --accent: #ef7a6d; --accent-ink: #1a1214; --blue-bg: #3a2523;
  --red: #ff6b5f; --red-bg: #3a1d1b; --orange: #ffa94d; --orange-bg: #3a2a17;
  --green: #4ad07e; --green-bg: #16301f; --grey-bg: #262b34;
  --shadow: none;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --grid: rgba(255, 255, 255, .08);
}
:root[data-theme="graphite"] {
  color-scheme: dark;
  --bg: #11141a; --surface: #191d25; --surface-2: #1f242e; --border: #2c323d; --text: #e7eaf0;
  --muted: #98a2b3; --accent: #6d8cff; --accent-ink: #0d1020; --blue-bg: #1f2a4a;
  --red: #ff6b5f; --red-bg: #3a1d1b; --orange: #ffa94d; --orange-bg: #3a2a17;
  --green: #4ad07e; --green-bg: #16301f; --grey-bg: #262b34;
  --shadow: none;
  --s1: #3987e5; --s2: #d95926; --s3: #199e70; --s4: #c98500; --s5: #d55181; --grid: rgba(255, 255, 255, .08);
}
/* fonts */
:root { --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
:root[data-font="poppins"] { --font: "Poppins", system-ui, sans-serif; }
:root[data-font="nunito"] { --font: "Nunito Sans", system-ui, sans-serif; }
:root[data-font="lora"] { --font: "Lora", Georgia, serif; }
:root[data-font="system"] { --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); }
button, input, select, textarea { font-family: inherit; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
a { color: var(--accent); }
.muted { color: var(--muted); } .small { font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand small { display: block; color: var(--muted); font-size: 12px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; }
.topbar-mid { flex: 1; display: flex; align-items: center; gap: 12px; min-width: 200px; flex-wrap: wrap; }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.topbar-actions form { margin: 0; }
.sync-info { color: var(--muted); font-size: 12px; }
.mode-badge { font-size: 11px; font-weight: 700; letter-spacing: .04em; padding: 4px 9px; border-radius: 999px; text-transform: uppercase; }
.mode-dry_run { background: var(--orange-bg); color: var(--orange); }
.mode-approval { background: var(--blue-bg); color: var(--accent); }
.mode-auto { background: var(--red-bg); color: var(--red); }

.banner { margin: 12px 20px 0; padding: 10px 14px; border-radius: var(--radius); background: var(--orange-bg);
  color: var(--text); border: 1px solid color-mix(in srgb, var(--orange) 35%, transparent); font-size: 13px; }
.banner.err { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 35%, transparent); }

/* buttons & inputs */
.btn { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px;
  padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; text-decoration: none; display: inline-flex;
  align-items: center; gap: 6px; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.danger-ghost { color: var(--red); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
input, select, textarea { font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 6px 9px; }
input[type=search] { min-width: 220px; }
input.qty { width: 90px; text-align: right; }

/* tabs */
.tabs { display: flex; gap: 2px; padding: 12px 20px 0; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 8px 12px; font: inherit; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.count { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; padding: 1px 7px; margin-left: 4px; }
.count.bad { background: var(--red); color: #fff; }
main { padding: 12px 20px 40px; }
.tab { display: none; } .tab.active { display: block; }

/* KPIs */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px;
  box-shadow: var(--shadow); cursor: pointer; text-align: left; font: inherit; color: inherit; border-left: 4px solid var(--border); }
.kpi:hover { background: var(--surface-2); }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 26px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 2px; }
.kpi .sub { color: var(--muted); font-size: 11px; margin-top: 2px; }
.kpi.red { border-left-color: var(--red); } .kpi.red .value { color: var(--red); }
.kpi.orange { border-left-color: var(--orange); } .kpi.orange .value { color: var(--orange); }
.kpi.green { border-left-color: var(--green); }
.kpi.blue { border-left-color: var(--accent); }

/* panels & tables */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px;
  margin-bottom: 14px; box-shadow: var(--shadow); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: 6px 10px; font: inherit; font-size: 12px; color: var(--muted); cursor: pointer; }
.seg button + button { border-left: 1px solid var(--border); }
.seg button.active { background: var(--accent); color: var(--accent-ink); }
.table-wrap { overflow-x: auto; }
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 7px 8px;
  border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface); position: sticky; top: 0; }
.grid td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid tr.row-critical td:first-child { box-shadow: inset 3px 0 0 var(--red); }
.grid tr.row-reorder_due td:first-child { box-shadow: inset 3px 0 0 var(--orange); }
.grid tr.row-healthy td:first-child { box-shadow: inset 3px 0 0 var(--green); }
.grid tr.clickable { cursor: pointer; } .grid tr.clickable:hover td { background: var(--surface-2); }
.grid .empty { text-align: center; color: var(--muted); padding: 24px; }
.pname { font-weight: 550; } .pcat { color: var(--muted); font-size: 11px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.b-critical { background: var(--red-bg); color: var(--red); }
.b-reorder_due { background: var(--orange-bg); color: var(--orange); }
.b-healthy { background: var(--green-bg); color: var(--green); }
.b-not_configured, .b-neutral { background: var(--grey-bg); color: var(--muted); }
.b-sent, .b-notified, .b-ok { background: var(--green-bg); color: var(--green); }
.b-failed, .b-blocked { background: var(--red-bg); color: var(--red); }
.b-dry_run, .b-pending_approval, .b-running { background: var(--orange-bg); color: var(--orange); }
.b-po_created, .b-covered, .b-processing { background: var(--blue-bg); color: var(--accent); }
.chip { font-size: 10px; color: var(--muted); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; margin-left: 4px; }
.warn { color: var(--red); font-size: 11px; display: block; }
.bar { height: 4px; background: var(--grey-bg); border-radius: 2px; margin-top: 4px; width: 80px; margin-left: auto; }
.bar > span { display: block; height: 100%; border-radius: 2px; }

.two-col { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }

/* settings */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.settings fieldset { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 14px; margin: 0; }
.settings legend { font-weight: 600; padding: 0 4px; }
.field { display: grid; gap: 4px; margin-bottom: 12px; }
.field > span { font-size: 12px; color: var(--muted); }
.field.inline { display: flex; align-items: center; gap: 8px; }
.radio-cards { display: grid; gap: 8px; }
.radio-cards label { display: flex; gap: 10px; border: 1px solid var(--border); border-radius: 8px; padding: 10px; cursor: pointer; }
.radio-cards label:has(input:checked) { border-color: var(--accent); background: var(--blue-bg); }
.radio-cards small { display: block; color: var(--muted); }
.checklist { display: grid; gap: 4px; max-height: 210px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.settings-actions { grid-column: 1 / -1; display: flex; gap: 8px; justify-content: flex-end; }

/* modal + toast */
dialog { border: 1px solid var(--border); border-radius: 12px; padding: 0; width: min(760px, calc(100vw - 32px));
  background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgba(10, 14, 22, .45); }
.modal-body { padding: 18px; max-height: 85vh; overflow: auto; }
.modal-body h3 { margin: 0 0 4px; }
.kv { display: grid; grid-template-columns: 150px 1fr; gap: 4px 12px; font-size: 13px; margin: 12px 0; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.callout { padding: 9px 12px; border-radius: 8px; font-size: 13px; margin: 10px 0; }
.callout.bad { background: var(--red-bg); color: var(--red); }
.callout.warn { background: var(--orange-bg); }
.callout.info { background: var(--blue-bg); }
div.email { border: 1px solid var(--border); border-radius: 8px; background: #fff; color: #1d2330; padding: 4px 14px;
  max-height: 340px; overflow: auto; font: 13px/1.5 Arial, sans-serif; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.toast { position: fixed; bottom: 20px; right: 20px; background: var(--text); color: var(--bg); padding: 10px 14px;
  border-radius: 8px; max-width: 420px; font-size: 13px; z-index: 20; }
.toast.err { background: var(--red); color: #fff; }
pre.json { background: var(--surface-2); padding: 8px; border-radius: 6px; font-size: 11px; overflow: auto; max-height: 200px; margin: 0; }

/* login */
.login-body { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 26px; width: min(360px, 100%);
  display: grid; gap: 14px; box-shadow: var(--shadow); }
.login-card label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.login-card input { padding: 9px 10px; font-size: 14px; }
.login-card .btn { justify-content: center; padding: 9px; }
.login-error { margin: 0; color: var(--red); font-size: 13px; }

@media (max-width: 760px) {
  .topbar { padding: 10px 16px; } main { padding: 12px 16px 40px; } .tabs { padding: 10px 16px 0; }
  .banner { margin: 12px 16px 0; }
  .two-col { grid-template-columns: 1fr; }
  input[type=search] { min-width: 0; width: 100%; }
  .filters { width: 100%; }
  .kpi .value { font-size: 22px; }
  .kv { grid-template-columns: 1fr; }
}

/* stock by location */
.ls-filters { margin-bottom: 8px; }
.chk { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; white-space: nowrap; }
.ls-wrap { max-height: 72vh; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
table.ls th, table.ls td { white-space: nowrap; }
table.ls th { z-index: 2; }
table.ls th[data-sort] { cursor: pointer; user-select: none; }
table.ls th[data-sort]:hover { color: var(--text); }
table.ls .stick { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 220px; max-width: 320px;
  white-space: normal; box-shadow: 1px 0 0 var(--border); }
table.ls thead .stick { z-index: 3; }
table.ls tfoot td { position: sticky; bottom: 0; background: var(--surface-2); font-weight: 600; border-top: 1px solid var(--border); }
table.ls tfoot .stick { background: var(--surface-2); z-index: 3; }
table.ls td.neg { color: var(--red); font-weight: 600; }
table.ls td.zero { color: var(--muted); }
table.ls td.tot, table.ls th.tot { background: var(--surface-2); }
.dd { position: relative; }
.dd > summary { list-style: none; }
.dd > summary::-webkit-details-marker { display: none; }
.dd-panel { position: absolute; z-index: 10; top: calc(100% + 4px); left: 0; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px; box-shadow: 0 8px 24px rgba(16, 24, 40, .18); min-width: 240px; max-height: 360px; overflow: auto; }
.dd-panel label { display: flex; gap: 8px; padding: 3px 2px; font-size: 13px; cursor: pointer; }
.dd-actions { display: flex; gap: 6px; margin-bottom: 6px; }

/* ---- role-based visibility: elements marked data-need="access|edit|superadmin" ---- */
body:not([data-role]) [data-need],
body[data-role="view"] [data-need="support"], body[data-role="view"] [data-need="access"], body[data-role="view"] [data-need="edit"],
body[data-role="view"] [data-need="superadmin"],
body[data-role="support"] [data-need="access"], body[data-role="support"] [data-need="edit"], body[data-role="support"] [data-need="superadmin"],
body[data-role="access"] [data-need="edit"], body[data-role="access"] [data-need="superadmin"],
body[data-role="edit"] [data-need="superadmin"] { display: none !important; }

/* header: logo, theme picker, user menu */
.logo { height: 30px; width: auto; display: block; }
.brand-text { border-left: 1px solid var(--border); padding-left: 10px; line-height: 1.25; }
.brand-text b { font-size: 14px; }
.brand-text .x { color: var(--accent); font-weight: 700; }
.dd.right .dd-panel { left: auto; right: 0; }
.look-panel { display: grid; gap: 8px; min-width: 270px; }
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.swatch { border: 2px solid var(--border); border-radius: 8px; padding: 6px; cursor: pointer; background: var(--surface);
  color: var(--text); font: inherit; font-size: 11px; display: grid; gap: 4px; justify-items: center; }
.swatch.active { border-color: var(--accent); }
.swatch i { display: flex; width: 100%; height: 16px; border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.swatch i b { flex: 1; }
.user-chip { list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; padding: 3px 10px 3px 3px;
  border: 1px solid var(--border); border-radius: 999px; }
.user-chip::-webkit-details-marker { display: none; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 13px; }
.user-meta { display: grid; line-height: 1.1; }
.user-meta b { font-size: 13px; } .user-meta small { font-size: 11px; color: var(--muted); }
#userDd .dd-panel { display: grid; gap: 6px; min-width: 210px; }
#userDd form { margin: 0; } #userDd .btn { width: 100%; justify-content: center; }

/* highlights strip: the points that need attention */
.highlights { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.hl { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; border: 1px solid transparent;
  font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; text-align: left; color: var(--text); }
.hl small { font-weight: 400; color: var(--muted); }
.hl .ic { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; color: #fff; flex: none; }
.hl-critical { background: var(--red-bg); border-color: color-mix(in srgb, var(--red) 30%, transparent); }
.hl-critical .ic { background: var(--red); }
.hl-warn { background: var(--orange-bg); border-color: color-mix(in srgb, var(--orange) 30%, transparent); }
.hl-warn .ic { background: var(--orange); }
/* info stays blue in every theme so it never reads as an alarm (coral accents look like "critical") */
.hl-info { background: color-mix(in srgb, var(--s1) 13%, var(--surface)); border-color: color-mix(in srgb, var(--s1) 30%, transparent); }
.hl-info .ic { background: var(--s1); }
.hl-ok { background: var(--green-bg); } .hl-ok .ic { background: var(--green); }

/* stock edit mode */
.warn-btn { border-color: color-mix(in srgb, var(--orange) 50%, var(--border)); color: var(--orange); }
.edit-bar { position: sticky; top: 64px; z-index: 4; display: flex; justify-content: space-between; align-items: center; gap: 10px;
  flex-wrap: wrap; padding: 10px 12px; margin-bottom: 8px; border-radius: 8px; background: var(--orange-bg);
  border: 1px solid color-mix(in srgb, var(--orange) 40%, transparent); font-size: 13px; }
input.cell-in { width: 86px; text-align: right; padding: 3px 6px; font-variant-numeric: tabular-nums; }
input.cell-in.changed { border-color: var(--orange); background: var(--orange-bg); font-weight: 700; }
.delta-pos { color: var(--green); font-weight: 700; } .delta-neg { color: var(--red); font-weight: 700; }

/* consumption & charts */
.kpis.compact .kpi { cursor: default; }
.kpis.compact .kpi .value { font-size: 22px; }
.kpi .value.text { font-size: 15px; line-height: 1.3; }
.two-col.even { grid-template-columns: 1fr 1fr; }
.progress-wrap { display: grid; gap: 4px; margin: 6px 0 10px; }
.progress { height: 8px; border-radius: 4px; background: var(--grey-bg); overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .4s; }
.chart { width: 100%; min-height: 60px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart text { fill: var(--muted); font-size: 11px; font-family: var(--font); }
.chart text.lbl { fill: var(--text); }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .baseline { stroke: var(--border); stroke-width: 1; }
.chart .hit { fill: transparent; }
.chart .row:hover .hbar-mark { opacity: .8; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; font-size: 12px; color: var(--text); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }
.viz-tip { position: fixed; z-index: 50; pointer-events: none; background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.18);
  max-width: 320px; }
.viz-tip .t { font-weight: 600; margin-bottom: 4px; }
.viz-tip .r { display: flex; justify-content: space-between; gap: 14px; }
.viz-tip .r i { width: 10px; height: 3px; border-radius: 2px; display: inline-block; margin-right: 6px; vertical-align: middle; }
.spark { display: block; }
.rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.share { color: var(--muted); font-size: 11px; display: block; }

/* users */
.stack { display: grid; gap: 4px; }
.role-legend { display: grid; gap: 6px; margin-top: 14px; font-size: 12px; }
.role-legend div { padding: 8px 10px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.b-role-superadmin { background: var(--red-bg); color: var(--red); }
.b-role-edit { background: var(--orange-bg); color: var(--orange); }
.b-role-access { background: var(--blue-bg); color: var(--accent); }
.b-role-view { background: var(--grey-bg); color: var(--muted); }

/* login */
.login-logo { height: 46px; width: auto; justify-self: center; }
.login-title { text-align: center; margin: 0; font-size: 17px; }
.login-title .x { color: var(--accent); }

@media (max-width: 900px) { .two-col.even { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .brand-text { display: none; }
  .user-meta { display: none; }
  .edit-bar { top: 0; }
}

/* replenishment */
.params { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; font-size: 13px; margin-bottom: 8px;
  padding: 10px 12px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.params input[type=number] { width: 64px; padding: 4px 6px; text-align: right; }
.params select { padding: 4px 6px; }
.pgroup { white-space: nowrap; }
.modal-body .progress { margin: 10px 0; }

/* consumption per day */
.day-wrap { max-height: 420px; margin-top: 10px; }
table.ls tr.weekend td { background: color-mix(in srgb, var(--grey-bg) 55%, var(--surface)); }
table.ls tr.weekend td.stick { background: color-mix(in srgb, var(--grey-bg) 55%, var(--surface)); }

/* overview summary */
.summary-kpis { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.ov-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 14px; }
.panel.ov { margin-bottom: 0; display: flex; flex-direction: column; }
.panel.ov h3 { font-size: 12px; font-weight: 600; color: var(--muted); margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .04em; }
.ov-link { font-size: 12px; text-decoration: none; font-weight: 600; }
.ov-empty { color: var(--muted); margin: 6px 0; }
.ov-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
.ov-lead { margin: 0 0 8px; }
.ov-stats { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.ov-stats b { color: var(--text); font-size: 18px; margin-right: 4px; }
.ov-two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ov-kv { grid-template-columns: 170px 1fr; margin: 0; }
table.grid.compact td, table.grid.compact th { padding: 5px 6px; }
.mini-bars { display: grid; gap: 5px; }
.mb-row { display: grid; grid-template-columns: minmax(90px, 42%) 1fr auto; gap: 8px; align-items: center; font-size: 12px; }
.mb-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mb-bar { height: 8px; background: var(--grey-bg); border-radius: 4px; overflow: hidden; }
.mb-bar i { display: block; height: 100%; background: var(--s1); border-radius: 4px; }
.mb-row b { font-variant-numeric: tabular-nums; }
@media (max-width: 760px) { .ov-grid { grid-template-columns: 1fr; } .ov-two { grid-template-columns: 1fr; } .ov-kv { grid-template-columns: 1fr; } }

/* support tickets */
dialog.wide { width: min(1180px, calc(100vw - 24px)); }
.b-role-support { background: color-mix(in srgb, var(--s3) 18%, var(--surface)); color: var(--text); }
.tk-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; flex-wrap: wrap; }
.tk-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.tk-status-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0; padding: 8px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--border); }
.tk-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.tk-cols h4 { margin: 12px 0 6px; font-size: 13px; }
.tk-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.tk-grid .field { margin-bottom: 8px; }
.tk-wide { grid-column: 1 / -1; }
.tk-email { padding: 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); }
.tk-email .field { margin-bottom: 8px; }
.tk-email textarea { font: 13px/1.5 var(--font); }
.tk-actions { display: flex; gap: 8px; flex-wrap: wrap; margin: 6px 0 10px; }
.tk-sent { display: flex; gap: 8px; flex-wrap: wrap; }
.tk-sent input { flex: 1; min-width: 200px; }
.tk-timeline { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; max-height: 340px; overflow: auto; }
.tk-timeline li { display: flex; gap: 8px; font-size: 13px; }
.tk-ic { width: 22px; text-align: center; flex: none; }
.tk-note { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; white-space: pre-wrap; }
.sla-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sla-grid label { display: grid; gap: 2px; font-size: 12px; color: var(--muted); }
textarea { width: 100%; resize: vertical; }
@media (max-width: 900px) { .tk-cols, .tk-grid { grid-template-columns: 1fr; } .sla-grid { grid-template-columns: 1fr 1fr; } }

/* Support role = ticket desk only: every other tab, the sync/mode header and the banners are hidden
   (the server also refuses those pages' data to this role) */
body[data-role="support"] #tabs button:not([data-tab="tickets"]),
body[data-role="support"] main > .tab:not(#tab-tickets),
body[data-role="support"] #modeBadge, body[data-role="support"] #syncInfo, body[data-role="support"] .brand-text,
body[data-role="support"] #banner { display: none !important; }

/* ticket attachments */
.tk-drop { border: 2px dashed var(--border); border-radius: 10px; padding: 12px; text-align: center; font-size: 13px; color: var(--muted);
  cursor: pointer; margin: 6px 0 10px; background: var(--surface-2); }
.tk-drop:hover, .tk-drop.over { border-color: var(--accent); color: var(--text); }
.tk-pending { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip-file { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 8px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border); }
.chip-file button { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 14px; }
.tk-att { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tk-att figure { margin: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: var(--surface-2); }
.tk-att img, .tk-att video { width: 100%; height: 120px; object-fit: cover; display: block; background: #000; }
.tk-att-file { display: grid; place-items: center; height: 120px; font-size: 12px; }
.tk-att figcaption { display: grid; grid-template-columns: 1fr auto; gap: 0 4px; padding: 6px 8px; font-size: 11px; }
.tk-att figcaption a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.tk-att figcaption span { grid-column: 1; color: var(--muted); }
.tk-att figcaption button { grid-row: 1 / span 2; grid-column: 2; align-self: center; }

/* end-of-day checklist */
.panel.eod { border-left: 4px solid var(--accent); }
.eod-row { display: grid; grid-template-columns: minmax(220px, 1fr) minmax(220px, 1fr); gap: 12px; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border); }
.eod-tick { display: flex; align-items: center; gap: 10px; font-weight: 600; cursor: pointer; }
.eod-tick input { width: 18px; height: 18px; }
.eod-count { display: flex; align-items: center; gap: 8px; justify-content: flex-end; font-size: 13px; color: var(--muted); }
.eod-count input { width: 100px; text-align: right; }
.ok-text { color: var(--green); font-weight: 600; }
.tick { font-weight: 700; } .tick.yes { color: var(--green); } .tick.no { color: var(--red); }
@media (max-width: 760px) { .eod-row { grid-template-columns: 1fr; } .eod-count { justify-content: flex-start; } }

/* new-ticket side pop-ups */
.popups { position: fixed; top: 72px; right: 16px; z-index: 45; display: grid; gap: 10px; width: min(360px, calc(100vw - 32px)); }
.popup { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-left: 4px solid var(--accent);
  border-radius: 10px; padding: 10px 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, .22); animation: popin .25s ease-out; }
@keyframes popin { from { transform: translateX(24px); } to { transform: none; } }   /* no fade: always fully visible */
.popup-head { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--accent); }
.popup-x { border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; line-height: 1; }
.popup-title { font-weight: 700; margin: 4px 0 2px; }
.popup-body { font-size: 13px; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.popup-meta { font-size: 11px; color: var(--muted); margin-top: 4px; }
.popup-actions { display: flex; gap: 6px; margin-top: 8px; }
.popup-all { justify-self: end; }

/* bell = Notification history */
.bell { position: relative; padding: 6px 9px; }
.bell.active { background: var(--blue-bg); border-color: var(--accent); color: var(--accent); }
.bell .count { position: absolute; top: -6px; right: -6px; margin: 0; font-size: 10px; padding: 1px 5px; }
body[data-role="support"] #btnBell { display: none !important; }

/* status-change pop-ups: coloured edge by the new status */
.popup.pop-ok { border-left-color: var(--green); }
.popup.pop-ok .popup-head { color: var(--green); }
.popup.pop-neutral { border-left-color: var(--muted); }
.popup.pop-neutral .popup-head { color: var(--muted); }

/* RTO redispatch list */
.rto-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.rto-form input { flex: 1 1 150px; min-width: 120px; }
.rto-form input[name="order_id"] { flex: 1 1 160px; font-weight: 600; }
.rto-form button { flex: 0 0 auto; }
.rto-act { white-space: nowrap; display: flex; gap: 6px; }

/* @mentions in notes */
.mention { color: var(--accent); font-weight: 600; background: var(--blue-bg); padding: 0 3px; border-radius: 4px; }
.stack { position: relative; }
.mention-dd { position: absolute; left: 0; right: 0; top: calc(100% - 42px); z-index: 50; background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.18); overflow: hidden; max-height: 210px; overflow-y: auto; }
.mention-opt { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--text);
  padding: 7px 10px; font-size: 13px; cursor: pointer; }
.mention-opt:hover, .mention-opt.active { background: var(--blue-bg); }
.popup.pop-mention { border-left-color: var(--accent); }
.popup.pop-mention .popup-head { color: var(--accent); }

/* redispatch stock-out board */
.rd-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin: 10px 0; background: var(--surface); }
.rd-card.done { opacity: .72; }
.rd-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.rd-head .rd-ck { width: 20px; display: inline-flex; }
.rd-spacer { flex: 1; }
.rd-prod { margin-top: 8px; }
.rd-prod th { font-size: 11px; color: var(--muted); font-weight: 600; text-align: left; }
.rd-pick { margin-top: 3px; max-width: 280px; }
#rdMapPanel summary { cursor: pointer; font-size: 14px; }
#rdMapPanel textarea { width: 100%; }
