﻿/* =====================================================================
   Tunwal Ops ERP — internal-tool stylesheet
   See skills.md §2.A for the design philosophy this file applies.
   ===================================================================== */

/* ---------- 1. Design tokens (single source of truth) ---------------- */
:root {
  /* Type scale */
  --fs-xxs: 11px;
  --fs-xs:  12px;
  --fs-sm:  13px;
  --fs-md:  14px;   /* body */
  --fs-lg:  16px;
  --fs-xl:  20px;
  --fs-xxl: 24px;

  /* Spacing scale (4-based) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 24px;
  --sp-6: 32px;
  --sp-7: 48px;

  /* Radius */
  --r-sm: 4px;
  --r-md: 6px;
  --r-lg: 8px;
  --r-xl: 12px;
  --r-pill: 999px;

  /* Colour — neutral 60% */
  --bg:           #eef2f8;       /* page */
  --surface:      #ffffff;       /* cards, tables, inputs */
  --surface-2:    #f6f8fc;       /* alt rows, subtle backgrounds */
  --surface-3:    #e9eef6;       /* hover, chips */
  --border:       #e3e8f1;       /* dividers, input borders — lighter; lean on shadow */
  --border-strong:#c7cedb;       /* emphasized dividers */
  --fg:           #1a1d23;       /* primary text */
  --fg-2:         #3d4754;       /* secondary text */
  --muted:        #6a7382;       /* tertiary / hints */

  /* Colour — brand 10% */
  --primary:        #1b4d8f;
  --primary-fg:     #ffffff;
  --primary-soft:   #e7effb;
  --primary-hover:  #163e72;
  --grad-brand:     linear-gradient(135deg, #245aa0 0%, #163e72 100%);
  --danger-hover:   #921e1e;
  --danger-fg-inv:  #ffffff;

  /* Colour — semantic */
  --success:      #1d8a3b;
  --success-bg:   #e3f5e1;
  --success-fg:   #14572a;

  --warn:         #b06b00;
  --warn-bg:      #fde8c8;
  --warn-fg:      #6f4a0c;

  --danger:       #b53030;
  --danger-bg:    #fde8e8;
  --danger-fg:    #8a1f1f;

  --info-bg:      #d6dffb;
  --info-fg:      #1b2f5d;

  /* Shadow */
  --shadow-sm: 0 1px 2px rgba(20, 30, 50, 0.05), 0 1px 1px rgba(20, 30, 50, 0.04);
  --shadow-md: 0 2px 4px rgba(20, 30, 50, 0.05), 0 10px 24px rgba(20, 30, 50, 0.08);
  --shadow-lg: 0 18px 40px rgba(20, 30, 50, 0.14), 0 6px 12px rgba(20, 30, 50, 0.06);

  /* Layout */
  --container-w: 1180px;
  --topbar-h:    52px;
  --sidebar-w:   240px;

  /* Controls — ONE height for every single-line control (input/select/button).
     UI Stabilization V1 (2026-07-10): mixed control heights were a top source of
     "different screens feel like different developers". */
  --control-h: 34px;
  /* Native widgets (select dropdown lists, date-picker calendars, checkboxes,
     scrollbars) follow the app theme instead of always rendering light. */
  color-scheme: light;
  /* Custom select chevron (theme-aware — re-declared in the dark tokens) */
  --select-arrow: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236a7382' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ---------- 2. Base & reset ----------------------------------------- */
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  font: var(--fs-md)/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); }
/* Centralized inline-SVG icon — inherits text colour, scales with font-size. */
.icon { width: 1em; height: 1em; vertical-align: -0.14em; flex: none; display: inline-block; }
a:hover { text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: var(--sp-4) 0; }

/* ---------- 3. Topbar (thin: brand + user dropdown only) ------------ */
.topbar {
  display: flex; align-items: center;
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(20, 30, 50, 0.05);
  gap: var(--sp-3);
  min-height: var(--topbar-h);
  position: sticky; top: 0; z-index: 100;
}
.brand { flex-shrink: 0; }
.brand a { display: inline-flex; align-items: center; gap: var(--sp-2); font-weight: 700; color: var(--primary); text-decoration: none; font-size: var(--fs-lg); letter-spacing: -0.01em; }
.brand a::before {
  content: ""; display: inline-block; flex-shrink: 0;
  width: 30px; height: 30px; border-radius: 6px;
  background: url('/public/img/tunwal-logo.png') center/contain no-repeat;
}
.brand a:hover { text-decoration: none; opacity: 0.9; }
.topbar-spacer { flex: 1; }

.sidebar-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--border); border-radius: var(--r-sm);
  background: var(--surface);
  font-size: 18px; cursor: pointer;
}

/* (Legacy .nav styles kept below; only the account-area dropdown still uses .navgroup.) */
.nav { display: flex; gap: var(--sp-1); align-items: center; flex: 1; }
.nav .navspacer { flex: 1; }
.nav .navlink, .nav .navtrigger {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--fg); text-decoration: none;
  background: none; border: none; cursor: pointer;
  font: inherit; line-height: 1.2;
  transition: background 120ms ease;
}
.nav .navlink:hover, .nav .navtrigger:hover { text-decoration: none; }
.nav .navlink:hover, .nav .navtrigger:hover { background: var(--surface-3); }
.nav .navcaret { font-size: 9px; color: var(--muted); }

.navgroup { position: relative; }

/* The dropdown menu — a real visible card, no pseudo-element trickery.
   No visual gap to the trigger: menu sits flush against the trigger so the
   hover area is continuous (cursor never leaves the hover zone). */
.navgroup .navmenu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  padding: var(--sp-1);
  z-index: 1000;
}

/* Open on hover OR via .open class (JS toggles for click/keyboard) */
.navgroup:hover > .navmenu,
.navgroup:focus-within > .navmenu,
.navgroup.open > .navmenu { display: block; }

/* Menu that opens UPWARD (the sidebar-bottom profile card, cakjs-crm pattern) */
/* ================================================================
   Sidebar account section — the "dOps profile menu" pattern.
   ONE cohesive block: the profile row + the collapse toggle sit
   flat under the single .sidebar-foot divider, so they read as one
   thing (not two bordered boxes). Card is transparent until hover;
   the avatar is the one premium accent. Menu opens upward. This is
   the canonical pattern — see build-kit/12-sidebar-profile-menu.md.
   ================================================================ */

/* Account menu — opens UPWARD from the card, premium surface + entrance. */
.navmenu.navmenu-up {
  /* Span the full account section (past the 32px collapse toggle + 2px gap) but NEVER
     wider — the sidebar has overflow:hidden, so an overflowing min-width gets clipped. */
  top: auto; bottom: calc(100% + 8px); left: 0; right: 0; min-width: 0;
  border-radius: var(--r-xl); overflow: hidden; padding: var(--sp-1);
  /* deep, soft shadow — the cakjs-crm shadow-2xl feel */
  box-shadow: 0 20px 44px -12px rgba(20, 30, 50, 0.30), 0 6px 14px rgba(20, 30, 50, 0.10);
  animation: menuUp 190ms ease-out;
}
.sidebar-foot .side-profile { position: static; }   /* menu anchors to the full-width foot, not the narrow card */
/* Collapsed rail (68px) can't hold the menu — pop it out to the right, full width, unclipped. */
.app-shell.nav-collapsed .navmenu.navmenu-up { left: 4px; right: auto; min-width: 216px; }
@keyframes menuUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* The account section: profile row (flex) + collapse toggle, flat, one line. */
.side-profile-wrap { display: flex; align-items: center; gap: 2px; }
.side-profile { position: relative; flex: 1 1 auto; min-width: 0; }

/* Profile row — flat by default (no fill/border); subtle hover; tinted when the menu is open. */
.side-profile-card {
  display: flex; align-items: center; gap: 9px; width: 100%; text-align: left;
  padding: 6px 7px; border-radius: var(--r-md);
  border: 1px solid transparent; background: transparent; cursor: pointer; color: inherit;
  transition: background-color 140ms ease;
}
.side-profile-card:hover { background: color-mix(in srgb, var(--surface-3) 70%, transparent); }
.side-profile.open > .side-profile-card { background: var(--primary-soft); }

/* Avatar — the single premium accent: soft gradient, white bold initial, faint lift. */
.side-avatar {
  flex: 0 0 auto; width: 32px; height: 32px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), color-mix(in srgb, var(--primary) 60%, #16183a));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-sm); font-weight: 700; text-transform: uppercase;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.18);
}
/* The account card is NAME on top, ROLE underneath — two lines, never three, never side
   by side. `min-width: 0` + `overflow: hidden` at every level so a long name or role can
   NEVER widen the fixed rail; each line truncates with an ellipsis instead. The old markup
   put the role BESIDE the name with `flex: 0 0 auto` (a chip that never shrinks), which is
   exactly what pushed the sidebar wider on /outlet ("Outlet Manager" + a long outlet name). */
.side-profile-id { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 2px; line-height: 1.25; overflow: hidden; }
.side-profile-id .who { display: block; max-width: 100%; font-size: var(--fs-sm); font-weight: 600; color: var(--fg); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-profile-role { display: block; max-width: 100%; width: fit-content; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Collapse toggle — flat icon button, same visual language as the row (no separate box). */
.side-profile-wrap .sidebar-collapse-btn {
  flex: 0 0 auto; width: 32px; height: 32px; padding: 0; justify-content: center;
  border: 1px solid transparent; border-radius: var(--r-md);
  background: transparent; color: var(--muted);
  transition: background-color 140ms ease, color 140ms ease;
}
.side-profile-wrap .sidebar-collapse-btn:hover { background: color-mix(in srgb, var(--surface-3) 70%, transparent); color: var(--fg); transform: none; border-color: transparent; }
.side-profile-wrap .sidebar-collapse-btn svg { width: 18px; height: 18px; }

/* Collapsed rail: avatar only, toggle stacked above it (Console). */
.app-shell.nav-collapsed .side-profile-wrap { flex-direction: column-reverse; gap: 6px; }
.app-shell.nav-collapsed .side-profile-id { display: none; }
.app-shell.nav-collapsed .side-profile-card { justify-content: center; padding: 5px; }

.navgroup .navmenu a,
.navgroup .navmenu button {
  display: block; width: 100%;
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-sm);
  color: var(--fg); text-decoration: none;
  font: inherit; text-align: left;
  background: none; border: none; cursor: pointer;
}
.navgroup .navmenu a:hover,
.navgroup .navmenu button:hover { background: var(--surface-3); }
.navgroup .navmenu-right { left: auto; right: 0; }
.navgroup .navlogout {
  margin: var(--sp-1) 0 0; padding: var(--sp-1) 0 0;
  border-top: 1px solid var(--border);
}
.navgroup .navlogout button { color: var(--danger); width: 100%; }

/* Caret rotates 180° when the dropdown is open */
.navcaret { display: inline-block; transition: transform 150ms ease; }
.navgroup:hover > .navtrigger .navcaret,
.navgroup:focus-within > .navtrigger .navcaret,
.navgroup.open > .navtrigger .navcaret { transform: rotate(180deg); }

.nav .navaccount .who { color: var(--muted); font-size: var(--fs-sm); }
.nav .navaccount .role { font-size: var(--fs-xxs); }

@media (max-width: 900px) {
  .topbar { padding: var(--sp-2) var(--sp-3); }
  .navgroup .navmenu, .navgroup .navmenu-right { left: 0; right: auto; }
  .nav .navaccount .who { display: none; }
}

/* ---------- 4. App shell: sidebar + main content -------------------- */
/* Flexbox shell so the sidebar can be absent (login page) without leaving an
   empty 240 px reservation. Sidebar is a fixed-width flex item; main takes
   the rest. When no sidebar is rendered, main is the sole flex item taking
   100 % width — `.container { margin: 0 auto }` then centres it in viewport. */
.app-shell {
  display: flex;
  min-height: calc(100vh - var(--topbar-h) - 60px);
}
.app-shell > main { flex: 1 1 auto; min-width: 0; }   /* min-width:0 lets long tables not overflow */

.sidebar {
  flex: 0 0 var(--sidebar-w);   /* fixed width, no shrink, no grow */
  /* ...except `flex-basis` alone does NOT fix the width. A flex item defaults to
     `min-width: auto`, meaning it refuses to shrink below its CONTENT's intrinsic size —
     so a long account name, a wide role chip, or any unbreakable string silently widened
     the whole rail. `min-width: 0` is what actually enforces the basis; `max-width` caps
     it from the other side. Without these two lines "fixed width" is a comment, not a rule. */
  min-width: 0;
  max-width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--surface) 0%, var(--surface-2) 100%);
  border-right: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-2);
  position: sticky;
  top: var(--topbar-h);
  z-index: 95;                   /* above page content (tables/tiles), below topbar(100)/modals(2000):
                                    the collapsed drawer pops out over the page, so the sidebar's
                                    stacking context must sit above it — else it renders BEHIND. */
  align-self: flex-start;
  height: calc(100vh - var(--topbar-h));
  overflow: visible;             /* the inner .sidenav scrolls itself (flex:1 + overflow-y:auto);
                                    visible lets the account menu escape the sidebar instead of
                                    being clipped — the cakjs-crm approach (its aside never clips). */
  display: flex; flex-direction: column;
  /* Smooth collapse/expand — animate width + padding, no layout jump. */
  transition: flex-basis 180ms ease, width 180ms ease, padding 180ms ease, box-shadow 160ms ease;
}
.sidebar-overlay {
  display: none;
  position: fixed; inset: var(--topbar-h) 0 0 0;
  background: rgba(15, 18, 23, 0.45);
  z-index: 90;
}

.sidenav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
/* Thin scrollbar, no reserved gutter — reclaims the empty strip on the right. */
.sidenav { scrollbar-width: thin; }
.sidenav::-webkit-scrollbar { width: 6px; }
.sidenav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
.sidenav .sidelink, .sidenav .sidegroup-head {
  display: flex; align-items: center; gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  color: var(--fg);
  text-decoration: none;
  font-size: var(--fs-md);
  line-height: 1.3;
}
.sidenav .sidelink:hover, .sidenav .sidegroup-head:hover {
  background: var(--surface-3);
  text-decoration: none;
}
.sidenav .sidelink.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}
.sidenav .sidelink.home { font-weight: 500; }

.sidenav .sidegroup { margin-top: var(--sp-3); display: flex; flex-direction: column; gap: 1px; }
.sidenav .sidegroup-row {
  display: flex; align-items: center;
  /* Head label gets the full row click area; toggle button sits flush right. */
}
.sidenav .sidegroup-head {
  flex: 1;
  font-size: var(--fs-xs);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--fg-2);
  font-weight: 700;
  padding-top: var(--sp-2);
  padding-bottom: var(--sp-1);
}
.sidenav .sidegroup-head:hover { color: var(--fg-2); background: transparent; }
.sidenav .sidegroup-head.active { background: transparent; color: var(--primary); }
.sidenav .sidegroup-toggle {
  background: transparent; border: 0; color: var(--muted);
  padding: 4px 10px; cursor: pointer; font-size: 11px;
  line-height: 1; border-radius: var(--r-sm);
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px;
  transition: color 120ms, background-color 120ms;
}
.sidenav .sidegroup-toggle:hover { color: var(--fg); background: var(--surface-2); }
.sidenav .sidegroup-toggle .caret { display: inline-block; transition: transform 120ms; }
.sidenav .sidegroup .sidelink {
  padding-left: var(--sp-4);
  font-size: var(--fs-sm);
  color: var(--fg-2);
}
/* Collapsible behaviour — when `.collapsed` is on the sidegroup, hide the items. */
.sidenav .sidegroup-items {
  display: flex; flex-direction: column; gap: 1px;
  overflow: hidden;
  max-height: 600px;
  transition: max-height 180ms ease-out;
}
.sidenav .sidegroup.collapsed .sidegroup-items {
  max-height: 0;
}

/* Flat sidebar — narrow-access roles (few groups, e.g. field-sales). No accordion:
   hide the collapse carets and keep every group's items expanded regardless of the
   `.collapsed` class the JS may set. Paired with `nav.focusLens` (auth/rbac.ts). */
.sidenav.sidenav--flat .sidegroup-toggle { display: none; }
.sidenav.sidenav--flat .sidegroup.collapsed .sidegroup-items { max-height: none; }

/* ---------- 30a. Search-icon button (filter bars) ----------------- */
/* Wrap the search text input + its icon button so they look like one control. */
.filters .search-input {
  display: inline-flex; align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  overflow: hidden;
}
.filters .search-input input[type="text"] {
  border: 0; border-radius: 0; outline: 0;
  padding: var(--sp-2) var(--sp-3);
  background: transparent;
  min-width: 240px;
}
.filters .search-input input[type="text"]:focus {
  outline: 0;
}
.filters .search-input:focus-within {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
.filters .search-icon-btn {
  background: var(--surface-2);
  border: 0;
  border-left: 1px solid var(--border);
  padding: 0 var(--sp-3);
  cursor: pointer; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  min-width: 36px;
  color: var(--fg-2);
  transition: background-color 120ms, color 120ms;
}
.filters .search-icon-btn:hover { background: var(--primary); color: white; }

/* ---------- 30. Topbar back button ---------------------------------- */
/* Back chevron — borderless, inline to the left of the page <h1> (app.js slots it there).
   Rendered hidden; shown on sub-pages (URL depth >= 2). */
.page-back {
  display: inline-flex; align-items: center; justify-content: center;
  background: none; border: 0; padding: 0; margin: 0 8px 0 0;
  color: var(--muted); cursor: pointer; vertical-align: middle; flex: none;
  transition: color 120ms;
}
.page-back svg { width: 0.72em; height: 0.72em; display: block; }
.page-back:hover { color: var(--fg); }
.page-back:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 3px; }
.page-back[hidden] { display: none; }

.sidebar-foot {
  position: relative;            /* the account menu anchors here (full width), not the narrow card */
  padding: var(--sp-2) 0 var(--sp-1);
  border-top: 1px solid var(--border);
  flex-shrink: 0;                /* pinned bottom — never scrolls with the menu */
}
/* Settings link lives in the foot (outside .sidenav), so it needs its own nav-link styling. */
.sidebar-foot .sidelink-settings {
  display: flex; align-items: center; gap: var(--sp-2);
  width: 100%; padding: var(--sp-2) var(--sp-3); margin-bottom: 4px;
  border-radius: var(--r-md); color: var(--fg-2); font-size: var(--fs-sm); text-decoration: none;
  transition: background-color 160ms ease, color 160ms ease;
}
.sidebar-foot .sidelink-settings:hover { background: var(--surface-3); color: var(--fg); }
.sidebar-foot .sidelink-settings .sideicon { color: var(--primary); }

.container {
  max-width: var(--container-w); margin: 0 auto; padding: var(--sp-5); width: 100%;
  min-width: 0;            /* allow the column to shrink below content width */
  overflow-x: clip;        /* contain wide content (tables) here — never let it scroll the
                              page/sidebar sideways. X-only: vertical scroll + sticky unaffected. */
}
.footer {
  text-align: center; padding: var(--sp-3) var(--sp-5);
  color: var(--muted); font-size: var(--fs-xs);
  border-top: 1px solid var(--border); background: var(--surface);
}

/* Mobile: sidebar slides in from left as an overlay (taken out of the flex
   flow via position:fixed). Main becomes the only in-flow flex item. */
@media (max-width: 900px) {
  .sidebar {
    flex: none;
    position: fixed;
    top: var(--topbar-h);
    left: 0;
    width: 260px;
    height: calc(100vh - var(--topbar-h));
    transform: translateX(-100%);
    transition: transform 200ms ease;
    z-index: 95;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .sidebar-toggle { display: inline-flex; }
}

/* ---------- 5. Typography ------------------------------------------- */
h1 { font-size: var(--fs-xxl); font-weight: 700; margin: 0 0 var(--sp-4); line-height: 1.2; letter-spacing: -0.02em; }
h2 { font-size: var(--fs-lg); font-weight: 600; margin: var(--sp-5) 0 var(--sp-2); line-height: 1.3; }
h3 { font-size: var(--fs-md); font-weight: 600; margin: var(--sp-4) 0 var(--sp-2); }
p  { margin: var(--sp-2) 0; }
.muted { color: var(--muted); }
.small { font-size: var(--fs-xs); }
.fg2   { color: var(--fg-2); }
.tabular { font-variant-numeric: tabular-nums; }

/* ---------- 6. Forms ------------------------------------------------- */
label { display: block; margin: var(--sp-3) 0; font-weight: 500; color: var(--fg-2); font-size: var(--fs-sm); }
input, select, textarea {
  width: 100%;
  padding: var(--sp-2) var(--sp-3);
  font: inherit;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--fg);
  line-height: 1.4;
}
/* ONE control height everywhere (UI Stabilization V1) — inputs, selects and
   buttons align on any toolbar without per-page nudging. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select:not([multiple]) { height: var(--control-h); }
/* Standardized select — same chevron in every browser, light and dark. */
select:not([multiple]) {
  appearance: none; -webkit-appearance: none;
  background-image: var(--select-arrow);
  background-repeat: no-repeat;
  background-position: right var(--sp-2) center;
  padding-right: calc(var(--sp-3) + 16px);
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}
textarea { resize: vertical; min-height: 60px; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--primary); }
.narrow { max-width: 440px; }

