/* ─── Etsy Order Management — Skeumorphism shell ─────────────────────────── */
:root {
  --bg: #f7eee6;
  --surface: #fff8f1;
  --surface-warm: #ead6c7;
  --surface-sunk: #ecdfd1;
  --fg: #2b211c;
  --fg-2: #5a4b43;
  --muted: #8a7a70;
  --meta: #b46a46;
  --border: #dac8b9;
  --border-soft: #eaded4;
  --accent: #b46a46;
  --accent-on: #ffffff;
  --accent-soft: color-mix(in oklab, var(--accent) 14%, transparent);
  --accent-hover: color-mix(in oklab, var(--accent), black 8%);
  --accent-active: color-mix(in oklab, var(--accent), black 14%);

  --success: #4d8f5a;
  --success-soft: color-mix(in oklab, var(--success) 16%, transparent);
  --warn: #c88735;
  --warn-soft: color-mix(in oklab, var(--warn) 18%, transparent);
  --danger: #b84c4c;
  --danger-soft: color-mix(in oklab, var(--danger) 18%, transparent);
  --danger-hover: color-mix(in oklab, var(--danger), black 9%);
  --info: #4a7ba6;
  --info-soft: color-mix(in oklab, var(--info) 16%, transparent);

  /* ─── Categorical palette ────────────────────────────────────────────────
     Semantic tokens above answer "is this good or bad?". These answer "which
     one is this?" — workshop vs workshop, shop vs shop, integration vs
     integration — where the hue carries identity, not sentiment. Never reuse
     --success/--danger for that: a green workshop chip reads as "healthy".

     Each theme hand-tunes all 8 slots so the palette matches its own tone.
     tests/categorical-palette.test.ts asserts every slot holds >=4.5:1 under
     all three recipes below and stays >=0.088 apart in OKLab from its sibling
     slots. Retuning a hue by eye breaks one of those silently — change a value
     and run `pnpm test tests/categorical-palette.test.ts`. */
  --cat-1: #a75037;
  --cat-2: #4c743e;
  --cat-3: #32628d;
  --cat-4: #6d4b82;
  --cat-5: #66625f;
  --cat-6: #1d5d57;
  --cat-7: #9e3459;
  --cat-8: #856100;

  --font-display: Georgia, "Iowan Old Style", "Times New Roman", serif;
  --font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  --font-mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;

  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 15px;
  --text-md: 16px;
  --text-lg: 18px;
  --text-xl: 22px;
  --text-2xl: 32px;
  --text-3xl: 44px;
  --text-4xl: 60px;

  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 22px;
  --radius-pill: 9999px;

  --elev-raised:
    8px 10px 24px rgba(128, 92, 70, 0.18),
    -8px -8px 20px rgba(255, 255, 255, 0.70);
  --elev-soft:
    3px 4px 12px rgba(128, 92, 70, 0.10),
    -3px -3px 8px rgba(255, 255, 255, 0.60);
  --elev-inset:
    inset 2px 3px 6px rgba(128, 92, 70, 0.18),
    inset -2px -2px 5px rgba(255, 255, 255, 0.55);
  --elev-pressed:
    inset 3px 4px 8px rgba(128, 92, 70, 0.22),
    inset -2px -2px 5px rgba(255, 255, 255, 0.50);
  --elev-control:
    1px 2px 4px color-mix(in oklab, var(--fg) 14%, transparent),
    inset 1px 1px 1px rgba(255, 255, 255, 0.55);
  --elev-accent:
    inset 1px 1px 1px rgba(255, 255, 255, 0.40),
    inset -1px -1px 1px rgba(0, 0, 0, 0.15),
    2px 3px 8px color-mix(in oklab, var(--accent) 34%, transparent);
  --elev-accent-soft:
    inset 1px 1px 1px rgba(255, 255, 255, 0.40),
    1px 2px 5px color-mix(in oklab, var(--accent) 24%, transparent);
  --elev-danger:
    inset 1px 1px 1px rgba(255, 255, 255, 0.30),
    2px 3px 8px color-mix(in oklab, var(--danger) 30%, transparent);
  --elev-dragged:
    0 12px 28px color-mix(in oklab, var(--fg) 24%, transparent),
    var(--elev-soft);
  --focus-ring: 0 0 0 4px rgba(180, 106, 70, 0.24);

  --sidebar-w: 232px;
  --sidebar-w-rail: 72px;
  --topbar-h: 64px;
}

/* Theme overrides stay at the semantic-token layer so every existing page/component
   inherits the selected appearance without carrying theme-specific business markup. */
body[data-theme="studio"] {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-warm: #eef1f8;
  --surface-sunk: #e9edf6;
  --fg: #171a2b;
  --fg-2: #3f465f;
  --muted: #707891;
  --meta: #5b5bd6;
  --border: #d9deeb;
  --border-soft: #e9ecf3;
  --accent: #5b5bd6;
  --success: #27865f;
  --warn: #b76b18;
  --danger: #c43d55;
  --info: #3975c6;
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --elev-raised: 0 12px 30px rgba(32, 42, 72, 0.12);
  --elev-soft: 0 3px 12px rgba(32, 42, 72, 0.08);
  --elev-inset: inset 0 1px 3px rgba(32, 42, 72, 0.12);
  --elev-pressed: inset 0 2px 5px rgba(32, 42, 72, 0.16);
  --focus-ring: 0 0 0 4px rgba(91, 91, 214, 0.22);

  /* Cooler, higher-chroma categorical set to match Studio's indigo shell. */
  --cat-1: #4c46c0;
  --cat-2: #027a4e;
  --cat-3: #0b64ae;
  --cat-4: #8b2fa8;
  --cat-5: #605c66;
  --cat-6: #007180;
  --cat-7: #ae2448;
  --cat-8: #8a590c;
}

body[data-theme="ops"] {
  --bg: #edf3f0;
  --surface: #ffffff;
  --surface-warm: #dfeae4;
  --surface-sunk: #d8e5de;
  --fg: #10231b;
  --fg-2: #29493b;
  --muted: #5d7469;
  --meta: #087a54;
  --border: #b9ccc2;
  --border-soft: #d7e3dd;
  --accent: #087a54;
  --success: #087a54;
  --warn: #a75b00;
  --danger: #b42335;
  --info: #176b87;
  --font-display: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, system-ui, sans-serif;
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 12px;
  --elev-raised: 0 8px 22px rgba(16, 52, 37, 0.14);
  --elev-soft: 0 2px 7px rgba(16, 52, 37, 0.11);
  --elev-inset: inset 0 1px 4px rgba(16, 52, 37, 0.17);
  --elev-pressed: inset 0 2px 5px rgba(16, 52, 37, 0.2);
  --focus-ring: 0 0 0 4px rgba(8, 122, 84, 0.24);

  /* Desaturated, industrial categorical set to match Ops' pine-green shell. */
  --cat-1: #007b4e;
  --cat-2: #1b587e;
  --cat-3: #3c5f06;
  --cat-4: #5e4e91;
  --cat-5: #5e6064;
  --cat-6: #007786;
  --cat-7: #98392f;
  --cat-8: #6e4f14;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  /* Recompute every derived token on the themed element. If these values only
     live on :root, nested var() references are resolved with Heritage colors
     before inheritance and leak brown shadows/soft fills into Studio and Ops. */
  --accent-soft: color-mix(in oklab, var(--accent) 14%, transparent);
  --accent-hover: color-mix(in oklab, var(--accent), black 8%);
  --accent-active: color-mix(in oklab, var(--accent), black 14%);
  --success-soft: color-mix(in oklab, var(--success) 16%, transparent);
  --warn-soft: color-mix(in oklab, var(--warn) 18%, transparent);
  --danger-soft: color-mix(in oklab, var(--danger) 18%, transparent);
  --danger-hover: color-mix(in oklab, var(--danger), black 9%);
  --info-soft: color-mix(in oklab, var(--info) 16%, transparent);
  --elev-control:
    1px 2px 4px color-mix(in oklab, var(--fg) 14%, transparent),
    inset 1px 1px 1px rgba(255, 255, 255, 0.55);
  --elev-accent:
    inset 1px 1px 1px rgba(255, 255, 255, 0.40),
    inset -1px -1px 1px rgba(0, 0, 0, 0.15),
    2px 3px 8px color-mix(in oklab, var(--accent) 34%, transparent);
  --elev-accent-soft:
    inset 1px 1px 1px rgba(255, 255, 255, 0.40),
    1px 2px 5px color-mix(in oklab, var(--accent) 24%, transparent);
  --elev-danger:
    inset 1px 1px 1px rgba(255, 255, 255, 0.30),
    2px 3px 8px color-mix(in oklab, var(--danger) 30%, transparent);
  --elev-dragged:
    0 12px 28px color-mix(in oklab, var(--fg) 24%, transparent),
    var(--elev-soft);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.52;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
a { color: inherit; text-decoration: none; }
button { font: inherit; cursor: pointer; border: 0; background: none; color: inherit; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.015em; margin: 0; text-wrap: balance; }
p { margin: 0; text-wrap: pretty; }

/* Shared Account/Settings appearance picker. The miniature shell previews are
   intentionally CSS-only, fast to render and truthful to the three token palettes. */
.theme-picker { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.theme-picker-admin { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.theme-option { position: relative; display: grid; grid-template-columns: 74px minmax(0, 1fr); align-items: center; gap: 12px; min-height: 88px; padding: 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; transition: border-color 140ms ease, box-shadow 140ms ease, transform 140ms ease; }
.theme-option:hover { border-color: color-mix(in oklab, var(--accent) 45%, var(--border)); transform: translateY(-1px); }
.theme-option:has(input:checked) { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--elev-soft); }
.theme-option:has(input:focus-visible) { box-shadow: var(--focus-ring); }
.theme-option > input { position: absolute; inline-size: 1px; block-size: 1px; opacity: 0; }
.theme-option-copy { display: grid; gap: 3px; min-width: 0; }
.theme-option-copy strong { font-size: 13px; line-height: 1.25; }
.theme-option-copy small { color: var(--muted); font-size: 11px; line-height: 1.35; }
.theme-preview { --pv-bg: #f7eee6; --pv-surface: #fff8f1; --pv-side: #ead6c7; --pv-accent: #b46a46; position: relative; display: block; width: 74px; height: 54px; overflow: hidden; border: 1px solid color-mix(in oklab, var(--pv-accent) 25%, #cbd0da); border-radius: 8px; background: var(--pv-bg); box-shadow: 0 3px 8px rgba(28, 34, 50, .1); }
.theme-preview[data-preview-theme="studio"] { --pv-bg: #f4f6fb; --pv-surface: #fff; --pv-side: #e8ebf4; --pv-accent: #5b5bd6; border-radius: 6px; }
.theme-preview[data-preview-theme="ops"] { --pv-bg: #edf3f0; --pv-surface: #fff; --pv-side: #dce8e1; --pv-accent: #087a54; border-radius: 4px; }
.theme-preview > i { position: absolute; inset: 0 auto 0 0; width: 20px; background: var(--pv-side); border-right: 1px solid color-mix(in oklab, var(--pv-accent) 22%, transparent); }
.theme-preview > i::before { content: ''; position: absolute; left: 5px; top: 7px; width: 9px; height: 9px; border-radius: 3px; background: var(--pv-accent); }
.theme-preview > i::after { content: ''; position: absolute; left: 5px; top: 23px; width: 10px; height: 2px; background: color-mix(in oklab, var(--pv-accent) 45%, transparent); box-shadow: 0 6px 0 color-mix(in oklab, var(--pv-accent) 28%, transparent), 0 12px 0 color-mix(in oklab, var(--pv-accent) 28%, transparent); }
.theme-preview > b, .theme-preview > em { position: absolute; left: 26px; right: 6px; background: var(--pv-surface); border: 1px solid color-mix(in oklab, var(--pv-accent) 17%, transparent); }
.theme-preview > b { top: 7px; height: 11px; border-radius: 3px; }
.theme-preview > em { top: 23px; height: 24px; border-radius: 4px; }
.theme-preview > em::before { content: ''; position: absolute; left: 4px; right: 12px; top: 5px; height: 3px; background: var(--pv-accent); opacity: .74; box-shadow: 0 7px 0 color-mix(in oklab, var(--pv-accent) 24%, transparent); }

@media (max-width: 760px) {
  .theme-picker, .theme-picker-admin { grid-template-columns: 1fr; }
}

/* ─── App shell ───────────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  /* Modern engines interpolate grid tracks — the desktop collapse animates;
     older ones simply snap, which is an acceptable fallback. */
  transition: grid-template-columns 220ms ease;
}
.sidebar {
  background:
    linear-gradient(180deg, var(--surface) 0%, var(--surface-warm) 100%);
  border-right: 1px solid var(--border);
  padding: var(--space-5) var(--space-4);
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  /* Flex column: brand pinned top, nav scrolls in the middle, footer pinned
     bottom. The sidebar itself never scrolls — the inner .sidebar-scroll owns
     the scroll so brand/footer stay put and the scrollbar is contained. */
  display: flex; flex-direction: column; min-height: 0;
  overflow: hidden;
}
.sidebar-brand {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-6);
}
/* Scrollable nav region — only this scrolls; scrollbar is thin + themed so the
   overflow reads as intentional instead of a raw browser bar cutting the list. */
.sidebar-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklab, var(--muted) 36%, transparent) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 8px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--muted) 32%, transparent);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
.sidebar-scroll:hover::-webkit-scrollbar-thumb {
  background: color-mix(in oklab, var(--muted) 50%, transparent);
  background-clip: padding-box;
}
.sidebar-scroll .sidebar-section:first-child { margin-top: 0; }
.sidebar-brand .mark {
  width: 36px; height: 36px; border-radius: 12px;
  background: linear-gradient(145deg, var(--accent) 0%, color-mix(in oklab, var(--accent), black 18%) 100%);
  box-shadow: var(--elev-accent);
  display: grid; place-items: center;
  color: var(--accent-on);
  font-family: var(--font-display);
  font-weight: 700; font-size: 18px;
}
.sidebar-brand .mark.has-logo { padding: 0; border-radius: 0; background: transparent; box-shadow: none; }
.sidebar-brand .mark.has-logo img { width: 100%; height: 100%; border-radius: 0; object-fit: contain; }
.sidebar-brand .brand-text { min-width: 0; line-height: 1.15; }
.sidebar-brand .brand-name { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand .brand-sub { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-brand .brand-text { flex: 1 1 auto; }
/* Shell controls in the brand row: desktop collapse chevron + drawer close X.
   The X only shows while the drawer is open (≤1024px); the chevron hides there. */
.sidebar-collapse-btn, .sidebar-close-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  border-radius: 8px;
  color: var(--muted);
  border: 1px solid transparent;
  flex-shrink: 0;
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, border-color 150ms ease;
}
.sidebar-collapse-btn:hover, .sidebar-close-btn:hover {
  color: var(--fg);
  background: rgba(255,255,255,0.55);
  border-color: var(--border-soft);
}
.sidebar-collapse-btn svg, .sidebar-close-btn svg { width: 16px; height: 16px; }
.sidebar-collapse-btn svg { transition: transform 200ms ease; }
.sidebar-close-btn { display: none; }

.sidebar-section { margin-top: var(--space-5); }
.sidebar-label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--muted);
  padding: 0 var(--space-3) var(--space-2);
}
.sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar-link {
  position: relative;
  display: flex; align-items: center; gap: var(--space-3);
  padding: 9px var(--space-3);
  min-height: 38px;
  border-radius: 10px;
  color: var(--fg-2);
  font-size: 14px;
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
}
.sidebar-link .nav-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* Accent indicator bar — grows in on activation so "where am I" reads even
   when the surface/background contrast is subtle (and in rail mode). */
.sidebar-link::before {
  content: '';
  position: absolute; left: 0; top: 50%;
  width: 3px; height: 0;
  border-radius: 999px;
  background: var(--accent);
  transform: translateY(-50%);
  transition: height 180ms ease;
}
.sidebar-link:hover { background: rgba(255,255,255,0.55); color: var(--fg); }
.sidebar-link.is-active {
  background: var(--surface);
  color: var(--fg);
  font-weight: 600;
  box-shadow: var(--elev-control);
}
.sidebar-link.is-active::before { height: 56%; }
.sidebar-link.is-active .nav-icon { color: var(--accent); }
.nav-icon { width: 18px; height: 18px; flex: 0 0 18px; color: var(--muted); }
.sidebar-link:hover .nav-icon { color: var(--fg); }
.sidebar-link .nav-badge {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 10px;
  background: var(--accent-soft);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 600;
}

.sidebar-footer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-3) var(--space-2);
  margin-top: var(--space-2);
}
/* Shell-chrome avatar. Uses slot 1 (brand-adjacent in all 3 themes) rather than --accent:
   white on --accent is 3.7:1 in Heritage, and the previous 28% white light stop dropped it
   to 2.6:1 on every page. Same 6% light stop as .cat-solid — keep them in sync. */
.sidebar-footer .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(
    145deg,
    color-mix(in oklab, var(--cat-1), white 6%),
    color-mix(in oklab, var(--cat-1), black 14%));
  color: #fff;
  display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 700;
  box-shadow: var(--elev-accent-soft);
  flex-shrink: 0;
}
.sidebar-account-link { display: flex; align-items: center; gap: var(--space-3); flex: 1; min-width: 0; padding: 4px; margin: -4px; border-radius: 11px; color: inherit; text-decoration: none; transition: background 150ms ease, box-shadow 150ms ease; }
.sidebar-account-link:hover, .sidebar-account-link.is-active { background: rgba(255,255,255,0.58); box-shadow: var(--elev-soft); }
.sidebar-footer .user-text { line-height: 1.2; flex: 1; min-width: 0; }
.sidebar-footer .user-name { font-size: 13px; font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-footer .user-role { font-size: 11px; color: var(--muted); font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; }
.sidebar-footer .signout-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--muted);
  box-shadow: var(--elev-soft);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
  flex-shrink: 0;
  text-decoration: none;
}
.sidebar-footer .signout-btn:hover {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 40%, var(--border));
  transform: translateY(-1px);
}
.sidebar-footer .signout-btn:active { transform: translateY(0); }
.sidebar-footer .signout-btn svg { width: 14px; height: 14px; }

/* ─── Topbar + main column ─────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: var(--space-4);
  padding: 0 var(--space-8);
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  position: sticky; top: 0; z-index: 20;
}
.topbar-title { flex: 1 1 0; min-width: 0; overflow: hidden; }
.topbar-title h1 {
  font-size: clamp(15px, 1.6vw + 6px, 22px);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.topbar-title .breadcrumb {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted); letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.topbar-search {
  flex: 1 1 320px;
  min-width: 160px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--elev-inset);
  font-size: 13px;
}
.topbar-search input:focus { outline: none; box-shadow: var(--elev-inset), var(--focus-ring); border-color: var(--accent); }
.topbar-search .search-icon {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted);
}
.topbar-tools {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 0 0 auto;
  min-width: 0;
  white-space: nowrap;
}
.topbar-tools > * { flex: 0 0 auto; }
.icon-btn {
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-2);
  box-shadow: var(--elev-soft);
  transition: transform 100ms ease, box-shadow 150ms ease;
}
.icon-btn:hover { color: var(--fg); }
.icon-btn:active { transform: translateY(1px); box-shadow: var(--elev-pressed); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot {
  position: absolute; margin-top: -14px; margin-left: 10px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
  border: 1.5px solid var(--surface);
}

.content {
  padding: var(--space-8);
  display: flex; flex-direction: column;
  gap: var(--space-6);
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px;
  border-radius: 12px;
  font-size: 13px; font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--elev-soft);
  transition: transform 80ms ease, box-shadow 150ms ease, background 150ms ease;
  white-space: nowrap;
}
.btn:hover { background: color-mix(in oklab, var(--surface), var(--accent) 4%); }
.btn:active { transform: translateY(1px); box-shadow: var(--elev-pressed); }
.btn-primary {
  background: var(--accent);
  color: var(--accent-on);
  border-color: color-mix(in oklab, var(--accent), black 10%);
  box-shadow: var(--elev-accent);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 4px 12px color-mix(in oklab, var(--accent) 28%, transparent);
  transform: translateY(-1px);
}
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--fg-2); }
.btn-ghost:hover { background: rgba(0,0,0,0.04); color: var(--fg); }
.btn-danger {
  background: var(--danger);
  color: white;
  border-color: color-mix(in oklab, var(--danger), black 10%);
  box-shadow: var(--elev-danger);
}
.btn-danger:hover {
  background: var(--danger-hover);
  box-shadow: 0 4px 12px color-mix(in oklab, var(--danger) 26%, transparent);
  transform: translateY(-1px);
}
.btn:disabled, .btn[aria-disabled="true"] { cursor: not-allowed; opacity: .5; transform: none; }
.btn:disabled:hover, .btn[aria-disabled="true"]:hover { transform: none; box-shadow: none; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 9px; }
.btn-lg { padding: 12px 20px; font-size: 14px; border-radius: 14px; }
.btn:focus-visible { outline: none; box-shadow: var(--elev-soft), var(--focus-ring); }
.btn-icon { width: 34px; padding: 0; }
.btn-icon svg { width: 16px; height: 16px; }

/* ─── Cards ───────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--elev-raised);
  padding: var(--space-6);
}
.card-soft { box-shadow: var(--elev-soft); border-radius: var(--radius-md); padding: var(--space-5); }
/* Was overflow:hidden (clipped table corners to the card radius). Now visible so a sticky
   <thead> can pin to the viewport under the topbar as the PAGE scrolls (overflow!=visible on
   an ancestor traps position:sticky). The corners the clip used to round are restored on the
   first child — only it has a filled background; table body cells are transparent, so the
   card's rounded bottom shows through untouched. */
.card-flush { padding: 0; overflow: visible; }
.card-flush > *:first-child { border-top-left-radius: var(--radius-lg); border-top-right-radius: var(--radius-lg); }
.card-flush > .ds-table:first-child thead th:first-child { border-top-left-radius: var(--radius-lg); }
.card-flush > .ds-table:first-child thead th:last-child { border-top-right-radius: var(--radius-lg); }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-4);
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-soft);
}
.card-header h2 { font-size: 17px; font-weight: 600; font-family: var(--font-display); letter-spacing: -0.01em; }
.card-header .subtitle { font-family: var(--font-mono); font-size: 11px; color: var(--muted); letter-spacing: 0.06em; text-transform: uppercase; }
.card-body { padding: var(--space-5) var(--space-6); }
.card-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-soft); background: color-mix(in oklab, var(--surface), var(--bg) 30%); }

/* ─── Metric tile ─────────────────────────────────────────────────────── */
.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-5) var(--space-5);
  box-shadow: var(--elev-soft);
  display: flex; flex-direction: column; gap: 10px;
  position: relative; overflow: hidden;
}
.metric .metric-label {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase;
  display: flex; align-items: center; gap: 6px;
}
.metric .metric-value {
  font-family: var(--font-display);
  font-size: 30px; font-weight: 600;
  color: var(--fg); letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}
.metric .metric-value .unit { font-size: 16px; color: var(--muted); margin-left: 4px; font-weight: 400; }
.metric .metric-delta {
  display: inline-flex; align-items: center; gap: 4px;
  font-family: var(--font-mono); font-size: 11px; font-weight: 600;
}
.metric .metric-delta.up { color: var(--success); }
.metric .metric-delta.down { color: var(--danger); }
.metric .metric-foot { font-size: 12px; color: var(--muted); }
.metric-strong {
  background: linear-gradient(155deg, var(--surface) 0%, color-mix(in oklab, var(--surface), var(--accent-soft) 80%) 100%);
}
.metric-strong .metric-value { color: var(--accent); }

/* ─── Status pill ─────────────────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border: 1px solid transparent;
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 2px color-mix(in oklab, currentColor, transparent 80%); }
.pill-neutral { background: color-mix(in oklab, var(--muted) 14%, transparent); color: var(--fg-2); border-color: color-mix(in oklab, var(--muted) 22%, transparent); }
.pill-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in oklab, var(--info) 22%, transparent); }
.pill-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in oklab, var(--success) 22%, transparent); }
.pill-warn { background: var(--warn-soft); color: color-mix(in oklab, var(--warn), black 6%); border-color: color-mix(in oklab, var(--warn) 26%, transparent); }
.pill-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklab, var(--danger) 22%, transparent); }
.pill-accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklab, var(--accent) 22%, transparent); }
.pill-plain { background: transparent; border-color: var(--border); color: var(--fg-2); }
.pill-plain::before { display: none; }

/* ─── Tag (no dot, used as chip / filter) ─────────────────────────────── */
.tag {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 11px;
  border-radius: var(--radius-pill);
  font-size: 12px; font-weight: 500;
  color: var(--fg-2);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--elev-soft);
}
.tag.is-active {
  background: var(--accent);
  color: var(--accent-on);
  border-color: color-mix(in oklab, var(--accent), black 10%);
  box-shadow: var(--elev-accent-soft);
}
.tag .count { font-family: var(--font-mono); font-size: 11px; opacity: 0.75; }