/* ---------- 7. Buttons ---------------------------------------------- */
button, .button {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 0 var(--sp-3);
  min-height: var(--control-h);
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--r-sm);
  cursor: pointer; font: inherit; color: var(--fg);
  text-decoration: none; line-height: 1.4;
  transition: background 120ms ease, border-color 120ms ease;
}
button:hover, .button:hover { background: var(--surface-3); border-color: var(--border-strong); text-decoration: none; }
button:focus-visible, .button:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
button.primary, .button.primary {
  background: var(--grad-brand); color: var(--primary-fg);
  border-color: var(--primary-hover); font-weight: 600;
  box-shadow: 0 1px 2px rgba(22, 62, 114, 0.25);
}
button.primary:hover, .button.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); box-shadow: 0 2px 6px rgba(22, 62, 114, 0.30); }
button.danger, .button.danger {
  background: var(--danger); color: var(--danger-fg-inv); border-color: var(--danger);
}
button.danger:hover, .button.danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
button.small, .button.small { padding: 0 var(--sp-2); min-height: 26px; font-size: var(--fs-xs); }
button.link {
  background: none; border: none; padding: 0;
  color: var(--primary); cursor: pointer; text-decoration: underline;
}
/* Ghost (tertiary) button — used in views but previously undefined (UI Stabilization V1). */
button.ghost, .button.ghost {
  background: transparent; border-color: transparent; color: var(--fg-2);
}
button.ghost:hover, .button.ghost:hover { background: var(--surface-3); border-color: var(--border); }
/* Vertical form stack — used in views but previously undefined. */
form.stack, .stack { display: flex; flex-direction: column; gap: var(--sp-3); }
.stack label { margin: 0; }

/* ---------- 8. Cards ------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  box-shadow: var(--shadow-md);
}
.card.narrow { max-width: 440px; margin: var(--sp-6) auto; }
/* All cards in the .grid share the same height per row AND across rows,
   regardless of content length. Combined with `.dash-actions { margin-top: auto }`
   the action buttons sit on the same baseline across every tile. */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  grid-auto-rows: 1fr;
  align-items: stretch;
  gap: var(--sp-4);
}
.card h2 { margin-top: 0; }
.card h2:first-child { margin-top: 0; }