/* ─── Categorical slots + recipes ─────────────────────────────────────────
   Callers pick a *slot*, never a colour, so switching theme reskins every
   categorical surface at once. Bind a slot with data-cat="1".."8" (or set
   --cat directly in page CSS when the category is fixed and named), then add
   one recipe class. Every recipe reads var(--cat) with an --accent fallback,
   so an unbound element degrades to the accent instead of an invalid colour.

   Colour alone must never be the only cue (WCAG 1.4.1) — always keep the
   text label or icon that sits next to the swatch. */
[data-cat="1"] { --cat: var(--cat-1); }
[data-cat="2"] { --cat: var(--cat-2); }
[data-cat="3"] { --cat: var(--cat-3); }
[data-cat="4"] { --cat: var(--cat-4); }
[data-cat="5"] { --cat: var(--cat-5); }
[data-cat="6"] { --cat: var(--cat-6); }
[data-cat="7"] { --cat: var(--cat-7); }
[data-cat="8"] { --cat: var(--cat-8); }

/* Colour-only modifier — layer onto .tag / .pill / .branch / any chip shell.
   Dark ink over a light tint of the same hue: readable down to 9.5px.
   The .tag/.pill variants keep this winning over stateful rules of the same
   specificity (.tag.is-active paints its own background) — don't drop them. */
.cat-soft,
.tag.cat-soft,
.pill.cat-soft {
  color: color-mix(in oklab, var(--cat, var(--cat-1)), var(--fg) 22%);
  background: color-mix(in oklab, var(--cat, var(--cat-1)), var(--surface) 86%);
  /* Full shorthand, not just border-color: .pill declares no border of its own. */
  border: 1px solid color-mix(in oklab, var(--cat, var(--cat-1)) 34%, transparent);
}
/* Solid fill for avatars and square badges. The light stop stays within 6% of
   the base so white text keeps >=4.5:1 across the whole gradient. */
.cat-solid {
  color: #fff;
  background: linear-gradient(
    145deg,
    color-mix(in oklab, var(--cat, var(--cat-1)), white 6%),
    color-mix(in oklab, var(--cat, var(--cat-1)), black 14%));
}
/* Legend/inline dot. Sized by the caller; only the fill lives here. */
.cat-dot { background: var(--cat, var(--cat-1)); }

/* ─── Form fields ─────────────────────────────────────────────────────── */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.input, .select, .textarea {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  font-size: 13px;
  box-shadow: var(--elev-inset);
  color: var(--fg);
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.textarea { height: auto; padding: 10px 12px; min-height: 80px; resize: vertical; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--elev-inset), var(--focus-ring);
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a7a70' stroke-width='2'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

/* ─── Table ───────────────────────────────────────────────────────────── */
.ds-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ds-table th, .ds-table td {
  padding: 13px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle;
}
.ds-table th {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
  background: color-mix(in oklab, var(--surface), var(--bg) 50%);
  border-bottom: 1px solid var(--border);
}
/* Sticky header (app-wide standard): the header row stays pinned just under the sticky topbar
   while the page scrolls, so column labels never disappear on long tables. z-index sits below
   the topbar (20). border-collapse detaches the th border while stuck → draw the edge via
   box-shadow. On mobile the table switches to card mode (thead hidden), so this is desktop-only.
   Wide tables inside a horizontal-scroll wrapper override `top` to 0 (see .table-scroll etc.). */
.ds-table thead th { position: sticky; top: var(--topbar-h); z-index: 5; box-shadow: inset 0 -1px 0 var(--border); }
/* A horizontal overflow wrapper becomes the sticky containing block. In that
   context the header pins to the wrapper itself, not below the page topbar. */
.table-scroll-context { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll-context .ds-table thead th { top: 0; }
/* Inside a modal/drawer the scroll container is the panel body (not the page), so pin the
   header to the panel top (0), not the topbar offset. */
.modal .ds-table thead th, .drawer .ds-table thead th { top: 0; }
.ds-table th:first-child { padding-left: var(--space-6); }
.ds-table td:first-child { padding-left: var(--space-6); }
.ds-table th:last-child { padding-right: var(--space-6); }
.ds-table td:last-child { padding-right: var(--space-6); }
.ds-table tbody tr { transition: background 100ms ease; cursor: pointer; }
.ds-table tbody tr:hover { background: color-mix(in oklab, var(--accent-soft) 60%, transparent); }
.ds-table tbody tr.is-selected { background: var(--accent-soft); }
.ds-table .num-col { font-family: var(--font-mono); font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.ds-table .mono { font-family: var(--font-mono); font-size: 12px; }
.ds-table .row-stack { display: flex; flex-direction: column; gap: 2px; }
.ds-table .row-stack .sub { font-size: 11px; color: var(--muted); font-family: var(--font-mono); }
.ds-table tbody tr:last-child td { border-bottom: 0; }

/* Kết quả rỗng của lọc nhanh client-side (app.js bindSearch tự chèn hàng này).
   Quy tắc: không bao giờ để bảng trống trơ khung — luôn có câu hướng dẫn. */
.search-empty-row { cursor: default; }
.search-empty-row:hover { background: transparent; }
.search-empty-row td {
  text-align: center; padding: 28px 12px;
  color: var(--muted); font-size: 12.5px;
}

/* ─── Checkbox ────────────────────────────────────────────────────────── */
.check {
  appearance: none;
  width: 16px; height: 16px;
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--elev-inset);
  position: relative;
  cursor: pointer;
  flex-shrink: 0;
}
.check:checked {
  background: linear-gradient(145deg, color-mix(in oklab, var(--accent), white 6%), var(--accent));
  border-color: color-mix(in oklab, var(--accent), black 10%);
  box-shadow: inset 1px 1px 1px rgba(255,255,255,0.3);
}
.check:checked::after {
  content: '';
  position: absolute; left: 4px; top: 1px;
  width: 5px; height: 9px;
  border: solid white; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* ─── Toolbar / filter row ────────────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.toolbar .left, .toolbar .right { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
.toolbar .left { flex: 1; }
.search-mini { position: relative; min-width: 260px; }
.search-mini input { padding-left: 34px; height: 36px; }
.search-mini svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--muted); }

.filter-row {
  display: flex; align-items: center; gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-6);
  background: color-mix(in oklab, var(--surface), var(--surface-warm) 24%);
  border-bottom: 1px solid var(--border-soft);
}
.filter-row .label {
  font-family: var(--font-mono); font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: 0.08em; margin-right: var(--space-2);
}

/* ─── Filter bar ─ compact inline filter toolbar ──────────────────────────
   Shared by Production board, Orders, and AI-review. Fields are labelled and
   auto-width (they must NOT inherit the base `.input{width:100%}` rule, which
   otherwise makes each control fill the row and wrap into an ugly stack). */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 10px 12px;
  padding: 14px 16px;
  background: color-mix(in oklab, var(--surface), var(--surface-warm) 24%);
  border-bottom: 1px solid var(--border-soft);
}
.filter-bar.is-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--elev-soft);
  margin-bottom: 14px;
}
.fb-field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.fb-field > label, .fb-label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
  white-space: nowrap;
}
.filter-bar .input, .filter-bar .select { width: 100%; height: 36px; font-size: 13px; }
.fb-sm   { width: 120px; }
.fb-md   { width: 160px; }
.fb-lg   { width: 200px; }
.fb-date { width: 148px; }
.fb-grow { flex: 1 1 200px; }
.fb-sep  { align-self: stretch; width: 1px; background: var(--border-soft); margin: 4px 2px; }
.fb-actions { display: flex; align-items: center; gap: 8px; margin-left: auto; }

/* ── Ô tìm kiếm CHUẨN của trang danh sách ────────────────────────────────
   Search phạm vi-danh-sách sống trong `.filter-bar` (KHÔNG phải `.topbar-search`
   — topbar ẩn ở <768px nên search list đặt ở đó sẽ biến mất trên mobile).
   `.fb-search`  = tìm server-side, luôn là field ĐẦU TIÊN, name="q", submit bằng Enter.
   `.fb-quick`   = lọc nhanh client-side trong trang hiện tại, đẩy sang PHẢI.
   `.topbar-search` chỉ dành cho tìm kiếm toàn cục (dashboard). */
.fb-search { flex: 1 1 240px; max-width: 360px; }
.fb-quick  { flex: 0 1 260px; margin-left: auto; }
.fb-search .search-mini, .fb-quick .search-mini { min-width: 0; width: 100%; }
.filter-bar .search-mini input { padding-left: 34px; }
@media (max-width: 720px) {
  .fb-field, .fb-sm, .fb-md, .fb-lg, .fb-date { width: 100%; }
  .filter-bar { gap: 10px; }
  .fb-actions { margin-left: 0; width: 100%; }
  .fb-search, .fb-quick { flex: 1 1 100%; max-width: none; margin-left: 0; }
  .fb-sep { display: none; }
}

/* Collapsible variant (AI-review narrow column): hidden until toggled. */
.filter-collapse { display: none; }
.filter-collapse.is-open { display: flex; }
.filter-toggle.is-active { color: var(--accent); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); }

/* ─── Tabs ────────────────────────────────────────────────────────────── */
.tabs {
  display: inline-flex;
  padding: 4px;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--elev-inset);
  gap: 2px;
}
.tab-btn {
  padding: 7px 14px;
  font-size: 12.5px; font-weight: 600;
  border-radius: 10px;
  color: var(--muted);
  transition: all 150ms ease;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--fg); }
.tab-btn.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--elev-control);
}
.tab-btn .count { font-family: var(--font-mono); font-size: 10px; font-weight: 600; opacity: 0.7; }
.tab-panel { display: none; }
.tab-panel.is-active { display: block; }

/* ─── Drawer / Modal ──────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0;
  background: color-mix(in oklab, var(--fg) 42%, transparent);
  backdrop-filter: blur(2px);
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
}
.overlay.is-open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; right: 0; top: 0;
  height: 100vh; width: 480px; max-width: 90vw;
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -12px 0 32px color-mix(in oklab, var(--fg) 18%, transparent);
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.2, 0, 0, 1);
  z-index: 101;
  display: flex; flex-direction: column;
}
.drawer.is-open { transform: translateX(0); }
.drawer-header { padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.drawer-header h2 { font-size: 18px; font-weight: 600; }
.drawer-header .sub { font-family: var(--font-mono); font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: var(--space-5) var(--space-6); display: flex; flex-direction: column; gap: var(--space-5); }
.drawer-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-soft); display: flex; gap: var(--space-2); justify-content: flex-end; background: color-mix(in oklab, var(--surface), var(--bg) 30%); }

.modal {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  z-index: 101;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms ease;
}
.modal.is-open { opacity: 1; pointer-events: auto; }

/* `[hidden]` is a UA rule (display:none) that ANY author `display` declaration overrides — so
   `<button class="btn" hidden>` stayed visible. Components that declare their own display must
   opt back in explicitly, otherwise every `el.hidden = true` in page JS is a silent no-op. */
.btn[hidden], .tag[hidden], .kpi-cell[hidden], .filter-row[hidden] { display: none !important; }

/* Warning variant of `.tag` — used wherever a count means "cần xử lý" (master-data cards,
   the alias-lạ panel on /shops). Was referenced by markup before it existed anywhere. */
.tag.warn {
  color: color-mix(in oklab, var(--warn), var(--fg) 25%);
  background: color-mix(in oklab, var(--warn), var(--surface) 84%);
  border-color: color-mix(in oklab, var(--warn) 34%, transparent);
}
.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 20px 24px 60px color-mix(in oklab, var(--fg) 28%, transparent), inset 1px 1px 1px rgba(255,255,255,0.6);
  width: 560px; max-width: 92vw;
  max-height: 86vh;
  /* Header/footer backgrounds and separators must be clipped to the rounded shell. */
  overflow: hidden;
  display: flex; flex-direction: column;
  transform: scale(0.96);
  transition: transform 200ms cubic-bezier(0.2, 0, 0, 1);
}
.modal.is-open .modal-panel { transform: scale(1); }
.modal-header { padding: var(--space-5) var(--space-6); border-bottom: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: space-between; }
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-body { padding: var(--space-5) var(--space-6); overflow-y: auto; flex: 1; }
.modal-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--border-soft); display: flex; gap: var(--space-2); justify-content: flex-end; background: color-mix(in oklab, var(--surface), var(--bg) 30%); }

/* ─── Utility ─────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: var(--space-3); }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); }
.stack { display: flex; flex-direction: column; }
.stack-2 > * + * { margin-top: 8px; }
.stack-3 > * + * { margin-top: 12px; }
.stack-4 > * + * { margin-top: 16px; }
.stack-5 > * + * { margin-top: 20px; }
.stack-6 > * + * { margin-top: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-5); }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--space-5); }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: var(--space-6); align-items: start; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: var(--space-6); align-items: start; }
/* Overflow safety net — grid/flex children default to min-width:auto, so a wide
   child (custom table, matrix, long mono string) forces the whole page wider than
   the viewport and cuts off siblings. Let these tracks shrink; wide content inside
   should scroll locally (overflow-x:auto) instead of pushing the layout. */