/* ---------- 9. Tables ----------------------------------------------- */
.data {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: var(--sp-3) 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.data th, .data td {
  padding: var(--sp-2) var(--sp-3);
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  line-height: 1.4;
}
.data tbody tr:last-child td { border-bottom: 0; }
.data th {
  font-weight: 600;
  background: var(--surface-2);
  color: var(--fg-2);
  font-size: var(--fs-sm);
  position: sticky;
  top: 0;
  z-index: 2;
}
.data tbody tr:hover { background: var(--surface-2); }
.data tbody tr:nth-child(even) { background: rgba(248, 250, 252, 0.4); }
.data tbody tr:nth-child(even):hover { background: var(--surface-2); }
.data td.num, .data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.data tfoot tr.totals td {
  border-top: 2px solid var(--border-strong);
  background: var(--surface-2);
  font-weight: 500;
}
.data td a { font-weight: 500; }

/* ---- Lead Management table: fixed columns so cells never jump width ----------
   Long names/products/dealers ellipsis-truncate (full text on hover via title);
   the Last-remark cell wraps to ~2 lines so the row grows a little for a long
   note but the layout stays clean. Row baseline height is unchanged. */
.leads-table { table-layout: fixed; }
.leads-table .lm-col-lead { width: 15%; }
.leads-table .lm-col-phone { width: 12%; }
.leads-table .lm-col-product { width: 12%; }
.leads-table .lm-col-status { width: 9%; }
.leads-table .lm-col-assigned { width: 14%; }
.leads-table .lm-col-followup { width: 10%; }
.leads-table .lm-col-remark { width: 19%; }
.leads-table .lm-col-action { width: 9%; }
/* Phone must always be fully visible — never truncate it (10 digits fit the 12% col). */
.leads-table td:nth-child(2) .lm-ellip { overflow: visible; text-overflow: clip; white-space: nowrap; }
.leads-table .lm-ellip { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leads-table td.lm-remark { white-space: normal; }
.leads-table .lm-remark-txt { display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--muted); font-size: 12.5px; line-height: 1.35; }
.leads-table .lm-remark-txt svg { width: 13px; height: 13px; vertical-align: -2px; }
.data .empty-row td {
  text-align: center;
  color: var(--muted);
  padding: var(--sp-6) var(--sp-3);
  font-size: var(--fs-sm);
}

tr.below-reorder { background: var(--danger-bg) !important; }
tr.below-reorder td:first-child { box-shadow: inset 4px 0 0 var(--danger); }

/* ---------- 10. Tags & pills (unified) ------------------------------ */
/* All status/category/role badges share this base. */
.tag, .role, .status, .shipstatus, .cat, .action {
  display: inline-block;
  padding: 2px var(--sp-2);
  border-radius: var(--r-pill);
  font-size: var(--fs-xxs);
  font-weight: 500;
  background: var(--surface-3);
  color: var(--fg-2);
  line-height: 1.5;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.cat, .action {
  border-radius: var(--r-sm);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.action { font-family: ui-monospace, Menlo, Consolas, monospace; text-transform: none; letter-spacing: 0; }

/* Role variants */
.role-admin         { background: var(--warn-bg);   color: var(--warn-fg); }
.role-store_manager { background: var(--success-bg);color: var(--success-fg); }
.role-hr            { background: var(--info-bg);   color: var(--info-fg); }
.role-viewer        { background: var(--surface-3); color: var(--fg-2); }
/* Outlet Workspace — a tight, muted section divider in the sidebar (no big gap) */
.sidenav-sep { font-size: var(--fs-xxs); text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 12px 4px; margin-top: 4px; border-top: 1px solid var(--border); }
/* Outlet Workspace roles */
.role-outlet_manager { background: var(--primary-soft); color: var(--primary); }
.role-outlet_sales   { background: var(--info-bg);      color: var(--info-fg); }
.role-outlet_stock   { background: var(--warn-bg);      color: var(--warn-fg); }
.role-warehouse      { background: var(--surface-3);    color: var(--fg-2); }

/* Employee status */
.status-active      { background: var(--success-bg);color: var(--success-fg); }
.status-on_leave    { background: var(--warn-bg);   color: var(--warn-fg); }
.status-exited      { background: var(--surface-3); color: var(--muted); }

/* Shipment status */
.shipstatus-in_transit { background: var(--warn-bg);   color: var(--warn-fg); }
.shipstatus-received   { background: var(--success-bg);color: var(--success-fg); }
.shipstatus-partial    { background: var(--info-bg);   color: var(--info-fg); }
.shipstatus-cancelled  { background: var(--surface-3); color: var(--muted); }

/* Material category */
.cat-packaging        { background: var(--warn-bg);   color: var(--warn-fg); }
.cat-raw              { background: var(--info-bg);   color: var(--info-fg); }
.cat-component        { background: var(--success-bg);color: var(--success-fg); }
.cat-finished_vehicle { background: #f3d6f5;          color: #5d1b4f; }

/* Audit action variants */
.action-failed_login        { background: var(--danger-bg);  color: var(--danger-fg); }
.action-login, .action-logout { background: var(--primary-soft); color: var(--info-fg); }

/* Movement-type variants (used on /movements) */
.mvtype { display: inline-block; padding: 2px var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-xxs); background: var(--surface-3); font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--fg-2); }
.mvtype-purchase, .mvtype-shipment_receipt, .mvtype-production_in,
.mvtype-adjust_in, .mvtype-opening_balance, .mvtype-transfer_in {
  background: var(--success-bg); color: var(--success-fg);
}
.mvtype-dispatch, .mvtype-production_out, .mvtype-adjust_out, .mvtype-transfer_out {
  background: var(--danger-bg); color: var(--danger-fg);
}
.qty-in  { color: var(--success-fg); font-weight: 600; }
.qty-out { color: var(--danger-fg);  font-weight: 600; }

/* ---------- 11. Alerts ---------------------------------------------- */
.error, .success, .flash {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  margin-bottom: var(--sp-4);
  font-size: var(--fs-sm);
  border: 1px solid transparent;
}
.error   { background: var(--danger-bg);  color: var(--danger-fg);  border-color: rgba(181, 48, 48, 0.18); }
.success { background: var(--success-bg); color: var(--success-fg); border-color: rgba(29, 138, 59, 0.18); }
.flash   { background: var(--primary-soft); color: var(--info-fg);  border-color: rgba(27, 77, 143, 0.15); }

/* ---------- 12. Key-value lists (detail pages) ---------------------- */
dl.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: var(--sp-1) var(--sp-4);
  margin: var(--sp-4) 0;
  padding: var(--sp-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
dl.kv dt { font-weight: 500; color: var(--muted); font-size: var(--fs-sm); padding: var(--sp-1) 0; }
dl.kv dd { margin: 0; padding: var(--sp-1) 0; }

/* ---------- 13. Filters & pagers (THE canonical list-page toolbar) --------
   UI Stabilization V1: every list page uses this one pattern —
   Search grows · selects/dates size to content · actions sit at the right end.
   <form class="filters"> [search input] [selects…] [dates…] <span class="spacer"></span> [buttons] */
.filters {
  display: flex; gap: var(--sp-2); margin-bottom: var(--sp-4);
  align-items: center; flex-wrap: wrap;
}
.filters input { flex: 1 1 200px; min-width: 160px; max-width: 340px; width: auto; }
.filters select { flex: none; width: auto; min-width: 110px; max-width: 180px; }
.filters input[type="date"], .filters input[type="month"] { flex: none; width: auto; min-width: 0; }
.filters input[type="number"] { flex: none; width: 90px; min-width: 0; }
.filters input[type="checkbox"], .filters input[type="radio"] { flex: none; min-width: 0; max-width: none; }
.filters label { margin: 0; display: inline-flex; align-items: center; gap: var(--sp-1); font-weight: 500; white-space: nowrap; }
.filters .spacer { margin-left: auto; }
.filters button, .filters .button { flex: none; }
.pager { display: flex; gap: var(--sp-3); margin-top: var(--sp-4); align-items: center; }
.pager .muted { margin: 0 auto; }

/* ---------- 14. Line form (shipment + purchase add-line) ------------ */
.line-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--sp-2) var(--sp-3);
  align-items: end;
  background: var(--surface);
  padding: var(--sp-4);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.line-form label { margin: 0; }
.line-form button { grid-column: -2 / -1; }

/* ---------- 15. Misc ------------------------------------------------- */
.json { white-space: pre-wrap; word-break: break-word; background: var(--surface-2); padding: var(--sp-2); border-radius: var(--r-sm); font-size: var(--fs-xs); margin: var(--sp-1) 0; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- 16. Login page (centered) ------------------------------ */
.login-shell {
  min-height: calc(100vh - var(--topbar-h) - 60px);
  display: flex; align-items: center; justify-content: center;
  padding: var(--sp-5);
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(36, 90, 160, 0.10), transparent 70%),
    var(--bg);
}
.login-shell .card {
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  border-radius: var(--r-xl);
  padding: var(--sp-7) var(--sp-6) var(--sp-6);
}
.login-shell .card::before {
  content: "T"; display: grid; place-items: center;
  width: 52px; height: 52px; margin: 0 0 var(--sp-4);
  border-radius: 14px; background: var(--grad-brand);
  color: #fff; font-size: 26px; font-weight: 800;
  box-shadow: var(--shadow-md);
}
.login-shell h1 { font-size: var(--fs-xxl); letter-spacing: -0.02em; }

/* ---------- 16.5 Login — modern landing-page style ----------------- */
.login-page { margin: 0; }
.login-stage {
  position: relative; min-height: 100vh; overflow: hidden;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 48px 24px; color: #fff;
  background:
    radial-gradient(900px 620px at 14% 16%, rgba(196, 24, 43, 0.55), transparent 58%),
    radial-gradient(820px 600px at 88% 86%, rgba(63, 165, 53, 0.32), transparent 60%),
    radial-gradient(680px 460px at 92% 6%, rgba(255, 255, 255, 0.07), transparent 60%),
    linear-gradient(135deg, #270a10 0%, #190709 52%, #0d1110 100%);
}
.login-orb { position: absolute; border-radius: 50%; filter: blur(72px); opacity: 0.5; pointer-events: none; }
.login-orb-1 { width: 380px; height: 380px; background: #d11f33; top: -90px; left: -60px; animation: orbFloat 15s ease-in-out infinite; }
.login-orb-2 { width: 420px; height: 420px; background: #3fa535; bottom: -120px; right: -80px; animation: orbFloat 19s ease-in-out infinite reverse; }
@keyframes orbFloat { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(26px, -26px); } }

.login-grid {
  position: relative; z-index: 1;
  display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 56px; align-items: center;
  width: 100%; max-width: 1000px;
}

.login-brand { animation: loginRise 700ms cubic-bezier(.2, .7, .2, 1) both; }
.login-pill {
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: 22px;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; letter-spacing: 0.02em;
  background: rgba(255, 255, 255, 0.10); border: 1px solid rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.login-pill-dot { width: 8px; height: 8px; border-radius: 50%; background: #3fde62; box-shadow: 0 0 10px #3fde62; }
.login-brand-logo {
  width: 78px; height: auto; display: block; margin-bottom: 22px;
  background: #fff; border-radius: 18px; padding: 9px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}
.login-brand h1 { font-size: 42px; line-height: 1.08; margin: 0 0 16px; font-weight: 800; letter-spacing: -0.03em; color: #fff; }
.login-grad {
  background: linear-gradient(100deg, #ff6b7a, #ffd27a 55%, #7dff8e);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-lede { font-size: 17px; line-height: 1.55; opacity: 0.86; margin: 0 0 24px; max-width: 440px; }
.login-feats { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 11px; }
.login-feats li { position: relative; padding-left: 30px; font-size: 14.5px; opacity: 0.9; }
.login-feats li::before {
  content: "\2713"; position: absolute; left: 0; top: 0;
  width: 20px; height: 20px; border-radius: 50%;
  background: linear-gradient(135deg, #d11f33, #3fa535); color: #fff;
  display: grid; place-items: center; font-size: 11px; font-weight: 800;
}
.login-motto { font-size: 15px; font-style: italic; opacity: 0.8; margin: 0; }

.login-card {
  position: relative;
  background: rgba(255, 255, 255, 0.96);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.55); border-radius: 22px;
  padding: 36px 34px 28px; color: var(--fg);
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.45);
  animation: loginRise 700ms cubic-bezier(.2, .7, .2, 1) 120ms both;
}
.login-card h2 { font-size: 26px; margin: 0; letter-spacing: -0.02em; color: #111827; font-weight: 700; }
.login-card-sub { color: #4b5563; font-size: 13px; margin: 4px 0 0; }
.login-card label { display: block; margin-top: 16px; font-weight: 700; font-size: 13.5px; color: #374151; }
.login-card input { width: 100%; margin-top: 6px; }
.login-submit {
  width: 100%; margin-top: 22px; padding: 12px; border: 0; border-radius: 10px;
  justify-content: center;   /* the global button rule sets inline-flex w/o this, which left-aligned the label */
  background: linear-gradient(135deg, #d11f33, #a3162a); color: #7dff8e;
  font-weight: 700; font-size: 15px; letter-spacing: 0.04em; cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.30);
  box-shadow: 0 8px 20px rgba(163, 22, 42, 0.35);
  transition: background 150ms, box-shadow 150ms, transform 150ms, color 150ms;
}
/* explicit hover bg + colour so the generic button:hover (light grey) can't win */
.login-submit:hover {
  background: linear-gradient(135deg, #b81a2d, #871222);
  color: #9dffb0;
  box-shadow: 0 12px 28px rgba(163, 22, 42, 0.45), 0 0 0 1px rgba(63, 165, 53, 0.5);
  transform: translateY(-1px);
}
.login-submit:active { transform: translateY(0); box-shadow: 0 6px 16px rgba(163, 22, 42, 0.42); }

/* Forgot password — present now, wired up next phase */
.login-forgot { margin-top: 12px; text-align: center; }
.login-forgot summary {
  display: inline-block; cursor: pointer; list-style: none;
  font-size: 13px; font-weight: 700; color: #8a1f1f;
}
.login-forgot summary::-webkit-details-marker { display: none; }
.login-forgot summary:hover { text-decoration: underline; }
.login-forgot p { margin: 8px auto 0; max-width: 300px; font-size: 12.5px; color: #4b5563; line-height: 1.45; }
.login-card-foot { margin-top: 16px; text-align: center; color: #4b5563; font-size: 12px; font-weight: 500; }

.login-credit { position: relative; z-index: 1; margin: 28px 0 0; font-size: 12.5px; color: #ffffff; }
.login-credit strong { color: #ffffff; font-weight: 700; }

@keyframes loginRise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

@media (max-width: 880px) {
  .login-grid { grid-template-columns: 1fr; gap: 30px; max-width: 430px; }
  .login-brand { text-align: center; }
  .login-pill, .login-brand-logo { margin-left: auto; margin-right: auto; }
  .login-brand h1 { font-size: 32px; }
  .login-lede { margin-left: auto; margin-right: auto; }
  .login-feats { display: none; }
}
@media (prefers-reduced-motion: reduce) { .login-orb, .login-brand, .login-card { animation: none; } }

/* ---------- 17. Home dashboard accents ------------------------------ */
.kpi {
  display: grid; gap: var(--sp-1);
  padding: var(--sp-3) 0;
}
.kpi .num {
  font-size: var(--fs-xxl);
  font-weight: 600;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}
.kpi .label { color: var(--muted); font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.5px; }
.card.dash {
  border-top: 3px solid var(--primary);
  /* Flex column so .dash-actions can sit at the bottom regardless of how much
     content the card has — keeps tile bottoms aligned in a grid row. */
  display: flex;
  flex-direction: column;
}
/* Card-tone modifiers (warn/success/danger) share names with alert utility
   classes (.success at line ~480, etc.). Without these resets the alert
   styles bleed into the dashboard tile — green background, 8px padding,
   text color override. Specificity 030 here beats the 010 alert rules,
   so we explicitly reset every property the alert utilities set. */
.card.dash.warn,
.card.dash.success,
.card.dash.danger {
  background: var(--surface);
  color: inherit;
  padding: var(--sp-5);
  margin: 0;                       /* alert utility sets margin-bottom: 16px */
  font-size: inherit;              /* alert utility sets fs-sm */
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
}
.card.dash.warn    { border-top: 3px solid var(--warn); }
.card.dash.success { border-top: 3px solid var(--success); }
.card.dash.danger  { border-top: 3px solid var(--danger); }
.dash-actions {
  display: flex; gap: var(--sp-2); flex-wrap: wrap;
  margin-top: auto;        /* push to bottom of the card */
  padding-top: var(--sp-3);
}
.dash-actions a { font-size: var(--fs-sm); }

/* ---------- 18. Active page in nav --------------------------------- */
.nav .navlink.active,
.nav .navtrigger.active { background: var(--primary-soft); color: var(--info-fg); font-weight: 500; }
.navgroup .navmenu a.active { background: var(--primary-soft); color: var(--info-fg); font-weight: 500; }

/* ---------- 19. Mobile table scroll wrap --------------------------- */
/* Data-grid scroll container: the table scrolls inside this box (BOTH axes), so
   the header row freezes (sticky to this box's top) and horizontal scroll stays
   ON THE TABLE — the page and sidebar never move sideways. Tables are wrapped in
   this automatically by app.js (§ table-wrap). */
.table-scroll {
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - var(--topbar-h) - 190px);
  margin: var(--sp-3) 0;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}
.table-scroll > .data { margin: 0; border: 0; border-radius: 0; }
.table-scroll > .data { margin: 0; }

/* Make sure tables inside scroll wrappers don't collapse weirdly */
@media (max-width: 720px) {
  .data { font-size: var(--fs-sm); }
  .data th, .data td { padding: var(--sp-1) var(--sp-2); }
  .container { padding: var(--sp-3); }
}

/* ---------- 20. Dark mode (token override) ------------------------- */
[data-theme="dark"] {
  /* Premium BLACK enterprise — true-black/charcoal/dark-gray (no navy tint).
     Primary blue #1658E5 kept for buttons/links/active/selected/focus. */
  --bg:           #0d0d0f;       /* near-black canvas */
  --surface:      #161618;       /* charcoal panels, tables, inputs, topbar */
  --surface-2:    #1d1d20;       /* alt rows, table header */
  --surface-3:    #26262b;       /* hover, chips */
  --border:       #2e2e34;       /* subtle dividers */
  --border-strong:#3d3d45;
  --fg:           #f0f0f2;
  --fg-2:         #c2c2ca;
  --muted:        #8a8a93;

  --primary:        #1658E5;     /* Tunwal primary blue */
  --primary-fg:     #ffffff;
  --primary-soft:   #182236;     /* subtle selected fill (minimal blue tint) */
  --primary-hover:  #2f6bef;
  --grad-brand:     linear-gradient(135deg, #2f6bef 0%, #1658E5 100%);
  --danger-hover:   #c25555;
  --danger-fg-inv:  #ffffff;

  --success:      #4ade80;
  --success-bg:   #14311f;
  --success-fg:   #a7f0ba;

  --warn:         #fbbf24;
  --warn-bg:      #352a0d;
  --warn-fg:      #f5d98b;

  --danger:       #f87171;
  --danger-bg:    #3a1c1c;
  --danger-fg:    #f3b4b4;

  --info-bg:      #16233c;
  --info-fg:      #a9c5f5;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.55);

  /* Native widgets go dark too — select dropdown lists, date-picker calendars,
     checkboxes, scrollbars. Without this they render light-on-light. */
  color-scheme: dark;
  --select-arrow: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a8a93' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}
/* Readable link blue on dark — --primary (#1658E5) stays for button FILLS (white
   text on blue is fine), but as TEXT on dark surfaces it is ~2.4:1. Same accessible
   blue the sidebar active state already uses. (UI Stabilization V1, measured.) */
[data-theme="dark"] a:not(.button) { color: #6ea0f5; }
[data-theme="dark"] .avatar { color: #6ea0f5; }
[data-theme="dark"] button.link { color: #6ea0f5; }
[data-theme="dark"] .navgroup .navmenu .theme-seg-btn.active { color: var(--fg); border-color: transparent; }
[data-theme="dark"] .data tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.025); }
[data-theme="dark"] tr.below-reorder { background: #4a2222 !important; }
[data-theme="dark"] .cat-finished_vehicle { background: #3a1f3a; color: #f0c6e8; }

/* ---------- 20a. Dark theme polish (restrained / enterprise) -------
   Deliberately NOT the flashy reference: no neon glow, no metallic text, no
   translucent blur. An ops system must read crisp at a glance over long shifts,
   so this keeps solid surfaces, high-contrast numbers, and quiet accents. */
[data-theme="dark"] .sidebar { background: #0a0a0b; border-right-color: #232327; }
/* Crisp primary-blue active rail (a clean indicator line, no blur). */
[data-theme="dark"] .sidenav .sidelink.active {
  background: rgba(22, 88, 229, 0.15);
  color: #cfe0ff;
  box-shadow: inset 3px 0 0 #1658E5;
}
[data-theme="dark"] .sidenav .sidelink.active .sideicon { color: #6ea0f5; }
[data-theme="dark"] .sidenav .sidegroup-head.active { color: #6ea0f5; }

/* Cards: solid elevated panel, 12px corners, a single hairline top rim-light.
   No translucency/blur — dense tables and forms stay legible. */
[data-theme="dark"] .card {
  border-radius: 12px;
  border-top-color: rgba(255, 255, 255, 0.10);
}
/* (button hover handled by token swap above) */

/* ---------- 20b. Blue theme (token override + blue sidebar) --------- */
/* Requested: NOT dark-blue — light-blue surfaces everywhere, with the sidebar
   in a strong blue. The sidebar gets explicit overrides (below) because in
   light/dark it leans on the neutral --surface tokens, which would otherwise
   make it light here too. */
[data-theme="blue"] {
  /* Modern premium enterprise BLUE (Flowly-inspired) — bright, clean, NOT dark.
     Off-white canvas, white cards, soft-blue borders, deep-navy sidebar only. */
  --bg:            #F5F7F8;       /* off-white page */
  --surface:       #ffffff;       /* white cards/tables/inputs */
  --surface-2:     #EEF3FA;       /* alt rows, table header — very light blue */
  --surface-3:     #DBE7F6;       /* hover, chips — soft blue */
  --border:        #C9DAF0;       /* soft-blue dividers / borders */
  --border-strong: #AAC7EB;       /* soft blue (palette) */
  --fg:            #0F1B2D;       /* deep navy text */
  --fg-2:          #3A4657;       /* secondary */
  --muted:         #535C6A;       /* slate gray tertiary */

  --primary:       #1658E5;       /* primary blue */
  --primary-fg:    #ffffff;
  --primary-soft:  #E3EDFC;       /* light-blue active/selected fills */
  --primary-hover: #0D3CBB;       /* royal blue */
  --grad-brand:    linear-gradient(135deg, #1658E5 0%, #0D3CBB 100%);
  --danger-hover:  #921e1e;
  --danger-fg-inv: #ffffff;

  --success:    #1d8a3b;  --success-bg: #e3f5e1;  --success-fg: #14572a;
  --warn:       #b06b00;  --warn-bg:    #fde8c8;  --warn-fg:    #6f4a0c;
  --danger:     #b53030;  --danger-bg:  #fde8e8;  --danger-fg:  #8a1f1f;
  --info-bg:    #dbeafe;  --info-fg:    #0D3CBB;   /* sky/royal-blue info */

  --shadow-sm: 0 1px 2px rgba(16, 42, 110, 0.06), 0 1px 1px rgba(16, 42, 110, 0.05);
  --shadow-md: 0 2px 4px rgba(16, 42, 110, 0.06), 0 10px 24px rgba(16, 42, 110, 0.10);
  --shadow-lg: 0 18px 40px rgba(16, 42, 110, 0.14), 0 6px 12px rgba(16, 42, 110, 0.07);
}
/* Deep-navy sidebar (the one dark element in an otherwise bright theme) —
   overrides the neutral --surface gradient used in light. */
[data-theme="blue"] .sidebar {
  background: #030D25;            /* deep navy rail */
  border-right-color: #0a1836;
}
[data-theme="blue"] .sidenav .sidelink { color: #c5d3e8; }
[data-theme="blue"] .sidenav .sidegroup .sidelink { color: #a9bcda; }
[data-theme="blue"] .sidenav .sidegroup-head { color: #b8c8e0; }
[data-theme="blue"] .sidenav .sidelink:hover,
[data-theme="blue"] .sidenav .sidegroup-head:hover { background: rgba(255, 255, 255, 0.07); color: #ffffff; }
[data-theme="blue"] .sidenav .sidelink.active {
  background: rgba(22, 88, 229, 0.24);
  color: #ffffff;
  box-shadow: inset 3px 0 0 #1658E5;   /* primary-blue rail */
}
[data-theme="blue"] .sidenav .sidelink.active .sideicon { color: #5498EF; }
[data-theme="blue"] .sidenav .sidegroup-head.active { color: #ffffff; }
[data-theme="blue"] .sidenav .sidegroup-toggle { color: #8fa3c4; }
[data-theme="blue"] .sidenav .sidegroup-toggle:hover { color: #ffffff; background: rgba(255, 255, 255, 0.08); }
[data-theme="blue"] .sidebar-foot { color: #8fa3c4; border-top-color: rgba(255, 255, 255, 0.10); }
/* Crisp white card lift on the off-white canvas — subtle top highlight + soft shadow. */
[data-theme="blue"] .card {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 4px 12px rgba(16, 42, 110, 0.07);
}

/* ---------- 20c. Theme switcher (account dropdown) ----------------- */
/* Scoped under .navmenu so these beat the generic menu-item button rules
   (.navgroup .navmenu button — which force display:block / width:100% / left). */
/* Theme control — a single-row segmented toggle (cakjs-crm pattern): equal segments
   inside a track, active = a raised pill. Fits one row; no wrapping label. */
/* Apple / iOS-style segmented control: an inset track with a single raised pill (thumb)
   that SLIDES to the active theme with Apple's spring easing. The thumb is one element
   moved by transform (driven purely by :has() on which segment is .active). */
.navgroup .navmenu .theme-seg {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 0;
  margin: 3px var(--sp-1) 4px; padding: 3px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: inset 0 1px 2px rgba(20, 30, 50, 0.07);
}
.navgroup .navmenu .theme-seg-label { display: none; }
.navgroup .navmenu .theme-seg-thumb {
  position: absolute; top: 3px; bottom: 3px; left: 3px; width: calc((100% - 6px) / 3);
  border-radius: calc(var(--r-lg) - 3px); background: var(--surface);
  box-shadow: 0 1px 2px rgba(20, 30, 50, 0.16), 0 1px 1px rgba(20, 30, 50, 0.06);
  z-index: 0; pointer-events: none;
  transition: transform 320ms cubic-bezier(0.32, 0.72, 0, 1);   /* Apple spring */
}
.navgroup .navmenu .theme-seg:has([data-theme-set="light"].active) .theme-seg-thumb { transform: translateX(0); }
.navgroup .navmenu .theme-seg:has([data-theme-set="blue"].active)  .theme-seg-thumb { transform: translateX(100%); }
.navgroup .navmenu .theme-seg:has([data-theme-set="dark"].active)  .theme-seg-thumb { transform: translateX(200%); }
.navgroup .navmenu .theme-seg-btn {
  position: relative; z-index: 1;
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; width: 100%;
  border: 0; background: transparent; color: var(--muted);
  padding: 5px 4px; border-radius: calc(var(--r-lg) - 3px); font-size: var(--fs-xxs); font-weight: 500; cursor: pointer;
  transition: color 200ms ease;
}
.navgroup .navmenu .theme-seg-btn:hover { background: transparent; color: var(--fg-2); }
.navgroup .navmenu .theme-seg-btn.active { background: transparent; color: var(--fg); font-weight: 600; box-shadow: none; }
@media (prefers-reduced-motion: reduce) { .navgroup .navmenu .theme-seg-thumb { transition: none; } }
/* Dark / blue themes: the raised pill must be LIGHTER than the track (surface is darkest there). */
[data-theme="dark"] .navgroup .navmenu .theme-seg-thumb,
[data-theme="blue"] .navgroup .navmenu .theme-seg-thumb { background: var(--surface-3); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35); }

/* Premium account drawer — match cakjs-crm: rounder surface, iconed items, comfy hover. */
.side-profile .navmenu-up { border-radius: var(--r-xl); }
.side-profile .navmenu-up a,
.side-profile .navmenu-up button:not(.theme-seg-btn) {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 10px; border-radius: var(--r-md);
  font-size: var(--fs-sm); font-weight: 500; color: var(--fg-2);
}
.side-profile .navmenu-up a:hover,
.side-profile .navmenu-up button:not(.theme-seg-btn):hover { background: color-mix(in srgb, var(--surface-3) 75%, transparent); color: var(--fg); }
.side-profile .navmenu-up .mi { flex: 0 0 auto; width: 16px; height: 16px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.side-profile .navmenu-up .mi svg { width: 16px; height: 16px; }
.side-profile .navmenu-up a:hover .mi,
.side-profile .navmenu-up button:not(.theme-seg-btn):hover .mi { color: var(--fg-2); }
.side-profile .navmenu-up .navmenu-sep { height: 1px; background: var(--border); margin: 4px 6px; }
.side-profile .navlogout { margin: 4px 0 0; padding: 4px 0 0; border-top: 1px solid var(--border); }
.side-profile .navlogout button { color: var(--danger); font-weight: 600; }
.side-profile .navlogout button:hover { background: var(--danger-bg); color: var(--danger); }
.side-profile .navlogout .mi { color: var(--danger); }
.theme-dot { width: 11px; height: 11px; border-radius: 50%; border: 1px solid rgba(0, 0, 0, 0.18); flex: none; }
.theme-dot-light { background: #ffffff; }
.theme-dot-blue { background: #2f6fe0; }
.theme-dot-dark { background: #181c25; }

/* ---------- 21. Keyboard shortcut help modal ----------------------- */
.kbd-help-shell {
  display: none;
  position: fixed; inset: 0;
  background: rgba(15, 18, 23, 0.55);
  z-index: 2000;
  align-items: center; justify-content: center;
  padding: var(--sp-4);
}
.kbd-help-shell.open { display: flex; }
.kbd-help-shell .card { max-width: 480px; width: 100%; }
kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font: 500 11px ui-monospace, Menlo, Consolas, monospace;
  color: var(--fg);
  min-width: 18px; text-align: center;
}
.kbd-table { width: 100%; }
.kbd-table td { padding: var(--sp-1) var(--sp-2); }
.kbd-table td:first-child { white-space: nowrap; width: 1%; }

/* ---------- 22. Empty-state CTA box (replaces "No X match") -------- */
.empty-state {
  text-align: center;
  padding: var(--sp-6) var(--sp-4);
  color: var(--muted);
}
.empty-state h3 { color: var(--fg-2); margin: 0 0 var(--sp-1); }
.empty-state p { margin: 0 0 var(--sp-3); font-size: var(--fs-sm); }
.empty-state .button { margin-top: var(--sp-1); }
.data .empty-row td .empty-state { padding: var(--sp-5) var(--sp-3); }

/* ---------- 23. Sticky filter bar ---------------------------------- */
.filters.sticky, .filters {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  padding: var(--sp-3) 0;
  margin-bottom: var(--sp-3);
  border-bottom: 1px solid transparent;
  transition: border-color 200ms ease;
}
.filters.sticky-active, .filters:not(:first-of-type),
.filters.is-stuck { border-bottom-color: var(--border); }
/* Pull the page background up under the filters so content doesn't bleed through */

/* ---------- 24. Toasts (auto-dismissing notifications) ------------- */
.toast-container {
  position: fixed; top: calc(var(--topbar-h) + var(--sp-3)); right: var(--sp-4);
  z-index: 1500;
  display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none;
  max-width: 360px;
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  box-shadow: var(--shadow-md);
  font-size: var(--fs-sm);
  display: flex; align-items: flex-start; gap: var(--sp-2);
  animation: toast-in 220ms ease-out;
}
.toast.success { border-left-color: var(--success); }
.toast.warn    { border-left-color: var(--warn); }
.toast.danger  { border-left-color: var(--danger); }
.toast .toast-msg { flex: 1; }
.toast .toast-close {
  background: none; border: none; padding: 2px 6px;
  color: var(--muted); cursor: pointer; font: inherit; line-height: 1;
}
.toast.leaving { animation: toast-out 220ms ease-in forwards; }
@keyframes toast-in  { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes toast-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(20px); opacity: 0; } }

/* Hide the legacy inline flash blocks (rendered through partials/flash.ejs);
   the same partial now emits a .toast inside .toast-container instead. */

/* ---------- 25. Breadcrumbs ---------------------------------------- */
.breadcrumbs {
  font-size: var(--fs-sm);
  color: var(--muted);
  margin: 0 0 var(--sp-3);
  display: flex; flex-wrap: wrap; gap: var(--sp-1);
  align-items: center;
}
.breadcrumbs a { color: var(--muted); text-decoration: none; }
.breadcrumbs a:hover { color: var(--fg); text-decoration: underline; }
.breadcrumbs .sep { opacity: 0.5; }
.breadcrumbs .current { color: var(--fg); font-weight: 500; }

/* ---------- 26. Form inline validation hints ----------------------- */
label .req { color: var(--danger); margin-left: 2px; font-weight: 600; }
label .hint { color: var(--muted); font-weight: 400; font-size: var(--fs-xs); margin-left: var(--sp-2); }
label .counter { float: right; color: var(--muted); font-weight: 400; font-size: var(--fs-xs); }
input:user-invalid,
textarea:user-invalid { border-color: var(--danger); }
input:user-invalid:focus,
textarea:user-invalid:focus { outline-color: var(--danger); }
.field-error { color: var(--danger-fg); font-size: var(--fs-xs); margin-top: var(--sp-1); }

/* ---------- 27. Sectioned forms (employees & similar) ---------------- */
.form-stacked { max-width: 720px; }
.form-section {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4) var(--sp-4);
  margin: 0 0 var(--sp-4);
  background: var(--surface);
}
/* A native <legend> gets special "rendered legend" treatment — it straddles the
   fieldset's top border, so the heading pokes ABOVE the box. display:block does
   NOT stop this in Chrome; only float (or absolute positioning) disqualifies a
   legend from that special rendering. So we float it full-width and clear the
   following fields, making it a normal heading INSIDE the box. Fixes
   "Identity / Contact / …" sitting outside the box on every .form-section form. */
.form-section > legend {
  float: left;
  width: 100%;
  box-sizing: border-box;
  margin: 0 0 var(--sp-3);
  padding: 0;
  font-weight: 600;
  font-size: var(--fs-sm);
  color: var(--fg);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.form-section > legend ~ * { clear: both; }
.form-section > legend .hint { text-transform: none; letter-spacing: 0; }
.grid-3 {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.grid-3 > label { margin: 0; }
@media (max-width: 720px) { .grid-3 { grid-template-columns: 1fr; } }
.checks { display: flex; flex-wrap: wrap; gap: var(--sp-4); margin: var(--sp-3) 0 var(--sp-1); }
label.check { display: inline-flex; align-items: center; gap: var(--sp-2); margin: 0; cursor: pointer; }
label.check input { width: auto; margin: 0; }
.form-actions { display: flex; gap: var(--sp-2); margin-top: var(--sp-3); }
.file-current {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-xs); color: var(--muted);
  margin: var(--sp-2) 0;
}
.file-current .thumb {
  width: 48px; height: 48px; object-fit: cover;
  border: 1px solid var(--border); border-radius: var(--r-sm);
}

/* ---------- 28. Employee detail: photo + masked PII ----------------- */
.emp-photo {
  width: 96px; height: 96px; object-fit: cover;
  border: 1px solid var(--border); border-radius: var(--r-md);
}
.emp-photo-placeholder {
  width: 96px; height: 96px; border: 1px solid var(--border);
  border-radius: var(--r-md); display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-2); color: var(--muted);
  font-size: 28px; font-weight: 600;
}
.pii-row {
  display: flex; align-items: center; gap: var(--sp-2);
  font-variant-numeric: tabular-nums;
}
.pii-row .masked { font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace); }
.btn-unmask { padding: 2px 8px; font-size: var(--fs-xs); }

/* List-page avatar thumb */
td.avatar { padding: 4px 8px; width: 48px; }
.avatar-thumb {
  width: 36px; height: 36px; object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border);
  display: block;
}
.avatar-initials {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--surface-2); color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--fs-xs); font-weight: 600;
  border: 1px solid var(--border);
}

/* ---------- 29. Compact home dashboard (KPI tiles + activity) ------- */
.home-hero {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: var(--sp-3); margin: var(--sp-2) 0 var(--sp-4);
}
.home-hero h1 { margin: 0 0 4px; font-size: var(--fs-xl); }
.kpi-strip {
  display: grid; gap: var(--sp-3);
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  margin: 0 0 var(--sp-5);
}
.kpi-tile {
  display: flex; flex-direction: column; gap: 4px;
  padding: var(--sp-4) var(--sp-4) var(--sp-3);
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  text-decoration: none; color: inherit;
  transition: border-color 120ms, box-shadow 120ms, transform 120ms;
}
.kpi-tile:hover {
  border-left-color: var(--primary-hover, var(--primary));
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 2px 8px rgba(0,0,0,0.04);
  transform: translateY(-1px);
}
.kpi-tile[data-tone="inventory"]   { border-left-color: #2e7d32; }
.kpi-tile[data-tone="procurement"] { border-left-color: #ed6c02; }
.kpi-tile[data-tone="admin"]       { border-left-color: #6a1b9a; }
.kpi-tile .kpi-label {
  font-size: var(--fs-xs); text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); font-weight: 600;
}
.kpi-tile .kpi-num {
  font-size: 28px; font-weight: 700; line-height: 1.1;
  font-variant-numeric: tabular-nums; color: var(--fg);
}
.kpi-tile .kpi-num-suffix { font-size: 16px; vertical-align: top; color: var(--muted); margin-left: 2px; }
.kpi-tile .kpi-sub { font-size: var(--fs-xs); color: var(--muted); }
.kpi-tile .kpi-cta {
  margin-top: 6px; font-size: var(--fs-xs); color: var(--primary); font-weight: 500;
}

/* ---------- 29.5 Searchable combobox (live option search) ---------- */
.combobox { position: relative; }
.combobox-input { width: 100%; }
.combobox-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 60;
  margin: 0; padding: 4px; list-style: none;
  max-height: 260px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--r-md); box-shadow: var(--shadow-md);
  display: none;
}
.combobox.open .combobox-list { display: block; }
.combobox-list li {
  padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer;
  font-size: var(--fs-sm); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.combobox-list li:hover { background: var(--surface-3); }
.combobox.no-match .combobox-list::after {
  content: 'No match'; display: block; padding: 6px 10px;
  color: var(--muted); font-size: var(--fs-xs);
}
.combobox-input.combobox-invalid { border-color: var(--danger); }

.activity-strip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  max-width: 720px;
}
.activity-strip h3 {
  margin: 0 0 var(--sp-2); font-size: var(--fs-sm);
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted);
}
/* Collapsible dashboard widgets: the h3 is the fold target; collapsing hides
   everything in the panel except the header, and rotates the caret. */
.activity-strip .widget-toggle {
  cursor: pointer; user-select: none; display: flex; align-items: center; gap: var(--sp-2);
}
.activity-strip .widget-toggle:hover { color: var(--fg-2); }
.activity-strip .widget-caret {
  display: inline-block; transition: transform 120ms; font-size: 0.85em; line-height: 1;
}
.activity-strip.collapsed { padding-bottom: var(--sp-3); }
.activity-strip.collapsed .widget-caret { transform: rotate(-90deg); }
.activity-strip.collapsed > *:not(.widget-toggle) { display: none; }
/* Widget chooser (§Phase D): hidden widgets removed from the dashboard. */
.activity-strip.widget-hidden { display: none; }

/* Ledger tabs — switch between the raw-material and vehicle stock/movements views. */
.ledger-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 var(--sp-3); flex-wrap: wrap; }
.ledger-tabs a {
  padding: 8px 14px; color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; font-weight: 500; font-size: var(--fs-sm);
}
.ledger-tabs a:hover { color: var(--fg); text-decoration: none; }
.ledger-tabs a.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.activity-list {
  list-style: none; padding: 0; margin: 0 0 var(--sp-3);
  font-size: var(--fs-sm); font-variant-numeric: tabular-nums;
}
.activity-list li {
  display: grid;
  grid-template-columns: 56px 90px 1fr;
  gap: var(--sp-2);
  align-items: baseline;
  padding: 4px 0;
  border-bottom: 1px solid var(--border-soft, var(--border));
}
.activity-list li:last-child { border-bottom: 0; }
.activity-list .actor { font-weight: 500; color: var(--fg); }
.activity-list .action { color: var(--fg-2); }

/* ---------- 41. Dealer portal (mobile-first cockpit, calm/premium) -- */
.portal-topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface);
  border-bottom: 1px solid var(--border); box-shadow: var(--shadow-sm);
}
.portal-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; color: var(--primary); font-size: var(--fs-lg); letter-spacing: -0.01em; text-decoration: none; }
.portal-nav { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.portal-nav a { padding: 7px 11px; border-radius: var(--r-md); color: var(--fg-2); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; }
.portal-nav a:hover { background: var(--surface-3); color: var(--fg); text-decoration: none; }
.portal-nav a.active { background: var(--primary-soft); color: var(--primary); }
.portal-nav form { margin: 0; }

.portal-main { max-width: 1000px; margin: 0 auto; padding: 18px; }
.portal-main.narrow { max-width: 680px; }
.portal-main > h1 { font-size: var(--fs-xxl); letter-spacing: -0.01em; }

.portal-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 14px 0; }
.portal-kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.portal-kpi .k-label { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.portal-kpi .k-value { font-size: var(--fs-xl); font-weight: 700; margin-top: 3px; line-height: 1.1; }
.portal-kpi .k-sub { font-size: var(--fs-xs); color: var(--muted); }

.portal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.portal-actions .button { flex: 1 1 160px; justify-content: center; text-align: center; padding: 11px 14px; }

.portal-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px 18px; margin: 14px 0; box-shadow: var(--shadow-sm); }
.portal-card > h3:first-child { margin-top: 0; }

/* Mobile: tighter padding; data tables scroll inside their own strip, not the page. */
@media (max-width: 640px) {
  .portal-topbar { padding: 9px 12px; }
  .portal-brand { font-size: var(--fs-md); }
  .portal-main { padding: 12px; }
  .portal-main > h1 { font-size: var(--fs-xl); }
  .portal-main .data { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .portal-actions .button { flex-basis: 100%; }
}
/* Printing an invoice: hide the portal chrome + anything marked .no-print. */
@media print {
  .portal-topbar, .no-print { display: none !important; }
  .portal-main { max-width: none; padding: 0; }
}

/* ----- Mini-CRM: tone utilities, chips, funnel, timeline, fields ----- */
/* Semantic text tones (namespaced per §2.C to avoid utility/cascade collisions). */
.tone-success { color: var(--success); }
.tone-warn    { color: var(--warn); }
.tone-danger  { color: var(--danger); }

/* Badge — used across my/, team/, admin, timesheets (~55 places) but previously
   UNDEFINED (rendered as bare text). Pill shape consistent with .tag; tone-*
   variants use the semantic bg/fg pairs so they read in light AND dark.
   (UI Stabilization V1) */
.badge {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: 2px var(--sp-2); border-radius: var(--r-pill);
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.5;
  background: var(--surface-3); color: var(--fg-2); white-space: nowrap;
}
.badge.tone-success { background: var(--success-bg); color: var(--success-fg); }
.badge.tone-warn    { background: var(--warn-bg);    color: var(--warn-fg); }
.badge.tone-danger  { background: var(--danger-bg);  color: var(--danger-fg); }

/* Vertical label/control field (label is display:block globally; stack its parts). */
.field { margin: 0; }
.field > span { display: block; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 3px; }
/* The JS-inserted required asterisk (span.req) must stay inline with the label text,
   not become a block (which the .field > span rule above would otherwise force). */
.field > span.req { display: inline; margin-bottom: 0; }
.field > input, .field > select, .field > textarea { width: 100%; }

/* Stage filter chips. */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 12px 0; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--border); color: var(--fg-2); font-size: var(--fs-sm); text-decoration: none; text-transform: capitalize; }
.chip:hover { background: var(--surface-3); color: var(--fg); text-decoration: none; }
.chip.active { background: var(--primary-soft); border-color: var(--primary-soft); color: var(--primary); font-weight: 600; }
.chip-n { font-size: var(--fs-xxs); background: var(--surface-3); color: var(--muted); border-radius: var(--r-pill); padding: 0 6px; min-width: 16px; text-align: center; }
.chip.active .chip-n { background: #fff; color: var(--primary); }

/* Funnel progress bar. */
.funnel { display: flex; gap: 0; margin: 14px 0; overflow-x: auto; }
.funnel-step { flex: 1 1 0; min-width: 80px; text-align: center; position: relative; padding-top: 18px; font-size: var(--fs-xs); color: var(--muted); text-transform: capitalize; }
.funnel-step .dot { position: absolute; top: 4px; left: 50%; transform: translateX(-50%); width: 12px; height: 12px; border-radius: 50%; background: var(--surface-3); border: 2px solid var(--border-strong); z-index: 1; }
.funnel-step::before { content: ''; position: absolute; top: 9px; left: 0; width: 100%; height: 2px; background: var(--border); }
.funnel-step:first-child::before { left: 50%; width: 50%; }
.funnel-step:last-child::before { width: 50%; }
.funnel-step.done .dot, .funnel-step.current .dot { background: var(--primary); border-color: var(--primary); }
.funnel-step.done::before { background: var(--primary); }
.funnel-step.current { color: var(--primary); font-weight: 600; }

/* Two-column responsive split for detail pages. */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: start; }
@media (max-width: 720px) { .two-col { grid-template-columns: 1fr; } }

/* Lead activity timeline. */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline > li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.timeline > li:last-child { border-bottom: 0; }
.timeline .t-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; }
.timeline .followup { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap;
  margin-top: 6px; padding: 6px 10px; border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.timeline .followup.overdue { background: var(--danger-bg); }
.timeline .followup.done { opacity: 0.6; }

/* ---------- 40. Sidebar icons + collapsible icon-rail --------------- */
:root { --sidebar-w-collapsed: 68px; }

/* Inline SVG icons sit left of the label. Stroke icons inherit currentColor. */
.sideicon { flex: 0 0 20px; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.sideicon svg { width: 20px; height: 20px; display: block; stroke: currentColor; }
.sidelabel { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidegroup-head .sideicon { color: var(--primary); }

/* The collapse toggle lives in the sidebar foot. */
.sidebar-collapse-btn {
  display: inline-flex; align-items: center; gap: var(--sp-2);
  width: 100%; padding: var(--sp-2) var(--sp-3); margin: 0;
  background: transparent; border: 0; border-radius: var(--r-md);
  color: var(--fg-2); font-size: var(--fs-sm); cursor: pointer; line-height: 1;
  transition: background-color 160ms ease, color 160ms ease, transform 160ms ease;
}
.sidebar-collapse-btn:hover { background: var(--surface-3); color: var(--fg); transform: scale(1.03); }
.sidebar-collapse-btn:active { transform: scale(0.98); }
.sidebar-collapse-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.sidebar-collapse-btn .sideicon { transition: transform 160ms ease; }

/* ----- Collapsed (icon-only) rail ----- */
/* max-width must move with the collapsed basis, or the expanded cap (240px) would let the
   collapsed rail be wider than intended the moment any content pushed against it. */
.app-shell.nav-collapsed .sidebar { flex-basis: var(--sidebar-w-collapsed); width: var(--sidebar-w-collapsed); max-width: var(--sidebar-w-collapsed); padding-left: var(--sp-1); padding-right: var(--sp-1); }
.app-shell.nav-collapsed .sidelabel,
.app-shell.nav-collapsed .sidegroup-toggle,
.app-shell.nav-collapsed .sidegroup-items,
.app-shell.nav-collapsed .sidebar-foot > span { display: none; }  /* hide version text only — icons survive */
.app-shell.nav-collapsed .sidebar-foot .sidelink-settings { justify-content: center; padding-left: 0; padding-right: 0; }
/* Centre every icon; group heads become tappable icon tiles to the overview. */
.app-shell.nav-collapsed .sidenav .sidelink,
.app-shell.nav-collapsed .sidenav .sidegroup-head {
  justify-content: center; padding-left: 0; padding-right: 0;
}
/* Sub-links are hidden when collapsed (group icon links to the overview); keep
   only the top-level group head + Home reachable as icons. */
.app-shell.nav-collapsed .sidegroup .sidelink { display: none; }
.app-shell.nav-collapsed .sidegroup { margin-top: var(--sp-2); }
.app-shell.nav-collapsed .sidegroup-head {
  font-size: 0;                /* hide the (now-uppercase) text node if any leaks */
  padding-top: var(--sp-2); padding-bottom: var(--sp-2);
  border-radius: var(--r-md);
}
.app-shell.nav-collapsed .sidegroup-head:hover { background: var(--surface-3); }
.app-shell.nav-collapsed .sidegroup-head.active { background: var(--primary-soft); }
.app-shell.nav-collapsed .sidebar-collapse-btn { justify-content: center; }
.app-shell.nav-collapsed .sidebar-collapse-btn .sideicon { transform: rotate(180deg); }

/* The whole collapsed rail reads as one click target: pointer everywhere, a
   subtle brighten + inset right-border on hover, and a clear focus ring. The
   nav icons/group heads keep their own hover tiles on top; JS lets only empty
   space expand (icon clicks still navigate). */
.app-shell.nav-collapsed .sidebar { cursor: pointer; }
.app-shell.nav-collapsed .sidebar:hover {
  box-shadow: inset 0 0 0 100vh color-mix(in srgb, var(--surface-3) 55%, transparent),
              inset -2px 0 0 var(--border-strong);
}
.app-shell.nav-collapsed .sidebar:focus-visible {
  outline: 2px solid var(--primary); outline-offset: -2px;
}
/* Respect reduced-motion — keep it functional, drop the movement. */
@media (prefers-reduced-motion: reduce) {
  .sidebar, .sidebar-collapse-btn, .sidebar-collapse-btn .sideicon { transition: none; }
  .sidebar-collapse-btn:hover, .sidebar-collapse-btn:active { transform: none; }
}
/* On mobile the sidebar is an off-canvas drawer — never apply the icon-rail there. */
@media (max-width: 720px) {
  .app-shell.nav-collapsed .sidebar { flex-basis: var(--sidebar-w); width: var(--sidebar-w); }
  .app-shell.nav-collapsed .sidelabel, .app-shell.nav-collapsed .sidegroup .sidelink { display: revert; }
}


/* ====================================================================
   42. Dealer portal v2 — premium + brand warmth (hamburger drawer,
   icon-led KPIs, identity header, progress, clean checklist)
   ==================================================================== */

/* ---- Topbar refinements + hamburger drawer ---- */
.portal-topbar { background: linear-gradient(180deg, var(--surface) 0%, var(--surface) 100%); }
.portal-brand { gap: 9px; }
.portal-brand .brandmark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--grad-brand); color: #fff; box-shadow: var(--shadow-sm);
}
.portal-brand .brandmark svg { width: 18px; height: 18px; display: block; }

.portal-burger {
  display: none; background: transparent; border: 0; padding: 6px; margin: 0;
  border-radius: var(--r-md); color: var(--fg-2); cursor: pointer; line-height: 0;
}
.portal-burger:hover { background: var(--surface-3); color: var(--fg); }
.portal-burger svg { width: 24px; height: 24px; display: block; stroke: currentColor; }
.portal-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.45);
  z-index: 60; opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s;
}

/* Desktop: inline nav, active pill. */
.portal-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.portal-nav a .ni { display: none; }   /* nav icons only in the mobile drawer */

@media (max-width: 760px) {
  .portal-burger { display: inline-flex; }
  .portal-nav {
    position: fixed; top: 0; right: 0; bottom: 0; width: 80%; max-width: 310px;
    flex-direction: column; align-items: stretch; gap: 2px;
    background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow-lg);
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom)); z-index: 70;
    transform: translateX(100%); transition: transform 0.22s ease; overflow-y: auto;
  }
  .portal-nav::before {
    content: "Menu"; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--muted); padding: 2px 12px 10px; font-weight: 600;
  }
  .portal-nav a {
    display: flex; align-items: center; gap: 11px; padding: 12px 14px;
    border-radius: var(--r-md); font-size: var(--fs-md); color: var(--fg-2);
  }
  .portal-nav a .ni { display: inline-flex; flex: 0 0 20px; }
  .portal-nav a .ni svg { width: 20px; height: 20px; stroke: currentColor; display: block; }
  .portal-nav form { margin: auto 0 0; padding-top: 12px; border-top: 1px solid var(--border); }
  .portal-nav form .button { width: 100%; justify-content: center; }
  body.nav-open { overflow: hidden; }
  body.nav-open .portal-nav { transform: translateX(0); }
  body.nav-open .portal-backdrop { opacity: 1; visibility: visible; }
}

/* ---- Branded identity header ---- */
.portal-identity {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-xl);
  padding: 16px 18px; box-shadow: var(--shadow-sm); margin: 4px 0 16px;
  position: relative; overflow: hidden;
}
.portal-identity::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--grad-brand); }
.portal-identity .id-mark {
  flex: 0 0 52px; width: 52px; height: 52px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.portal-identity .id-mark svg { width: 28px; height: 28px; }
.portal-identity .id-name { font-size: var(--fs-xl); font-weight: 700; letter-spacing: -0.01em; line-height: 1.15; }
.portal-identity .id-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); font-size: var(--fs-sm); }
.portal-identity .id-code { font-variant-numeric: tabular-nums; }
.dot-badge { display: inline-flex; align-items: center; gap: 6px; font-size: var(--fs-xs); font-weight: 600; }
.dot-badge::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 3px var(--success-bg); }
.dot-badge.is-warn::before { background: var(--warn); box-shadow: 0 0 0 3px var(--warn-bg); }

/* ---- Icon-led KPI tiles (color-coded) ---- */
.portal-kpi.has-icon { display: flex; gap: 12px; align-items: center; transition: box-shadow 0.15s, transform 0.15s; }
.portal-kpi.has-icon:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.portal-kpi .k-icon {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 11px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary);
}
.portal-kpi .k-icon svg { width: 21px; height: 21px; stroke: currentColor; display: block; }
.portal-kpi .k-body { min-width: 0; }
.portal-kpi .k-value { font-variant-numeric: tabular-nums; }
.portal-kpi.kpi-primary .k-icon { background: var(--primary-soft); color: var(--primary); }
.portal-kpi.kpi-warn    .k-icon { background: var(--warn-bg); color: var(--warn); }
.portal-kpi.kpi-danger  .k-icon { background: var(--danger-bg); color: var(--danger); }
.portal-kpi.kpi-success .k-icon { background: var(--success-bg); color: var(--success); }
.portal-kpi.kpi-info    .k-icon { background: var(--info-bg); color: var(--info-fg); }
.portal-kpi a:hover { text-decoration: none; }
.portal-kpi .k-badge { display:inline-block; min-width:16px; padding:0 5px; border-radius:9px; background:#ef4444; color:#fff; font-size:10px; font-weight:700; line-height:16px; text-align:center; vertical-align:middle; }

/* ---- Dashboard: greeting hero ---- */
.portal-hero { display:flex; align-items:flex-end; justify-content:space-between; gap:16px; flex-wrap:wrap; margin:2px 0 14px; }
.portal-hero h1 { margin:0 0 3px; font-size:var(--fs-xl); }
.portal-hero .hero-sub { margin:0; color:var(--muted); font-size:var(--fs-sm); }
.portal-hero .hero-meta { text-align:right; min-width:0; }
.portal-hero .hero-dealer { font-weight:600; font-size:var(--fs-sm); }
.portal-hero .hero-date { color:var(--muted); font-size:var(--fs-xs); margin-top:2px; }

/* ---- Dashboard: Today's Work triage queue ---- */
.tw-list { list-style:none; margin:0; padding:0; }
.tw-item { display:flex; align-items:center; gap:11px; padding:10px 0; border-bottom:1px solid var(--surface-2); }
.tw-item:last-child { border-bottom:0; }
.tw-dot { flex:0 0 8px; width:8px; height:8px; border-radius:50%; }
.tw-sev-high { background:#dc2626; } .tw-sev-medium { background:#d97706; } .tw-sev-low { background:#2563eb; }
.tw-ic { flex:0 0 20px; color:var(--muted); display:inline-flex; }
.tw-ic svg { width:18px; height:18px; }
.tw-text { flex:1 1 auto; min-width:0; font-size:var(--fs-sm); }
.tw-cta { flex:0 0 auto; font-weight:600; font-size:var(--fs-sm); white-space:nowrap; }
.tw-empty { display:flex; align-items:center; gap:10px; color:var(--muted); font-size:var(--fs-sm); padding:6px 0; }
.tw-empty-ic { flex:0 0 26px; width:26px; height:26px; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; background:var(--success-bg); color:var(--success); }
.tw-empty-ic svg { width:16px; height:16px; }

/* ---- Dashboard: sales-this-month tiles + sparkline ---- */
.sales-kpis { display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin-bottom:14px; }
.sales-kpis .sk { background:var(--surface-2); border-radius:var(--r-md); padding:10px 12px; }
.sales-kpis .sk-label { font-size:var(--fs-xs); color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.sales-kpis .sk-num { font-size:var(--fs-lg); font-weight:700; line-height:1.15; margin-top:2px; font-variant-numeric:tabular-nums; }
.sales-kpis .sk-sub { font-size:var(--fs-xs); color:var(--muted); }
/* revenue area+line chart */
.sline { display:block; }
.sline-svg { width:100%; height:96px; display:block; overflow:visible; }
.sline-labels { display:flex; justify-content:space-between; margin-top:4px; padding:0 4px; }
.sline-labels span { font-size:var(--fs-xs); color:var(--muted); }

/* ---- Dashboard: row 1 — Today's work (wide) paired with Quick actions ---- */
.dash-row1 { display:grid; grid-template-columns:minmax(0,1.9fr) minmax(240px,1fr); gap:14px; align-items:stretch; margin:14px 0; }
@media (max-width:820px){ .dash-row1 { grid-template-columns:1fr; } }

/* Today's-work stat-action cards (icon · title · number · button) */
.tw-cards { display:grid; grid-template-columns:repeat(auto-fit,minmax(130px,1fr)); gap:12px; }
@media (max-width:560px){ .tw-cards { grid-template-columns:repeat(2,1fr) !important; } }
.tw-card { display:flex; flex-direction:column; gap:8px; padding:14px; border:1px solid var(--border); border-radius:var(--r-md); background:var(--surface); }
.tw-card-ic { width:34px; height:34px; border-radius:10px; display:inline-flex; align-items:center; justify-content:center; }
.tw-card-ic svg { width:19px; height:19px; stroke:currentColor; }
.tone-ic-success { background:var(--success-bg); color:var(--success); }
.tone-ic-danger  { background:var(--danger-bg);  color:var(--danger); }
.tone-ic-warn    { background:var(--warn-bg);    color:var(--warn); }
.tone-ic-info    { background:var(--info-bg);    color:var(--info-fg); }
.tone-ic-primary { background:var(--primary-soft); color:var(--primary); }
.tone-ic-muted   { background:var(--surface-3);   color:var(--muted); }
/* A zero-count "Today's work" card reads calm, not alarming. */
.tw-card-zero { background:var(--surface-2); }
.tw-card-zero .tw-card-num { color:var(--muted); }
.tw-card-zero .tw-card-btn { background:var(--surface-3); color:var(--fg-2); }
.tw-card-zero .tw-card-btn:hover { filter:none; background:var(--border); }
.tw-card-title { font-size:var(--fs-sm); color:var(--muted); line-height:1.3; min-height:2.6em; }
.tw-card-num { font-size:26px; font-weight:700; line-height:1; font-variant-numeric:tabular-nums; }
.tw-card-btn { margin-top:auto; display:inline-flex; align-items:center; justify-content:center; gap:6px; background:var(--primary); color:#fff; padding:7px 10px; border-radius:8px; font-size:var(--fs-sm); font-weight:600; }
.tw-card-btn:hover { text-decoration:none; filter:brightness(.94); }

/* Quick-actions filled accent card (ERP primary, white controls) */
.qa-card { background:var(--primary); border-color:var(--primary); }
.qa-card .card-head h3 { color:#fff; }
.qa-card .card-head .ch-icon { background:rgba(255,255,255,.18); color:#fff; }
.qa-grid { display:grid; grid-template-columns:1fr 1fr; gap:10px; }
.qa-grid .button { display:inline-flex; align-items:center; justify-content:center; gap:8px; font-weight:600; width:100%;
  background:rgba(255,255,255,.14); color:#fff; border:1px solid rgba(255,255,255,.30); }
.qa-grid .button:hover { background:rgba(255,255,255,.24); }
.qa-grid .button svg { width:17px; height:17px; stroke:#fff; flex:0 0 auto; }
.qa-grid .qa-span { grid-column:1 / -1; }

/* ---- Dashboard: outstanding-balance footer inside the sales card ---- */
.sales-out { display:flex; align-items:baseline; gap:8px; margin-top:14px; padding-top:12px; border-top:1px solid var(--surface-2); }
.sales-out .so-label { font-size:var(--fs-sm); color:var(--muted); flex:1 1 auto; }
.sales-out .so-val { font-size:var(--fs-md); font-weight:700; font-variant-numeric:tabular-nums; }
.sales-out .so-sub { font-size:var(--fs-xs); color:var(--muted); }

/* ---- Dashboard: lead funnel bars ---- */
.funnel { display:flex; flex-direction:column; gap:9px; }
.funnel .fn-row { display:flex; align-items:center; gap:10px; }
.funnel .fn-row:hover { text-decoration:none; }
.funnel .fn-label { flex:0 0 92px; font-size:var(--fs-sm); color:var(--fg); }
.funnel .fn-track { flex:1 1 auto; height:16px; background:var(--surface-2); border-radius:8px; overflow:hidden; }
.funnel .fn-fill { display:block; height:100%; background:var(--grad-brand, var(--primary)); border-radius:8px; min-width:3px; }
.funnel .fn-num { flex:0 0 auto; min-width:26px; text-align:right; font-weight:700; font-variant-numeric:tabular-nums; font-size:var(--fs-sm); }

/* Dashboard — dealer inventory stock overview (replaces the old lead funnel). */
.stock-list { display:flex; flex-direction:column; gap:10px; }
.stock-row { display:flex; align-items:center; gap:12px; padding:11px 12px; border:1px solid var(--border); border-radius:var(--r-md); background:var(--surface); transition:border-color .14s ease, background .14s ease; }
.stock-row:hover { text-decoration:none; border-color:var(--border-strong); background:var(--surface-2); }
.stock-ic { flex:0 0 38px; width:38px; height:38px; border-radius:10px; display:inline-flex; align-items:center; justify-content:center; background:var(--primary-soft); color:var(--primary); }
.stock-ic svg { width:20px; height:20px; stroke:currentColor; }
.stock-ic-spare { background:var(--info-bg); color:var(--info-fg); }
.stock-main { display:flex; flex-direction:column; gap:2px; min-width:0; flex:1 1 auto; }
.stock-label { font-size:var(--fs-md); font-weight:600; color:var(--fg); }
.stock-sub { font-size:var(--fs-xs); color:var(--muted); }
.stock-fig { flex:0 0 auto; text-align:right; display:flex; flex-direction:column; gap:1px; }
.stock-out { font-size:var(--fs-md); font-weight:700; font-variant-numeric:tabular-nums; }
.stock-figlbl { font-size:var(--fs-xxs); color:var(--muted); text-transform:uppercase; letter-spacing:.04em; }
.stock-foot { display:flex; justify-content:space-between; align-items:center; gap:10px; padding:11px 4px 2px; margin-top:2px; border-top:1px dashed var(--border); font-size:var(--fs-sm); color:var(--muted); }
.stock-foot strong { color:var(--fg); font-size:var(--fs-lg); font-weight:700; font-variant-numeric:tabular-nums; }

/* ---- Action buttons with icons ---- */
.portal-actions .button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; }
.portal-actions .button svg { width: 17px; height: 17px; stroke: currentColor; }

/* ---- Section card heading with icon ---- */
.card-head { display: flex; align-items: center; gap: 9px; margin: 0 0 12px; }
.card-head .ch-icon {
  flex: 0 0 28px; width: 28px; height: 28px; border-radius: 8px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface-3); color: var(--primary);
}
.card-head .ch-icon svg { width: 16px; height: 16px; stroke: currentColor; }
.card-head h3 { margin: 0; font-size: var(--fs-lg); }
.card-head .ch-sub { margin-left: auto; color: var(--muted); font-size: var(--fs-sm); font-weight: 400; }

/* ---- Progress bar (onboarding) ---- */
.progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; margin: 2px 0 14px; }
.progress > span { display: block; height: 100%; border-radius: var(--r-pill); background: var(--grad-brand); transition: width 0.3s ease; }

/* ---- Clean checklist (no double markers) ---- */
.checklist { list-style: none; margin: 0; padding: 0; }
.checklist > li { display: flex; align-items: flex-start; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--surface-2); }
.checklist > li:last-child { border-bottom: 0; }
.checklist .ck {
  flex: 0 0 20px; width: 20px; height: 20px; border-radius: 50%; margin-top: 1px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  background: var(--surface-3); color: var(--muted);
}
.checklist > li.done .ck { background: var(--success-bg); color: var(--success); }
.checklist .ck-text { min-width: 0; }
.checklist > li:not(.done) .ck-text { color: var(--muted); }
.checklist .ck-detail { color: var(--muted); font-size: var(--fs-xs); }

/* Mobile: identity + KPI breathing room. */
@media (max-width: 640px) {
  .portal-identity { gap: 12px; padding: 14px; }
  .portal-identity .id-mark { flex-basis: 46px; width: 46px; height: 46px; }
  .portal-identity .id-name { font-size: var(--fs-lg); }
}

/* KPI tiles that are links: kill the anchor underline + blue text inheritance
   (numbers stay dark; tone-* on .k-value still wins as a direct class). */
a.portal-kpi, a.portal-kpi:hover { color: var(--fg); text-decoration: none; }

/* ---- Portal inner-page polish: headers, empty states, pills, avatars ---- */
.portal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.portal-head .ph-titles { min-width: 0; }
.portal-head h1 { margin: 0; font-size: var(--fs-xxl); letter-spacing: -0.01em; line-height: 1.15; }
.portal-head .ph-sub { margin: 4px 0 0; color: var(--muted); font-size: var(--fs-sm); }
.portal-head .ph-actions { display: flex; gap: 8px; flex-wrap: wrap; }
@media (max-width: 640px) {
  .portal-head h1 { font-size: var(--fs-xl); }
  .portal-head .ph-actions { width: 100%; }
  .portal-head .ph-actions .button { flex: 1 1 auto; justify-content: center; }
}

/* Back link with chevron */
.portal-back { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: var(--fs-sm); text-decoration: none; margin-bottom: 4px; }
.portal-back:hover { color: var(--primary); text-decoration: none; }
.portal-back svg { width: 15px; height: 15px; stroke: currentColor; }

/* Empty state — canonical rules live in section 22; this block only adds the
   optional icon medallion (UI Stabilization V1: removed a duplicate definition
   that overrode the tokenized padding with raw pixels). */
.empty-state .es-icon { width: 46px; height: 46px; margin: 0 auto var(--sp-3); border-radius: var(--r-xl); display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--muted); }
.empty-state .es-icon svg { width: 24px; height: 24px; stroke: currentColor; }
.empty-state p:last-child { margin-bottom: 0; }

/* Stage / status pills (colour-coded) */
.s-pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: var(--r-pill); font-size: var(--fs-xs); font-weight: 600; background: var(--surface-3); color: var(--fg-2); text-transform: capitalize; white-space: nowrap; }
.s-pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.85; }
.s-pill.s-enquiry, .s-pill.s-contacted { background: var(--info-bg); color: var(--info-fg); }
.s-pill.s-test_ride, .s-pill.s-quote { background: var(--warn-bg); color: var(--warn-fg); }
.s-pill.s-booking { background: var(--primary-soft); color: var(--primary); }
.s-pill.s-won, .s-pill.s-active { background: var(--success-bg); color: var(--success-fg); }
.s-pill.s-lost, .s-pill.s-void, .s-pill.s-expired { background: var(--danger-bg); color: var(--danger-fg); }

/* Customer / prospect avatar (initials) */
.avatar { flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: var(--fs-sm); font-weight: 700; background: var(--primary-soft); color: var(--primary); text-transform: uppercase; }
.cell-id { display: flex; align-items: center; gap: 10px; }

/* Mini metric row (lead detail / customer detail summary) */
.mini-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 0 0 14px; }
.mini-metric { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 10px 12px; }
.mini-metric .m-label { font-size: var(--fs-xxs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.mini-metric .m-value { font-size: var(--fs-lg); font-weight: 700; margin-top: 2px; font-variant-numeric: tabular-nums; }

/* s-pill colours for commercial statuses (orders / invoices / warranties / claims) */
.s-pill.s-issued, .s-pill.s-approved, .s-pill.s-dispatched, .s-pill.s-closed, .s-pill.s-resolved, .s-pill.s-fulfilled { background: var(--success-bg); color: var(--success-fg); }
.s-pill.s-cancelled, .s-pill.s-rejected { background: var(--danger-bg); color: var(--danger-fg); }
.s-pill.s-raised, .s-pill.s-confirmed, .s-pill.s-in_review, .s-pill.s-partially_dispatched, .s-pill.s-pending, .s-pill.s-open { background: var(--info-bg); color: var(--info-fg); }

/* Constrain inline SVG icons inside any portal button (header actions, empty
   states, etc.) — not just .portal-actions. Inline width:Npx styles still win. */
.portal-main .button svg, .portal-head .button svg { width: 17px; height: 17px; flex: 0 0 auto; }

/* ---- Portal topbar: user menu (right) + theme switcher ---- */
.portal-topbar { justify-content: flex-start; }
.portal-nav { margin-left: auto; }
.topbar-right { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }

.portal-usermenu { position: relative; }
.um-trigger {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 8px 5px 5px; margin: 0;
  background: transparent; border: 1px solid transparent; border-radius: var(--r-pill);
  color: var(--fg-2); cursor: pointer; font-size: var(--fs-sm); line-height: 1; max-width: 220px;
}
.um-trigger:hover { background: var(--surface-3); }
.portal-usermenu.open .um-trigger { background: var(--surface-3); border-color: var(--border); }
.um-avatar {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: var(--fs-xs);
}
.um-name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.um-caret { color: var(--muted); font-size: 11px; transition: transform 0.15s; }
.portal-usermenu.open .um-caret { transform: rotate(180deg); }

.um-dropdown {
  position: absolute; right: 0; top: calc(100% + 8px); min-width: 248px; z-index: 65;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg);
  box-shadow: var(--shadow-lg); overflow: hidden; padding: 6px;
}
.um-head { padding: 8px 10px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.um-head-name { font-weight: 700; font-size: var(--fs-md); }
.um-head-sub { color: var(--muted); font-size: var(--fs-xs); word-break: break-all; }

.um-dropdown .theme-seg { display: flex; align-items: center; flex-wrap: wrap; gap: 5px; padding: 6px 10px 8px; }
.um-dropdown .theme-seg-label { flex: 0 0 100%; font-size: var(--fs-xs); color: var(--muted); margin-bottom: 3px; }
.um-dropdown .theme-seg-btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; margin: 0;
  border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface);
  color: var(--fg-2); font-size: var(--fs-xs); cursor: pointer; line-height: 1;
}
.um-dropdown .theme-seg-btn:hover { background: var(--surface-3); color: var(--fg); border-color: var(--border-strong); }
.um-dropdown .theme-seg-btn.active { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); font-weight: 600; }

.um-logout { margin: 6px 0 0; border-top: 1px solid var(--border); padding-top: 6px; }
.um-logout button {
  display: flex; align-items: center; gap: 9px; width: 100%; padding: 9px 10px; margin: 0;
  background: transparent; border: 0; border-radius: var(--r-md); color: var(--danger);
  font-size: var(--fs-sm); font-weight: 600; cursor: pointer; text-align: left;
}
.um-logout button:hover { background: var(--danger-bg); }
.um-logout svg { width: 17px; height: 17px; stroke: currentColor; }

/* Mobile: avatar-only trigger (hide the name + caret to save room next to the burger). */
@media (max-width: 560px) {
  .um-trigger { padding: 4px; }
  .um-name, .um-caret { display: none; }
}

/* ====================================================================
   43. Dealer portal — app shell (fixed sidebar like the ERP)
   ==================================================================== */
:root { --portal-sidebar-w: 240px; --ptop: 63px; }

.portal-topbar { justify-content: flex-start; gap: 10px; min-height: var(--ptop); }
.topbar-right { margin-left: auto; }

.portal-sidebar {
  position: fixed; left: 0; top: var(--ptop); bottom: 0; width: var(--portal-sidebar-w); z-index: 40;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow-y: auto; padding: 8px 10px 16px;
}
.side-nav { display: flex; flex-direction: column; gap: 1px; }
.side-section { font-size: var(--fs-xxs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; padding: 14px 12px 4px; }
.side-section:first-of-type { padding-top: 6px; }
.sidelink { display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: var(--r-md); color: var(--fg-2); text-decoration: none; font-size: var(--fs-sm); font-weight: 500; }
.sidelink:hover { background: var(--surface-3); color: var(--fg); text-decoration: none; }
.sidelink.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; box-shadow: inset 2px 0 0 var(--primary); }
.sidelink .si { flex: 0 0 20px; width: 20px; height: 20px; display: inline-flex; align-items: center; justify-content: center; }
.sidelink .si svg { width: 19px; height: 19px; stroke: currentColor; }
.sidelink .sl { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidelink.soon { color: var(--muted); cursor: default; }
.sidelink.soon:hover { background: transparent; color: var(--muted); }
.sidelink.soon .si { opacity: 0.7; }
.soon-badge { flex: 0 0 auto; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); background: var(--surface-3); border-radius: var(--r-pill); padding: 1px 7px; }
.side-foot { margin-top: auto; padding: 10px 4px 2px; }

/* Dealer account card pinned at the sidebar bottom (cakjs-crm pattern). Reuses the
   .portal-usermenu markup + portal.js toggle; here it's a full-width card and the
   dropdown opens UPWARD. Divider above separates it from the nav (like the CRM border-t). */
.side-usermenu { position: relative; width: 100%; border-top: 1px solid var(--border); padding-top: 10px; }
.side-usermenu .um-trigger {
  display: flex; align-items: center; gap: 9px; width: 100%; max-width: none;
  padding: 7px 9px; border-radius: var(--r-md); border: 1px solid var(--border);
  background: var(--surface-2); text-align: left;
}
.side-usermenu .um-trigger:hover { background: var(--surface-3); }
.side-usermenu.open .um-trigger { border-color: var(--primary); background: var(--primary-soft); }
.side-usermenu .um-avatar { flex: 0 0 32px; width: 32px; height: 32px; background: var(--primary); color: var(--primary-fg); }
.side-usermenu .um-id { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; line-height: 1.25; }
.side-usermenu .um-id .um-name { max-width: none; font-size: var(--fs-sm); color: var(--fg); }
.side-usermenu .um-id .um-sub { font-size: var(--fs-xxs); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-usermenu .um-caret { margin-left: auto; flex: 0 0 auto; }
.side-usermenu .um-dropdown { top: auto; bottom: calc(100% + 6px); left: 0; right: 0; min-width: 0; }

/* Portal sidebar accordion (single-open). The .pgroup-head replaces the old
   static .side-section label with a clickable fold target. */
.portal-sidebar .pgroup { display: flex; flex-direction: column; }
.portal-sidebar .pgroup-head {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  font: inherit; font-size: var(--fs-xxs); text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 700; padding: 12px 12px 4px;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.portal-sidebar .pgroup-head:hover { color: var(--fg-2); }
.portal-sidebar .pg-caret { font-size: 0.85em; transition: transform 120ms; }
.portal-sidebar .pgroup.collapsed .pg-caret { transform: rotate(-90deg); }
.portal-sidebar .pgroup.collapsed .pgroup-items { display: none; }
.portal-sidebar .pgroup-items { display: flex; flex-direction: column; gap: 1px; }

/* ERP focus lens — narrows the visible sidegroups (presentation only). */
.nav-focus-wrap { display: flex; align-items: center; gap: 6px; padding: 8px 12px 4px; }
.nav-focus-label { font-size: var(--fs-xxs); text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 700; }
.nav-focus {
  flex: 1 1 auto; min-width: 0; font-size: var(--fs-sm); padding: 4px 6px;
  border: 1px solid var(--border); border-radius: var(--r-sm, 6px); background: var(--surface); color: var(--fg-2);
}
.app-shell.nav-collapsed .nav-focus-wrap { display: none; }
.sidenav .sidegroup.focus-hidden { display: none; }

/* Dashboard widget chooser (Command Center). */
.widget-chooser { font-size: var(--fs-sm); }
.widget-chooser > summary {
  cursor: pointer; user-select: none; list-style: none; color: var(--muted);
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--r-pill, 999px); white-space: nowrap;
}
.widget-chooser > summary::-webkit-details-marker { display: none; }
.widget-chooser > summary:hover { color: var(--fg); }
.widget-chooser[open] > summary { color: var(--fg); }
.widget-chooser-grid { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; justify-content: flex-end; }
.widget-chooser-grid label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

/* Content clears the fixed sidebar on desktop. */
@media (min-width: 761px) {
  .portal-main { margin-left: var(--portal-sidebar-w); }
}

/* Mobile: the sidebar is an off-canvas drawer; the hamburger toggles it. */
@media (max-width: 760px) {
  .portal-sidebar { transform: translateX(-100%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg); z-index: 70; width: 84%; max-width: 300px; top: var(--ptop); }
  body.sidebar-open .portal-sidebar { transform: translateX(0); }
  body.sidebar-open .portal-backdrop { opacity: 1; visibility: visible; }
  body.sidebar-open { overflow: hidden; }
}

/* ---- Collapsible card (onboarding dropdown) ---- */
.acc > summary { list-style: none; cursor: pointer; }
.acc > summary::-webkit-details-marker { display: none; }
.acc > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; border-radius: var(--r-md); }
.acc .acc-caret { color: var(--muted); font-size: 12px; margin-left: 8px; transition: transform 0.18s ease; }
.acc[open] .acc-caret { transform: rotate(180deg); }
.acc > summary .card-head { margin-bottom: 10px; }
.acc > summary:hover h3 { color: var(--primary); }

/* ====================================================================
   44. Dealer portal — sign-in page (one branded surface, floating card)
   ==================================================================== */
.dl-body { margin: 0; }
/* One continuous brand surface fills the page; the form floats on it. */
.dl-wrap {
  min-height: 100vh; background: var(--grad-brand);
  display: flex; align-items: center; justify-content: center; padding: 40px 24px;
}
.dl-inner { display: flex; align-items: center; gap: 56px; width: 100%; max-width: 940px; }

/* Brand sits as text directly on the surface (no separate panel/background). */
.dl-brand { flex: 1 1 0; min-width: 0; color: #fff; display: flex; flex-direction: column; }
.dl-brand-top { display: flex; align-items: center; gap: 16px; }
.dl-logo-chip {
  background: #fff; border-radius: 18px; padding: 10px; display: inline-flex;
  box-shadow: 0 10px 28px rgba(0,0,0,0.28); flex: 0 0 auto;
}
.dl-logo-chip img { display: block; }
.dl-eyebrow { text-transform: uppercase; letter-spacing: 0.13em; font-size: 12px; opacity: 0.82; font-weight: 600; }
.dl-brand h1 { margin: 3px 0 0; font-size: 30px; line-height: 1.1; color: #fff; letter-spacing: -0.01em; }
.dl-lede { margin: 26px 0 22px; font-size: 16.5px; line-height: 1.5; opacity: 0.9; max-width: 40ch; }
.dl-feat { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 13px; }
.dl-feat li { display: flex; align-items: center; gap: 13px; font-size: 14.5px; opacity: 0.95; }
.dl-fi { flex: 0 0 34px; width: 34px; height: 34px; border-radius: 9px; background: rgba(255,255,255,0.14); display: inline-flex; align-items: center; justify-content: center; }
.dl-fi svg { width: 18px; height: 18px; stroke: #fff; }
.dl-brand-foot { margin-top: 30px; font-size: 12.5px; opacity: 0.66; }

/* The single floating sign-in card. */
.dl-form { flex: 0 0 400px; max-width: 400px; }
.dl-card {
  width: 100%; background: var(--surface); border: 1px solid rgba(255,255,255,0.10);
  border-radius: 16px; box-shadow: 0 24px 60px rgba(0,0,0,0.32); padding: 32px 30px 26px;
}
.dl-logo-chip-sm { display: none; }
.dl-card h2 { margin: 0; font-size: 22px; letter-spacing: -0.01em; }
.dl-fields { display: flex; flex-direction: column; gap: 14px; }
.dl-fields .field input { width: 100%; }
.dl-submit { width: 100%; justify-content: center; padding: 11px 14px; margin-top: 4px; font-size: 15px; }
.dl-help { margin: 14px 0 0; }
.dl-divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Tablet/phone: stack the brand above the card, centred — still one surface. */
@media (max-width: 880px) {
  .dl-wrap { padding: 36px 20px; align-items: flex-start; }
  .dl-inner { flex-direction: column; gap: 26px; max-width: 400px; }
  .dl-brand { align-items: center; text-align: center; }
  .dl-brand-top { flex-direction: column; gap: 12px; }
  .dl-brand .dl-lede, .dl-brand .dl-feat, .dl-brand-foot { display: none; }
  .dl-brand h1 { font-size: 24px; }
  .dl-form { flex: 1 1 auto; width: 100%; max-width: none; }
}

/* ---- Password show/hide toggle (shared: ERP login, dealer portal, etc.) ---- */
.pw-field { position: relative; display: block; }
/* Zero the input's own vertical margin so the wrapper box == the input box; the
   toggle then centres on the input, not on the input + its margin (which sat ~3px high). */
.pw-field > input { width: 100%; padding-right: 44px; margin: 0; }
.login-card .pw-field { margin-top: 6px; }   /* restore the ERP label→input gap removed above */
.pw-toggle {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: transparent; border: 0; padding: 6px; margin: 0; cursor: pointer;
  color: var(--muted); display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--r-sm); line-height: 0;
}
.pw-toggle:hover { color: var(--fg-2); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.pw-toggle svg { width: 19px; height: 19px; stroke: currentColor; fill: none; }
.pw-toggle .i-eye-off { display: none; }
.pw-toggle.is-shown .i-eye { display: none; }
.pw-toggle.is-shown .i-eye-off { display: inline-block; }

/* Employee Self-Service sign-in — reuses the .dl-* login components, distinct teal surface. */
.ess-login .dl-wrap { background: linear-gradient(140deg, #0e7c74 0%, #0b3b3a 100%); }

/* ====================================================================
   45. Employee Self-Service (ESS) — mobile-first portal
   ==================================================================== */
.ess-body { margin: 0; background: var(--bg); }
.ess-top {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 16px; background: linear-gradient(135deg, #0e7c74, #0b5d57); color: #fff;
}
.ess-top-id { display: flex; align-items: center; gap: 11px; min-width: 0; }
.ess-top .avatar { flex: 0 0 38px; width: 38px; height: 38px; font-size: var(--fs-sm); background: rgba(255,255,255,0.18); color: #fff; }
.ess-hi { font-weight: 700; font-size: var(--fs-md); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ess-status { opacity: 0.95; }
.ess-top .ess-status { color: rgba(255,255,255,0.9); }
.ess-out { background: rgba(255,255,255,0.14); border: 0; color: #fff; padding: 8px; border-radius: var(--r-md); cursor: pointer; display: inline-flex; line-height: 0; }
.ess-out:hover { background: rgba(255,255,255,0.26); }
.ess-out svg { width: 20px; height: 20px; stroke: currentColor; }
.ess-main { max-width: 720px; margin: 0 auto; padding: 16px; }

.ess-banner { background: var(--info-bg); color: var(--info-fg); border-radius: var(--r-lg); padding: 12px 14px; font-size: var(--fs-sm); line-height: 1.45; margin: 0 0 14px; }
.ess-banner.ok { background: var(--success-bg); color: var(--success-fg); }
.ess-banner.wait { background: var(--warn-bg); color: var(--warn-fg); }

/* My details — stacked label/value rows (replaces the cramped desktop table) */
.ess-facts { margin: 0; }
.ess-fact { display: flex; justify-content: space-between; align-items: baseline; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--surface-2); }
.ess-fact:last-child { border-bottom: 0; }
.ess-fact dt { margin: 0; color: var(--muted); font-size: var(--fs-sm); flex: 0 0 auto; }
.ess-fact dd { margin: 0; font-weight: 600; text-align: right; word-break: break-word; min-width: 0; }

/* Photo + upload */
.ess-photo { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.ess-photo-img, .ess-photo-ph { width: 84px; height: 84px; border-radius: 12px; flex: 0 0 auto; }
.ess-photo-img { object-fit: cover; border: 1px solid var(--border); }
.ess-photo-ph { display: flex; align-items: center; justify-content: center; border: 1px dashed var(--border-strong); color: var(--muted); font-size: var(--fs-xs); text-align: center; padding: 4px; }
.ess-upload { display: flex; flex-direction: column; gap: 8px; flex: 1 1 200px; min-width: 0; }
.ess-upload .button { width: 100%; justify-content: center; }
.ess-file { width: 100%; }

/* Documents list */
.ess-docs { list-style: none; margin: 0 0 12px; padding: 0; }
.ess-docs li { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--surface-2); }
.ess-docs li:last-child { border-bottom: 0; }
.ess-doc-ic { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 8px; background: var(--surface-3); color: var(--primary); display: inline-flex; align-items: center; justify-content: center; }
.ess-doc-ic svg { width: 17px; height: 17px; stroke: currentColor; }

.ess-submit { width: 100%; padding: 13px; font-size: 15px; justify-content: center; }

/* Bottom quick-nav (icon tiles) */
.ess-nav { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.ess-nav a { display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 12px 6px; border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); color: var(--fg-2); text-decoration: none; font-size: var(--fs-xs); text-align: center; }
.ess-nav a:hover { background: var(--surface-3); color: var(--fg); text-decoration: none; }
.ess-nav a svg { width: 20px; height: 20px; stroke: currentColor; }

/* ESS sub-pages (edit form, etc.) — teal header + mobile form */
.ess-subhead { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 10px; padding: 11px 14px; background: linear-gradient(135deg, #0e7c74, #0b5d57); color: #fff; }
.ess-subhead h1 { margin: 0; font-size: var(--fs-lg); font-weight: 700; }
.ess-back { display: inline-flex; padding: 6px; border-radius: var(--r-md); color: #fff; background: rgba(255,255,255,0.14); line-height: 0; }
.ess-back:hover { background: rgba(255,255,255,0.26); }
.ess-back svg { width: 20px; height: 20px; stroke: currentColor; }
.ess-form { display: flex; flex-direction: column; gap: 13px; }
.ess-form label { display: block; font-weight: 600; font-size: var(--fs-sm); color: var(--fg-2); margin: 0; }
.ess-form label input, .ess-form label textarea, .ess-form label select { display: block; width: 100%; margin-top: 5px; }
.ess-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.ess-form fieldset { border: 1px solid var(--border); border-radius: var(--r-lg); padding: 12px 14px; margin: 0; }
.ess-form fieldset legend { color: var(--muted); font-size: var(--fs-xs); padding: 0 4px; }
.ess-save { width: 100%; padding: 13px; justify-content: center; font-size: 15px; margin-top: 4px; }

/* ESS timesheet (Phase 1) */
.ts-weeknav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.ts-weeklabel { flex: 1 1 auto; text-align: center; font-weight: 600; min-width: 0; }
.ts-weektotal { font-size: var(--fs-xs); color: var(--muted); font-weight: 500; }
.ts-arrow { flex: 0 0 auto; display: inline-flex; padding: 7px; border-radius: var(--r-md); background: var(--surface-3); color: var(--fg-2); line-height: 0; }
.ts-arrow:hover { background: var(--border-strong); }
.ts-arrow svg { width: 18px; height: 18px; stroke: currentColor; }
.ts-arrow.is-disabled { opacity: 0.3; pointer-events: none; }

.ts-week { display: flex; gap: 5px; }
.ts-day { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 2px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid transparent; }
.ts-day.has { background: var(--primary-soft); }
.ts-day.today { border-color: #0e7c74; background: #d8f1ee; }
.ts-dow { font-size: 10px; color: var(--muted); text-transform: uppercase; }
.ts-dom { font-size: var(--fs-md); font-weight: 700; }
.ts-dh { font-size: 10px; color: var(--fg-2); font-weight: 600; }

.ts-time { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.ts-list { list-style: none; margin: 0; padding: 0; }
.ts-date { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 700; padding: 12px 0 4px; }
.ts-date:first-child { padding-top: 0; }
.ts-entry { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--surface-2); }
.ts-entry:last-child { border-bottom: 0; }
.ts-hrs { font-weight: 700; color: var(--primary); font-size: var(--fs-sm); margin-left: 6px; white-space: nowrap; }
.ts-actions { flex: 0 0 auto; display: flex; gap: 6px; align-items: center; }
.ts-del { color: var(--danger); padding: 5px 9px; }
.ts-del:hover { background: var(--danger-bg); }

/* ====================================================================
   Refined, theme-aware scrollbars — replaces the default grey/white bar.
   Thin, rounded, inset, with a hover state; built from the design tokens
   so it adapts to light / blue / dark automatically (no hardcoded hex).
   (per ui-ux-pro-max: token-driven theming + state-clarity + theme parity)
   ==================================================================== */
* {
  scrollbar-width: thin;                                   /* Firefox */
  scrollbar-color: var(--border-strong) transparent;
}
::-webkit-scrollbar { width: 11px; height: 11px; }         /* Chrome / Edge / Safari */
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 3px solid transparent;        /* transparent padding ring → a slim, floating thumb */
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
::-webkit-scrollbar-corner { background: transparent; }

/* The sidebar overflows when the Focus lens = "Everything" shows every module.
   The inner .sidenav scrolls with a thin overlay scrollbar (no reserved gutter),
   so no empty strip is left on the right. */

/* ===== Dealer distribution module (Phase B–D) ============================= */
.page-head { display:flex; align-items:center; justify-content:space-between; gap:12px; flex-wrap:wrap; }
.alert { padding:10px 14px; border-radius:8px; margin:10px 0; font-size:14px; border:1px solid var(--border); }
.alert.success { background:#e8f6ee; border-color:#bfe6cd; color:#15803d; }
.alert.danger  { background:var(--danger-bg); border-color:#f1c7c7; color:var(--danger-fg); }
.filterbar { display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin:12px 0; }
.chip { display:inline-block; padding:5px 11px; border-radius:999px; background:var(--primary-soft); color:var(--primary);
        font-size:12.5px; font-weight:600; text-decoration:none; border:1px solid transparent; }
.chip-on { background:var(--primary); color:#fff; }
.inline-assign { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.inline-lbl { display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--muted); }
.cols-2 { display:grid; grid-template-columns:1fr 1fr; gap:16px; }
@media (max-width:820px){ .cols-2 { grid-template-columns:1fr; } }

/* status pills — one vocabulary across staff + portal + notifications */
.dist-pill { display:inline-block; padding:3px 10px; border-radius:999px; font-size:11.5px; font-weight:700;
             letter-spacing:.2px; background:#eef1f6; color:#445; white-space:nowrap; text-transform:capitalize; }
.dist-po_raised      { background:#eef2ff; color:#4338ca; }
.dist-asp_submitted  { background:#e0f2fe; color:#0369a1; }
.dist-rsm_confirmed  { background:#fef9c3; color:#854d0e; }
.dist-invoiced,.dist-unpaid,.dist-part_paid { background:#ffedd5; color:#9a3412; }
.dist-paid           { background:#dcfce7; color:#15803d; }
.dist-in_transit     { background:#cffafe; color:#0e7490; }
.dist-delivered      { background:#e9d5ff; color:#7e22ce; }
.dist-closed         { background:#e2e8f0; color:#334155; }
.dist-rejected,.dist-cancelled { background:var(--danger-bg); color:var(--danger-fg); }

/* lifecycle timeline */
.dist-timeline { list-style:none; margin:0; padding:0; }
.dist-timeline li { position:relative; padding:6px 0 6px 24px; color:var(--muted); font-size:13.5px; }
.dist-timeline li .dot { position:absolute; left:4px; top:11px; width:10px; height:10px; border-radius:50%;
                         background:#cbd5e1; border:2px solid #fff; box-shadow:0 0 0 1px #cbd5e1; }
.dist-timeline li::before { content:""; position:absolute; left:8px; top:18px; bottom:-6px; width:2px; background:#e2e8f0; }
.dist-timeline li:last-child::before { display:none; }
.dist-timeline li.done { color:var(--text,#1a1a1a); }
.dist-timeline li.done .dot { background:#15803d; box-shadow:0 0 0 1px #15803d; }
.dist-timeline li.current .dot { background:var(--primary); box-shadow:0 0 0 1px var(--primary); }
.dist-timeline li .lbl { font-weight:600; }
.dist-timeline li .at { margin-left:8px; }

/* ===== Dealer portal — invoice tabs + filter bar (DMS-style) ============== */
.dist-issued { background:#e0f2fe; color:#0369a1; }
.portal-tabs { display:flex; gap:4px; flex-wrap:wrap; margin:14px 0 12px; border-bottom:1px solid var(--border); }
.ptab { padding:9px 16px; font-size:14px; font-weight:600; color:var(--muted); text-decoration:none;
        border-bottom:2px solid transparent; margin-bottom:-1px; display:inline-flex; align-items:center; gap:7px; }
.ptab:hover { color:var(--text,#1a1a1a); }
.ptab-on { color:var(--primary); border-bottom-color:var(--primary); }
.ptab-count { font-size:11px; font-weight:700; background:#eef1f6; color:#556; border-radius:999px; padding:1px 7px; }
.ptab-on .ptab-count { background:var(--primary-soft); color:var(--primary); }
.portal-filterbar { display:flex; align-items:center; gap:10px; flex-wrap:nowrap; padding:12px 14px; margin-bottom:12px; }
.portal-filterbar > * { min-width:0; }                         /* every control may shrink to fit — one row, no h-scroll */
/* override the global `input,select,textarea{width:100%}` so controls size to content/flex, not full-width */
.portal-filterbar input[type=search] { width:auto; flex:1 1 140px; min-width:90px; }   /* search fields share the slack */
.portal-filterbar .fb-lbl { display:inline-flex; align-items:center; gap:6px; font-size:13px; color:var(--muted); white-space:nowrap; flex:0 0 auto; }
.portal-filterbar input[type=date] { width:auto; flex:0 0 auto; }
.portal-filterbar select { width:auto; flex:0 0 auto; }        /* was 100% -> blew the row out to a scrollbar */
.portal-filterbar .button { flex:0 0 auto; white-space:nowrap; }

/* ===== Claim form — responsive field grid ================================= */
.claim-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:10px 16px; }
.claim-grid label { display:flex; flex-direction:column; font-size:13px; color:var(--muted); gap:3px; }
.claim-grid label.wide { grid-column:1 / -1; }
@media (max-width:760px){ .claim-grid { grid-template-columns:1fr; } }

/* ===== Dealer portal — pre-delivery polish (autocomplete, flat nav, validation) ===== */
/* Flat sidebar (no accordion dropdowns) */
.side-section { margin-top: 10px; }
.side-section-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .7px; color: var(--muted);
                      padding: 6px 14px 2px; opacity: .85; }

/* Searchable autocomplete (enhances <select data-ac>) — matches inputs */
.ac { position: relative; display: block; }
.ac-input { width: 100%; }
.ac-list { position: absolute; left: 0; right: 0; top: calc(100% + 2px); z-index: 60; max-height: 260px; overflow-y: auto;
           background: var(--card, #fff); border: 1px solid var(--border-strong, #c7cedb); border-radius: 8px;
           box-shadow: 0 8px 24px rgba(15,23,42,.14); padding: 4px; }
.ac-item { padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13.5px; white-space: nowrap;
           overflow: hidden; text-overflow: ellipsis; }
.ac-item:hover, .ac-item.active { background: var(--primary-soft, #e7effb); color: var(--primary, #1b4d8f); }
.ac-empty { padding: 8px 10px; color: var(--muted); font-size: 13px; }

/* Validation / error states */
.field-error { color: var(--danger, #b53030); font-size: 12px; margin-top: 3px; }
.invalid, .invalid:focus { border-color: var(--danger, #b53030) !important; box-shadow: 0 0 0 2px var(--danger-bg, #fde8e8) !important; }
.ac .ac-input.invalid { border-color: var(--danger, #b53030) !important; }

/* Compact form layouts (reduce excessive spacing) */
.field-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.field-row > label { flex: 1 1 180px; }
.field-block { display: block; }
.fs-compact { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; }
.fs-compact > legend { padding: 0 6px; font-size: 13px; color: var(--muted); }
.claim-grid-compact { gap: 8px 14px; }
.claim-grid-compact label { font-size: 12.5px; gap: 2px; }
.claim-grid-compact input, .claim-grid-compact select { padding: 6px 8px; }

/* Lead drawer (Marketing module) — slides in from the right; opens a lead in place,
   reusing the existing theme tokens so it matches light/blue/dark. */
.lead-drawer {
  position: fixed; top: 0; right: 0; height: 100vh; width: min(480px, 92vw);
  background: var(--surface); border-left: 1px solid var(--border);
  box-shadow: -10px 0 36px rgba(0, 0, 0, 0.20);
  transform: translateX(100%); transition: transform 0.22s ease;
  z-index: 1000; display: flex; flex-direction: column; overflow: hidden;
}
.lead-drawer.open { transform: translateX(0); }
.lead-drawer-backdrop {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.12);
  opacity: 0; transition: opacity 0.22s ease; z-index: 999;
}
.lead-drawer-backdrop.open { opacity: 1; }
/* The body div between .lead-drawer and .lead-panel must also flex so the inner body
   gets a bounded height and actually scrolls (min-height:0 lets it shrink). */
#lead-drawer-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lead-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.lead-panel-head {
  display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--border); background: var(--bg); flex: none;
}
/* Identity + Edit share the top row: customer info left, edit control right. The
   edit form opens as a floating panel under the button (no layout push), scrolling
   internally if it outgrows the drawer. */
.lead-identity-row { display: flex; align-items: flex-start; gap: 10px; }
.lead-identity-row .lead-identity { flex: 1; min-width: 0; }
.lead-edit-details { flex: none; position: relative; }
.lead-edit-details > summary { list-style: none; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.lead-edit-details > summary::-webkit-details-marker { display: none; }
.lead-edit-details .lead-edit-body {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 70;
  width: min(400px, 86vw); max-height: min(65vh, 540px); overflow-y: auto;
  text-align: left; border: 1px solid var(--border); border-radius: var(--r-lg);
  padding: 12px; background: var(--surface); box-shadow: var(--shadow-lg);
}
/* Destructive action zone — bottom of the drawer, visually separated from daily work */
.lead-panel-footer { margin-top: 22px; padding-top: 12px; border-top: 1px solid var(--border); }
.lead-panel-body { padding: 16px 18px; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
/* Drawer header — dark navy banner (slate-900), per the design mockup. */
.lead-panel-head { background: #0f172a; border-bottom-color: #0f172a; }
.lead-panel-head h2 { color: #fff; }
.lead-panel-head .button { background: rgba(255,255,255,0.18); color: #fff; border-color: transparent; }
.lead-panel-head .button:hover { background: rgba(255,255,255,0.30); }
/* Identity block: avatar + name + phone + location + status. */
.lead-identity { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.lead-identity .lead-avatar { width: 48px; height: 48px; border-radius: 50%; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; font-weight: 700; font-size: 1.05rem; flex: none; }
/* Drawer tabs. */
.lead-tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin: 0 0 14px; flex-wrap: wrap; }
.lead-tabs button { background: none; border: none; padding: 8px 12px; cursor: pointer; color: var(--muted); font-size: 13px; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.lead-tabs button.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
.lead-tabs button:hover { color: var(--fg); }
.lead-panel-body h3 { margin: 14px 0 6px; font-size: 0.95rem; }
@media (prefers-reduced-motion: reduce) {
  .lead-drawer, .lead-drawer-backdrop { transition: none; }
}

/* Lead lifecycle — consistent status pills (reuse the .status base) + a stage stepper. */
.status-lead-new            { background: #4338ca;            color: #fff; }
.status-lead-assigned       { background: var(--primary-soft); color: var(--primary); }
.status-lead-follow_up      { background: var(--warn-bg);     color: var(--warn-fg); }
.status-lead-interested     { background: var(--success-bg);  color: var(--success-fg); }
.status-lead-not_interested { background: var(--surface-3);   color: var(--muted); }
.status-lead-converted      { background: var(--success-bg);  color: var(--success-fg); }
.status-lead-closed         { background: var(--surface-3);   color: var(--muted); }

.lifecycle { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 4px 0 6px; }
.lc-step { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--muted); }
.lc-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); display: grid; place-items: center; font-size: 9px; line-height: 1; flex: none; }
.lc-step.done .lc-dot { background: var(--success-bg); border-color: var(--success-fg); color: var(--success-fg); }
.lc-step.current { color: var(--fg); font-weight: 600; }
.lc-step.current .lc-dot { background: var(--primary); border-color: var(--primary); color: var(--primary-fg); }
.lc-step.lost .lc-dot { background: var(--danger-bg); border-color: var(--danger); color: var(--danger); }
.lc-sep { color: var(--border); margin: 0 1px; }
.kpi-tile.kpi-active { outline: 2px solid var(--primary); outline-offset: -2px; }
/* Lead widgets — emphasize the inline counts in the sub-line (scoped so other kpi-strips
   in the ERP are untouched). New = highlighted; follow-up/total counts = larger. */
.lead-widgets .kpi-sub { font-size: 12.5px; }
.lead-widgets .kpi-sub b { font-size: 15px; font-weight: 700; color: var(--fg); }
.lead-widgets .kpi-sub b.hi { color: var(--primary); background: var(--primary-soft); border-radius: 5px; padding: 0 5px; }
/* Each count in a type widget is its own link — show it's clickable on hover. */
.lead-widgets a.kpi-num { display: inline-block; }
.lead-widgets a.kpi-num:hover, .lead-widgets .kpi-sub a:hover { color: var(--primary); text-decoration: underline; }

/* ===== Lead Management page — lm-v2 namespace (leads page only, zero leakage) ===== */
.lm-v2-section { background: #fff; border: 1px solid #E2E8F0; border-radius: 12px; padding: 14px 16px 16px; margin-bottom: 16px; }
.lm-v2-section-label { color: #2563EB; font-weight: 700; font-size: 13px; margin: 0 0 12px; }

/* Today's Work — 3-col action grid with tinted icon chips + chevron */
.lm-v2-action-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.lm-v2-action-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 12px; border: 1px solid #E2E8F0; text-decoration: none; transition: box-shadow .12s ease; }
.lm-v2-action-card:hover { box-shadow: 0 4px 14px rgba(0,0,0,.08); }
.lm-v2-ac-icon { width: 44px; height: 44px; border-radius: 11px; display: grid; place-items: center; flex: none; }
.lm-v2-ac-icon .lm-v2-ico { width: 22px; height: 22px; }
.lm-v2-ac-num { font-size: 1.7rem; font-weight: 800; line-height: 1; color: #0f172a; }
.lm-v2-ac-label { font-weight: 700; color: #0f172a; }
.lm-v2-ac-sub { color: #64748b; font-size: 12.5px; }
.lm-v2-ac-arrow { margin-left: auto; font-size: 1.3rem; }
.lm-v2-ac-red   { background: #FEF2F2; border-color: #FEE2E2; }
.lm-v2-ac-red   .lm-v2-ac-icon { background: #FEE2E2; color: #dc2626; }
.lm-v2-ac-red   .lm-v2-ac-arrow { color: #991B1B; }
.lm-v2-ac-amber { background: #FFFBEB; border-color: #FEF3C7; }
.lm-v2-ac-amber .lm-v2-ac-icon { background: #FEF3C7; color: #d97706; }
.lm-v2-ac-amber .lm-v2-ac-arrow { color: #92400E; }
.lm-v2-ac-green { background: #ECFDF5; border-color: #D1FAE5; }
.lm-v2-ac-green .lm-v2-ac-icon { background: #D1FAE5; color: #059669; }
.lm-v2-ac-green .lm-v2-ac-arrow { color: #065F46; }

/* Quick Summary — premium light cards, per-count clickable, hover-only scrollbar */
.lm-v2-summary-row { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: thin; scrollbar-color: transparent transparent; }
.lm-v2-summary-row:hover { scrollbar-color: #cbd5e1 transparent; }
.lm-v2-summary-row::-webkit-scrollbar { height: 8px; }
.lm-v2-summary-row::-webkit-scrollbar-track { background: transparent; }
.lm-v2-summary-row::-webkit-scrollbar-thumb { background: transparent; border-radius: 99px; }
.lm-v2-summary-row:hover::-webkit-scrollbar-thumb { background: #cbd5e1; }
.lm-v2-summary-card { flex: 1 1 0; min-width: 150px; background: #FCFDFF; border: 1px solid #EEF2F7; border-radius: 14px; padding: 15px 16px; transition: box-shadow .15s ease, border-color .15s ease, transform .15s ease; }
.lm-v2-summary-card:hover { border-color: #E2E8F0; box-shadow: 0 6px 18px rgba(15,23,42,.06); transform: translateY(-1px); }
.lm-v2-sum-label { font-size: 12px; color: #64748b; font-weight: 600; margin-bottom: 10px; }
.lm-v2-sum-body { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; }
.lm-v2-sum-head { display: inline-flex; align-items: baseline; gap: 5px; text-decoration: none; }
.lm-v2-sum-num { font-size: 1.7rem; font-weight: 800; line-height: 1; color: #0f172a; }
.lm-v2-sum-unit { font-size: 12px; color: #64748b; font-weight: 600; }
.lm-v2-sum-head:hover .lm-v2-sum-num, .lm-v2-sum-head:hover .lm-v2-sum-unit { color: #2563EB; }
.lm-v2-sum-total { display: block; margin-top: 6px; font-size: 12px; color: #64748b; text-decoration: none; }
.lm-v2-sum-total:hover { color: #2563EB; text-decoration: underline; }
.lm-v2-sum-icon { flex: none; opacity: .9; align-self: flex-end; }
.lm-v2-sum-icon .lm-v2-ico { width: 26px; height: 26px; }

/* Toolbar — ONE card, ONE row on desktop. The filter <form> participates in the
   card's flex row via display:contents, so the Export menu lives INSIDE the same
   toolbox (right edge), styled like every other toolbar control. Ops staff live on
   this page all day: compact by default, dropdowns reveal the rest. */
.lm-v2-filters-form { display: contents; }
.lm-v2-toolbar .search-input { flex: 1 1 180px; min-width: 140px; }
.lm-v2-toolbar .lm-v2-filter-select { min-width: 0; flex: 0 1 auto; }
/* The Enquiry Type / Status / Assigned To filters are custom .lm-dd dropdowns (like
   Date/Export), NOT native <select>s — so the browser's own arrow can never clip the
   label. Consistent box, caret pinned right, no shrink; the toolbar wraps instead. */
.lm-v2-toolbar .lm-fdd { flex: 0 0 auto; }
.lm-fdd > summary.lm-dd-btn { justify-content: space-between; gap: 10px; min-width: 132px; }
.lm-fdd-panel { min-width: 184px; }
.lm-fdd-panel a.lm-dd-item { text-decoration: none; }  /* anchor items, not buttons — no underline */
.lm-dd-item.is-sel, .lm-dd-item.is-sel:hover { background: var(--primary-soft, #eaf1fb); color: var(--primary, #2563EB); font-weight: 600; }
.lm-dd-export { margin-left: auto; }
.lm-dd-export > summary.lm-v2-filter-select { display: inline-flex; align-items: center; }

/* Details-based dropdown (lm-dd) — progressive disclosure, CSP-safe (no inline JS;
   app.js closes open ones on outside click / Escape). Same card language as .um-dropdown. */
.lm-dd { position: relative; }
.lm-dd > summary { list-style: none; cursor: pointer; user-select: none; white-space: nowrap; display: inline-flex; align-items: center; }
.lm-dd > summary::-webkit-details-marker { display: none; }
.lm-dd-caret { margin-left: 6px; font-size: 10px; opacity: .65; transition: transform .15s; }
.lm-dd[open] > summary .lm-dd-caret { transform: rotate(180deg); }
.lm-dd-panel {
  position: absolute; top: calc(100% + 6px); left: 0; z-index: 65; min-width: 250px;
  background: #fff; border: 1px solid #E2E8F0; border-radius: 12px;
  box-shadow: 0 10px 24px -6px rgba(0,0,0,.16); padding: 8px;
}
.lm-dd-panel-right { left: auto; right: 0; }
/* Set by app.js when the opened panel would leave the viewport: flip = re-anchor to
   the trigger's right edge; unflip = force back to the left edge. */
.lm-dd-panel-flip { left: auto; right: 0; }
.lm-dd-panel-unflip { left: 0; right: auto; }
.lm-dd-field { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 5px 6px; font-size: 13px; color: #334155; }
/* Panel date inputs must not inherit the toolbar's flexible-input sizing (.filters input) */
.lm-dd-panel input[type="date"] { flex: 0 1 auto; min-width: 0; }
.lm-dd-field input[type="date"] { padding: 7px 9px; border: 1px solid #E2E8F0; border-radius: 8px; font-size: 13px; color: #334155; background: #fff; }
.lm-dd-field input[type="date"]:focus { outline: none; border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.lm-dd-actions { display: flex; gap: 8px; padding: 6px 6px 2px; }
.lm-dd-actions .button { margin: 0; }
.lm-dd-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; border-radius: 8px; padding: 9px 10px; cursor: pointer; font-size: 13px; color: #0F172A; }
.lm-dd-item:hover { background: #F1F5F9; }
.lm-dd-item[disabled] { opacity: .5; cursor: not-allowed; }
.lm-dd-item[disabled]:hover { background: transparent; }
.lm-dd-item-sub { display: block; font-size: 11px; color: #94A3B8; font-weight: 400; margin-top: 2px; }
.lm-dd-sub { border-top: 1px solid #E2E8F0; margin-top: 4px; padding-top: 4px; }
.lm-dd-sub > summary { list-style: none; }
.lm-dd-sub > summary::-webkit-details-marker { display: none; }
.lm-dd-custom { display: grid; gap: 2px; padding: 2px 4px 4px; }

/* Filters strip — search + inline self-labelling selects (no external labels) */
.lm-v2-filters { align-items: center; gap: 10px; border: 1px solid #E2E8F0; border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; background: #fff; }
.lm-v2-filter-select { min-width: 150px; padding: 10px 12px; border: 1px solid #E2E8F0; border-radius: 10px; background: #fff; color: #334155; font-size: 13px; cursor: pointer; }
.lm-v2-filter-select:focus { outline: none; border-color: #2563EB; box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.lm-v2-filter-select.is-default { color: #94a3b8; }  /* placeholder-style when no filter chosen — matches the search box */

/* Table — premium white card wrapper + row hover */
.lm-v2-table-card { border: 1px solid #E2E8F0; border-radius: 12px; background: #fff; box-shadow: 0 4px 6px -1px rgba(0,0,0,.05); }
.lm-v2-table-card .data tbody tr:hover { background: #F8FAFC; }

/* ── Dark theme — the lm-v2 lead workspace was styled light-first with literal
   colours; map every one onto the dark palette so the page follows the theme
   (white cards → charcoal, light row-hover → dark hover so text stays readable). */
[data-theme="dark"] .lm-v2-section { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .lm-v2-filters { background: var(--surface); border-color: var(--border); }
[data-theme="dark"] .lm-v2-filter-select { background: var(--surface-2); border-color: var(--border); color: var(--fg-2); }
[data-theme="dark"] .lm-v2-filter-select.is-default { color: var(--muted); }
[data-theme="dark"] .lm-v2-table-card { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-sm); }
[data-theme="dark"] .lm-v2-table-card .data tbody tr:hover { background: var(--surface-3); }
[data-theme="dark"] .lm-v2-action-card { border-color: var(--border); }
[data-theme="dark"] .lm-v2-ac-num, [data-theme="dark"] .lm-v2-ac-label { color: var(--fg); }
[data-theme="dark"] .lm-v2-ac-sub { color: var(--muted); }
[data-theme="dark"] .lm-v2-ac-red   { background: #2a1717; border-color: #46201f; }
[data-theme="dark"] .lm-v2-ac-red   .lm-v2-ac-icon { background: #46201f; color: var(--danger); }
[data-theme="dark"] .lm-v2-ac-red   .lm-v2-ac-arrow { color: var(--danger-fg); }
[data-theme="dark"] .lm-v2-ac-amber { background: #2a220f; border-color: #453a17; }
[data-theme="dark"] .lm-v2-ac-amber .lm-v2-ac-icon { background: #453a17; color: var(--warn); }
[data-theme="dark"] .lm-v2-ac-amber .lm-v2-ac-arrow { color: var(--warn-fg); }
[data-theme="dark"] .lm-v2-ac-green { background: #12281b; border-color: #1e4230; }
[data-theme="dark"] .lm-v2-ac-green .lm-v2-ac-icon { background: #1e4230; color: var(--success); }
[data-theme="dark"] .lm-v2-ac-green .lm-v2-ac-arrow { color: var(--success-fg); }
[data-theme="dark"] .lm-v2-summary-card { background: var(--surface-2); border-color: var(--border); }
[data-theme="dark"] .lm-v2-summary-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-md); }
[data-theme="dark"] .lm-v2-sum-num { color: var(--fg); }
[data-theme="dark"] .lm-v2-sum-label, [data-theme="dark"] .lm-v2-sum-unit, [data-theme="dark"] .lm-v2-sum-total { color: var(--muted); }
[data-theme="dark"] .lm-v2-summary-row:hover { scrollbar-color: var(--border-strong) transparent; }
[data-theme="dark"] .lm-v2-summary-row:hover::-webkit-scrollbar-thumb { background: var(--border-strong); }
[data-theme="dark"] .lm-dd-panel { background: var(--surface); border-color: var(--border); box-shadow: var(--shadow-lg); }
[data-theme="dark"] .lm-dd-item { color: var(--fg); }
[data-theme="dark"] .lm-dd-item:hover { background: var(--surface-3); }
[data-theme="dark"] .lm-dd-item[disabled]:hover { background: transparent; }
[data-theme="dark"] .lm-dd-item-sub { color: var(--muted); }
[data-theme="dark"] .lm-dd-field { color: var(--fg-2); }
[data-theme="dark"] .lm-dd-field input[type="date"] { background: var(--surface-2); border-color: var(--border); color: var(--fg); }
[data-theme="dark"] .lm-dd-sub { border-top-color: var(--border); }

/* Add Lead form — required labels stay on one line; auto-filled fields read as read-only */
.lm-lead-form { display: grid; gap: 12px; }
.lm-lead-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 9px 12px; align-items: end; }
.lm-lead-grid > legend { grid-column: 1 / -1; margin-bottom: 0; }
.lm-lead-grid > .lm-span6 { grid-column: 1 / -1; }
.lm-lead-form .field > span { margin-bottom: 2px; }
.lm-span2 { grid-column: span 2; }
.lm-span3 { grid-column: span 3; }
.lm-lead-form .field > span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lm-lead-form .req { color: var(--danger, #b53030); }
.lm-auto-field { background: #f1f5f9; color: #475569; cursor: default; }
.lm-auto-field:focus { outline: none; box-shadow: none; }
.lm-lead-form select.lm-auto-field { cursor: pointer; }   /* State stays usable as a manual fallback */

/* lm-v2 SVG icon colours (replace OS emojis on the Leads cards) */
.lm-v2-ico { display: block; flex: none; }
.lm-v2-c-red    { color: #dc2626; }
.lm-v2-c-amber  { color: #d97706; }
.lm-v2-c-green  { color: #16a34a; }
.lm-v2-c-teal   { color: #0d9488; }
.lm-v2-c-orange { color: #ea580c; }
.lm-v2-c-purple { color: #7c3aed; }
.lm-v2-c-blue   { color: var(--primary); }

/* ===== Lead Details drawer — identity, tabs, overview sections ===== */
.lead-identity .lead-avatar { background: #e9ecef; color: #6c757d; }
[data-theme="dark"] .lead-identity .lead-avatar, [data-theme="blue"] .lead-identity .lead-avatar { background: rgba(255,255,255,.12); color: #cbd5e1; }
.lead-identity .li-line { font-size: 13px; margin-top: 2px; }
.lead-identity .li-phone { color: #16a34a; }

/* Overview key-values — two-column grid (label | value). */
.ov-kv { display: grid; grid-template-columns: 130px 1fr; gap: 9px 10px; margin: 2px 0 16px; font-size: 13px; }
.ov-kv dt { color: var(--muted); margin: 0; }
.ov-kv dd { color: var(--fg); margin: 0; font-weight: 500; }
.ov-h { font-size: 13px; font-weight: 700; margin: 16px 0 8px; }
.ov-date { font-size: 13px; margin-bottom: 8px; }
/* Follow-up: date + button share one row to save vertical space. */
.ov-followup { display: flex; gap: 8px; align-items: stretch; }
.ov-followup input[type="date"] { flex: 1; min-width: 0; margin-bottom: 0; box-sizing: border-box; }
.ov-followup .button { white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.ov-btn-wide { width: 100%; justify-content: center; display: flex; align-items: center; gap: 6px; }
.ov-assign { display: flex; gap: 8px; align-items: stretch; }
.ov-assign select { flex: 1; min-width: 0; }
/* Assign-dealer: search + button on ONE row; search grows to fill (roomy input),
   the city hint wraps to its own line below (it's a caption, not a control). */
.ov-assign--stack { flex-wrap: wrap; }
.ov-assign--stack .combobox { flex: 1; min-width: 0; }
.ov-assign--stack .combobox-input { height: 40px; font-size: 14px; }
.ov-assign--stack .button { justify-content: center; white-space: nowrap; }
/* Inline link-button that jumps to another drawer tab (e.g. Overview → Remarks). */
.ov-tablink { background: none; border: none; padding: 2px 0; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; color: var(--primary, #1658e5); font-weight: 600; font-size: 13px; }
.ov-tablink:hover { text-decoration: underline; }
.ov-remark { display: flex; flex-direction: column; gap: 8px; }
.ov-remark textarea { width: 100%; box-sizing: border-box; }
.ov-save { align-self: flex-end; }
.ov-journey { border: 1px solid var(--border); border-left: 3px solid #16a34a; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.ov-timeline { border-left: 2px solid var(--border); padding-left: 12px; }
.ov-tl-item { padding: 6px 0; }
.ov-remark-item { border: 1px solid var(--border); border-radius: 8px; padding: 9px 12px; margin-bottom: 7px; }

/* Quick Actions — tinted action buttons in a 3-up grid. */
.quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.quick-actions .qa { display: flex; align-items: center; justify-content: center; gap: 5px; padding: 9px 6px; border-radius: 9px; font-size: 13px; font-weight: 600; border: 1px solid transparent; cursor: pointer; text-decoration: none; line-height: 1.1; }
.quick-actions .qa-green { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
.quick-actions .qa-blue { color: var(--primary); border-color: #bfdbfe; background: #eff6ff; }
.quick-actions .qa-red { color: #b91c1c; border-color: #fecaca; background: #fef2f2; }
.quick-actions .qa:hover { filter: brightness(.97); }

/* ============================ People & Access ============================ */
/* Employee-centric admin console. Uses design-system tokens only, so it themes
   across Light / Blue / Dark automatically. */
.pa-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-bottom: var(--sp-3); }
.pa-head h1 { margin-bottom: 2px; }
.pa-tabs { display: inline-flex; gap: 2px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-md); padding: 3px; }
.pa-tab { padding: 6px 12px; border-radius: calc(var(--r-md) - 3px); font-size: var(--fs-sm); color: var(--muted); text-decoration: none; white-space: nowrap; }
.pa-tab:hover { color: var(--fg); background: var(--surface-3); }
.pa-tab.active { color: var(--primary-fg); background: var(--primary); }

.pa-filters { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; margin: var(--sp-3) 0; }
.pa-filters input[type="search"] { min-width: 280px; flex: 1 1 auto; max-width: 460px; }
.pa-count { margin-left: auto; }

.pa-table th, .pa-table td { vertical-align: middle; }
.pa-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
.pa-avatar-i { background: var(--primary-soft); color: var(--primary); font-size: 11px; font-weight: 700; }
.pa-avatar.lg { width: 52px; height: 52px; font-size: 17px; }

.pa-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; border: 1px solid transparent; }
.pa-badge.lg { padding: 5px 14px; font-size: var(--fs-sm); }
.pa-badge-enabled { background: var(--success-bg); color: var(--success-fg); }
.pa-badge-disabled { background: var(--surface-3); color: var(--muted); }
.pa-badge-locked { background: var(--warn-bg); color: var(--warn-fg); }
.pa-badge-none { background: var(--surface-2); color: var(--muted); border-color: var(--border); }
.pa-badge-pending { background: var(--warn-bg); color: var(--warn-fg); margin-left: 4px; }
.pa-emp-active { color: var(--success); } .pa-emp-on_leave { color: var(--warn); } .pa-emp-exited { color: var(--muted); }

.pa-actions { white-space: nowrap; }
.pa-actions a, .pa-link { font-size: var(--fs-sm); margin-right: 8px; }
.pa-inline { display: inline; }
.pa-link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--primary); font: inherit; }
.pa-link.danger { color: var(--danger); } .pa-link.ok { color: var(--success); }

.pa-pager { display: flex; gap: 4px; margin-top: var(--sp-3); flex-wrap: wrap; }
.pa-pager a { padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--r-sm); text-decoration: none; color: var(--fg-2); font-size: var(--fs-sm); }
.pa-pager a.active { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }

/* Manage Access workspace */
.pa-mhead { display: flex; align-items: center; gap: var(--sp-3); margin: var(--sp-2) 0 var(--sp-3); }
.pa-mhead h1 { margin: 0; }
.pa-mhead .pa-badge { margin-left: auto; }
.pa-subnav { display: flex; gap: var(--sp-2); position: sticky; top: var(--topbar-h); background: var(--bg); padding: var(--sp-2) 0; border-bottom: 1px solid var(--border); margin-bottom: var(--sp-3); z-index: 2; }
.pa-subnav a { font-size: var(--fs-sm); color: var(--muted); text-decoration: none; padding: 4px 8px; border-radius: var(--r-sm); }
.pa-subnav a:hover { color: var(--fg); background: var(--surface-2); }

.pa-sec { margin-bottom: var(--sp-3); scroll-margin-top: calc(var(--topbar-h) + 60px); }
.pa-sec h2 { display: flex; align-items: center; gap: var(--sp-2); }
.pa-owned { font-size: var(--fs-xs); font-weight: 500; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); padding: 1px 8px; border-radius: 999px; }
.pa-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: var(--sp-3); margin-top: var(--sp-2); }
.pa-grid > div { display: flex; flex-direction: column; gap: 2px; }
.pa-grid span { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.pa-grid b { font-size: var(--fs-sm); color: var(--fg); }

.pa-cred { background: var(--success-bg); border: 1px solid var(--success); border-radius: var(--r-md); padding: var(--sp-3); margin-bottom: var(--sp-3); }
.pa-cred-row { display: flex; align-items: center; gap: var(--sp-2); margin-top: 6px; }
.pa-cred-row span { min-width: 150px; font-size: var(--fs-sm); color: var(--fg-2); }
.pa-cred-row code { background: var(--surface); border: 1px solid var(--border); padding: 3px 10px; border-radius: var(--r-sm); font-size: var(--fs-sm); }

.pa-form { display: flex; align-items: flex-end; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-2); }
.pa-form.inline { margin: 0; }
.pa-actions-row { display: flex; align-items: flex-end; gap: var(--sp-2); flex-wrap: wrap; margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.pa-note { color: var(--muted); background: var(--surface-2); border-left: 3px solid var(--border-strong); padding: 8px 12px; border-radius: var(--r-sm); margin-top: var(--sp-2); }
.pa-note-warn { color: var(--fg); background: var(--warn-bg); border-left-color: var(--warn); }

/* ---- Employee month calendar ---- */
.cal-head { display:flex; align-items:flex-start; justify-content:space-between; gap:16px; flex-wrap:wrap; }
.cal-nav { display:flex; align-items:center; gap:8px; }
.cal-nav .cal-title { font-weight:650; font-size:15px; min-width:150px; text-align:center; }
.cal-nav .button { padding:5px 12px; }
.cal-today-btn { margin-left:4px; }
.cal-legend { display:flex; flex-wrap:wrap; gap:8px; margin:0 0 12px; }
.cal-chip { font-size:11.5px; padding:2px 9px; border-radius:999px; border:1px solid var(--border); background:var(--surface-2); color:var(--muted); }
.cal-grid { display:grid; grid-template-columns:repeat(7,1fr); gap:1px; background:var(--border); border:1px solid var(--border); border-radius:var(--r-lg); overflow:hidden; }
.cal-dow { background:var(--surface-2); padding:8px 6px; text-align:center; font-size:11px; font-weight:650; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); }
.cal-cell { background:var(--surface); min-height:104px; padding:5px 6px; display:flex; flex-direction:column; gap:4px; }
.cal-cell.cal-empty { background:var(--surface-2); }
.cal-cell.cal-today { background:var(--primary-soft); box-shadow:inset 0 0 0 2px var(--primary); }
.cal-daynum { font-size:12.5px; font-weight:600; color:var(--muted); align-self:flex-start; }
.cal-today .cal-daynum { color:var(--primary); font-weight:700; }
.cal-items { display:flex; flex-direction:column; gap:3px; }
.cal-item { font-size:11.5px; line-height:1.3; padding:2px 6px; border-radius:5px; border-left:3px solid var(--muted);
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; background:var(--surface-2); color:var(--fg); }
.cal-more { font-size:11px; color:var(--muted); padding:0 4px; }
.cal-item.tone-primary { background:var(--primary-soft); border-left-color:var(--primary); color:var(--info-fg); }
.cal-item.tone-danger  { background:var(--danger-bg); border-left-color:var(--danger); color:var(--danger-fg); }
.cal-item.tone-warn    { background:var(--warn-bg); border-left-color:var(--warn); color:var(--warn-fg); }
.cal-item.tone-info    { background:color-mix(in srgb, #0d9488 14%, var(--surface)); border-left-color:#0d9488; color:color-mix(in srgb, #0d9488 60%, var(--fg)); }
.cal-item.tone-success { background:var(--success-bg); border-left-color:var(--success); color:var(--success-fg); }
.cal-item.tone-note    { background:color-mix(in srgb, #6d28d9 12%, var(--surface)); border-left-color:#6d28d9; color:color-mix(in srgb, #6d28d9 55%, var(--fg)); }
.cal-item.tone-done    { background:var(--surface-2); border-left-color:var(--border-strong); color:var(--muted); text-decoration:line-through; }
.cal-chip.tone-primary { background:var(--primary-soft); border-color:var(--primary); color:var(--info-fg); }
.cal-chip.tone-warn    { background:var(--warn-bg); border-color:var(--warn); color:var(--warn-fg); }
.cal-chip.tone-info    { background:color-mix(in srgb, #0d9488 14%, var(--surface)); border-color:#0d9488; color:color-mix(in srgb, #0d9488 60%, var(--fg)); }
.cal-chip.tone-success { background:var(--success-bg); border-color:var(--success); color:var(--success-fg); }
.cal-chip.tone-note    { background:color-mix(in srgb, #6d28d9 12%, var(--surface)); border-color:#6d28d9; color:color-mix(in srgb, #6d28d9 55%, var(--fg)); }
@media (max-width:720px){ .cal-cell { min-height:76px; } .cal-item-label { font-size:10.5px; } }

/* ---- Task monitoring stats strip (HR dashboard reflection) ---- */
.task-stats { display:grid; grid-template-columns:repeat(auto-fit,minmax(120px,1fr)); gap:10px; margin:0 0 16px; }
.task-stat { display:flex; flex-direction:column; gap:2px; padding:12px 14px; background:var(--surface); border:1px solid var(--border);
  border-left:4px solid var(--muted); border-radius:var(--r-lg); text-decoration:none; color:inherit; box-shadow:var(--shadow-sm); transition:transform 120ms, box-shadow 120ms; }
.task-stat:hover { transform:translateY(-1px); box-shadow:0 2px 8px rgba(0,0,0,.06); }
.task-stat-n { font-size:24px; font-weight:700; line-height:1.1; font-variant-numeric:tabular-nums; }
.task-stat-l { font-size:11.5px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted); font-weight:600; }
.task-stat.tone-danger { border-left-color:var(--danger); } .task-stat.tone-danger .task-stat-n { color:var(--danger); }
.task-stat.tone-warn { border-left-color:var(--warn); } .task-stat.tone-warn .task-stat-n { color:var(--warn); }
.task-stat.tone-success { border-left-color:#15803d; } .task-stat.tone-success .task-stat-n { color:#15803d; }

.pa-modgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--sp-2); margin-top: var(--sp-2); }
.pa-mod { border: 1px solid var(--border); border-radius: var(--r-md); padding: var(--sp-2) var(--sp-3); background: var(--surface); }
.pa-mod.off { opacity: .5; }
.pa-mod-h { font-weight: 600; font-size: var(--fs-sm); margin-bottom: 6px; }
.pa-mod-a { display: flex; flex-wrap: wrap; gap: 4px; }
.pa-perm { font-size: var(--fs-xs); padding: 1px 7px; border-radius: 999px; }
.pa-perm.on { background: var(--primary-soft); color: var(--primary); }
.pa-perm.off { background: var(--surface-2); color: var(--muted); text-decoration: line-through; }

.pa-rolegrid, .pa-tmplgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: var(--sp-3); margin: var(--sp-3) 0; }
.pa-role-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.pa-role-mods { display: flex; flex-wrap: wrap; gap: 5px; margin-top: var(--sp-2); }
.pa-chip { font-size: var(--fs-xs); background: var(--surface-2); border: 1px solid var(--border); color: var(--fg-2); padding: 2px 9px; border-radius: 999px; }
.pa-tmpl h2 { font-size: var(--fs-md); margin-bottom: var(--sp-2); }
.pa-tmpl-row { display: flex; gap: var(--sp-2); padding: 6px 0; border-top: 1px solid var(--border); }
.pa-tmpl-act { min-width: 90px; font-size: var(--fs-sm); font-weight: 600; color: var(--fg-2); }
.pa-tmpl-roles { display: flex; flex-wrap: wrap; gap: 4px; }

/* ============================ Settings hub ============================ */
/* Administration Center — Business Configuration vs ERP Configuration. Cards
   link to existing admin pages; "Coming soon" cards are future containers. */
.set-section { margin: var(--sp-4) 0; }
.set-sec-head { display: flex; align-items: baseline; gap: var(--sp-2); border-bottom: 1px solid var(--border); padding-bottom: 6px; margin-bottom: var(--sp-3); }
.set-sec-head h2 { margin: 0; }
.set-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-3); }
.set-card { display: block; text-decoration: none; color: inherit; position: relative; transition: box-shadow 140ms ease, border-color 140ms ease, transform 140ms ease; }
.set-card-h { font-weight: 600; font-size: var(--fs-md); margin-bottom: 4px; color: var(--fg); }
a.set-card:hover { border-color: var(--primary); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.set-live .set-card-h::after { content: ''; }
/* Coming-soon = clearly inactive (flat, dashed, muted) so live areas stand out. */
.set-soon { opacity: .6; background: var(--surface-2); border-style: dashed; box-shadow: none; cursor: default; }
.set-soon .set-card-h { color: var(--muted); }
.set-tag { display: inline-block; margin-top: 6px; font-size: var(--fs-xs); font-weight: 600; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; }
.set-links { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.set-links span { font-size: var(--fs-xs); background: var(--primary-soft); color: var(--primary); border-radius: 999px; padding: 2px 9px; }

/* ---- Sidebar second-level sub-sections (Sales domain) ---- */
.sidesub-head {
  display: flex; align-items: center; gap: 6px; width: 100%;
  background: none; border: 0; cursor: pointer; text-align: left; font-family: inherit;
  padding: 8px var(--sp-2) 8px var(--sp-3); border-radius: var(--r-md);
  color: var(--fg-2); font-size: var(--fs-sm); font-weight: 500;
  transition: background-color 140ms ease, color 140ms ease;
}
.sidesub-head:hover { background: var(--surface-2); color: var(--fg); }
.sidesub-caret { font-size: .68em; color: var(--muted); flex: 0 0 10px; transition: transform 140ms ease; }
.sidesub.collapsed .sidesub-items { display: none; }
.sidesub-items {
  display: flex; flex-direction: column; gap: 1px;
  margin: 1px 0 4px calc(var(--sp-3) + 4px); padding-left: 8px;
  border-left: 1px solid var(--border);
}
.sidesub-items .sidelink { font-size: 13px; padding-top: 6px; padding-bottom: 6px; }
/* In the icon-only rail the sub-sections don't apply (whole submenu is hidden). */
.app-shell.nav-collapsed .sidesub-head { display: none; }

/* ============ Global sidebar = modules only · in-page module nav ============ */
/* Sidebar entries are one-per-module (.modlink inherits .sidelink styling). The
   module's child pages live in .modnav, a horizontal tab bar under the topbar. */
.modnav {
  display: flex; align-items: center; gap: 2px; flex-wrap: wrap;
  margin: 0 0 var(--sp-4); border-bottom: 1px solid var(--border);
}
.modnav-title { font-weight: 700; font-size: var(--fs-md); color: var(--fg); margin-right: var(--sp-3); }
.modnav-tab {
  padding: 9px 13px; font-size: var(--fs-sm); color: var(--muted); text-decoration: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color 140ms ease, border-color 140ms ease;
}
.modnav-tab:hover { color: var(--fg); }
.modnav-tab.active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 600; }
/* L3 — section navigation: filters / views inside a primary page (pill chips). */
.modnav + .secnav { margin-top: calc(-1 * var(--sp-2)); }
.secnav { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 var(--sp-4); }
.secnav-chip {
  padding: 4px 12px; font-size: var(--fs-sm); border: 1px solid var(--border); border-radius: 999px;
  color: var(--fg-2); text-decoration: none; background: var(--surface);
  transition: border-color 140ms ease, color 140ms ease, background-color 140ms ease;
}
.secnav-chip:hover { border-color: var(--border-strong); color: var(--fg); }
.secnav-chip.active { background: var(--primary); color: var(--primary-fg); border-color: var(--primary); }
@media print { .modnav, .secnav { display: none; } }

/* ---- Employee Access Center — new-login credential card (shareable) ---- */
.cred-card { border: 1px solid var(--success); background: var(--success-bg); border-radius: var(--r-md); padding: 16px 18px; margin: 0 0 18px; }
.cred-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.cred-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 12px; }
.cred-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cred-k { min-width: 150px; font-size: var(--fs-sm); color: var(--fg-2); font-weight: 600; }
.cred-v { background: var(--surface); border: 1px solid var(--border); padding: 5px 12px; border-radius: var(--r-sm); font-size: var(--fs-sm); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; user-select: all; }

/* ---- Employee Access Center — create form (production layout) ---- */
.eac-create { padding: 18px 20px; }
.eac-create h2 { margin: 0 0 4px; font-size: var(--fs-lg); }
.eac-lede { margin: 0 0 16px; max-width: 640px; }
.eac-form { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px 16px; max-width: 820px; align-items: end; }
/* Block layout (NOT flex-column): the label text + JS asterisk stay inline on one
   line, the input drops to the next line. Flex-column blockifies the .req span and
   forces the asterisk onto its own row — that was the bug. */
.eac-form .field { display: block; margin: 0; }
.eac-form .field > span { display: inline; font-size: var(--fs-sm); color: var(--fg-2); font-weight: 500; margin: 0; }
.eac-form .field > span.req { margin-left: 2px; }
.eac-form .field > input { display: block; width: 100%; margin-top: 6px; }
.eac-form .field > .eac-roles { margin-top: 8px; }
.eac-form .span-2 { grid-column: span 2; }
.eac-form .span-3 { grid-column: 1 / -1; }
/* First / Middle / Surname — always their own 3-up row (independent of the outer grid). */
.eac-name { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px 16px; }
@media (max-width: 560px) { .eac-name { grid-template-columns: 1fr; } }
.eac-roles { display: flex; flex-wrap: wrap; gap: 8px; }
.eac-role { display: inline-flex; align-items: center; gap: 7px; padding: 7px 13px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: var(--fs-sm); user-select: none; transition: border-color 140ms ease, background-color 140ms ease; }
.eac-role:hover { border-color: var(--border-strong); }
.eac-role:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.eac-role input { margin: 0; }
.eac-actions { margin-top: 4px; }
@media (max-width: 720px) { .eac-form { grid-template-columns: 1fr 1fr; } .eac-form .span-2, .eac-form .span-3 { grid-column: 1 / -1; } }
@media (max-width: 480px) { .eac-form { grid-template-columns: 1fr; } }

/* ---- Employee manage page — Create login row + Manage expander ---- */
.pa-login-create { display: flex; align-items: flex-end; gap: var(--sp-3); flex-wrap: wrap; margin-top: var(--sp-2); }
.pa-manage { margin-top: var(--sp-3); }
.pa-manage-toggle { display: inline-flex; align-items: center; gap: 7px; list-style: none; cursor: pointer; user-select: none; }
.pa-manage-toggle::-webkit-details-marker { display: none; }
.pa-manage-toggle::before { content: '⚙'; font-size: 1em; line-height: 1; }
.pa-manage[open] .pa-manage-toggle::before { content: '✕'; }
.pa-manage-body { margin-top: var(--sp-3); padding-top: var(--sp-3); border-top: 1px solid var(--border); }
.pa-manage-body .pa-actions-row { padding-top: 0; border-top: 0; margin-top: 0; }

/* ---- My Tasks — read-only HR tasks pulled from HRM ---- */
.my-hr-tasks { display: grid; gap: 10px; margin-bottom: 10px; }
.my-hr-task { padding: 12px 14px; border-left: 3px solid var(--warn); }
.my-hr-task-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; }

/* ============================================================================
   DEALER PORTAL — PREMIUM LAYER (2026-07)
   Scoped to portal-* classes ONLY — the internal ERP look is untouched.
   Elevates every portal page at once via the shared shell + components:
   depth, refined surfaces, richer brand, smoother interactions. No new options.
   ============================================================================ */
:root {
  --pt-shadow:   0 1px 2px rgba(20,35,66,.05), 0 8px 22px -8px rgba(20,35,66,.14);
  --pt-shadow-h: 0 3px 8px rgba(20,35,66,.08), 0 20px 42px -14px rgba(20,35,66,.24);
}

/* Canvas: layered light so cards read as floating, not a flat slab. */
body:has(.portal-topbar) {
  background:
    radial-gradient(1100px 560px at 85% -10%, rgba(36,90,160,.08), transparent 62%),
    linear-gradient(180deg, #eff3fa 0%, #e6edf7 100%) fixed;
}

/* Topbar: glassy, floating. */
.portal-topbar {
  background: rgba(255,255,255,.82);
  -webkit-backdrop-filter: saturate(1.5) blur(12px);
  backdrop-filter: saturate(1.5) blur(12px);
  border-bottom: 1px solid rgba(20,35,66,.07);
  box-shadow: 0 6px 22px -14px rgba(20,35,66,.4);
}
.portal-brand { gap: 10px; }
.portal-brand .brandmark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; border-radius: 12px; background: #fff; overflow: hidden;
  box-shadow: 0 0 0 1px rgba(20,35,66,.06), 0 3px 10px -3px rgba(20,35,66,.2);
}
.portal-brand .brandmark img { width: 32px; height: 32px; object-fit: contain; }
.portal-brand-txt { font-weight: 500; letter-spacing: -.01em; color: var(--fg-2); font-size: 15px; }
.portal-brand-txt b { color: var(--primary); font-weight: 800; }

/* Sidebar: quiet gradient rail + a premium active pill. */
.portal-sidebar {
  background: linear-gradient(180deg, #ffffff 0%, #f3f7fc 100%);
  border-right: 1px solid rgba(20,35,66,.06);
}
.portal-sidebar .side-section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); padding: 15px 16px 6px;
}
.portal-sidebar .sidelink {
  position: relative; margin: 2px 8px; padding: 9px 12px; border-radius: 10px;
  color: var(--fg-2); font-weight: 500;
  transition: background .16s ease, color .16s ease, transform .12s ease;
}
.portal-sidebar .sidelink:hover { background: rgba(27,77,143,.07); color: var(--fg); }
.portal-sidebar .sidelink.active {
  background: var(--primary-soft); color: var(--primary); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}

/* Cards: layered elevation + hover lift + larger radius. */
.portal-card {
  border: 1px solid rgba(20,35,66,.06); border-radius: 14px;
  box-shadow: var(--pt-shadow); padding: 18px 20px;
  transition: box-shadow .22s ease, transform .22s ease;
}
.portal-card:hover { box-shadow: var(--pt-shadow-h); transform: translateY(-1px); }
.portal-card.qa-card:hover { transform: none; }

/* Hero: crisper heading. */
.portal-hero h1, .portal-main > h1 { letter-spacing: -.02em; }

/* Tables: refined header, roomy rows, quiet hover, no hard grid. */
.portal-main table { border-collapse: separate; border-spacing: 0; }
.portal-main table thead th {
  background: linear-gradient(180deg, #f8fafd, #eef3fa);
  color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  padding: 12px 14px; border-bottom: 1px solid rgba(20,35,66,.08);
}
.portal-main table tbody td { padding: 13px 14px; border-bottom: 1px solid rgba(20,35,66,.05); }
.portal-main table tbody tr { transition: background .14s ease; }
.portal-main table tbody tr:hover td { background: rgba(27,77,143,.035); }
.portal-main table tbody tr:last-child td { border-bottom: 0; }

/* Buttons: primary gets the brand gradient + soft depth + lift. */
.portal-main .btn, .portal-topbar .btn { transition: transform .12s ease, box-shadow .2s ease, filter .18s ease; }
.portal-main .btn.primary, .portal-topbar .btn.primary {
  background: var(--grad-brand); border: 0; color: #fff;
  box-shadow: 0 2px 6px -1px rgba(20,35,66,.3), inset 0 1px 0 rgba(255,255,255,.16);
}
.portal-main .btn.primary:hover, .portal-topbar .btn.primary:hover {
  transform: translateY(-1px); box-shadow: 0 8px 18px -5px rgba(20,35,66,.36); filter: saturate(1.06);
}

/* Status pills / badges: softer, rounder. */
.portal-main .pill, .portal-main .status, .portal-main .state, .portal-main .chip, .portal-main .badge {
  border-radius: var(--r-pill); font-weight: 600;
}

/* ============================================================================
   DEALER PORTAL — ADVANCED PREMIUM (typography scale, emoji nav, deeper depth)
   ============================================================================ */

/* Emoji nav icons — sit in a soft rounded tile, sized + aligned. */
.portal-sidebar .sidelink { gap: 11px; font-size: 13.75px; }
.portal-sidebar .sidelink .si {
  width: 27px; height: 27px; font-size: 16.5px; line-height: 1; flex: none;
  display: inline-flex; align-items: center; justify-content: center; border-radius: 8px;
  background: rgba(27,77,143,.05); transition: background .16s ease, transform .12s ease;
}
.portal-sidebar .sidelink:hover .si { background: rgba(27,77,143,.11); transform: translateY(-1px); }
.portal-sidebar .sidelink.active .si { background: #fff; box-shadow: 0 1px 4px rgba(20,35,66,.16); }

/* Typography — a confident, premium scale (tabular figures for all data). */
.portal-main, .portal-card { font-variant-numeric: tabular-nums; }
.portal-main > h1, .portal-hero h1 {
  font-size: 27px; font-weight: 700; letter-spacing: -.025em; line-height: 1.14; color: var(--fg);
}
.portal-hero p, .portal-main > h1 + p { font-size: 14.5px; color: var(--muted); }
.portal-card > h3, .portal-card h3:first-child { font-size: 15px; font-weight: 600; letter-spacing: -.01em; }
.portal-sidebar .side-section-label { font-size: 10px; letter-spacing: .14em; }

/* Depth — crisper, more expensive elevation. */
.portal-card {
  border: 1px solid rgba(20,35,66,.055);
  box-shadow: 0 1px 2px rgba(20,35,66,.05), 0 12px 30px -12px rgba(20,35,66,.20);
}
.portal-card:hover { box-shadow: 0 2px 6px rgba(20,35,66,.07), 0 24px 50px -16px rgba(20,35,66,.28); }

/* Tables — a touch more air + tighter premium header. */
.portal-main table thead th { padding: 13px 16px; font-size: 10.5px; letter-spacing: .08em; }
.portal-main table tbody td { padding: 14px 16px; font-size: 13.5px; }

/* ============================================================================
   DEALER PORTAL — SIDEBAR REFINEMENT (spacing rhythm + right-sized rows)
   Fixes the .side-section wrapper's text-transform cascade that was
   UPPERCASING + truncating the nav links, and normalises section spacing.
   ============================================================================ */

.side-nav { gap: 3px; }

/* Dashboard clears the sticky topbar with a little breathing room. */
.portal-sidebar { padding-top: 12px; }

/* The .side-section wrapper is a group container, not a label — it must not
   impose uppercase / weight / tracking on the links nested inside it. */
.portal-sidebar .side-section {
  display: flex; flex-direction: column; gap: 2px;
  padding: 0; margin: 7px 0 0;
  font-size: inherit; font-weight: 400; line-height: inherit;
  letter-spacing: normal; text-transform: none; color: inherit;
}
.portal-sidebar .side-section:first-of-type { margin-top: 4px; }

/* Group label owns its own spacing — one clean, consistent rhythm. */
.portal-sidebar .side-section-label {
  display: block; padding: 0 14px 5px; margin: 0;
  font-size: 10.5px; font-weight: 700; letter-spacing: .11em;
  text-transform: uppercase; color: var(--muted); opacity: .78;
}

/* Nav rows — title case (cascade reset), right-sized, even vertical rhythm. */
.portal-sidebar .sidelink {
  text-transform: none; letter-spacing: normal;
  margin: 0 8px; padding: 7px 10px; border-radius: 9px;
  gap: 10px; font-size: 13.5px; font-weight: 500; line-height: 1.2;
}
.portal-sidebar .sidelink.active { font-weight: 600; }

/* Emoji tile — slightly smaller + softer, so the rail reads refined not chunky. */
.portal-sidebar .sidelink .si {
  width: 26px; height: 26px; font-size: 14.5px; border-radius: 7px;
}

/* The unread badge must shrink the label (ellipsis) before it ever clips. */
.portal-sidebar .sidelink .sl { flex: 1 1 auto; min-width: 0; }

/* Footer sits a little clear of the last group. */
.portal-sidebar .side-foot { margin-top: 16px; }

/* ============================================================================
   DEALER PORTAL — DARK / BLUE THEME CORRECTIONS
   The premium layer above hardcodes LIGHT surfaces (glass topbar, white sidebar
   rail, light table headers, white icon tiles) that ignore the theme — so dark
   mode rendered a white bar + rail. Re-point them at the active theme's tokens.
   ============================================================================ */
[data-theme="dark"] body:has(.portal-topbar),
[data-theme="blue"] body:has(.portal-topbar) {
  background:
    radial-gradient(1100px 560px at 85% -10%, rgba(90,140,210,.10), transparent 62%),
    var(--bg) fixed;
}
[data-theme="dark"] .portal-topbar { background: rgba(18,18,20,.72); border-bottom-color: rgba(255,255,255,.07); }
[data-theme="blue"] .portal-topbar { background: rgba(14,28,52,.74); border-bottom-color: rgba(255,255,255,.08); }
[data-theme="dark"] .portal-sidebar,
[data-theme="blue"] .portal-sidebar { background: var(--surface); border-right-color: var(--border); }
[data-theme="dark"] .portal-main table thead th,
[data-theme="blue"] .portal-main table thead th {
  background: var(--surface-2); color: var(--muted); border-bottom-color: var(--border);
}
[data-theme="dark"] .portal-card,
[data-theme="blue"] .portal-card { border-color: var(--border); }
[data-theme="dark"] .portal-main table tbody td,
[data-theme="blue"] .portal-main table tbody td { border-bottom-color: var(--border); }
[data-theme="dark"] .portal-main table tbody tr:hover td,
[data-theme="blue"] .portal-main table tbody tr:hover td { background: rgba(255,255,255,.035); }
[data-theme="dark"] .portal-sidebar .sidelink .si,
[data-theme="blue"] .portal-sidebar .sidelink .si { background: rgba(255,255,255,.06); }
[data-theme="dark"] .portal-sidebar .sidelink:hover .si,
[data-theme="blue"] .portal-sidebar .sidelink:hover .si { background: rgba(255,255,255,.12); }
[data-theme="dark"] .portal-sidebar .sidelink.active .si,
[data-theme="blue"] .portal-sidebar .sidelink.active .si { background: var(--primary-soft); box-shadow: none; }
[data-theme="dark"] .stock-row:hover,
[data-theme="blue"] .stock-row:hover { background: var(--surface-2); }