.grid-2, .grid-3, .grid-4, .grid-2-1, .grid-1-2 { min-width: 0; }
.grid-2 > *, .grid-3 > *, .grid-4 > *, .grid-2-1 > *, .grid-1-2 > * { min-width: 0; }
@media (max-width: 1280px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 1100px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Icon rail (html.nav-rail) ───────────────────────────────────────────
   One visual, two triggers (app.js syncRail): the user collapsing the sidebar
   on desktop (persisted in localStorage), or the 769–1024px tablet band where
   the rail is always on so primary navigation stays visible without stealing
   content width. `:not(.is-open)` keeps the full drawer styles intact when the
   tablet overlay is expanded. Labels are hidden; app.js mirrors them into
   `title` tooltips and badges collapse onto the icon corner. */
html.nav-rail .app { grid-template-columns: var(--sidebar-w-rail) 1fr; }
/* Pin the content to track 2. When the tablet drawer opens, the sidebar goes
   position:fixed (out of flow) — without this, .main auto-places into the empty
   72px rail track and the whole page squeezes into that sliver. */
html.nav-rail .app > .main { grid-column: 2; }
html.nav-rail .sidebar:not(.is-open) {
  position: sticky;
  transform: none;
  width: auto;
  box-shadow: none;
  padding-left: max(var(--space-2), env(safe-area-inset-left));
  padding-right: var(--space-2);
}
html.nav-rail .sidebar:not(.is-open) .sidebar-brand {
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-2) 0 var(--space-4);
}
html.nav-rail .sidebar:not(.is-open) .brand-text { display: none; }
html.nav-rail .sidebar:not(.is-open) .sidebar-collapse-btn svg { transform: rotate(180deg); }
html.nav-rail .sidebar:not(.is-open) .sidebar-label { display: none; }
html.nav-rail .sidebar:not(.is-open) .sidebar-section {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border-soft);
}
html.nav-rail .sidebar:not(.is-open) .sidebar-scroll .sidebar-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
html.nav-rail .sidebar:not(.is-open) .sidebar-link { justify-content: center; padding: 10px 0; }
html.nav-rail .sidebar:not(.is-open) .nav-label { display: none; }
html.nav-rail .sidebar:not(.is-open) .nav-badge {
  position: absolute; top: 2px; right: 6px;
  margin-left: 0;
  padding: 1px 5px;
  font-size: 9px;
}
html.nav-rail .sidebar:not(.is-open) .sidebar-footer {
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3) 0 var(--space-2);
}
html.nav-rail .sidebar:not(.is-open) .sidebar-account-link { flex: 0 0 auto; padding: 4px; margin: 0; }
html.nav-rail .sidebar:not(.is-open) .sidebar-footer .user-text { display: none; }

/* ─── Mobile hamburger + sidebar backdrop (hidden by default) ─────────── */
.topbar-toggle {
  display: none;
  width: 38px; height: 38px;
  place-items: center;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-2);
  box-shadow: var(--elev-soft);
  transition: transform 100ms ease, box-shadow 150ms ease, color 150ms ease;
  flex-shrink: 0;
  cursor: pointer;
}
.topbar-toggle:hover { color: var(--fg); }
.topbar-toggle:active { transform: translateY(1px); box-shadow: var(--elev-pressed); }
.topbar-toggle svg { width: 20px; height: 20px; }

.sidebar-backdrop {
  position: fixed; inset: 0;
  background: color-mix(in oklab, var(--fg) 42%, transparent);
  backdrop-filter: blur(2px);
  z-index: 109;
  opacity: 0; pointer-events: none;
  transition: opacity 200ms ease;
}
.sidebar-backdrop.is-open { opacity: 1; pointer-events: auto; }
body.sidebar-locked { overflow: hidden; }

/* ─── Tablet + mobile (≤ 1024px) — full sidebar becomes a slide-in drawer.
   On 769–1024px html.nav-rail (see above) overrides the closed state into a
   persistent icon rail; ≤768px there is no rail and the drawer is the only nav. */
@media (max-width: 1024px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; left: 0;
    width: min(300px, 86vw);
    height: 100vh;
    height: 100dvh;
    z-index: 110;
    transform: translateX(-100%);
    transition: transform 240ms cubic-bezier(0.2, 0, 0, 1);
    box-shadow: 12px 0 32px color-mix(in oklab, var(--fg) 22%, transparent);
    overflow: hidden; /* .sidebar-scroll owns the scroll (same as desktop) */
    padding-left: max(var(--space-4), env(safe-area-inset-left));
    padding-bottom: max(var(--space-2), env(safe-area-inset-bottom));
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar.is-open .sidebar-close-btn { display: grid; }
  .sidebar.is-open .sidebar-collapse-btn { display: none; }
  /* Touch comfort: 44px minimum targets inside the drawer (Apple HIG). */
  .sidebar.is-open .sidebar-link { padding: 11px var(--space-3); min-height: 44px; }
  .sidebar.is-open .sidebar-footer .signout-btn { width: 40px; height: 40px; }
  .topbar-toggle { display: grid; }
  .topbar { padding: 0 var(--space-5); gap: var(--space-3); }
  .topbar-search { flex: 1 1 0; min-width: 120px; max-width: 360px; }
  .content { padding: var(--space-6); gap: var(--space-5); }
  .grid-2-1, .grid-1-2 { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .app, .sidebar, .sidebar-backdrop, .sidebar-link::before, .sidebar-collapse-btn svg { transition: none; }
}

/* ─── Small tablet / large phone (≤ 768px) ───────────────────────────── */
@media (max-width: 768px) {
  :root { --topbar-h: 56px; }
  .topbar { padding: 0 var(--space-4); height: 56px; gap: var(--space-2); }
  .topbar-search { display: none; }
  .topbar-title { flex: 1 1 0; min-width: 0; }
  .topbar-title h1 { font-size: clamp(13px, 3.4vw, 16px); line-height: 1.15; }
  .topbar-title .breadcrumb { display: none; }
  .topbar-tools { gap: 6px; }
  .topbar-tools .btn { padding: 7px 11px; font-size: 12px; }
  /* Preserve the primary action and shared controls; secondary page actions
     are intentionally compacted before the tools can consume the title area. */
  .topbar-tools .btn:not(.btn-primary) { display: none; }
  .icon-btn { width: 36px; height: 36px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .topbar-toggle { width: 36px; height: 36px; }

  .content { padding: var(--space-4); gap: var(--space-4); }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; gap: var(--space-3); }

  /* KPI row → 2 columns with cleanly redrawn dividers */
  .kpi-row { grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); }
  .kpi-row .kpi-cell { border-right: 0; border-bottom: 1px solid var(--border-soft); padding: var(--space-3) var(--space-4); }
  .kpi-row .kpi-cell:nth-child(odd) { border-right: 1px solid var(--border-soft); }
  .kpi-row .kpi-cell:nth-last-child(-n+2) { border-bottom: 0; }
  .kpi-row .kpi-num { font-size: 20px; }

  /* Card density */
  .card { padding: var(--space-5); border-radius: var(--radius-md); }
  .card-soft { padding: var(--space-4); }
  .card-header { padding: var(--space-4); flex-wrap: wrap; gap: var(--space-3); }
  .card-header h2 { font-size: 15px; }
  .card-body { padding: var(--space-4); }
  .card-footer { padding: var(--space-3) var(--space-4); }

  /* Toolbars and filters wrap tightly */
  .toolbar { padding: var(--space-3) var(--space-4); gap: var(--space-2); }
  .filter-row { padding: var(--space-2) var(--space-4); gap: 6px; }
  .filter-row .label { width: 100%; margin-right: 0; }
  .search-mini { min-width: 0; flex: 1 1 100%; }
  .search-mini input { width: 100%; }

  /* Responsive của `.pager` sống cạnh định nghĩa gốc ở §Pagination (cuối file)
     để không phải sửa 2 nơi khi đổi chuẩn. */

  .section-head { flex-direction: column; align-items: flex-start; gap: var(--space-2); }

  /* Tables collapse into card-mode rows on mobile.
     Each TR becomes a stacked card; each TD becomes a label/value row using
     data-label="..." (auto-applied by app.js from <thead> text). */
  .card-flush { overflow-x: visible; }
  .ds-table { display: block; width: 100%; min-width: 0; }
  .ds-table thead { display: none; }
  .ds-table tbody { display: block; }
  .ds-table tbody tr {
    display: block;
    padding: 12px 14px;
    margin: 10px var(--space-4);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    background: var(--surface);
    box-shadow: var(--elev-soft);
  }
  .ds-table tbody tr:hover { background: var(--surface); }
  .ds-table tbody tr.is-selected {
    background: var(--accent-soft);
    border-color: color-mix(in oklab, var(--accent) 30%, transparent);
  }
  .ds-table tbody tr td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border: 0;
    border-bottom: 1px solid var(--border-soft);
    text-align: left;
    white-space: normal;
    min-height: 30px;
    font-size: 13px;
  }
  .ds-table tbody tr td:last-child { border-bottom: 0; padding-bottom: 0; }
  .ds-table tbody tr td:first-child { padding-top: 0; }
  .ds-table tbody td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    max-width: 50%;
    font-family: var(--font-mono);
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
    line-height: 1.3;
  }
  /* Cells without a meaningful header label (checkbox, action button)
     don't render a leading label; the cell sits flush right (action) or left (checkbox). */
  .ds-table tbody td[data-label=""],
  .ds-table tbody td:not([data-label]) { justify-content: flex-end; }
  .ds-table tbody td[data-label=""]::before,
  .ds-table tbody td:not([data-label])::before { display: none; }
  .ds-table tbody td.num-col { text-align: right; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
  /* Inner row/row-stack should align to the right side of the card */
  .ds-table tbody td > .row,
  .ds-table tbody td > .row-stack { max-width: 65%; }
  .ds-table tbody td > .row-stack { align-items: flex-end; text-align: right; }
  .ds-table tbody td .pill { flex-shrink: 0; }
  /* Avoid breaking long mono strings (tracking, IDs, emails) */
  .ds-table tbody td .mono { word-break: break-all; }
  /* User-row (avatar + email) keeps left alignment under the label */
  .ds-table tbody td > .user-row { max-width: 65%; }
  .ds-table tbody td > .user-row .email { font-size: 11px; word-break: break-all; }

  /* Tabs scroll horizontally if too wide */
  .tabs { max-width: 100%; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab-btn { white-space: nowrap; flex-shrink: 0; }

  /* Drawer + modal full-width on phone */
  .drawer { width: 100%; max-width: 100%; }
  .drawer-header, .drawer-footer { padding-left: var(--space-4); padding-right: var(--space-4); }
  .drawer-body { padding: var(--space-4); }
  .modal-panel { width: 96vw; max-height: 92vh; }
  .modal-header, .modal-footer { padding: var(--space-4); }
  .modal-body { padding: var(--space-4); }

  /* Metric tiles tighter */
  .metric { padding: var(--space-4); gap: 8px; }
  .metric .metric-value { font-size: 24px; }

  /* Timeline / activity */
  .timeline-item { grid-template-columns: 28px 1fr; }
  .timeline-time { grid-column: 2; padding-top: 0; }
}

/* ─── Small phone (≤ 480px) ──────────────────────────────────────────── */
@media (max-width: 480px) {
  .sidebar { width: min(86vw, 300px); }

  .kpi-row { grid-template-columns: 1fr; }
  .kpi-row .kpi-cell { border-right: 0 !important; border-bottom: 1px solid var(--border-soft); }
  .kpi-row .kpi-cell:last-child { border-bottom: 0; }

  /* Hide low-priority topbar icon-btn (help button is typically the 2nd one) */
  .topbar-tools .icon-btn ~ .icon-btn { display: none; }
  .topbar-tools .btn:not(.btn-primary) { display: none; }

  .topbar-title h1 { font-size: clamp(12px, 3.6vw, 15px); }

  .card { padding: var(--space-4); }
  .card-header h2 { font-size: 14px; }
  .metric .metric-value { font-size: 22px; }
}

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.tnum { font-variant-numeric: tabular-nums; }
.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.text-display { font-family: var(--font-display); letter-spacing: -0.015em; }
.eyebrow { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.divider { border: 0; border-top: 1px solid var(--border-soft); margin: 0; }
.divider-strong { border: 0; border-top: 1px solid var(--border); margin: 0; }

/* ─── Activity / timeline ─────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: grid; grid-template-columns: 32px 1fr auto;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  position: relative;
}
.timeline-item:not(:last-child)::after {
  content: '';
  position: absolute; left: 15px; top: 28px; bottom: -2px;
  width: 1px; background: var(--border);
}
.timeline-dot {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--elev-soft);
  display: grid; place-items: center;
  position: relative; z-index: 1;
  color: var(--muted);
  flex-shrink: 0;
}
.timeline-dot svg { width: 14px; height: 14px; }
.timeline-dot.is-accent { background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 30%, transparent); color: var(--accent); }
.timeline-dot.is-success { background: var(--success-soft); border-color: color-mix(in oklab, var(--success) 30%, transparent); color: var(--success); }
.timeline-dot.is-warn { background: var(--warn-soft); border-color: color-mix(in oklab, var(--warn) 30%, transparent); color: color-mix(in oklab, var(--warn), black 6%); }
.timeline-dot.is-danger { background: var(--danger-soft); border-color: color-mix(in oklab, var(--danger) 30%, transparent); color: var(--danger); }
.timeline-body .title { font-size: 13.5px; font-weight: 600; color: var(--fg); }
.timeline-body .desc { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.timeline-time { font-family: var(--font-mono); font-size: 11px; color: var(--muted); white-space: nowrap; padding-top: 6px; }

/* ─── Mini chart helpers ──────────────────────────────────────────────── */
.spark { width: 100%; height: 40px; display: block; }
.bar-stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; background: var(--surface-sunk); box-shadow: var(--elev-inset); }
.bar-stack > span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: 12px; color: var(--muted); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }

/* ─── Bilingual label helper ──────────────────────────────────────────── */
.bi {
  display: inline-flex; flex-direction: column; line-height: 1.1;
}
.bi .en { font-size: inherit; }
.bi .vi { font-size: 11px; color: var(--muted); font-family: var(--font-body); margin-top: 1px; }

/* ─── Avatar ──────────────────────────────────────────────────────────── */
/* Buyer initial on list rows — same slot-1 fill as .sidebar-footer .avatar (11px text, so
   the 28% white light stop it used to have was 3.1:1). */
.avatar-sm {
  width: 28px; height: 28px; border-radius: 50%;
  background: linear-gradient(
    145deg,
    color-mix(in oklab, var(--cat-1), white 6%),
    color-mix(in oklab, var(--cat-1), black 14%));
  color: #fff;
  display: inline-grid; place-items: center;
  font-family: var(--font-display); font-weight: 700;
  font-size: 11px;
  box-shadow: var(--elev-accent-soft);
  flex-shrink: 0;
}
.avatar-list { display: flex; }
.avatar-list .avatar-sm { margin-left: -8px; border: 2px solid var(--surface); }
.avatar-list .avatar-sm:first-child { margin-left: 0; }

/* ─── Floating bulk action bar ───────────────────────────────────────────
   Used on every list page (orders / catalog / shops). Dark pill anchored to
   the bottom-center, slides up when `.is-visible` is toggled by bindBulkSelect
   (see app.js). Buttons use rounded-pill borders; primary action gets the
   accent fill; counter is mono + accent for emphasis. */
.bulk-bar {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom));
  left: 50%;
  /* Hidden state clears the pill's height + the bottom offset so the top edge
     never peeks above the viewport bottom. */
  transform: translateX(-50%) translateY(calc(100% + 40px));
  background: var(--fg);
  color: var(--surface);
  padding: 11px 14px 11px 18px;
  border-radius: 999px;
  box-shadow: 0 14px 32px color-mix(in oklab, var(--fg) 32%, transparent), inset 1px 1px 1px rgba(255,255,255,0.1);
  display: flex; align-items: center; gap: 10px;
  transition: transform 220ms cubic-bezier(0.2, 0, 0, 1);
  z-index: 50;
  font-size: 13px;
  max-width: calc(100vw - 32px);
  flex-wrap: wrap;
  justify-content: center;
}
.bulk-bar.is-visible { transform: translateX(-50%) translateY(0); }
.bulk-bar [data-bulk-count] {
  font-family: var(--font-mono);
  font-weight: 700;
  color: color-mix(in oklab, var(--accent), white 28%);
  font-size: 14px;
}
.bulk-bar > span:first-child { white-space: nowrap; }
.bulk-bar button,
.bulk-bar a {
  color: inherit;
  padding: 7px 13px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 12.5px;
  border: 1px solid rgba(255,255,255,0.18);
  background: transparent;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.bulk-bar button:hover,
.bulk-bar a:hover { background: rgba(255,255,255,0.10); border-color: rgba(255,255,255,0.32); }
.bulk-bar button:disabled,
.bulk-bar a[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; pointer-events: none; }
.bulk-bar button.primary { background: var(--accent); border-color: transparent; color: white; }
.bulk-bar button.primary:hover { background: color-mix(in oklab, var(--accent), white 6%); }
.bulk-bar button.danger { background: var(--danger); border-color: transparent; color: white; }
.bulk-bar button.danger:hover { background: color-mix(in oklab, var(--danger), white 6%); }
.bulk-bar .sep {
  width: 1px;
  height: 22px;
  background: rgba(255,255,255,0.18);
  flex-shrink: 0;
}
.bulk-bar svg { width: 14px; height: 14px; flex-shrink: 0; }

@media (max-width: 640px) {
  .bulk-bar { padding: 9px 10px 9px 14px; font-size: 12.5px; gap: 8px; }
  .bulk-bar button,
  .bulk-bar a { padding: 6px 11px; font-size: 12px; }
  .bulk-bar [data-bulk-count] { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  .bulk-bar { transition: none; }
}

/* ─── Pagination ─ CHUẨN CHUNG cho mọi trang danh sách ───────────────────
   Anatomy cố định:  [info]  [page-size]  ·····  [nav: ‹ 1 … 4 5 6 … 20 ›]

   Dùng qua 1 trong 2 đường, cùng ra DOM giống hệt nhau:
   • Server-side  → `include('../partials/list-pager', h.pagerModel({...}))`
   • Client-side  → `OMS.renderPager(el, { page, pageSize, total, onNavigate })`
   KHÔNG tự chế markup phân trang mới cho từng trang (xem list-page-design-standard.md §6).

   Legacy alias: `.pager .info` / `.pager .controls` được style y hệt
   `.pager-info` / `.pager-nav` để markup cũ không vỡ trong lúc migrate. */
.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3) var(--space-4); flex-wrap: wrap;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border-soft);
}
/* Biến thể cho pager nằm trong modal/drawer: panel đã có padding riêng nên bỏ
   padding ngang + viền trên của pager để không thành 2 lớp khung lồng nhau. */
.pager.pager-inset { padding: var(--space-3) 0 0; border-top: 0; }

/* Cụm trái: thông tin phạm vi + chọn số dòng/trang */
.pager-lead { display: flex; align-items: center; gap: var(--space-4); flex-wrap: wrap; min-width: 0; }
.pager-info, .pager .info {
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pager-info b, .pager .info b { color: var(--fg); font-weight: 600; }

/* Chọn số item hiển thị — chuẩn hoá: 25 / 50 / 100 (xem PAGE_SIZE_OPTIONS) */
.pager-size { display: flex; align-items: center; gap: 6px; }
.pager-size > label {
  font-family: var(--font-mono); font-size: 10px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em;
  white-space: nowrap;
}
.pager-size .select {
  width: auto; height: 32px; padding: 0 28px 0 10px;
  font-family: var(--font-mono); font-size: 12px;
}

/* Cụm phải: điều hướng trang */
.pager-nav, .pager .controls { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager-step, .pager-page, .pager-nav button, .pager .controls a, .pager .controls button {
  min-width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  padding: 0 8px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--elev-soft);
  font-family: var(--font-mono); font-size: 12px; color: var(--fg-2);
  text-decoration: none; cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
}
.pager-step:hover, .pager-page:hover, .pager-nav button:hover,
.pager .controls a:hover, .pager .controls button:hover {
  background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 40%, var(--border));
  color: var(--fg);
}
/* Trang hiện tại — `aria-current="page"` là nguồn sự thật, class chỉ để tô màu */
.pager-page.is-current, .pager-nav button.is-active,
.pager .controls a.is-active, .pager .controls button.is-active {
  background: var(--accent); color: #fff;
  border-color: color-mix(in oklab, var(--accent), black 10%);
  cursor: default;
}
.pager-page.is-current:hover, .pager .controls button.is-active:hover { background: var(--accent); color: #fff; }
/* Vô hiệu: dùng <span class="is-disabled"> (server) hoặc [disabled] (client) —
   KHÔNG dùng inline `pointer-events:none;opacity:.5` rải rác như trước. */
.pager-step.is-disabled, .pager-page.is-disabled,
.pager-nav [disabled], .pager .controls [disabled], .pager [aria-disabled="true"] {
  opacity: 0.4; cursor: not-allowed; pointer-events: none; box-shadow: none;
}
.pager-ellipsis {
  min-width: 20px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 12px; color: var(--muted);
}
.pager-step-label { display: inline; }

@media (max-width: 768px) {
  /* Nav lên trước info (thao tác chính nằm trong tầm ngón cái), touch target ≥40px */
  .pager { flex-direction: column-reverse; align-items: stretch; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
  .pager-lead { justify-content: space-between; width: 100%; }
  .pager-nav, .pager .controls { justify-content: center; gap: 6px; }
  .pager-info, .pager .info { text-align: left; }
  .pager-step, .pager-page, .pager-nav button, .pager .controls a, .pager .controls button {
    min-width: 40px; height: 40px;
  }
  .pager-ellipsis { height: 40px; }
}
@media (max-width: 480px) {
  /* Nhãn chữ của prev/next nhường chỗ cho mũi tên; số trang vẫn đủ rộng để chạm */
  .pager-step-label { display: none; }
  .pager-lead { flex-direction: column; align-items: flex-start; gap: var(--space-2); }
}

/* ─── Section header ──────────────────────────────────────────────────── */
.section-head { display: flex; align-items: end; justify-content: space-between; gap: var(--space-4); }
.section-head h2 { font-size: 20px; font-weight: 600; font-family: var(--font-display); letter-spacing: -0.015em; }
.section-head .sub { font-size: 13px; color: var(--muted); margin-top: 4px; }

/* ─── Order-status mini KPIs row ──────────────────────────────────────── */
/* auto-fit: cells stretch to fill the full width for ANY count (4/5/6 fixed KPIs
   OR a variable list like Finance per-shop), and wrap when too many to fit.
   Responsive rules below pin explicit counts on smaller screens. */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--elev-soft); }
.kpi-row .kpi-cell { padding: var(--space-4) var(--space-5); border-right: 1px solid var(--border-soft); }
.kpi-row .kpi-cell:last-child { border-right: 0; }
.kpi-row .kpi-label { font-family: var(--font-mono); font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.kpi-row .kpi-num { font-family: var(--font-display); font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi-row .kpi-unit { font-family: var(--font-mono); font-size: 12px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.kpi-row .kpi-cell.is-warn .kpi-num { color: var(--warn); }
.kpi-row .kpi-cell.is-danger .kpi-num { color: var(--danger); }
/* Production board (phase 02): KPI cells double as filter links. Strip the anchor's own
   look so a clickable cell is visually identical to a static one, then mark the active
   filter with an accent rail — the cell must read as "this filter is on", not as a link. */
a.kpi-cell { display: block; text-decoration: none; color: inherit; cursor: pointer; transition: background 0.12s ease; }
a.kpi-cell:hover { background: var(--surface-sunk); }
a.kpi-cell:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.kpi-row .kpi-cell.is-active { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
@media (max-width: 1100px) { .kpi-row { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); } .kpi-row .kpi-cell:nth-child(3) { border-right: 0; } }
/* Re-assert smaller counts AFTER the ≤1100 rule: for equal-specificity max-width
   queries the later source rule wins, so these must follow to beat repeat(3). */
@media (max-width: 768px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .kpi-row { grid-template-columns: 1fr; } }

/* ─── Notification drawer (injected on every page) ───────────────────── */
.notif-drawer { width: 440px; }
.notif-drawer .drawer-body { padding: 0; gap: 0; }
.notif-tabs {
  display: flex;
  gap: 4px;
  padding: 10px var(--space-5);
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--surface), var(--bg) 38%);
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}
.notif-tabs::-webkit-scrollbar { display: none; }
.notif-tab {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 6px 12px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: all 150ms ease;
}
.notif-tab:hover { color: var(--fg); background: rgba(255,255,255,0.5); }
.notif-tab.is-active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--elev-control);
}
.notif-tab .ct { font-weight: 700; margin-left: 4px; opacity: 0.7; }
.notif-tab.is-active .ct { color: var(--accent); opacity: 1; }

.notif-group { padding: var(--space-3) 0; }
.notif-group-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 4px var(--space-5) 8px;
  display: flex; align-items: center; justify-content: space-between;
}
.notif-item {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  padding: 12px var(--space-5);
  align-items: start;
  border-top: 1px solid var(--border-soft);
  position: relative;
  cursor: pointer;
  transition: background 120ms ease;
}
.notif-item:hover { background: color-mix(in oklab, var(--accent-soft) 30%, transparent); }
.notif-item.is-unread { background: color-mix(in oklab, var(--accent-soft) 22%, transparent); }
.notif-item.is-unread::before {
  content: '';
  position: absolute;
  left: 6px; top: 50%;
  transform: translateY(-50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.notif-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--elev-soft);
  color: var(--muted);
  flex-shrink: 0;
}
.notif-icon svg { width: 16px; height: 16px; }
.notif-icon.is-accent { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklab, var(--accent) 30%, transparent); }
.notif-icon.is-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in oklab, var(--success) 30%, transparent); }
.notif-icon.is-warn { background: var(--warn-soft); color: color-mix(in oklab, var(--warn), black 6%); border-color: color-mix(in oklab, var(--warn) 30%, transparent); }
.notif-icon.is-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklab, var(--danger) 30%, transparent); }
.notif-icon.is-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in oklab, var(--info) 30%, transparent); }
.notif-body { min-width: 0; }
.notif-title { font-size: 13.5px; font-weight: 600; color: var(--fg); line-height: 1.4; }
.notif-title .mono { font-family: var(--font-mono); font-size: 12.5px; }
.notif-desc { font-size: 12.5px; color: var(--muted); margin-top: 3px; line-height: 1.45; }
.notif-meta { font-family: var(--font-mono); font-size: 10.5px; color: var(--muted); white-space: nowrap; letter-spacing: 0.04em; padding-top: 2px; }
.notif-tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 999px;
  font-family: var(--font-mono); font-size: 10px;
  letter-spacing: 0.04em; font-weight: 600;
  margin-right: 5px; margin-top: 6px;
  border: 1px solid transparent;
}
.notif-tag.t-order { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in oklab, var(--accent) 22%, transparent); }
.notif-tag.t-production { background: var(--warn-soft); color: color-mix(in oklab, var(--warn), black 6%); border-color: color-mix(in oklab, var(--warn) 22%, transparent); }
.notif-tag.t-shipping { background: var(--info-soft); color: var(--info); border-color: color-mix(in oklab, var(--info) 22%, transparent); }
.notif-tag.t-case { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in oklab, var(--danger) 22%, transparent); }
.notif-tag.t-system { background: color-mix(in oklab, var(--muted) 14%, transparent); color: var(--fg-2); border-color: color-mix(in oklab, var(--muted) 22%, transparent); }

.notif-empty {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.notif-foot-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
}
.notif-foot-actions a { font-size: 12.5px; color: var(--fg-2); display: inline-flex; align-items: center; gap: 6px; }
.notif-foot-actions a:hover { color: var(--accent); }
.notif-foot-actions a svg { width: 12px; height: 12px; }

/* Bell button red dot */
.icon-btn[data-open-notif] { position: relative; }
.icon-btn[data-open-notif] .notif-dot {
  position: absolute;
  top: 7px; right: 8px;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--surface);
  display: block;
}
.icon-btn[data-open-notif][data-notif-count="0"] .notif-dot { display: none; }

@media (max-width: 768px) {
  .notif-drawer { width: 100%; max-width: 100%; }
  .notif-tabs { padding: 8px var(--space-4); }
  .notif-tab { font-size: 10.5px; padding: 5px 10px; }
  .notif-item { padding: 11px var(--space-4); grid-template-columns: 32px 1fr; }
  .notif-meta { grid-column: 2; padding-top: 0; }
  .notif-group-label { padding: 4px var(--space-4) 6px; }
  .notif-icon { width: 32px; height: 32px; }
}

/* ─── Dashboard-specific mobile reflow (donut/workshop/chart) ─────────── */
@media (max-width: 768px) {
  .donut-wrap { flex-direction: column; gap: 16px; align-items: stretch; }
  .donut { margin: 0 auto; }
  .donut-legend { width: 100%; }
  .workshop-card { grid-template-columns: 1fr; }
  .workshop-card > div:nth-child(2) { text-align: left !important; }
  .alert-card { grid-template-columns: 30px 1fr; gap: 10px 12px; }
  .alert-card .btn, .alert-card a.btn { grid-column: 2; justify-self: start; }
  .chart-area { height: 180px; }
  .chart-area .ax-label { font-size: 9px; }
  .spark-card { padding: 12px; gap: 10px; }
  .spark-card svg { height: 36px; }
  /* Footer of revenue chart wraps */
  .card-footer .row { flex-wrap: wrap; gap: 14px !important; }
  .card-footer .row > div[style*="margin-left: auto"] { margin-left: 0 !important; }
}

/* ─── Language toggle (EN / VI) ─────────────────────────────────────── */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--surface-sunk);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px;
  box-shadow: var(--elev-inset);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  flex-shrink: 0;
}
.lang-toggle button {
  padding: 5px 11px;
  border-radius: 999px;
  color: var(--muted);
  transition: background 150ms ease, color 150ms ease, box-shadow 150ms ease;
  line-height: 1;
}
.lang-toggle button:hover { color: var(--fg-2); }
.lang-toggle button.is-active {
  background: linear-gradient(145deg, var(--surface), color-mix(in oklab, var(--surface), var(--surface-warm) 18%));
  color: var(--accent);
  box-shadow: var(--elev-control);
}
@media (max-width: 480px) {
  .lang-toggle button { padding: 4px 8px; font-size: 10px; }
}

/* ─── Production product photos in .queue-card ──────────────────────── */
.queue-card .img.has-photo {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  position: relative;
}
.queue-card .img.has-photo::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: var(--elev-inset);
  pointer-events: none;
}

/* ─── Kanban drag-and-drop ──────────────────────────────────────────── */
.kanban-col {
  position: relative;
  transition: background 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.kanban-col.drag-over {
  background: color-mix(in oklab, var(--accent-soft) 60%, var(--surface));
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--accent) 30%, transparent), var(--elev-inset);
}
.queue-card[draggable="true"] { cursor: grab; }
.queue-card[draggable="true"]:active { cursor: grabbing; }
.queue-card.is-dragging {
  opacity: 0.45;
  transform: rotate(-1.2deg) scale(0.99);
  box-shadow: var(--elev-dragged);
  cursor: grabbing;
}

/* Cases kanban (lane + case-card) — same drag affordance */
.lane {
  transition: background 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.lane.drag-over {
  background: color-mix(in oklab, var(--accent-soft) 60%, var(--surface));
  border-color: var(--accent);
  box-shadow: inset 0 0 0 2px color-mix(in oklab, var(--accent) 30%, transparent), var(--elev-inset);
}
.case-card[draggable="true"] { cursor: grab; }
.case-card[draggable="true"]:active { cursor: grabbing; }
.case-card.is-dragging {
  opacity: 0.45;
  transform: rotate(-1.2deg) scale(0.99);
  box-shadow: var(--elev-dragged);
  cursor: grabbing;
}

/* ─── Production daily-output chart polish ──────────────────────────── */
.bar-chart-wrap {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 12px;
  align-items: stretch;
}
.bar-chart-yaxis {
  display: flex; flex-direction: column;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  text-align: right;
  padding-right: 4px;
  padding-bottom: 22px;
  letter-spacing: 0.04em;
}
.bar-chart {
  position: relative;
  height: 220px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
  background-image:
    repeating-linear-gradient(
      to top,
      transparent 0,
      transparent calc(25% - 1px),
      var(--border-soft) calc(25% - 1px),
      var(--border-soft) 25%
    );
  background-position: 0 calc(100% - 22px);
  background-size: 100% calc(100% - 22px);
  background-repeat: no-repeat;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  align-items: end;
}
.bar-group {
  display: flex; flex-direction: column;
  align-items: center;
  height: 100%;
  position: relative;
  padding-bottom: 22px;
}
.bar-group .bars {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 100%;
  width: 100%;
  justify-content: center;
}
.bar-group .bar {
  width: 14px;
  border-radius: 3px 3px 0 0;
  box-shadow: var(--elev-soft);
  position: relative;
  transition: transform 150ms ease, filter 150ms ease;
  cursor: pointer;
  min-height: 2px;
}
.bar-group .bar:hover { transform: translateY(-2px); filter: brightness(1.05); }
.bar-group .bar .val {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: var(--fg-2);
  opacity: 0;
  transition: opacity 120ms ease;
  pointer-events: none;
  white-space: nowrap;
}
.bar-group .bar:hover .val { opacity: 1; }
.bar-group .day {
  position: absolute;
  bottom: 0; left: 50%; transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--muted);
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.bar-group.is-today .day { color: var(--accent); font-weight: 700; }
.bar-group.is-today::before {
  content: '';
  position: absolute;
  inset: 0 -4px 22px -4px;
  background: color-mix(in oklab, var(--accent-soft) 60%, transparent);
  border-radius: 6px;
  z-index: -1;
}
.bar-md { background: linear-gradient(180deg, var(--accent), color-mix(in oklab, var(--accent), black 12%)); }
.bar-th { background: linear-gradient(180deg, var(--success), color-mix(in oklab, var(--success), black 12%)); }
.bar-bt { background: linear-gradient(180deg, var(--info), color-mix(in oklab, var(--info), black 12%)); }

@media (max-width: 640px) {
  .bar-chart-wrap { grid-template-columns: 28px 1fr; gap: 8px; }
  .bar-chart { height: 180px; gap: 4px; }
  .bar-group .bar { width: 8px; }
  .bar-group .bars { gap: 2px; }
  .bar-group .day { font-size: 9.5px; }
}

/* ─── Role-coloured avatar (sidebar-footer · login demo cards) ─────────────
   Role identity, so it draws from the categorical palette (theme-tuned) rather
   than baked hues. Slots match users.css / account.css so the same role reads
   the same colour on /users, /account and the sidebar. Admin keeps the accent. */
.avatar[data-role-color] {
  background: linear-gradient(145deg,
    color-mix(in oklab, var(--cat, var(--accent)), white 26%),
    var(--cat, var(--accent)));
}
.avatar[data-role-color="seller"]   { --cat: var(--cat-3); }
.avatar[data-role-color="support"]  { --cat: var(--cat-8); }
.avatar[data-role-color="workshop"] { --cat: var(--cat-2); }

/* Sidebar role badge is shell chrome, so it follows the active interface theme. */
.sidebar-footer .user-role {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  margin-top: 2px;
  font-size: 10px;
  letter-spacing: 0.08em;
  border: 1px solid transparent;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-footer .user-role {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 25%, transparent);
}

/* ─── Login: demo-account picker cards ──────────────────────────────────── */
.demo-accounts {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.demo-account {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 9px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--elev-soft);
  cursor: pointer;
  text-align: left;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
  font-family: var(--font-body);
  min-width: 0;
}
.demo-account:hover {
  transform: translateY(-1px);
  border-color: color-mix(in oklab, var(--accent) 35%, var(--border));
  box-shadow: var(--elev-raised);
}
.demo-account.is-active {
  border-color: var(--accent);
  background: color-mix(in oklab, var(--accent-soft) 50%, var(--surface));
}
.demo-account .avatar {
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 11.5px;
  box-shadow: var(--elev-soft);
  flex-shrink: 0;
}
.demo-account .info { min-width: 0; flex: 1; }
.demo-account .info .nm {
  font-size: 12px; font-weight: 600; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.demo-account .info .rl {
  font-family: var(--font-mono);
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  line-height: 1.2;
}
.demo-account .info .em { display: none; }
.demo-accounts-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 14px;
  display: flex; align-items: center; gap: 10px;
}
.demo-accounts-label::before,
.demo-accounts-label::after {
  content: ''; flex: 1; height: 1px; background: var(--border-soft);
}
@media (max-width: 480px) {
  .demo-accounts { grid-template-columns: 1fr; }
}

/* ─── Notifications center + header quick-view ───────────────────────── */
.notification-visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.notification-page { display: grid; gap: var(--space-5); }
.notification-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  padding: var(--space-5) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 90% 10%, var(--accent-soft), transparent 34%),
    var(--surface);
  box-shadow: var(--elev-soft);
}
.notification-hero-copy { display: flex; align-items: center; gap: var(--space-4); min-width: 0; }
.notification-hero-icon {
  width: 48px; height: 48px; flex: 0 0 48px;
  display: grid; place-items: center;
  border-radius: 15px;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklab, var(--accent) 25%, transparent);
}
.notification-hero-icon svg { width: 23px; height: 23px; }
.notification-hero h2 { font-size: var(--text-xl); font-weight: 600; }
.notification-hero p { margin-top: 4px; color: var(--fg-2); font-size: var(--text-sm); }
.notification-kpis { grid-template-columns: repeat(3, 1fr); }
.notification-shell { overflow: visible; }
.notification-tabs {
  display: flex;
  gap: 4px;
  padding: 8px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-soft);
  scrollbar-width: none;
}
.notification-tabs::-webkit-scrollbar { display: none; }
.notification-primary-tabs { padding: 10px var(--space-5); }
.notification-tab {
  min-height: 40px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 8px 14px;
  border-radius: 11px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  white-space: nowrap;
  transition: color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}
.notification-tab:hover { color: var(--fg); background: var(--surface-warm); }
.notification-tab.is-active {
  color: var(--fg);
  background: var(--surface);
  box-shadow: var(--elev-soft);
}
.notification-status-tabs {
  min-height: 52px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px var(--space-5);
  overflow-x: auto;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--surface), var(--bg) 20%);
  scrollbar-width: none;
}
.notification-status-tabs::-webkit-scrollbar { display: none; }
.notification-status-tabs .tag { min-height: 36px; white-space: nowrap; }
.notification-filter-panel {
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--surface), var(--bg) 24%);
}
.notification-filter-panel > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-left: auto;
  padding: 8px var(--space-5);
  color: var(--fg-2);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
  list-style: none;
}
.notification-filter-panel > summary::-webkit-details-marker { display: none; }
.notification-filter-panel > summary svg { width: 16px; height: 16px; transition: transform 160ms ease; }
.notification-filter-panel[open] > summary svg { transform: rotate(180deg); }
.notification-filter-count {
  min-width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  color: var(--accent-on);
  background: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
}
.notification-tab:focus-visible,
.notification-filter-chip:has(input:focus-visible),
.notice-bell-btn:focus-visible,
.notice-mark-all-btn:focus-visible,
.notice-dropdown-item-button:focus-visible,
.notice-view-all:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.notification-filter-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-3);
}
.notification-filter-head h3 { font: 650 15px/1.3 var(--font-body); }
.notification-filter-head p { margin-top: 2px; color: var(--muted); font-size: 12px; }
.notification-filters {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-soft);
  background: transparent;
}
.notification-type-filter {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.notification-type-filter summary {
  min-height: 44px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 9px 12px;
  cursor: pointer;
  color: var(--fg-2);
  font-size: 13px;
  font-weight: 650;
  list-style: none;
}
.notification-type-filter summary::-webkit-details-marker { display: none; }
.notification-type-filter summary svg { width: 16px; height: 16px; transition: transform 160ms ease; }
.notification-type-filter[open] summary svg { transform: rotate(180deg); }
.notification-type-list {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 4px 12px 12px;
  border-top: 1px solid var(--border-soft);
}
.notification-type-list fieldset { display: contents; }
.notification-filter-chip {
  min-height: 44px;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--fg-2);
  background: var(--surface);
  font-size: 12px;
  cursor: pointer;
}
.notification-filter-chip:has(input:checked) {
  color: var(--accent);
  border-color: color-mix(in oklab, var(--accent) 44%, var(--border));
  background: var(--accent-soft);
}
.notification-filter-chip input { width: 16px; height: 16px; accent-color: var(--accent); }
.notification-filter-grid {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) repeat(2, minmax(150px, 220px)) auto;
  gap: var(--space-3);
  align-items: end;
  margin-top: var(--space-3);
}
.notification-read-policy { align-self: center; color: var(--muted); font-size: 12px; line-height: 1.45; }
.notification-filter-grid .btn { min-height: 44px; }
.notification-filter-grid .input { min-height: 44px; }
.notification-filter-grid-status { grid-template-columns: repeat(3, minmax(150px, 220px)) auto; }
.notification-alert-filter-grid { grid-template-columns: repeat(2, minmax(170px, 240px)) auto; }
.notification-alert-filter-grid .btn { justify-self: start; }
.alert-create {
  margin: var(--space-4) var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}
.alert-create summary { min-height: 48px; display: flex; align-items: center; padding: 10px 14px; cursor: pointer; font-weight: 650; color: var(--fg-2); }
.alert-create-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: var(--space-3); padding: 0 14px 14px; }
.alert-create-grid .wide { grid-column: 1 / -1; }
.alert-create-grid .btn { min-height: 44px; }
.notification-table tbody tr { cursor: default; }
.notification-alert-table tbody tr { cursor: default; }
.notification-table td { vertical-align: top; }
.notification-type-cell { display: flex; align-items: center; gap: 8px; }
.notification-severity-dot {
  width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%;
  background: var(--info);
  box-shadow: 0 0 0 3px var(--info-soft);
}
.notification-severity-dot.is-warning { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.notification-severity-dot.is-critical { background: var(--danger); box-shadow: 0 0 0 3px var(--danger-soft); }
.notification-content { min-width: 0; max-width: 640px; }
.notification-content-head { display: flex; align-items: center; gap: 8px; }
.notification-title { font-weight: 680; color: var(--fg); line-height: 1.4; }
.notification-unread-label {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--accent);
  font-family: var(--font-mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  white-space: nowrap;
}
.notification-unread-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.notification-desc { margin-top: 4px; color: var(--fg-2); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.notification-entity-link { display: inline-flex; align-items: center; min-height: 32px; margin-top: 4px; color: var(--accent); font-size: 12px; font-weight: 650; }
.notification-time-stack { display: grid; gap: 5px; min-width: 155px; }
.notification-time-line { display: grid; gap: 2px; }
.notification-time-label { color: var(--muted); font-family: var(--font-mono); font-size: 9.5px; letter-spacing: .06em; text-transform: uppercase; }
.notification-time { color: var(--fg-2); font-family: var(--font-mono); font-size: 11px; line-height: 1.45; white-space: nowrap; }
.notification-actions { display: flex; gap: 7px; justify-content: flex-end; flex-wrap: wrap; }
.notification-actions .btn { min-height: 44px; }
.notification-unread td { background: color-mix(in oklab, var(--accent-soft) 30%, transparent); }
.notification-unread td:first-child { box-shadow: inset 3px 0 0 var(--accent); }
.notification-status-stack { display: grid; justify-items: start; gap: 6px; }
.notification-ack-required { display: inline-flex; align-items: center; gap: 5px; color: var(--danger); font-size: 11px; font-weight: 700; }
.notification-ack-required svg { width: 13px; height: 13px; }
.notification-inline-status { min-height: 20px; padding: 0 var(--space-5); color: var(--muted); font-size: 12px; }
.notification-inline-status:empty { display: none; }
.overdue { color: var(--danger); font-weight: 650; }
.notification-detail-dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  margin: auto 12px auto auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--fg);
  background: var(--surface);
  box-shadow: 0 24px 72px color-mix(in oklab, var(--fg) 28%, transparent);
}
.notification-detail-dialog[open] { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
/* Neutral black scrim, not a warm one: ::backdrop only inherits custom properties
   on newer engines, so a token here would silently compute to transparent. */
.notification-detail-dialog::backdrop { background: rgba(0, 0, 0, .48); }
.notification-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5);
  border-bottom: 1px solid var(--border-soft);
}
.notification-detail-head h2 { margin-top: 4px; font: 650 var(--text-xl)/1.35 var(--font-display); }
.notification-detail-eyebrow {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
}
.notification-detail-body { overflow-y: auto; padding: var(--space-5); }
.notification-detail-badges { display: flex; flex-wrap: wrap; gap: 8px; }
.notification-detail-message { margin-top: var(--space-4); color: var(--fg-2); line-height: 1.6; overflow-wrap: anywhere; }
.notification-detail-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
  margin-top: var(--space-5);
}
.notification-detail-meta > div {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  background: var(--surface-warm);
}
.notification-detail-meta dt,
.notification-detail-section h3 {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.notification-detail-meta dd { margin-top: 4px; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }
.notification-detail-section { margin-top: var(--space-5); }
.notification-detail-section p { margin-top: 7px; color: var(--fg-2); line-height: 1.55; overflow-wrap: anywhere; }
.notification-detail-section.is-danger p { color: var(--danger); }
.notification-detail-timeline { display: grid; gap: 0; margin-top: 10px; list-style: none; }
.notification-detail-timeline li {
  position: relative;
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 12px;
  padding: 0 0 18px 20px;
  color: var(--fg-2);
  font-size: 12px;
}
.notification-detail-timeline li::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 1px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.notification-detail-timeline li:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 15px;
  bottom: 3px;
  left: 5px;
  width: 1px;
  background: var(--border);
}
.notification-detail-timeline span { font-weight: 650; }
.notification-detail-timeline time { font-family: var(--font-mono); font-size: 11px; }
.notification-detail-actions {
  min-height: 68px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px var(--space-5);
  border-top: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--surface), var(--bg) 22%);
}
.notification-detail-actions .btn { min-height: 44px; }

/* Header quick-view */
.notice-bell-wrap { position: relative; z-index: 30; display: inline-block; flex: 0 0 auto; }
.notice-bell-btn {
  position: relative;
  width: 44px; height: 44px;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border);
  border-radius: 13px;
  color: var(--fg-2);
  background: var(--surface);
  box-shadow: var(--elev-soft);
  transition: color 160ms ease, background-color 160ms ease, transform 120ms ease;
}
.notice-bell-btn:hover, .notice-bell-btn[aria-expanded="true"] { color: var(--accent); background: var(--surface-warm); }
.notice-bell-btn:active { transform: scale(.97); }
.notice-bell-btn svg { width: 20px; height: 20px; }
.notice-bell-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 19px; height: 19px; padding: 0 5px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-pill);
  color: var(--accent-on);
  background: var(--danger);
  border: 2px solid var(--surface);
  font-family: var(--font-mono); font-size: 9px; font-weight: 800;
}
.notice-bell-badge[data-notice-count="0"] { display: none; }
.notice-dropdown {
  position: absolute; top: calc(100% + 10px); right: 0;
  width: min(400px, calc(100vw - 24px));
  max-height: calc(100dvh - var(--topbar-h) - 20px);
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 18px;
  color: var(--fg);
  background: var(--surface);
  box-shadow: 12px 18px 44px color-mix(in oklab, var(--fg) 20%, transparent), -4px -4px 16px rgba(255,255,255,.46);
  transform-origin: top right;
  animation: notice-popover-in 180ms ease-out;
}
.notice-dropdown[hidden] { display: none; }
@keyframes notice-popover-in { from { opacity: 0; transform: translateY(-5px) scale(.98); } }
.notice-dropdown-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-3);
  padding: 16px;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--surface), var(--bg) 28%);
}
.notice-dropdown-title { color: var(--fg); font: 650 17px/1.25 var(--font-display); }
.notice-dropdown-subtitle { max-width: 240px; margin-top: 3px; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.notice-mark-all-btn {
  min-height: 40px; flex: 0 0 auto;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--accent);
  background: var(--surface);
  font-size: 11.5px; font-weight: 700;
  transition: background-color 160ms ease, opacity 160ms ease;
}
.notice-mark-all-btn:hover { background: var(--accent-soft); }
.notice-mark-all-btn:disabled { opacity: .5; cursor: not-allowed; }
.notice-dropdown-list {
  min-height: 96px; max-height: 420px;
  overflow-y: auto; overscroll-behavior: contain;
  list-style: none; padding: 0; margin: 0;
}
.notice-dropdown-state {
  min-height: 120px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  padding: 24px 16px;
  color: var(--muted); text-align: center; font-size: 13px;
}
.notice-loading-spinner {
  width: 22px; height: 22px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: notice-spin 700ms linear infinite;
}
@keyframes notice-spin { to { transform: rotate(360deg); } }
.notice-dropdown-item { border-bottom: 1px solid var(--border-soft); }
.notice-dropdown-item-button {
  width: 100%; min-height: 74px;
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: start; gap: 10px;
  padding: 12px 14px;
  text-align: left;
  background: var(--surface);
  transition: background-color 160ms ease;
}
.notice-dropdown-item-button:hover { background: var(--surface-warm); }
.notice-dropdown-item.is-unseen .notice-dropdown-item-button {
  background: color-mix(in oklab, var(--accent) 7%, var(--surface));
  box-shadow: inset 3px 0 0 var(--accent);
}
.notice-dropdown-glyph {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  border-radius: 10px;
  color: var(--info);
  background: var(--info-soft);
}
.notice-dropdown-glyph svg { width: 16px; height: 16px; }
.notice-dropdown-glyph.is-warning { color: var(--warn); background: var(--warn-soft); }
.notice-dropdown-glyph.is-critical { color: var(--danger); background: var(--danger-soft); }
.notice-dropdown-copy { min-width: 0; display: grid; gap: 3px; }
.notice-dropdown-meta { display: flex; align-items: center; gap: 7px; min-width: 0; }
.notice-dropdown-pill {
  color: var(--muted);
  font-family: var(--font-mono); font-size: 9.5px; font-weight: 750;
  letter-spacing: .04em; text-transform: uppercase;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.notice-dropdown-unread { color: var(--accent); font-size: 10px; font-weight: 700; }
.notice-dropdown-msg {
  color: var(--fg); font-size: 12.5px; line-height: 1.4;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.notice-dropdown-time { color: var(--muted); font-family: var(--font-mono); font-size: 9.5px; white-space: nowrap; padding-top: 2px; }
.notice-dropdown-alert { border-bottom: 1px solid var(--border-soft); }
.notice-dropdown-alert a {
  min-height: 48px;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px;
  color: color-mix(in oklab, var(--warn), var(--fg) 25%);
  background: var(--warn-soft);
  font-size: 12px; font-weight: 700;
}
.notice-dropdown-alert svg { width: 17px; height: 17px; flex: 0 0 17px; }
.notice-dropdown-alert .notice-alert-arrow { margin-left: auto; }
.notice-dropdown-footer { padding: 8px; border-top: 1px solid var(--border-soft); background: color-mix(in oklab, var(--surface), var(--bg) 24%); }
.notice-view-all {
  min-height: 44px;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: 11px;
  color: var(--accent);
  font-size: 12.5px; font-weight: 700;
}
.notice-view-all:hover { background: var(--accent-soft); }
.notice-view-all svg { width: 15px; height: 15px; }

@media (max-width: 900px) {
  .notification-filter-grid, .alert-create-grid { grid-template-columns: 1fr 1fr; }
  .notification-filter-grid > :first-child, .alert-create-grid .wide { grid-column: 1 / -1; }
}
@media (max-width: 768px) {
  .notification-hero { padding: var(--space-4); }
  .notification-hero-icon { width: 42px; height: 42px; flex-basis: 42px; }
  .notification-kpis { grid-template-columns: 1fr; }
  .notification-filter-grid, .alert-create-grid { grid-template-columns: 1fr; }
  .notification-filter-grid > :first-child, .alert-create-grid .wide { grid-column: auto; }
  .notification-filters { padding: var(--space-3); }
  .notification-table tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "type time" "content content" "state actions";
    gap: 12px 14px;
    padding: 14px;
  }
  .notification-table tbody tr td { display: block; min-height: 0; padding: 0; border: 0; }
  .notification-table tbody tr td::before { display: none; }
  .notification-table tbody tr td:nth-child(1) { grid-area: type; }
  .notification-table tbody tr td:nth-child(2) { grid-area: content; }
  .notification-table tbody tr td:nth-child(3) { grid-area: time; }
  .notification-table tbody tr td:nth-child(4) { grid-area: state; }
  .notification-table tbody tr td:nth-child(5) { grid-area: actions; }
  .notification-table .notification-time-stack { min-width: 0; justify-items: end; }
  .notification-table .notification-time { white-space: normal; text-align: right; }
  .notification-table .notification-actions { align-self: end; }
  .notification-table .notification-actions .btn { min-height: 44px; }
  .notification-detail-dialog {
    width: calc(100vw - 16px);
    max-height: calc(100dvh - 16px);
    margin: auto;
    border-radius: 18px;
  }
  .notification-detail-meta { grid-template-columns: 1fr; }
  .notification-detail-actions { flex-wrap: wrap; }
}
@media (max-width: 480px) {
  .notification-hero-copy { align-items: flex-start; }
  .notification-hero h2 { font-size: 18px; }
  .notification-table tbody tr {
    grid-template-areas: "type type" "time time" "content content" "state state" "actions actions";
  }
  .notification-table .notification-time-stack { justify-items: start; }
  .notification-table .notification-time { text-align: left; }
  .notification-table .notification-actions { justify-content: stretch; }
  .notification-table .notification-actions .btn { flex: 1 1 100%; }
  .notification-primary-tabs,
  .notification-status-tabs { padding-inline: var(--space-3); }
  .notification-filter-panel > summary { padding-inline: var(--space-3); }
  .notification-detail-head,
  .notification-detail-body { padding: var(--space-4); }
  .notification-detail-actions { padding: 10px var(--space-4); }
  .notification-detail-actions .btn { flex: 1 1 100%; }
  .notice-dropdown {
    position: fixed;
    top: calc(var(--topbar-h) + 8px);
    right: 8px;
    width: calc(100vw - 16px);
    max-height: calc(100dvh - var(--topbar-h) - 16px);
    transform-origin: top center;
  }
  .notice-dropdown-head { padding: 14px; }
  .notice-dropdown-subtitle { display: none; }
  .notice-mark-all-btn { min-height: 44px; }
  .notice-dropdown-item-button { grid-template-columns: 32px minmax(0, 1fr); }
  .notice-dropdown-time { grid-column: 2; padding-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .notice-dropdown, .notice-loading-spinner { animation: none; }
  .notification-type-filter summary svg,
  .notification-filter-panel > summary svg,
  .notification-tab, .notice-bell-btn, .notice-dropdown-item-button { transition: none; }
}
/* Shared accessible dialog used instead of browser alert/confirm/prompt. */
.app-dialog-backdrop { position:fixed; inset:0; z-index:3000; display:grid; place-items:center; padding:20px; background:color-mix(in oklab, var(--fg) 48%, transparent); backdrop-filter:blur(4px); }
.app-dialog-backdrop[hidden] { display:none; }
.app-dialog { width:min(440px,100%); display:grid; grid-template-columns:42px 1fr; gap:14px 16px; padding:22px; border:1px solid var(--border); border-radius:18px; background:var(--surface); box-shadow:0 24px 70px color-mix(in oklab, var(--fg) 28%, transparent); animation:app-dialog-in 150ms ease-out; }
.app-dialog-icon { width:42px; height:42px; display:grid; place-items:center; border-radius:12px; background:var(--accent-soft); color:var(--accent); font-weight:800; }
.app-dialog[data-tone="danger"] .app-dialog-icon { background:var(--danger-soft); color:var(--danger); }
.app-dialog[data-tone="success"] .app-dialog-icon { background:var(--success-soft); color:var(--success); }
.app-dialog-copy h2 { margin:1px 0 7px; font:600 20px/1.2 var(--font-display); }
.app-dialog-copy p { margin:0; color:var(--fg-2); line-height:1.5; white-space:pre-wrap; overflow-wrap:anywhere; }
.app-dialog-input-wrap { display:grid; gap:6px; margin-top:14px; font-size:12px; font-weight:650; }
.app-dialog-input-wrap[hidden] { display:none; }
.app-dialog-actions { grid-column:1 / -1; display:flex; justify-content:flex-end; gap:9px; margin-top:4px; }
@keyframes app-dialog-in { from { opacity:0; transform:translateY(8px) scale(.98); } }
@media (prefers-reduced-motion:reduce) { .app-dialog { animation:none; } }

/* ─── App toast (non-blocking CRUD feedback: success / info / danger) ───────
   Design follows the skeumorphism shell: warm surface, soft border, colored
   stripe on the left that doubles as the tone cue. Icon + title + message keeps
   it scannable; a bottom progress bar visualises the auto-dismiss countdown. */
.app-toast-holder {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 260;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(380px, calc(100vw - 36px));
  pointer-events: none;
}
.app-toast {
  position: relative;
  display: grid;
  grid-template-columns: 4px auto 1fr auto;
  grid-template-rows: auto auto;
  grid-template-areas:
    "stripe icon  body   close"
    "stripe icon  body   close"
    "prog  prog  prog   prog";
  align-items: start;
  column-gap: 10px;
  padding: 11px 12px 9px 12px;
  border-radius: 12px;
  font-size: 13px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.08);
  pointer-events: auto;
  overflow: hidden;
  opacity: 0;
  transform: translateY(10px) scale(0.985);
  transition: opacity .22s ease, transform .22s cubic-bezier(.2,.7,.3,1);
  max-width: 380px;
  min-width: 240px;
}
.app-toast.is-in { opacity: 1; transform: translateY(0) scale(1); }
.app-toast.is-paused .app-toast-progress > span { animation-play-state: paused; }
.app-toast-silent-remove { display: none; }

.app-toast-stripe {
  grid-area: stripe;
  align-self: stretch;
  width: 4px;
  border-radius: 4px 0 0 4px;
  background: var(--border);
}
.app-toast-icon {
  grid-area: icon;
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--surface-sunk);
  color: var(--muted);
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
  margin-top: 1px;
}
.app-toast-body {
  grid-area: body;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.app-toast-title {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
.app-toast-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--fg);
  line-height: 1.4;
  word-wrap: break-word;
}
.app-toast-action {
  grid-area: body;
  align-self: center;
  margin-left: 8px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--accent);
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
  font-family: inherit;
  white-space: nowrap;
}
.app-toast-action:hover { background: var(--accent-soft); }
.app-toast-close {
  grid-area: close;
  align-self: start;
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background .12s ease, color .12s ease;
}
.app-toast-close:hover { background: var(--surface-sunk); color: var(--fg); }

.app-toast-progress {
  grid-area: prog;
  position: absolute;
  left: 0;
  bottom: 0;
  right: 0;
  height: 3px;
  background: transparent;
  overflow: hidden;
}
.app-toast-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  background: currentColor;
  opacity: 0.35;
  transform-origin: left center;
  animation: app-toast-progress linear forwards;
}
@keyframes app-toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* ── Tones: success / danger / info ──
   Stripe + icon + progress bar all take the same tone color so the eye reads
   the toast at a glance even when stacked. */
.app-toast-success {
  border-color: color-mix(in oklab, var(--success) 45%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in oklab, var(--surface), var(--success-soft) 60%), var(--surface));
}
.app-toast-success .app-toast-stripe { background: var(--success); }
.app-toast-success .app-toast-icon {
  background: var(--success-soft);
  color: var(--success);
  border-color: color-mix(in oklab, var(--success) 30%, transparent);
}
.app-toast-success .app-toast-progress > span { color: var(--success); }

.app-toast-danger {
  border-color: color-mix(in oklab, var(--danger) 45%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in oklab, var(--surface), var(--danger-soft) 60%), var(--surface));
}
.app-toast-danger .app-toast-stripe { background: var(--danger); }
.app-toast-danger .app-toast-icon {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: color-mix(in oklab, var(--danger) 30%, transparent);
}
.app-toast-danger .app-toast-progress > span { color: var(--danger); }

.app-toast-info {
  border-color: color-mix(in oklab, var(--info) 40%, var(--border));
  background:
    linear-gradient(180deg, color-mix(in oklab, var(--surface), var(--info-soft) 50%), var(--surface));
}
.app-toast-info .app-toast-stripe { background: var(--info); }
.app-toast-info .app-toast-icon {
  background: var(--info-soft);
  color: var(--info);
  border-color: color-mix(in oklab, var(--info) 30%, transparent);
}
.app-toast-info .app-toast-progress > span { color: var(--info); }

@media (max-width: 540px) {
  .app-toast-holder { right: 12px; left: 12px; bottom: 12px; max-width: none; }
  .app-toast { min-width: 0; max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  .app-toast { transition: none; transform: none; }
  .app-toast-progress > span { animation: none; transform: scaleX(0); }
}

/* ─── Image lightbox ──────────────────────────────────────────────────
   Xem ảnh cỡ lớn (thumbnail dòng hàng, ảnh catalog…). Nằm TRÊN cả modal và
   sidebar drawer (z-index 110) vì có thể mở từ trong một modal. */
.img-lightbox {
  position: fixed; inset: 0; z-index: 200;
  display: grid; place-items: center;
  padding: max(var(--space-4), env(safe-area-inset-top)) var(--space-4);
  background: color-mix(in oklab, var(--fg) 78%, transparent);
  backdrop-filter: blur(3px);
}
.img-lightbox[hidden] { display: none; }
.img-lightbox-body { margin: 0; display: grid; gap: 10px; justify-items: center; max-width: 100%; }
.img-lightbox-body img {
  max-width: min(92vw, 1100px); max-height: 82vh;
  width: auto; height: auto; object-fit: contain;
  border-radius: var(--radius-md, 10px);
  box-shadow: 0 18px 60px color-mix(in oklab, black 45%, transparent);
  background: var(--surface);
}
.img-lightbox-body figcaption { color: white; font-size: 12.5px; text-align: center; max-width: min(92vw, 1100px); overflow-wrap: anywhere; }
.img-lightbox-close {
  position: absolute; top: 14px; right: 16px;
  width: 38px; height: 38px; border-radius: 999px;
  border: 1px solid color-mix(in oklab, white 35%, transparent);
  background: color-mix(in oklab, black 35%, transparent); color: white;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.img-lightbox-close:hover { background: color-mix(in oklab, black 55%, transparent); }
body.has-lightbox { overflow: hidden; }
/* Ảnh bấm được — con trỏ phải nói ra điều đó. */
[data-lightbox] { cursor: zoom-in; }
[data-lightbox]:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
