/* =========================================================================
   PERFECT JEWELRY — DESIGN SYSTEM
   One file, two themes (light / dark), driven entirely by CSS custom
   properties keyed off [data-theme]. No component below reaches for a raw
   color — everything reads from the token list. When this gets ported to
   Django templates, these two blocks (:root + [data-theme="..."]) are the
   only place a re-skin ever needs to touch.
   ========================================================================= */

/* ---------- Tokens that never change between themes ---------- */
:root {
  --font-serif: 'Cormorant', serif;
  --font-sans: 'Geist', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;

  --sidebar-w: 232px;
  --sidebar-w-collapsed: 0px;
  --sidebar-w-mini: 72px;
  --header-h: 52px;

  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-pill: 999px;

  --ease: cubic-bezier(.4, 0, .2, 1);
  --t-fast: .15s;
  --t-med: .25s;

  /* ---------- Scales (UI review, 22 Oct 2026) ----------
     Defined here, not yet applied. New and touched rules should use these
     instead of literals; existing rules move over as they are edited.
     Each step absorbs the cluster of values next to it today. */

  /* Type. 11px is the floor on screen; smaller sizes are for print only. */
  --fs-caption: 11px;   /* caps labels, pills, table heads   (was 9–11px)      */
  --fs-small: 12px;     /* meta lines, help text, .btn-sm    (was 11.5–12.5px) */
  --fs-body: 13px;      /* tables, forms, body copy          (was 13–13.5px)   */
  --fs-lead: 15px;      /* panel titles, emphasis            (was 14–16px)     */
  --fs-h3: 18px;        /* section headings, serif           (was 17–20px)     */
  --fs-h2: 22px;        /* page title, KPI figures           (was 21–24px)     */
  --fs-display: 30px;   /* login, landing, big totals        (was 26–34px)     */

  /* Weights. Geist is loaded at 400/500/600/700 only; 550 and 650 round. */
  --fw-regular: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;       /* figures only */

  --lh-tight: 1.15;     /* headings, large figures */
  --lh-snug: 1.3;       /* pills, buttons, one-line rows */
  --lh-body: 1.45;      /* running text */

  --tracking-caps: .06em;   /* uppercase labels */
  --tracking-tight: -.02em; /* large mono figures */

  /* Spacing on a 4px grid. --space-half covers icon-to-label gaps. */
  --space-half: 6px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;

  /* Layers, named by role. Values match what each role uses today so
     adopting them moves nothing. Toasts currently sit at 15, under the
     header and modals; --z-toast is the intended value above modals. */
  --z-raised: 1;        /* slides, pinned table cells */
  --z-sticky: 5;        /* in-page sticky bars, tabs, split head */
  --z-header: 20;       /* app top bar */
  --z-drawer: 30;       /* sidebar on small screens (backdrop 25) */
  --z-dropdown: 450;    /* menus, search suggestions */
  --z-modal: 1500;
  --z-toast: 1600;
  --z-lightbox: 2000;
  --z-progress: 4000;   /* page-load bar */

  /* Breakpoints. Custom properties can't be read inside @media, so these
     are the agreed widths to write literally; new media queries use only
     these four (max-width: N-1px / min-width: Npx).
       phone 480px · tablet 768px · laptop 1024px · desktop 1280px */

  /* brand gold stays constant across themes — it's the one color that IDs the brand */
  --brand: #c6a15b;
  --brand-soft: #e7d3a8;
  --brand-strong: #a9813f;
  --focus-ring: #8a6a2e;
}

/* ---------- LIGHT THEME ---------- */
[data-theme="light"] {
  /* Aliases some pages use. Defined per theme so dark mode does not fall
     back to light-only literals. */
  --line: var(--border);
  --muted: var(--text-muted);
  --bg-soft: var(--surface-2);
  --gold: var(--brand-ink);
  --bg: #faf7f1;
  /* page background */
  --bg-2: #f4efe4;
  /* secondary background (table head, hovers, chips) */
  --surface: #ffffff;
  /* cards, tables, header, modal */
  --panel: #ffffff;
  --surface-2: #f4efe4;
  /* subtle fill inside a surface */
  /* Control borders clear WCAG 3:1 on white / cream so fields stay visible in glare. */
  --border: #978f7e;
  --border-strong: #7a7264;
  /* Hairline for cards and section frames (not controls, which need 3:1).
     Not applied yet; see the UI review's "calmer borders" step. */
  --border-subtle: #e5ddcc;
  /* Chart grid aliases the neutral control border so light charts stay as they are. */
  --chart-grid: var(--border);
  --focus-ring: #8a6a2e;

  /* Secondary and faint copy clear WCAG AA 4.5:1 on --surface, --bg, and --bg-2
     (showroom glare). Placeholders use --text-faint. */
  --text: #2b2622;
  --text-muted: #6a5f4f;
  --text-faint: #766c56;
  --text-on-brand: #1c1712;

  --brand-dim: rgba(198, 161, 91, .14);
  --brand-ink: #8a6a2e;
  /* text used on --brand-dim fills */

  /* The rail stays charcoal in both themes. Content keeps the tokens above. */
  --sidebar-bg: linear-gradient(180deg, #100d0b 0%, #221e1a 100%);
  --sidebar-border: #726C66;
  --sidebar-text: #d8cdb9;
  --sidebar-text-muted: #8f8676;
  --sidebar-logo: #ffffff;
  --sidebar-ink: #e9d7ac;
  --sidebar-dim: rgba(198, 161, 91, .16);
  --sidebar-focus: #e9d7ac;
  --sidebar-scrollbar: #8f8676;

  --header-bg: #ffffff;
  --header-border: #e5ddcc;

  --shadow-sm: 0 1px 2px rgba(20, 17, 15, .06);
  --shadow-md: 0 10px 30px rgba(20, 17, 15, .10);
  --overlay: rgba(30, 26, 20, .45);

  /* Ok sits at leaf green (138°) and warn at burnt orange (55°) so neither
     reads as the brand gold (81°) or a sister app's emerald (165°). */
  --ok: #467536;
  --ok-bg: #ecf3e8;
  /* Orange / gray pill text also clears 4.5:1 on their tinted fills (10.5px labels). */
  --warn: #9c5212;
  --warn-bg: #fbede2;
  --danger: #a13f3f;
  --danger-bg: #f8ecec;
  /* Info is blue so "open / still in play" never reads like neutral "closed". */
  --info: #426c91;
  --info-bg: #e8f0f7;
  --neutral: #6e695c;
  --neutral-bg: #f1efe9;
  --violet: #6c4a80;
  --violet-bg: #f3ecf6;

  color-scheme: light;
}

/* ---------- DARK THEME ---------- */
[data-theme="dark"] {
  /* Aliases some pages use. Defined per theme so dark mode does not fall
     back to light-only literals. */
  --line: var(--border);
  --muted: var(--text-muted);
  --bg-soft: var(--surface-2);
  --gold: var(--brand-ink);
  --bg: #15120f;
  --bg-2: #1c1815;
  --surface: #221e1a;
  --panel: #221e1a;
  --surface-2: #2b2620;
  --border: rgba(198, 161, 91, .55);
  --border-strong: rgba(198, 161, 91, .72);
  /* Warm neutral hairline for cards, so gold can stay for focus and active.
     Same value as the accounting app's dark --border. Not applied yet. */
  --border-subtle: #3b342c;
  /* Neutral grid, separate from the gold card frame. Clears 3:1 on --surface and --bg. */
  --chart-grid: #726C66;
  --focus-ring: #e9d7ac;

  --text: #ece4d5;
  /* Secondary copy stays at 4.5:1 on status tints as well as the page surfaces. */
  --text-muted: #A59D8C;
  /* Faint copy clears 4.5:1 on --surface-2, the darkest text surface. */
  --text-faint: #938D83;
  --text-on-brand: #1c1712;

  --brand-dim: rgba(198, 161, 91, .16);
  --brand-ink: #e9d7ac;

  --sidebar-bg: linear-gradient(180deg, #100d0b 0%, #221e1a 100%);
  --sidebar-border: #726C66;
  --sidebar-text: #d8cdb9;
  --sidebar-text-muted: #8f8676;
  --sidebar-logo: #ffffff;
  --sidebar-ink: #e9d7ac;
  --sidebar-dim: rgba(198, 161, 91, .16);
  --sidebar-focus: #e9d7ac;
  --sidebar-scrollbar: #8f8676;

  --header-bg: #1c1815;
  --header-border: rgba(198, 161, 91, .14);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 14px 34px rgba(0, 0, 0, .45);
  --overlay: rgba(0, 0, 0, .6);

  --ok: #a6d28f;
  --ok-bg: rgba(110, 160, 90, .18);
  --warn: #f0a46b;
  --warn-bg: rgba(200, 120, 60, .18);
  --danger: #e2938f;
  --danger-bg: rgba(178, 86, 86, .20);
  --info: #9dbbd8;
  --info-bg: rgba(66, 108, 145, .22);
  --neutral: #beb6a4;
  --neutral-bg: rgba(154, 146, 124, .18);
  --violet: #cdaee0;
  --violet-bg: rgba(140, 100, 168, .20);

  color-scheme: dark;
}

/* =========================================================================
   RESET + BASE
   ========================================================================= */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background var(--t-med) var(--ease), color var(--t-med) var(--ease);
}

h1,
h2,
h3,
.serif {
  font-family: var(--font-serif);
}

a {
  color: inherit;
}

button {
  font-family: inherit;
}

::selection {
  background: var(--brand-dim);
  color: var(--brand-ink);
}

/* Thin, theme-aware scrollbars — content, tables, dropdowns, modals.
   The rail has its own thumb below so this color stays off the charcoal sidebar.
   Horizontal thumbs stay visible enough to discover table scroll on phones. */
.content,
.modal-body,
.table-scroll,
.notif-list,
.dropdown {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.content::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.table-scroll::-webkit-scrollbar,
.notif-list::-webkit-scrollbar,
.dropdown::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.content::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb,
.table-scroll::-webkit-scrollbar-thumb,
.notif-list::-webkit-scrollbar-thumb,
.dropdown::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.sb-scroll {
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-scrollbar) transparent;
}

.sb-scroll::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.sb-scroll::-webkit-scrollbar-thumb {
  background: var(--sidebar-scrollbar);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.table-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--text-muted) 55%, var(--border-strong));
  background-clip: padding-box;
}

/* =========================================================================
   SHELL / LAYOUT
   ========================================================================= */
.app-shell {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  padding: 0 0 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  transition: background var(--t-med) var(--ease), border-color var(--t-med) var(--ease),
    width var(--t-med) var(--ease), flex-basis var(--t-med) var(--ease);
  z-index: 30;
}

.sb-logo {
  display: flex;
  align-items: center;
  height: var(--header-h);
  padding: 0 10px 0 14px;
  margin-bottom: 4px;
  box-sizing: border-box;
}

.sb-logo-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-width: 0;
  text-decoration: none;
  color: inherit;
  border-radius: var(--radius-sm);
  line-height: 1.1;
}

.sb-mark {
  display: block;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  object-fit: contain;
  border: 0;
  background: transparent;
}

.sb-brand {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
}

.sb-brand-name,
.sb-brand-sub {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-brand-name {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .1px;
  color: var(--sidebar-text);
  line-height: 1.15;
}

.sb-brand-sub {
  margin-top: 1px;
  font-size: 9.5px;
  letter-spacing: .9px;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  line-height: 1.2;
}

.sb-brand-group {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 1px;
  font-size: 8px;
  letter-spacing: .7px;
  text-transform: uppercase;
  color: var(--sidebar-text-muted);
  opacity: .85;
  line-height: 1.2;
}

.sb-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
}

.nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-section {
  padding: 10px 8px 2px;
}

.sb-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 10px 6px;
  color: var(--sidebar-text-muted);
}

.sb-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.6px;
  text-transform: uppercase;
}

.sb-scroll > .sb-section:first-child {
  padding-top: 8px;
}

.sb-section-head:hover {
  color: var(--sidebar-text);
}

.sb-section:has(.nav-item.active) > .sb-section-head {
  color: var(--brand);
}

.sb-section-head i.chev {
  font-size: 9px;
  transition: transform var(--t-fast) var(--ease);
}

.sb-section.collapsed .chev {
  transform: rotate(-90deg);
}

/* Accordion section body: subtle expand/collapse (~150ms). Scoped to
   labelled [data-collapsible] groups only — not the icon-rail / whole sidebar. */
.sb-section[data-collapsible] > .nav-list {
  overflow: hidden;
  max-height: 40rem;
  opacity: 1;
  visibility: visible;
  transition:
    max-height var(--t-fast) var(--ease),
    opacity var(--t-fast) var(--ease),
    visibility 0s linear 0s;
}

.sb-section[data-collapsible].collapsed > .nav-list {
  max-height: 0;
  opacity: 0;
  visibility: hidden;
  transition:
    max-height var(--t-fast) var(--ease),
    opacity var(--t-fast) var(--ease),
    visibility 0s linear var(--t-fast);
}

@media (prefers-reduced-motion: reduce) {
  .sb-section[data-collapsible] > .nav-list,
  .sb-section[data-collapsible].collapsed > .nav-list,
  .sb-section-head i.chev {
    transition: none;
  }
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 10px;
  min-height: 44px;
  margin-bottom: 1px;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  border-left: 2px solid transparent;
  background: none;
  border-top: none;
  border-right: none;
  border-bottom: none;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
  text-align: left;
}

.nav-item i {
  width: 15px;
  font-size: 12.5px;
  color: var(--sidebar-text-muted);
  text-align: center;
  transition: color var(--t-fast);
}

.nav-item:hover {
  background: var(--sidebar-dim);
}

.nav-item.active {
  background: var(--sidebar-dim);
  color: var(--sidebar-ink);
  border-left-color: var(--brand);
  font-weight: 600;
}

.nav-item.active i {
  color: var(--brand);
}

.nav-item:focus-visible,
.sb-section-head:focus-visible,
.sb-logo-link:focus-visible {
  outline: 2px solid var(--sidebar-focus);
  outline-offset: 2px;
}

.nav-item.top-level {
  padding-left: 10px;
}

.sb-foot {
  margin-top: auto;
  padding: 16px 20px 4px;
  border-top: 1px solid var(--sidebar-border);
}

.sb-foot-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sb-foot .u-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex: 0 0 32px;
  background: var(--sidebar-dim);
  color: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 13px;
}

.sb-foot .u-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--sidebar-text);
}

.sb-foot .u-role {
  font-size: 10.5px;
  color: var(--sidebar-text-muted);
  letter-spacing: .3px;
}

/* mobile sidebar backdrop */
.sb-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 25;
}

/* ---------- Sidebar — collapsed / icon-rail state (desktop & tablet only;
   the hamburger drives this state above the 900px breakpoint, and the
   existing off-canvas open/close below it — see the responsive block at
   the bottom of this file) ---------- */
@media(min-width:901px) {
  .app-shell.sb-collapsed .sidebar {
    width: var(--sidebar-w-mini);
    flex-basis: var(--sidebar-w-mini);
  }

  .app-shell.sb-collapsed .sb-logo {
    height: var(--header-h);
    padding: 0;
    justify-content: center;
  }

  .app-shell.sb-collapsed .sb-logo-link {
    justify-content: center;
    width: auto;
    gap: 0;
  }

  .app-shell.sb-collapsed .sb-brand {
    display: none;
  }

  .app-shell.sb-collapsed .sb-mark {
    display: block;
  }

  .app-shell.sb-collapsed .sb-section {
    padding: 2px 8px 0;
  }

  .app-shell.sb-collapsed .sb-section-head {
    display: none;
  }

  /* Group collapse hides links in the open sidebar. On the icon rail the
     headers are gone, so the icons stay visible (override accordion hide). */
  .app-shell.sb-collapsed .sb-section[data-collapsible].collapsed > .nav-list {
    max-height: none;
    opacity: 1;
    visibility: visible;
    overflow: visible;
    transition: none;
  }

  .app-shell.sb-collapsed .nav-item {
    justify-content: center;
    padding: 10px 0;
    gap: 0;
  }

  .app-shell.sb-collapsed .nav-item.top-level {
    padding-left: 0;
  }

  .app-shell.sb-collapsed .nav-item i {
    width: auto;
    font-size: 15px;
  }

  .app-shell.sb-collapsed .nav-label {
    display: none;
  }

  .app-shell.sb-collapsed .sb-foot {
    padding: 16px 8px 4px;
  }

  .app-shell.sb-collapsed .sb-foot-user {
    justify-content: center;
  }

  .app-shell.sb-collapsed .sb-foot-user>div:not(.u-avatar) {
    display: none;
  }
}

@media print {
  .sidebar,
  .sb-backdrop {
    display: none !important;
  }
}

/* ---------- Main column ---------- */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

header.topbar {
  height: var(--header-h);
  background: var(--header-bg);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 20;
  transition: background var(--t-med) var(--ease), border-color var(--t-med) var(--ease);
}

.hamburger {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 17px;
  cursor: pointer;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  margin-left: -8px;
  border-radius: var(--radius);
}

.hamburger:hover,
.hamburger:focus-visible {
  background: var(--bg-2);
  color: var(--text);
  outline: none;
}

.topbar-left {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.crumbs {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(46vw, 420px);
  min-width: 0;
}

.crumbs b {
  color: var(--text);
  font-weight: 600;
}

.crumbs a {
  color: inherit;
  text-decoration: none;
}

.crumbs a:hover {
  color: var(--text);
  text-decoration: underline;
}

.crumbs-sep {
  margin: 0 6px;
  opacity: .5;
}

.page-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 600;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-search {
  flex: 1;
  display: flex;
  justify-content: center;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 8px 16px;
  font-size: 12.5px;
  color: var(--text-muted);
  width: 100%;
  max-width: 420px;
  position: relative;
  overflow: visible;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.search-box:focus-within {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}

.search-dd {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 400;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  max-height: min(420px, 70vh);
  overflow-y: auto;
  padding: 6px;
  font-size: 12.5px;
  isolation: isolate;
}

.sd-group + .sd-group {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 4px;
}

.sd-group-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  padding: 6px 10px 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sd-group-count {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  background: var(--bg-2);
  border-radius: 999px;
  padding: 1px 7px;
  letter-spacing: 0;
  text-transform: none;
}

.sd-row {
  display: block;
  padding: 7px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.sd-row:hover,
.sd-row.active {
  background: var(--neutral-bg);
}

.sd-row.sd-exact {
  background: var(--ok-bg);
}

.sd-row.sd-exact.active {
  background: var(--ok-bg);
  outline: 1px solid var(--ok);
}

.sd-label {
  font-weight: 600;
}

.sd-label mark,
.sd-sub mark {
  background: color-mix(in srgb, var(--brand) 22%, transparent);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
}

.sd-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 1px;
}

.sd-empty {
  padding: 16px 12px;
  color: var(--text-muted);
  text-align: center;
}

.sd-empty-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-faint);
}

.sd-loading {
  padding: 18px 12px;
  color: var(--text-muted);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 12px;
}

.sd-foot-wrap {
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.sd-foot {
  display: block;
  text-align: center;
  padding: 8px;
  color: var(--brand-strong);
  font-weight: 600;
  font-size: 11.5px;
  text-decoration: none;
}

.sd-foot:hover {
  background: var(--neutral-bg);
}

.sd-kbd-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
  padding: 4px 8px 8px;
  font-size: 10px;
  color: var(--text-faint);
}

.sd-kbd-hint kbd {
  font-family: var(--font-sans);
  font-size: 9.5px;
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 0 4px;
  background: var(--bg-2);
  color: var(--text-muted);
}

.search-box i {
  font-size: 12px;
}

.search-box input {
  border: none;
  background: none;
  outline: none;
  font-family: inherit;
  font-size: 12.5px;
  color: var(--text);
  width: 100%;
}

.search-box input::placeholder {
  color: var(--text-faint);
}

.search-box kbd {
  font-family: var(--font-sans);
  font-size: 10px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  margin-left: auto;
}

.search-box .search-close {
  display: none;
  border: none;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 13px;
  margin-left: auto;
}

.search-toggle {
  display: none;
}

/* ---------- Search results page ---------- */
.search-page-form {
  align-items: stretch;
}

.search-page-input-wrap {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 0 14px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.search-page-input-wrap:focus-within {
  border-color: color-mix(in srgb, var(--brand) 55%, var(--border));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 14%, transparent);
}

.search-page-input-wrap i {
  color: var(--text-muted);
  font-size: 12px;
}

.search-page-input-wrap .fbar-input {
  border: none;
  background: transparent;
  box-shadow: none;
  padding-left: 0;
  padding-right: 0;
  flex: 1;
}

.search-page-input-wrap .fbar-input:focus {
  outline: none;
  box-shadow: none;
}

.search-page-clear {
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px;
  line-height: 1;
  text-decoration: none;
}

.search-page-clear:hover {
  color: var(--text);
}

.search-hints {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.search-hint {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.search-hint > i {
  color: var(--brand-strong);
  font-size: 15px;
  margin-top: 2px;
  width: 18px;
  text-align: center;
}

.search-hint strong {
  display: block;
  font-size: 13px;
  margin-bottom: 2px;
}

.search-hint span {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.search-jump {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 4px 0 18px;
}

.search-jump-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.search-jump-chip span {
  font-size: 10.5px;
  font-weight: 700;
  background: var(--surface);
  border-radius: 999px;
  padding: 1px 7px;
  color: var(--text-faint);
}

.search-jump-chip:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--brand) 35%, var(--border));
}

.search-jump-chip.active {
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 45%, var(--border));
  color: var(--brand-strong);
}

.search-jump-chip.active span {
  background: color-mix(in srgb, var(--brand) 18%, var(--surface));
  color: var(--brand-strong);
}

.search-section {
  margin-top: 8px;
  scroll-margin-top: calc(var(--header-h) + 12px);
}

.search-section .section-heading {
  margin-top: 20px;
}

.search-section-count {
  margin-left: auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-faint);
}

.search-empty {
  margin-top: 24px;
  text-align: center;
  padding: 40px 24px;
}

.search-empty > i {
  font-size: 28px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.search-empty-tips {
  list-style: none;
  padding: 0;
  margin: 14px auto 0;
  max-width: 360px;
  text-align: left;
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
}

.search-empty-tips li {
  padding-left: 14px;
  position: relative;
}

.search-empty-tips li::before {
  content: "·";
  position: absolute;
  left: 2px;
  color: var(--text-faint);
}

.db-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.db-badge.dev {
  background: var(--ok-bg);
  color: var(--ok);
}
.db-badge.prod {
  background: var(--danger-bg);
  color: var(--danger);
}
.db-badge.test {
  background: var(--warn);
  color: var(--bg);
}
.db-switch {
  margin: 0;
  display: inline-flex;
}
.db-switch .db-badge {
  border: 0;
  cursor: pointer;
  font-family: inherit;
}
.db-switch .db-badge i {
  font-size: 9px;
  margin-left: 3px;
  opacity: .7;
}
.db-switch .db-badge:hover i {
  opacity: 1;
}

/* Test mode: a stripe on the sticky header stays in view after the banner scrolls away.
   The sandbox server gets the same stripe, with the SANDBOX badge beside it. */
.app-shell.is-test-mode header.topbar,
.app-shell.is-sandbox header.topbar {
  box-shadow: inset 0 3px 0 var(--warn);
}
.test-mode-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--warn);
  color: var(--warn);
  background: repeating-linear-gradient(
    -45deg,
    var(--warn-bg) 0 14px,
    color-mix(in srgb, var(--warn-bg) 60%, var(--warn) 12%) 14px 28px
  );
  font-size: 13px;
  line-height: 1.45;
}
.test-mode-banner > i {
  font-size: 18px;
  flex: none;
}
.test-mode-banner-text {
  flex: 1;
  min-width: 0;
}
.test-mode-banner-text strong {
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-right: 4px;
}
.test-mode-banner form {
  margin: 0;
  flex: none;
}
@media (max-width: 640px) {
  .test-mode-banner {
    flex-wrap: wrap;
  }
  .test-mode-banner form {
    width: 100%;
  }
}

.test-mode-panel {
  max-width: 720px;
}
.test-mode-facts {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 10px 20px;
  margin: 0 0 20px;
}
.test-mode-facts dt {
  color: var(--text-muted);
  font-size: 12px;
  padding-top: 2px;
}
.test-mode-facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.test-mode-error {
  margin-top: 6px;
  color: var(--danger);
  font-size: 12px;
}
.test-mode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.test-mode-actions form {
  margin: 0;
}
.test-mode-notes {
  margin: 0;
  padding-left: 18px;
  font-size: 12px;
  line-height: 1.6;
  opacity: .85;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid transparent;
  background: none;
  color: var(--text-muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background var(--t-fast), color var(--t-fast);
}

.icon-btn:hover,
.icon-btn:focus-visible {
  background: var(--bg-2);
  color: var(--text);
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring, var(--brand-ink));
}

.icon-btn .badge {
  position: absolute;
  top: 8px;
  right: 8px;
  min-width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  border: 2px solid var(--header-bg);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--danger) 40%, transparent);
}
/* live.js shows and hides the dot as the count changes. */
.icon-btn .badge[hidden] { display: none; }

/* Per-computer sound switch under the bell list (live.js). */
.notif-sound-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 44px;
  margin-top: 2px;
  padding: 6px 4px;
  border: none;
  border-top: 1px solid var(--border);
  background: none;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
}
.notif-sound-toggle[hidden] { display: none; }
.notif-sound-toggle:hover { color: var(--text); }
.notif-sound-toggle:focus-visible { outline: 2px solid var(--brand-strong); outline-offset: -2px; }
.notif-sound-toggle[aria-pressed="false"] { color: var(--text-faint); }

/* theme toggle (legacy class kept for any leftover markup) */
.theme-toggle .fa-sun {
  display: none;
}

.theme-toggle .fa-moon {
  display: inline;
}

html[data-theme="dark"] .theme-toggle .fa-sun {
  display: inline;
}

html[data-theme="dark"] .theme-toggle .fa-moon {
  display: none;
}

.avatar.avatar-img {
  object-fit: cover;
  padding: 0;
  background: var(--bg-2);
}

/* ---------- dropdown menus (user + notifications) ---------- */
.menu-wrap {
  position: relative;
}

.menu-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px 6px 5px 5px;
  border-radius: var(--radius-pill);
  color: var(--text);
}

.menu-trigger:hover {
  background: var(--bg-2);
}

.avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--text);
  color: var(--brand-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 600;
  flex: 0 0 30px;
}

[data-theme="dark"] .avatar {
  background: var(--brand);
  color: var(--text-on-brand);
}

.menu-trigger .u-meta {
  text-align: left;
  line-height: 1.2;
  display: none;
}

.menu-trigger .u-meta .n {
  font-size: 12px;
  font-weight: 600;
}

.menu-trigger .u-meta .r {
  font-size: 10px;
  color: var(--text-muted);
}

.menu-trigger .fa-chevron-down {
  font-size: 9px;
  color: var(--text-faint);
}

@media(min-width:1180px) {
  .menu-trigger .u-meta {
    display: block;
  }
}

.dropdown {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  /* Keep panels inside the viewport on 320–414 phones and narrow landscape. */
  width: min(250px, calc(100vw - 16px));
  max-width: calc(100vw - 16px);
  max-height: min(70vh, calc(100dvh - 72px));
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  padding: 8px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px);
  transition: opacity var(--t-fast) var(--ease), transform var(--t-fast) var(--ease), visibility var(--t-fast);
  /* Above search (400); below modal overlays (2000). */
  z-index: 450;
  overscroll-behavior: contain;
}

.menu-wrap.open .dropdown {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-head {
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}

.dropdown-head .n {
  font-size: 13px;
  font-weight: 600;
}

.dropdown-head .e {
  font-size: 11px;
  color: var(--text-muted);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 12px 10px;
  min-height: 44px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  font-size: 12.5px;
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}

.dropdown-item:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--focus-ring, var(--brand-ink));
}

.dropdown-item i {
  width: 15px;
  color: var(--text-muted);
  font-size: 12px;
}

.dropdown-item:hover {
  background: var(--bg-2);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger i {
  color: var(--danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 6px 2px;
}

.dropdown.notif {
  width: min(320px, calc(100vw - 16px));
}

/* Phones: pin panels to the viewport so a 320px notif menu cannot clip. */
@media (max-width: 480px) {
  .menu-wrap.open .dropdown {
    position: fixed;
    top: calc(var(--header-h, 56px) + 6px);
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    width: auto;
    max-width: none;
    bottom: auto;
  }
}

.notif-toggle {
  display: flex;
  gap: 4px;
  margin: 0 8px 8px;
  padding: 3px;
  background: var(--bg-2);
  border-radius: 8px;
}

.notif-toggle button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-faint);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
}

.notif-toggle button.is-on {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(20, 17, 15, 0.08);
}

.notif-n {
  display: inline-block;
  min-width: 1.25em;
  margin-left: 2px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--brand-soft, #f3ead8);
  font-size: 10px;
}

.notif-toggle button.is-on .notif-n {
  background: var(--text);
  color: var(--brand-soft, #e7d3a8);
}

/* Dark count chips were light-on-light (brand-soft on cream, or cream on the light text). */
[data-theme="dark"] .notif-n,
[data-theme="dark"] .notif-toggle button.is-on .notif-n {
  background: var(--brand);
  color: var(--text-on-brand);
}

.notif-list {
  /* Cap each list so two sections + footer still fit short landscape phones. */
  max-height: min(220px, 36vh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.notif-row {
  display: flex;
  gap: 10px;
  padding: 10px;
  min-height: 44px;
  align-items: flex-start;
  border-radius: var(--radius-sm);
  box-sizing: border-box;
}

.notif-row:hover {
  background: var(--bg-2);
}

.notif-dot-wrap {
  width: 8px;
  padding-top: 6px;
  flex: 0 0 8px;
}

.notif-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--brand);
}

.notif-row.read .notif-dot {
  background: transparent;
}

.notif-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  flex: 0 0 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.notif-body {
  min-width: 0;
}

.notif-body .t {
  font-size: 12px;
  color: var(--text);
  line-height: 1.35;
}

.notif-body .m {
  font-size: 10.5px;
  color: var(--text-faint);
  margin-top: 2px;
}

.dropdown-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  text-align: center;
  padding-top: 8px;
  margin-top: 4px;
  border-top: 1px solid var(--border);
}

.dropdown-foot a,
.dropdown-foot-btn {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand-strong);
  text-decoration: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px 4px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.dropdown-foot a:hover,
.dropdown-foot-btn:hover,
.dropdown-foot a:focus-visible,
.dropdown-foot-btn:focus-visible {
  text-decoration: underline;
  outline: none;
}

.notif-mark-all-form {
  margin: 0;
  display: inline;
}

/* =========================================================================
   CONTENT
   ========================================================================= */
.content {
  padding: 18px 24px 32px;
  flex: 1;
}

.page {
  display: none;
  animation: fade .2s var(--ease);
}

.page.active {
  display: block;
}

@keyframes fade {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

/* Title block may shrink and wrap; long PJ / supplier codes break
   instead of pushing the page sideways. */
.page-head > div:first-child {
  flex: 1 1 320px;
  min-width: 0;
}

.page-head h1 {
  font-size: 22px;
  line-height: 1.2;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.page-head p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 3px;
  overflow-wrap: anywhere;
}

/* "What this page is for" line from apps/core/nav.py, above the page's own notes. */
.page-head p.page-purpose {
  font-size: 13px;
  color: var(--text);
}

.page-head-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Lane tabs on merged hubs (QC workflow, Tags). */
.lane-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.lane-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.lane-tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.lane-tab.is-active {
  color: var(--text-on-brand);
  background: var(--brand);
}

.lane-tab.is-active:hover {
  color: var(--text-on-brand);
  background: var(--brand-strong);
}

.lane-lead {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--text-muted);
}

@media (max-width: 480px) {
  .lane-tabs {
    flex-direction: column;
  }

  .lane-tab {
    justify-content: center;
  }
}

/* ---------- KPI cards ---------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 18px;
}

.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-fast);
}

a.kpi-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

a.kpi-link:hover {
  border-color: var(--brand);
}

.kpi-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--kpi-accent, var(--brand));
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.kpi-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 1.1px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.kpi-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--kpi-bg, var(--brand-dim));
  color: var(--kpi-accent, var(--brand));
  font-size: 11px;
  flex: 0 0 26px;
}

.kpi-num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
}

.kpi-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 5px;
}

.kpi-sub.up {
  color: var(--ok);
}

.kpi-sub.down {
  color: var(--danger);
}

/* ---------- Filter bar ---------- */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  margin-bottom: 18px;
}

.filter-bar.has-labels {
  align-items: flex-end;
}

.fbar-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1 1 9.5rem;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.fbar-field .fbar-input,
.fbar-field .fbar-select {
  width: 100%;
  min-width: 0;
  flex: none;
}

@media (max-width: 640px) {
  .filter-bar.has-labels .fbar-field {
    flex-basis: 100%;
  }
}

.seg {
  display: flex;
  background: var(--bg-2);
  border-radius: var(--radius-pill);
  padding: 3px;
  gap: 2px;
}

.seg button {
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}

.seg button.active {
  background: var(--text);
  color: var(--brand-soft);
}

[data-theme="dark"] .seg button.active {
  background: var(--brand);
  color: var(--text-on-brand);
}

.field,
.fbar-input,
.fbar-select {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

/* iOS Safari zooms the page when focused inputs are under 16px. */
@media (max-width: 900px) {
  .field,
  .fbar-input,
  .fbar-select,
  .form-field input,
  .form-field select,
  .form-field textarea,
  .search-box input,
  .search-page-input-wrap .fbar-input {
    font-size: 16px;
  }
}

.field:focus,
.fbar-input:focus,
.fbar-select:focus,
.field:focus-visible,
.fbar-input:focus-visible,
.fbar-select:focus-visible {
  border-color: var(--focus-ring);
  box-shadow: 0 0 0 2px var(--focus-ring);
}

.fbar-input {
  flex: 1;
  min-width: 80px;
}

/* A row of labelled fields with the submit button on the baseline:
   recording a payment and applying pondo (invoice page, pondo page). */
.inv-pay-form {
  margin-top: 12px;
}

.inv-pay-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.inv-pay-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.inv-pay-row .fbar-input {
  min-width: 140px;
}

.inv-pay-row button {
  margin-bottom: 1px;
}

/* A long option (e.g. a bank name) must not push the select past the card. */
.inv-pay-row label {
  min-width: 0;
  max-width: 100%;
}

.inv-pay-row .fbar-input {
  max-width: 100%;
}

@media (max-width: 480px) {
  .inv-pay-row label {
    flex: 1 1 100%;
  }

  .inv-pay-row .fbar-input {
    width: 100%;
    min-width: 0;
  }
}

.btn {
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  padding: 6px 14px;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: .2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  /* Many buttons are <a> links; without this they keep the link underline. */
  text-decoration: none;
}

.btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: 12px;
  top: 12px;
  z-index: 1000;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--brand-soft);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transform: translateY(-200%);
}
.skip-link:focus,
.skip-link:focus-visible {
  transform: translateY(0);
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--text);
  color: var(--brand-soft);
  border-color: var(--text);
}

.btn-primary:hover {
  background: var(--brand);
  color: var(--text-on-brand);
  border-color: var(--brand);
}

[data-theme="dark"] .btn-primary {
  background: var(--brand);
  color: var(--text-on-brand);
  border-color: var(--brand);
}

[data-theme="dark"] .btn-primary:hover {
  background: var(--brand-soft);
  border-color: var(--brand-soft);
}

.btn-ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--border);
}

.btn-ghost:hover {
  border-color: var(--brand);
  color: var(--brand-strong);
}

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-bg);
}

/* Credit / pondo — green, not the same near-black primary as Record payment. */
.btn-ok {
  background: var(--ok);
  color: #ffffff;
  border-color: var(--ok);
}

.btn-ok:hover {
  filter: brightness(0.92);
}

[data-theme="dark"] .btn-ok {
  color: var(--text-on-brand);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn[disabled],
.btn:disabled {
  background: var(--neutral-bg);
  color: var(--text-muted);
  border-color: var(--border);
  opacity: 1;
  cursor: not-allowed;
}

.field:disabled,
.fbar-input:disabled,
.fbar-select:disabled,
.field[disabled],
.fbar-input[disabled],
.fbar-select[disabled] {
  background: var(--bg-2);
  color: var(--text-muted);
  border-color: var(--border);
  cursor: not-allowed;
  opacity: 1;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--bg-2);
  color: var(--text-muted);
  cursor: not-allowed;
}

/* ---------- Section heading ---------- */
.section-heading {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  margin: 22px 0 10px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-heading::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.section-heading .tag {
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-faint);
}

/* ---------- Table ---------- */
.table-wrap {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.table-scroll {
  overflow-x: auto;
  min-width: 0;
  max-width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  min-width: 640px;
}

/* Two-column label/value tables in detail panels aren't data grids —
   the 640px floor above made them push their panels off-screen. */
table.spec-table {
  min-width: 0;
}

.spec-table td {
  overflow-wrap: anywhere;
}

/* Detail-page grid columns may shrink below their content so wide data
   tables scroll inside their .table-scroll instead of widening the page. */
.pd-grid > * {
  min-width: 0;
}

thead th {
  text-align: left;
  padding: 9px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  white-space: nowrap;
}

tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

tbody tr:last-child td {
  border-bottom: none;
}

tfoot td {
  padding: 10px 14px;
}

tbody tr:hover {
  background: var(--bg-2);
}

/* The PJ / invoice column stays on screen while the rest of the table scrolls.
   border-collapse: separate is what makes position: sticky work on cells. */
.table-scroll:has(.col-pin) table {
  border-collapse: separate;
  border-spacing: 0;
}

.col-pin {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: 1px 0 0 var(--border);
}

thead th.col-pin {
  z-index: 2;
  background: var(--bg-2);
}

tbody tr:hover .col-pin {
  background: var(--bg-2);
}

.col-pin .row-id {
  display: flex;
  align-items: center;
  gap: 8px;
}

.col-pin .row-actions {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  margin-top: 6px;
  max-width: 11rem;
}

.col-pin .row-actions .fbar-input {
  width: 100%;
  max-width: 11rem;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .col-optional {
    display: none;
  }
}

@media print {
  .col-pin {
    position: static;
    box-shadow: none;
  }

  .col-optional {
    display: table-cell;
  }
}

.mono {
  font-family: var(--font-mono);
  font-size: .95em;
  font-variant-numeric: tabular-nums;
}

td.num,
th.num {
  text-align: right;
}

td.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.cell-strong {
  font-weight: 600;
}

.cell-muted {
  color: var(--text-muted);
}

.row-check {
  width: 34px;
}

.table-actions {
  display: flex;
  gap: 4px;
  justify-content: flex-end;
}

.icon-action {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
}

.icon-action:hover {
  background: var(--bg-2);
  color: var(--brand-strong);
  border-color: var(--border);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.pill-ok {
  background: var(--ok-bg);
  color: var(--ok);
}

.pill-info {
  background: var(--info-bg);
  color: var(--info);
}

.pill-warn {
  background: var(--warn-bg);
  color: var(--warn);
}

.pill-danger {
  background: var(--danger-bg);
  color: var(--danger);
}

.pill-violet {
  background: var(--violet-bg);
  color: var(--violet);
}

.pill-neutral {
  background: var(--neutral-bg);
  color: var(--neutral);
}

.table-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
  flex-wrap: wrap;
  gap: 10px;
}

.pagination {
  display: flex;
  gap: 4px;
}

.pagination a,
.pagination button,
.pagination .pg-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11.5px;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
}

.pagination a:focus-visible,
.pagination button:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}

.pagination button.active,
.pagination .pg-current {
  background: var(--text);
  color: var(--brand-soft);
  border-color: var(--text);
  cursor: default;
}

th a.th-sort {
  color: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

th.num a.th-sort { float: right; }

th a.th-sort i { font-size: 9px; color: var(--text-faint); }

th a.th-sort.is-active i { color: var(--brand); }

.table-foot-tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.per-page {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  color: var(--text-muted);
}

.per-page select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
}

.cap-note { color: var(--warn); margin-left: 6px; }

.seg a {
  border: none;
  background: transparent;
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  color: var(--text-muted);
  text-decoration: none;
  transition: background var(--t-fast), color var(--t-fast);
}

.seg a.active {
  background: var(--text);
  color: var(--brand-soft);
}

[data-theme="dark"] .seg a.active {
  background: var(--brand);
  color: var(--text-on-brand);
}

.rpt-tabs { margin-bottom: 12px; flex-wrap: wrap; }

[data-theme="dark"] .pagination button.active,
[data-theme="dark"] .pagination .pg-current {
  background: var(--brand);
  color: var(--text-on-brand);
  border-color: var(--brand);
}

/* ---------- Tracker gauge (Product Tracker: Entered / Expected) ---------- */
.pj-gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 22px 0;
}

.pj-gauge {
  width: 340px;
  height: 340px;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 5px solid var(--brand-soft);
  box-shadow: 0 0 0 1px var(--border-strong), 0 8px 20px rgba(0, 0, 0, .08);
}

.pj-gauge-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.pj-gauge-half.entered {
  background: var(--text);
  color: var(--bg);
}

.pj-gauge-half.expected {
  background: var(--brand);
  color: var(--text-on-brand);
}

.pj-gauge-num {
  font-family: var(--font-serif);
  font-size: 5rem;
  font-weight: 600;
  line-height: 1;
  margin-bottom: 12px;

}

.pj-gauge-label {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1.3px;
  text-transform: uppercase;
  opacity: .85;
}

.pj-gauge-badge {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  background: var(--surface);
  text-align: center;
  max-width: 260px;
}

/* ---------- Generic surface panel / card ---------- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.two-col {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: 16px;
  align-items: start;
}

@media(max-width:980px) {
  .two-col {
    grid-template-columns: 1fr;
  }
}

/* ---------- Products catalogue ---------- */
.pl-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.pl-sum {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: border-color var(--t-fast), background var(--t-fast);
  min-width: 0;
}

.pl-sum:hover {
  border-color: var(--brand);
}

.pl-sum.is-active {
  border-color: var(--brand);
  background: var(--brand-dim);
}

.pl-sum-static {
  cursor: default;
}

.pl-sum-static:hover {
  border-color: var(--border-subtle);
}

.pl-sum-n {
  font-family: var(--font-mono);
  font-size: 19px;
  letter-spacing: -.02em;
  font-weight: 600;
  line-height: 1.1;
}

.pl-sum-l {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pl-sum-l.is-wrap {
  white-space: normal;
  letter-spacing: 0;
  text-transform: none;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
}

.pl-sum-basis {
  font-size: 11px;
  line-height: 1.3;
  color: var(--text-muted);
}

.rpt-note {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 4px 0 10px;
  max-width: 78ch;
}

/* ---------- Report layout (money-pages PR 2) ----------
   A report page reads: header (title, one line, exports) → one filter line
   (period chips, search, the filters people use most, "More filters") →
   a slim strip of totals → the table filling the rest of the window. Long
   explanations go in a .rpt-how fold. */

/* "How this is counted": the page's longer explanation, folded. */
.rpt-how { margin-top: var(--space-1); font-size: var(--fs-small); color: var(--text-muted); }
.rpt-how > summary { cursor: pointer; color: var(--text); width: fit-content; }
.rpt-how[open] > summary { margin-bottom: var(--space-1); }
.rpt-how p { margin: 0 0 var(--space-2); max-width: 78ch; line-height: var(--lh-body); }

/* Totals in one row of compact cards. */
.rpt-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
}
.rpt-strip .pl-sum { padding: var(--space-2) var(--space-3); min-width: 0; }
.rpt-strip .pl-sum-n { font-size: 17px; }
.rpt-strip .pl-sum-l { font-size: var(--fs-caption); }

/* One quiet line under the strip: flags and secondary figures. */
.rpt-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-3);
  margin: 0 0 var(--space-2);
  font-size: var(--fs-small);
  color: var(--text-muted);
}
.rpt-line strong { color: var(--text); font-weight: var(--fw-semibold); }
.rpt-line .rpt-line-part { display: inline-flex; align-items: center; gap: var(--space-half); }

/* The one filter line. Period chips lead; rarely-used filters fold away. */
.rpt-filters { padding: var(--space-2) var(--space-3); gap: var(--space-2); margin-bottom: var(--space-3); }
/* The phone-filters script moves the fields into a display:contents panel,
   so match them with or without it. */
/* Small bases so the line fits before it wraps; free space then goes to search. */
.rpt-filters > .fbar-select,
.rpt-filters > .phone-filter-panel > .fbar-select { flex: 1 1 6rem; min-width: 0; max-width: 15rem; }
.rpt-filters > .fbar-input[name="q"],
.rpt-filters > .phone-filter-panel > .fbar-input[name="q"] { flex: 1 1 6rem; min-width: 0; }
.rpt-period { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1); }
.rpt-period-l {
  font-size: var(--fs-caption);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--text-muted);
}
.rpt-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  font-size: var(--fs-small);
  font-weight: var(--fw-medium);
  color: var(--text);
  text-decoration: none;
  white-space: nowrap;
}
a.rpt-chip:hover { border-color: var(--brand); }
.rpt-chip.is-on { background: var(--brand-dim); border-color: var(--brand); color: var(--brand-ink); }
.rpt-more { flex: 0 0 auto; }
.rpt-more > summary { list-style: none; cursor: pointer; }
.rpt-more > summary::-webkit-details-marker { display: none; }
.rpt-more[open] { flex-basis: 100%; }
.rpt-more-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-2);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}
.rpt-more-body .fbar-field { flex: 1 1 10rem; }

/* On laptop widths the label yields its room to the dropdowns; screen readers
   still hear it, and the page line and the date fields say which date it is. */
@media (max-width: 1439px) {
  .rpt-period-l {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
  }
}

/* Notes meant for the printed page only. */
.print-only { display: none; }
@media print { .print-only { display: block; } }

@media (max-width: 768px) {
  .rpt-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rpt-chip { min-height: 36px; }
  /* Inside the phone Filters panel: search on its own row, dropdowns two by two. */
  .rpt-filters > .phone-filter-panel > .fbar-input[name="q"] { flex: 1 1 100%; }
  .rpt-filters > .phone-filter-panel > .fbar-select { flex: 1 1 calc(50% - 4px); max-width: none; }
  .rpt-filters .rpt-period { flex-basis: 100%; }
}

.pl-sum-ok .pl-sum-n { color: var(--ok); }
.pl-sum-warn .pl-sum-n { color: var(--warn); }

.pl-filters {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pl-search {
  position: relative;
  display: flex;
  align-items: center;
}

.pl-search > i {
  position: absolute;
  left: 12px;
  color: var(--text-faint);
  font-size: 12px;
  pointer-events: none;
}

.pl-search .field {
  width: 100%;
  padding-left: 36px;
}

.pl-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pl-filter-row .fbar-select {
  flex: 1 1 140px;
  min-width: 130px;
}

/* Phone: JS wraps genuine filter bars and adds a toggle.
   Without that script the fields stay in place (no button, no wrapper). */
.phone-filter-toggle { display: none; }
.phone-filter-panel { display: contents; }
.phone-filter-count {
  display: inline-block;
  min-width: 1.25rem;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--bg-2);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  line-height: 1.4;
}

@media (max-width: 768px) {
  .phone-filter-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    align-self: flex-start;
    min-height: 44px;
    padding-inline: 14px;
  }
  .filter-bar > .phone-filter-panel,
  .pl-filters > .phone-filter-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    width: 100%;
    min-width: 0;
  }
  .pl-filters > .phone-filter-panel {
    flex-direction: column;
    align-items: stretch;
  }
  .filter-bar.is-phone-collapsed,
  .pl-filters.is-phone-collapsed {
    padding: 8px 10px;
    gap: 0;
  }
  .filter-bar.is-phone-collapsed > .phone-filter-panel,
  .pl-filters.is-phone-collapsed > .phone-filter-panel {
    display: none;
  }
}

.pl-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.pl-chips-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: uppercase;
  color: var(--text-faint);
}

.pl-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--radius-pill);
  background: var(--brand-dim);
  color: var(--brand-ink);
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-chip .fa-xmark {
  font-size: 10px;
  opacity: .7;
}

.pl-chip:hover .fa-xmark {
  opacity: 1;
}

.pl-chip-clear {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand-strong);
  text-decoration: none;
}

.pl-chip-clear:hover {
  text-decoration: underline;
}

.pl-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.pl-toolbar-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.pl-toolbar-meta b {
  color: var(--text);
  font-weight: 600;
}

.pl-view-seg a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 28px;
  border-radius: var(--radius-pill);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 12px;
}

.pl-view-seg a.active {
  background: var(--text);
  color: var(--brand-soft);
}

[data-theme="dark"] .pl-view-seg a.active {
  background: var(--brand);
  color: var(--text-on-brand);
}

.pl-view-sep {
  width: 1px;
  align-self: stretch;
  background: var(--border);
  margin: 2px 4px;
}

.pl-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.pl-card {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  content-visibility: auto;
  contain-intrinsic-size: auto 300px;
  transition: border-color var(--t-fast), transform var(--t-fast), box-shadow var(--t-fast);
}

.pl-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.pl-card-media {
  position: relative;
  aspect-ratio: 1;
  background: var(--bg-2);
  overflow: hidden;
}

.pl-card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform var(--t-med) var(--ease);
}

.pl-card:hover .pl-card-media img {
  transform: scale(1.04);
}

.pl-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 28px;
}

.pl-card-badge {
  position: absolute;
  top: 10px;
  left: 10px;
}

/* multi-photo card slideshow (see catalogue/_card_media.html) */
.pl-slides {
  position: absolute;
  inset: 0;
}

.pl-card-media .pl-slides img.pl-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.7s var(--ease), transform var(--t-med) var(--ease);
}

.pl-card-media .pl-slides img.pl-slide.is-active.is-loaded {
  z-index: 1;
  opacity: 1;
}

.pl-card-media .pl-slides img.pl-slide.is-prev {
  opacity: 1;
  transition: none;
}

.pl-dots {
  position: absolute;
  left: 50%;
  bottom: 8px;
  z-index: 2;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(4px);
  opacity: 0.85;
  transition: opacity var(--t-fast);
}

.pl-card:hover .pl-dots {
  opacity: 1;
}

.pl-dot {
  display: block;
  width: 6px;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  cursor: pointer;
  transition: width 0.35s var(--ease), background-color 0.35s var(--ease);
}

.pl-dot.is-active {
  width: 16px;
  background: #fff;
}

/* design photo gallery (catalogue/_photo_gallery.html + core/js/gallery.js) */
.pg {
  margin-bottom: 16px;
}

.pg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.pg-head-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pg-counter {
  font-size: 12px;
  color: var(--text-muted);
}

.pg-counter b {
  color: var(--text);
  font-weight: 600;
}

.pg-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: none;
  transition: color var(--t-fast), border-color var(--t-fast), background-color var(--t-fast);
}

.pg-icon-btn:hover {
  color: var(--brand-ink);
  border-color: var(--brand);
}

.pg-stage {
  position: relative;
  height: clamp(260px, 52vw, 520px);
  border-radius: 10px;
  overflow: hidden;
  background: radial-gradient(ellipse at center, var(--surface) 0%, var(--neutral-bg) 75%);
  cursor: zoom-in;
  outline: none;
}

.pg-stage:focus-visible {
  box-shadow: 0 0 0 2px var(--brand);
}

.pg-slide {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  transition: opacity 0.6s var(--ease);
}

.pg-slide.is-active {
  z-index: 1;
  opacity: 1;
}

.pg-slide.is-prev {
  opacity: 1;
  transition: none;
}

.pg-slide img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.6s var(--ease);
}

.pg-stage:hover .pg-slide.is-active img {
  transform: scale(1.015);
}

.pg-caption {
  position: absolute;
  left: 12px;
  top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 70px);
  font-size: 12px;
  color: var(--text);
}

.pg-caption span:not(.pill) {
  padding: 3px 8px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pg-zoom,
.pg-nav {
  position: absolute;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  color: var(--text);
  box-shadow: 0 2px 10px rgba(20, 17, 15, 0.16);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--t-med) var(--ease), transform var(--t-med) var(--ease), background-color var(--t-fast);
}

.pg-zoom {
  top: 12px;
  right: 12px;
  width: 34px;
  height: 34px;
  font-size: 13px;
}

.pg-nav {
  top: 50%;
  width: 42px;
  height: 42px;
  margin-top: -21px;
  font-size: 14px;
}

.pg-prev { left: 14px; transform: translateX(-6px); }
.pg-next { right: 14px; transform: translateX(6px); }

.pg-stage:hover .pg-zoom,
.pg-stage:hover .pg-nav,
.pg-stage:focus-within .pg-zoom,
.pg-stage:focus-within .pg-nav {
  opacity: 1;
  transform: none;
}

.pg-zoom:hover,
.pg-nav:hover {
  background: var(--surface);
}

.pg-zoom:focus-visible,
.pg-nav:focus-visible,
.pg-dot:focus-visible,
.pg-thumb:focus-visible,
.pg-icon-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

@media (hover: none) {
  .pg-zoom,
  .pg-nav {
    opacity: 0.92;
    transform: none;
  }
}

.pg-dots {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 9px;
  border-radius: 999px;
  background: rgba(20, 17, 15, 0.32);
  backdrop-filter: blur(6px);
}

.pg-dot {
  position: relative;
  display: block;
  width: 8px;
  height: 8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  overflow: hidden;
  cursor: pointer;
  transition: width 0.35s var(--ease), background-color 0.35s var(--ease);
}

.pg-dot:hover {
  background: rgba(255, 255, 255, 0.8);
}

.pg-dot.is-active {
  width: 26px;
  background: #fff;
}

/* While playing, the active dot fills up until the next slide. */
.pg.is-playing .pg-dot.is-active {
  background: rgba(255, 255, 255, 0.5);
}

.pg-dot span {
  position: absolute;
  inset: 0;
  width: 0;
  border-radius: inherit;
  background: #fff;
}

.pg.is-playing .pg-dot.is-active span {
  animation: pg-fill var(--pg-interval, 5s) linear forwards;
}

@keyframes pg-fill {
  from { width: 0; }
  to { width: 100%; }
}

.pg-thumbs {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  padding: 2px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  scrollbar-width: thin;
}

.pg-thumb {
  position: relative;
  flex: 0 0 auto;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  background: var(--neutral-bg);
  line-height: 0;
  cursor: pointer;
  opacity: 0.6;
  scroll-snap-align: center;
  transition: opacity var(--t-fast), border-color var(--t-fast);
}

.pg-thumb:hover {
  opacity: 0.9;
}

.pg-thumb.is-active {
  border-color: var(--brand);
  opacity: 1;
}

.pg-thumb img {
  display: block;
  width: 68px;
  height: 68px;
  object-fit: cover;
}

.pg-thumb-flag {
  position: absolute;
  right: 4px;
  bottom: 4px;
  font-size: 11px;
  line-height: 1;
  color: var(--info, #2f5d8a);
  text-shadow: 0 0 3px #fff;
}

.pg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(12, 10, 8, 0.92);
  opacity: 0;
  transition: opacity 0.2s var(--ease);
}

.pg-lightbox[hidden] {
  display: none;
}

.pg-lightbox.is-open {
  opacity: 1;
}

.pg-lightbox img {
  max-width: min(92vw, 1600px);
  max-height: 86vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  cursor: zoom-out;
  transform: scale(0.97);
  transition: transform 0.25s var(--ease);
}

.pg-lightbox.is-open img {
  transform: none;
}

.pg-lightbox {
  overflow: hidden;
}

.pg-lightbox img {
  cursor: zoom-in;
  touch-action: none;
  user-select: none;
  -webkit-user-drag: none;
  will-change: transform;
}

.pg-lightbox.is-zoomed img {
  cursor: grab;
  border-radius: 0;
}

.pg-lightbox.is-dragging img {
  cursor: grabbing;
  transition: none;
}

.pg-lb-bar {
  z-index: 2;
  padding: 4px 6px 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
}

.pg-zoombar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px;
  margin-right: 4px;
  border-right: 1px solid rgba(255, 255, 255, 0.2);
}

.pg-zoom-level {
  min-width: 52px;
  height: 38px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: rgba(255, 255, 255, 0.85);
  font-size: 12px;
  cursor: pointer;
  border-radius: 6px;
}

.pg-zoom-level:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.pg-lb-hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.45);
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  transition: opacity 0.2s var(--ease);
}

.pg-lightbox.is-zoomed .pg-lb-hint {
  opacity: 0;
}

.pg-lightbox.is-zoomed .pg-nav {
  opacity: 0.35;
}

.pg-lightbox.is-zoomed .pg-nav:hover {
  opacity: 1;
}

.pg-lb-bar {
  position: absolute;
  top: 14px;
  right: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 13px;
}

.pg-lb-bar .pg-icon-btn {
  width: 38px;
  height: 38px;
  font-size: 15px;
  border-color: rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.pg-lb-bar .pg-icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.5);
}

.pg-lightbox .pg-nav {
  opacity: 1;
  transform: none;
  width: 48px;
  height: 48px;
  margin-top: -24px;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  box-shadow: none;
}

.pg-lightbox .pg-nav:hover {
  background: rgba(255, 255, 255, 0.24);
}

html.pg-lock {
  overflow: hidden;
}

@media (max-width: 640px) {
  .pg-thumb img {
    width: 56px;
    height: 56px;
  }

  .pg-lightbox .pg-nav {
    width: 40px;
    height: 40px;
    margin-top: -20px;
  }

  .pg-lb-bar {
    right: 10px;
    gap: 6px;
  }

  .pg-zoombar .pg-icon-btn {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pg-slide,
  .pg-slide img,
  .pg-dot,
  .pg-zoom,
  .pg-nav,
  .pg-lightbox,
  .pg-lightbox img {
    transition: none;
  }

  .pg-stage:hover .pg-slide.is-active img {
    transform: none;
  }
}

/* waiting-for-PJ cards (catalogue/product_waiting.html) */
.pw-card:hover {
  transform: none;
}

.pw-card .pl-card-media {
  display: block;
}

.pw-card .pl-card-style {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pw-assign {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.pw-assign .field {
  flex: 1;
  min-width: 0;
  height: 30px;
  padding: 0 8px;
  font-size: 12.5px;
  text-transform: uppercase;
}

.pw-assign .field::placeholder {
  text-transform: none;
}

.pw-status {
  min-height: 1em;
  font-size: 12px;
  line-height: 1.35;
  color: var(--text-muted);
}

.pw-status:empty {
  display: none;
}

.pw-status.is-ok { color: var(--ok, #16803c); }
.pw-status.is-warn { color: var(--warn, #b8860b); }
.pw-status.is-err { color: var(--danger, #c0392b); }

.pw-card.is-busy {
  opacity: 0.75;
}

.pw-card.is-done {
  border-color: var(--ok, #16803c);
}

.pw-card {
  transition: border-color var(--t-fast), opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.pw-card.is-gone {
  opacity: 0;
  transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
  .pl-card-media .pl-slides img.pl-slide,
  .pl-dot {
    transition: none;
  }
}

.pl-card-body {
  padding: 12px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.pl-card-name {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.pl-card-ref {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: 0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-card-style {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-card-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 11px;
  color: var(--text-muted);
}

.pl-card-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.pl-card-metal {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pl-card-price {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-strong);
  flex-shrink: 0;
}

[data-theme="dark"] .pl-card-price {
  color: var(--brand);
}

.pl-th-img,
.pl-td-img {
  width: 64px;
  padding-left: 12px !important;
  padding-right: 8px !important;
}

.pl-thumb {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: var(--bg-2);
}

.pl-thumb-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  font-size: 14px;
}

.pl-row {
  cursor: pointer;
}

.pl-pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 4px 0;
  font-size: 11.5px;
  color: var(--text-muted);
}

.pl-pager-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  color: var(--text-faint);
}

.pl-empty {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

@media (max-width: 1100px) {
  .pl-summary {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .pl-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .pl-sum-static {
    grid-column: 1 / -1;
  }

  .pl-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }

  .pl-card-body {
    padding: 10px;
  }

  .pl-card-name {
    font-size: 12.5px;
  }

  .pl-card-ref {
    font-size: 12.5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pl-card,
  .pl-card-media img {
    transition: none;
  }

  .pl-card:hover {
    transform: none;
  }

  .pl-card:hover .pl-card-media img {
    transform: none;
  }
}

/* location cards (Inventory > Location) */
.loc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 22px;
}

@media(max-width:1200px) {
  .loc-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

.loc-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  transition: border-color var(--t-fast);
}

.loc-card:hover,
.loc-card.active {
  border-color: var(--brand);
}

.loc-card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.loc-card-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--brand-dim);
  color: var(--brand-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  flex: 0 0 32px;
}

[data-theme="dark"] .loc-card-icon {
  color: var(--brand);
}

.loc-card-name {
  font-size: 13px;
  font-weight: 600;
}

.loc-card-type {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.loc-card-num {
  font-family: var(--font-mono);
  font-size: 20px;
  letter-spacing: -.02em;
  font-weight: 600;
}

.loc-card-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.dash-mini-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 12px;
}

.dash-mini-num {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 600;
  margin-top: 4px;
}

.dash-seq-intro {
  margin: -4px 0 12px;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 62ch;
}

.dash-seq-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 24px;
}

.dash-seq-card {
  padding: 16px 18px 18px;
}

.dash-seq-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.dash-seq-series {
  margin-top: 2px;
  font-size: 11px;
  color: var(--text-muted);
}

.dash-seq-next {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 14px;
  background: var(--brand-dim);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  margin-bottom: 12px;
}

.dash-seq-next-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.dash-seq-next-code {
  font-size: 22px;
  font-weight: 700;
  color: var(--brand-strong);
  letter-spacing: 0.02em;
}

[data-theme="dark"] .dash-seq-next-code {
  color: var(--brand);
}

.dash-seq-last {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 12.5px;
  margin-bottom: 14px;
}

.dash-seq-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin: 0;
}

.dash-seq-meta dt {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 0 0 2px;
}

.dash-seq-meta dd {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 800px) {
  .dash-seq-grid {
    grid-template-columns: 1fr;
  }
}

.kpi-card.is-alert {
  --kpi-accent: var(--danger);
  --kpi-bg: var(--danger-bg);
}

button.linkish {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-strong);
  cursor: pointer;
}

button.linkish:hover {
  text-decoration: underline;
}

.dash-actions {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}

.action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 18px 10px;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-align: center;
  transition: border-color var(--t-fast);
}

.action-card:hover {
  border-color: var(--brand);
  color: inherit;
}

.action-card i {
  font-size: 18px;
  color: var(--text-muted);
}

.action-card:hover i {
  color: var(--brand);
}

/* report cards (Reports page) */
.report-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media(max-width:980px) {
  .report-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media(max-width:640px) {
  .report-grid {
    grid-template-columns: 1fr;
  }
}

.report-card {
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--t-fast), transform var(--t-fast);
}

.report-card:hover {
  border-color: var(--brand);
  transform: translateY(-2px);
}

.report-card-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: var(--brand-dim);
  color: var(--brand-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

[data-theme="dark"] .report-card-icon {
  color: var(--brand);
}

.report-card h3 {
  font-size: 15.5px;
  font-weight: 600;
  font-family: var(--font-sans);
}

.report-card p {
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.5;
  flex: 1;
}

.report-card a {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--brand-strong);
  text-decoration: none;
  letter-spacing: .3px;
}

.report-card a i {
  margin-left: 4px;
  font-size: 10px;
}

/* tag print preview */
.tag-preview {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.tag-chip {
  width: 100%;
  max-width: 230px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}

.tag-chip .brand {
  font-family: var(--font-serif);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .5px;
  margin-bottom: 6px;
}

.tag-chip .code {
  font-family: var(--font-sans);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.tag-chip .bars {
  height: 34px;
  background: repeating-linear-gradient(90deg, var(--text) 0 2px, transparent 2px 4px);
  margin-bottom: 8px;
  opacity: .85;
}

.tag-chip .price {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  color: var(--brand-strong);
}

[data-theme="dark"] .tag-chip .price {
  color: var(--brand);
}

/* empty state */
.empty-state {
  text-align: center;
  padding: 50px 20px;
  color: var(--text-muted);
}

.empty-state i {
  font-size: 26px;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.empty-state p {
  font-size: 12.5px;
}

.note {
  padding: 12px 16px;
  background: var(--brand-dim);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  font-size: 12px;
  color: var(--brand-ink);
  margin-bottom: 18px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.note i {
  margin-top: 1px;
}


/* Auth — see the AUTH / SIGN-IN section further down for the split layout. */
.auth-shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: stretch;
}


/* =========================================================================
   MODALS
   ========================================================================= */
html.modal-open,
body.modal-open {
  overflow: hidden;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  padding: max(12px, env(safe-area-inset-top, 0px))
    max(12px, env(safe-area-inset-right, 0px))
    max(12px, env(safe-area-inset-bottom, 0px))
    max(12px, env(safe-area-inset-left, 0px));
  /* Above search, sticky chrome menus, and flash toasts. */
  z-index: 1500;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t-med) var(--ease), visibility var(--t-med);
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: min(560px, 100%);
  max-height: min(88vh, calc(100dvh - 24px));
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: var(--shadow-md);
  transform: translateY(10px);
  transition: transform var(--t-med) var(--ease);
  border: 1px solid var(--border-subtle);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal.wide {
  max-width: min(760px, 100%);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.modal-head h2 {
  font-size: 19px;
  font-weight: 600;
}

.modal-head p {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 0;
  width: 44px;
  height: 44px;
  margin: -8px -8px 0 0;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.modal-close:hover,
.modal-close:focus-visible {
  color: var(--text);
  background: var(--bg-2);
  outline: none;
}

.modal-body {
  padding: 20px 22px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  flex: 1 1 auto;
  min-height: 0;
}

.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

/* Phone / narrow landscape: bottom sheet so wide invoice modals stay usable. */
@media (max-width: 640px) {
  .modal-overlay {
    align-items: flex-end;
    padding-left: 0;
    padding-right: 0;
    padding-top: max(8px, env(safe-area-inset-top, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  .modal,
  .modal.wide {
    max-width: 100%;
    width: 100%;
    max-height: min(92dvh, 92vh);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(16px);
  }

  .modal-overlay.open .modal {
    transform: translateY(0);
  }

  .modal-head,
  .modal-body,
  .modal-foot {
    padding-left: 16px;
    padding-right: 16px;
  }
}

.modal-foot .spacer {
  margin-right: auto;
  font-size: 11.5px;
  color: var(--text-muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid.single {
  grid-template-columns: 1fr;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field.span-2 {
  grid-column: 1/-1;
}

.form-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .3px;
  text-transform: uppercase;
}

.form-field input,
.form-field select,
.form-field textarea {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color var(--t-fast);
}

.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  border-color: var(--brand);
}

.form-field textarea {
  resize: vertical;
  min-height: 70px;
}

.mini-table {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 6px;
}

.mini-table table {
  min-width: 0;
  font-size: 12px;
}

.mini-table thead th {
  padding: 8px 12px;
}

.mini-table tbody td {
  padding: 9px 12px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 2px;
  font-size: 13px;
}

.total-row.grand {
  font-weight: 700;
  font-size: 15px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 12px;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.detail-row .k {
  color: var(--text-muted);
}

.detail-row .v {
  font-weight: 600;
}

/* =========================================================================
   RESPONSIVE — off-canvas sidebar under 900px
   ========================================================================= */
@media(max-width:900px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    height: 100dvh;
    max-width: min(var(--sidebar-w), 100vw);
    transform: translateX(-100%);
    transition: transform var(--t-med) var(--ease);
    box-shadow: var(--shadow-md);
  }

  .app-shell.nav-open .sidebar {
    transform: translateX(0);
  }

  .app-shell.nav-open .sb-backdrop {
    display: block;
  }

  .crumbs {
    max-width: min(42vw, 200px);
  }

  .topbar-search {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 30;
    background: var(--header-bg);
    padding: 0 12px;
    align-items: center;
    justify-content: stretch;
  }

  .topbar-search.is-open {
    display: flex;
  }

  .topbar-search .search-box {
    max-width: none;
    width: 100%;
  }

  .topbar-search .search-box kbd {
    display: none;
  }

  .topbar-search .search-box .search-close {
    display: inline-flex;
  }

  .topbar-search .search-dd {
    left: 12px;
    right: 12px;
    width: auto;
  }

  .search-toggle {
    display: flex;
  }
}

@media(max-width:560px) {
  .content {
    padding: 18px 16px 60px;
  }

  .page-head {
    flex-direction: column;
    align-items: stretch;
  }

  .page-head > div:first-child {
    flex: none;
  }

  .page-head-actions {
    gap: 8px;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }
}

/* Phones: the DB badge's label ran under the search and settings icons.
   Show it as a colored dot on its tinted circle, in a 28px tap target; the
   label stays in the DOM for screen readers and the title still names the
   database. */
@media (max-width: 480px) {
  .db-badge {
    font-size: 0;
    letter-spacing: 0;
    padding: 0;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .db-badge::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: currentColor;
  }
  .db-badge.test { background: var(--warn-bg); color: var(--warn); }
  .db-switch .db-badge i { display: none; }
}
/* =========================================================================
   AUTH / SIGN-IN
   The login page previously rendered `{{ form.as_p }}`, so the panel and
   button picked up the design system while the inputs fell back to browser
   defaults — labels inline with colons, hairline borders, no dark-theme
   support. These rules cover the fields the template now writes out
   explicitly.
   ========================================================================= */
.auth-main::before {
  /* A quiet wash behind the card on the form column so it isn't a flat
     expanse. Brand hue at very low alpha — reads in both themes without a
     second colour being introduced. */
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(42rem 28rem at 110% -15%, color-mix(in srgb, var(--brand) 9%, transparent), transparent 72%);
  pointer-events: none;
}

/* ── Split sign-in: slideshow left, form right ──────────────────────────
   The aside is always dark (photo + scrim) regardless of theme; the form
   column follows the active theme. Below 860px the aside drops to a dim
   fixed backdrop and the card floats over it. Slideshow is decorative
   only — aria-hidden, and it freezes for prefers-reduced-motion. */
.auth-aside {
  position: relative;
  flex: 1 1 0;
  overflow: hidden;
  background: #14110f;
  display: flex;
}

.auth-slideshow {
  position: absolute;
  inset: 0;
}

.auth-slideshow > img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transform: scale(1.06);
  animation: authKenBurns 84s infinite;
  will-change: opacity, transform;
}

/* 12 frames x 7s = the 84s loop. Each holds ~4s with a ~1.5s cross-fade. */
.auth-slideshow > img:nth-child(1)  { animation-delay:  0s; }
.auth-slideshow > img:nth-child(2)  { animation-delay:  7s; }
.auth-slideshow > img:nth-child(3)  { animation-delay: 14s; }
.auth-slideshow > img:nth-child(4)  { animation-delay: 21s; }
.auth-slideshow > img:nth-child(5)  { animation-delay: 28s; }
.auth-slideshow > img:nth-child(6)  { animation-delay: 35s; }
.auth-slideshow > img:nth-child(7)  { animation-delay: 42s; }
.auth-slideshow > img:nth-child(8)  { animation-delay: 49s; }
.auth-slideshow > img:nth-child(9)  { animation-delay: 56s; }
.auth-slideshow > img:nth-child(10) { animation-delay: 63s; }
.auth-slideshow > img:nth-child(11) { animation-delay: 70s; }
.auth-slideshow > img:nth-child(12) { animation-delay: 77s; }

@keyframes authKenBurns {
  0%    { opacity: 0; transform: scale(1.06); }
  1.8%  { opacity: 1; }
  7.1%  { opacity: 1; }
  8.9%  { opacity: 0; transform: scale(1.12); }
  100%  { opacity: 0; transform: scale(1.12); }
}

.auth-aside-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(155deg, rgba(20, 17, 15, .28) 0%, rgba(20, 17, 15, .55) 55%, rgba(20, 17, 15, .82) 100%);
}

.auth-aside-copy {
  position: relative;
  margin-top: auto;
  padding: 48px;
  color: #f4ecdd;
}

.auth-aside-mark {
  width: 46px;
  height: 46px;
  border: 1px solid var(--brand);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--brand);
  margin-bottom: 18px;
}

.auth-aside-name {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: .5px;
}

.auth-aside-tag {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: rgba(231, 211, 168, .72);
}

.auth-main {
  position: relative;
  flex: 0 0 clamp(380px, 38vw, 540px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  /* The column IS the surface. It used to sit on --bg with a bordered
     card floating inside it — two dark planes of nearly the same value,
     with a 1px border doing all the work of telling them apart. Painting
     the column in --panel and dropping the inner card gives one honest
     surface, and matches the mobile sheet so both breakpoints express the
     same idea. */
  /* --panel is pure #ffffff in the light theme, which put a clinical
     white slab against a dark photograph. --bg is the warm off-white the
     rest of the light UI sits on, so the column reads as part of the same
     world as the gold. The dark theme keeps --panel, where the lift over
     --bg is what makes the column a surface at all. */
  background: var(--bg);
  /* Lifts the column off the photograph without a hard rule. */
  box-shadow: -24px 0 48px -24px rgba(0, 0, 0, .55);
  z-index: 1;
}

[data-theme="dark"] .auth-main {
  background: var(--panel);
}

@media (prefers-reduced-motion: reduce) {
  .auth-slideshow > img { animation: none; transform: none; }
  .auth-slideshow > img:not(:first-child) { display: none; }
  .auth-slideshow > img:first-child { opacity: 1; }
}

.auth-card {
  /* No longer a card — just the measure the form is set to. Kept as a
     class so the mobile rules and the markup don't have to change. */
  position: relative;
  width: min(380px, 100%);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 26px;
}

.auth-mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 50%;
  border: 1px solid var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 18px;
  color: var(--brand);
}

.auth-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 600;
  line-height: 1.15;
}

.auth-sub {
  font-size: 10.5px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}

.auth-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 600;
  margin: 0 0 4px;
}

.auth-lede {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 0 0 22px;
}

.auth-back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 26px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text-muted);
  text-decoration: none;
}

.auth-back:hover { color: var(--brand-ink); }
.auth-back i { font-size: 10px; transition: transform var(--t-fast) var(--ease); }
.auth-back:hover i { transform: translateX(-3px); }

.auth-error {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  background: var(--danger-bg);
  color: var(--danger);
  border-radius: var(--radius);
  padding: 10px 12px;
  font-size: 12.5px;
  line-height: 1.45;
  margin-bottom: 18px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.auth-field .field {
  width: 100%;
  font-size: 14px;
  padding: 11px 13px;
}

.auth-pw {
  position: relative;
  display: flex;
}

.auth-pw .field {
  padding-right: 42px;
}

.auth-pw-toggle {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  /* 44x44 is the smallest reliable tap target Apple and Google both
     publish. This was roughly 34px — fine with a mouse, fiddly with a
     thumb. */
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  line-height: 1;
  border-radius: var(--radius);
}

.auth-pw-toggle:hover { color: var(--text); }
.auth-pw-toggle:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.auth-caps {
  font-size: 11px;
  color: var(--warn);
  display: flex;
  align-items: center;
  gap: 5px;
}

/* `display:flex` above is an author rule and outranks the browser's own
   `[hidden] { display: none }`, so without this the Caps Lock hint shows
   from page load and never hides however correctly the JS sets the
   attribute. Any element that gets a display value AND uses `hidden`
   needs this guard. */
.auth-caps[hidden] {
  display: none;
}

.auth-submit {
  width: 100%;
  padding: 12px 18px;
  font-size: 12px;
  margin-top: 4px;
}

.auth-submit:disabled { opacity: .65; cursor: progress; }

.auth-foot {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-muted);
}

/* ---- Mobile: hero photo above, form on a sheet that rises over it ----
   The desktop layout is a side-by-side split. Squeezing that onto a phone
   by turning the photo into a full-bleed background meant veiling it to
   88% so the form stayed readable — which downloaded 1.7 MB of imagery to
   render something indistinguishable from a flat dark panel.

   Here the photo gets the top third at a veil light enough to actually
   see it, and the form sits on an opaque sheet with a rounded top edge
   overlapping the image. Brand identity is where the eye lands first, the
   sign-in button falls in the thumb zone, and the picture earns its
   bytes. */
@media (max-width: 860px) {
  .auth-shell {
    display: flex;
    flex-direction: column;
  }

  .auth-aside {
    flex: none;
    height: clamp(190px, 34dvh, 340px);
  }

  /* Fades from a light wash at the top into the panel colour at the
     bottom, so the sheet's edge reads as a join rather than a seam. */
  .auth-aside-veil {
    background: linear-gradient(180deg,
      rgba(20, 17, 15, .30) 0%,
      rgba(20, 17, 15, .45) 55%,
      rgba(20, 17, 15, .70) 100%);
  }

  /* One image, not twelve. A login screen is on screen for a few seconds,
     so a slideshow is spend without payoff — and a `display:none` image
     with loading="lazy" is never fetched, so the other eleven cost
     nothing. The first slot is always the newest catalogue photo. */
  .auth-slideshow > img:nth-child(n+2) { display: none; }
  .auth-slideshow > img:first-child {
    animation: none;
    opacity: 1;
    transform: none;
  }

  .auth-aside-copy {
    display: block;
    margin-top: auto;
    padding: 0 22px 30px;
    padding-left: max(22px, env(safe-area-inset-left));
  }

  .auth-aside-mark {
    width: 34px;
    height: 34px;
    font-size: 15px;
    margin-bottom: 10px;
  }

  .auth-aside-name { font-size: 21px; }
  .auth-aside-tag { font-size: 9.5px; }

  .auth-main {
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    /* A flex column, not a block: the card below uses flex:1 to fill the
       sheet so `margin-top:auto` on the footer actually reaches the
       bottom. A percentage height on the card would not resolve here,
       because this element's own height comes from flex, not from a
       definite value. */
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--panel);
    /* Pulls the sheet up over the photo — the overlap is what makes it
       read as a sheet rather than two stacked bands. */
    margin-top: -20px;
    border-radius: 20px 20px 0 0;
    /* The desktop rule casts a shadow to the left, where the column meets
       the photo. Here the seam is the top edge, so the shadow turns with
       it — which is also what sells the sheet as rising over the image. */
    box-shadow: 0 -18px 36px -18px rgba(0, 0, 0, .6);
    background: var(--bg);
    padding: 28px 22px 22px;
    padding-left: max(22px, env(safe-area-inset-left));
    padding-right: max(22px, env(safe-area-inset-right));
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  .auth-main::before { display: none; }

  /* The sheet is the card now, so the card stops being one. */
  .auth-card {
    width: 100%;
    max-width: 440px;
    margin: 0 auto;
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
  }

  /* Brand appears once, on the hero. */
  .auth-brand { display: none; }

  .auth-title {
    font-size: 30px;
    margin-bottom: 4px;
    /* Paired with the footer's own `margin-top:auto` below, this splits
       the sheet's spare height in two — so on a tall phone the form sits
       optically centred instead of stranded at the top above a void. On a
       short phone there is no spare height and both autos collapse to
       zero, which is exactly the behaviour wanted there. */
    margin-top: auto;
  }

  .auth-submit {
    padding: 15px 18px;
    font-size: 12.5px;
  }

  /* Pushes the footer to the bottom of the sheet so the button lands in
     the thumb zone instead of floating mid-screen. */
  .auth-foot { margin-top: auto; }
}

/* iOS Safari zooms the page whenever a focused input renders below 16px,
   and never zooms back out. 14px reads better on a desktop, so the bump
   is scoped to small screens rather than applied everywhere. */
@media (max-width: 640px) {
  .auth-field .field { font-size: 16px; }
  .auth-pw .field { padding-right: 50px; }
}

@media (max-width: 460px) {
  .auth-card { padding: 26px 22px 20px; border-radius: 12px; }
  .auth-title { font-size: 23px; }
}

/* Login mark. The staff rail uses .sb-mark beside the company name. */
.auth-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.auth-mark {
  border: none;
  padding: 2px;
}

.auth-aside-logo {
  display: block;
  width: clamp(150px, 42%, 240px);
  height: auto;
  margin-bottom: 14px;
}

@media (max-width: 860px) {
  .auth-aside-logo {
    width: clamp(120px, 38%, 165px);
    margin-bottom: 10px;
  }
}

/* ---- Autofill ----------------------------------------------------------
   Chrome paints its own pale blue (or yellow) over any field it fills, and
   it wins over `background` — which is why every filled input in this app
   sits off-palette in both themes. There is no property to turn that off,
   so the standard workaround is an inset box-shadow thick enough to cover
   the field, plus -webkit-text-fill-color for the text on top of it. The
   absurd transition delay stops Chrome animating its colour back in on
   focus. Applies app-wide, not just to the sign-in form. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus,
input:-webkit-autofill:active,
textarea:-webkit-autofill,
select:-webkit-autofill {
  -webkit-text-fill-color: var(--text);
  -webkit-box-shadow: 0 0 0 1000px var(--surface) inset;
  box-shadow: 0 0 0 1000px var(--surface) inset;
  caret-color: var(--text);
  transition: background-color 100000s ease-in-out 0s;
}

/* ---- Page load + image placeholders ----------------------------------- */
.pj-page-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 4000;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  background: transparent;
  transition: opacity var(--t-fast) var(--ease);
}
.pj-page-progress.is-on {
  opacity: 1;
}
.pj-page-progress-bar {
  height: 100%;
  width: 35%;
  background: var(--brand);
  transform: translateX(-100%);
  animation: pj-page-indet 1.15s var(--ease) infinite;
}
@keyframes pj-page-indet {
  0% { transform: translateX(-100%); width: 28%; }
  50% { width: 55%; }
  100% { transform: translateX(320%); width: 28%; }
}

.pl-card-media img.is-loaded,
.pd-photo-main img.is-loaded,
.pd-thumb img.is-loaded,
.pu-thumb img.is-loaded {
  opacity: 1;
}
.pj-img-pending img:not(.is-loaded) {
  opacity: 0;
}
.pj-img-pending img {
  transition: opacity var(--t-med) var(--ease);
}
.pj-img-pending {
  position: relative;
  isolation: isolate;
}
.pj-img-pending::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: var(--bg-2);
  animation: pj-img-pulse 1.1s ease-in-out infinite;
}
@keyframes pj-img-pulse {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 1; }
}

.pl-thumb {
  position: relative;
  overflow: hidden;
}
.pl-td-img {
  position: relative;
}
.pd-thumb {
  position: relative;
}
.pu-thumb,
.pu-thumb-wrap {
  position: relative;
}

@media (prefers-reduced-motion: reduce) {
  .pj-page-progress-bar,
  .pj-img-pending::after,
  .pj-img-pending img:not(.is-loaded) {
    animation: none;
    transition: none;
  }
  .pj-page-progress.is-on .pj-page-progress-bar {
    transform: none;
    width: 100%;
  }
}

/* Custom error pages (templates/400.html, 403.html, 403_csrf.html, 404.html, 500.html, 503.html)
   Shared jewelry/mining illustrations + soft gold glow. Premium ERP chrome, playful art. */
.error-page {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  background: var(--bg);
}
.error-card {
  max-width: 480px;
  width: 100%;
  text-align: center;
  background: var(--bg-2);
  border: 1px solid var(--border, rgba(169, 129, 63, 0.25));
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-5);
  box-shadow: 0 12px 40px rgba(43, 38, 34, 0.06);
}
.error-illustration {
  width: min(220px, 70vw);
  margin: 0 auto var(--space-3);
  line-height: 0;
}
.error-svg {
  width: 100%;
  height: auto;
  display: block;
}
.error-icon {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  background: var(--warn-bg, rgba(169, 129, 63, 0.15));
  color: var(--brand-strong);
}
.error-code {
  font-family: var(--font-serif);
  font-size: var(--fs-small);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-caps);
  color: var(--brand-strong);
  text-transform: uppercase;
  margin-bottom: var(--space-2);
}
.error-card h1 {
  font-family: var(--font-serif);
  font-size: var(--fs-h3);
  font-weight: var(--fw-semibold);
  line-height: var(--lh-tight);
  color: var(--text);
  margin: 0 0 var(--space-3);
}
.error-card p,
.error-card .error-desc {
  color: var(--text-muted);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  margin: 0 0 var(--space-5);
}
.error-actions {
  display: flex;
  gap: var(--space-2);
  justify-content: center;
  flex-wrap: wrap;
}
.error-actions .btn {
  min-height: 44px;
}

/* Soft sparkle / lantern pulse — gold brand accents only */
@keyframes error-sparkle {
  0%, 100% { opacity: 0.35; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.35); }
}
@keyframes error-glow-pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
.error-spark {
  transform-origin: center;
  animation: error-sparkle 2.8s var(--ease) infinite;
}
.error-spark--b {
  animation-delay: 1.1s;
}
.error-glow,
.error-lantern {
  animation: error-glow-pulse 3.2s var(--ease) infinite;
}
@media (prefers-reduced-motion: reduce) {
  .error-spark,
  .error-glow,
  .error-lantern {
    animation: none;
  }
}

@media (max-width: 479px) {
  .error-page {
    padding: var(--space-3);
    align-items: flex-start;
    padding-top: max(var(--space-5), env(safe-area-inset-top, 0px));
  }
  .error-card {
    padding: var(--space-5) var(--space-4);
    border-radius: var(--radius);
  }
  .error-illustration {
    width: min(180px, 64vw);
  }
  .error-card h1 {
    font-size: var(--fs-lead);
  }
  .error-actions {
    flex-direction: column;
  }
  .error-actions .btn {
    width: 100%;
  }
}


/* Staff-only error preview chrome */
.error-preview-banner {
  position: absolute;
  top: var(--space-3);
  left: 50%;
  transform: translateX(-50%);
  z-index: 2;
  font-size: var(--fs-small);
  font-weight: var(--fw-semibold);
  letter-spacing: var(--tracking-caps);
  text-transform: uppercase;
  color: var(--brand-strong);
  background: var(--bg-2);
  border: 1px solid var(--border, rgba(169, 129, 63, 0.35));
  border-radius: 999px;
  padding: 6px 14px;
  white-space: nowrap;
}
.error-preview-banner a {
  color: var(--brand-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.error-page {
  position: relative;
}
.error-preview-index-card {
  max-width: 520px;
  text-align: left;
}
.error-preview-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.error-preview-list a {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border, rgba(169, 129, 63, 0.25));
  border-radius: var(--radius);
  background: var(--surface, #fff);
  color: var(--text);
  text-decoration: none;
  min-height: 44px;
}
.error-preview-list a:hover {
  border-color: var(--brand-strong);
  background: var(--bg);
}
.error-preview-status {
  font-family: var(--font-serif);
  font-weight: var(--fw-bold);
  color: var(--brand-strong);
  min-width: 2.5rem;
}
.error-preview-index-actions {
  justify-content: flex-start;
  margin-top: var(--space-5);
}
/* =========================================================================
   LANDING — public page at `/` for signed-out visitors.
   The hero is always dark (photo + veil), like the sign-in aside, and
   reuses .auth-slideshow for its cross-fade. Sections below the hero
   follow the active theme.
   ========================================================================= */
.landing {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

.ld-nav {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px clamp(16px, 4vw, 48px);
}

.ld-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f4ecdd;
  text-decoration: none;
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: .3px;
}

.ld-nav-brand img { width: 36px; height: 36px; object-fit: contain; }

.ld-nav-cta { padding: 9px 20px; }

.ld-hero {
  position: relative;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: flex-end;
  overflow: hidden;
  background: #14110f;
  color: #f4ecdd;
}

.ld-hero-veil {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(20, 17, 15, .82) 0%, rgba(20, 17, 15, .45) 48%, rgba(20, 17, 15, .12) 100%),
    linear-gradient(180deg, rgba(20, 17, 15, .45) 0%, transparent 22%, transparent 60%, rgba(20, 17, 15, .75) 100%);
}

.ld-hero-copy {
  position: relative;
  z-index: 2;
  max-width: 620px;
  padding: 120px clamp(16px, 4vw, 48px) clamp(72px, 12vh, 128px);
}

.ld-hero .ld-eyebrow { color: var(--brand-soft); margin-bottom: 18px; }

.ld-hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(36px, 5.6vw, 64px);
  font-weight: 500;
  line-height: 1.04;
  letter-spacing: -.3px;
  margin: 0 0 16px;
  color: #fbf5ea;
  text-wrap: balance;
}

.ld-hero p {
  font-size: clamp(13.5px, 1.3vw, 15.5px);
  line-height: 1.65;
  color: rgba(244, 236, 221, .78);
  margin: 0 0 30px;
  max-width: 470px;
}

.ld-hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.ld-hero-actions .btn {
  padding: 13px 24px;
  font-size: 12px;
}

.ld-hero-actions .btn i { font-size: 11px; margin-left: 4px; }

.ld-btn-glass {
  background: rgba(244, 236, 221, .08);
  border: 1px solid rgba(231, 211, 168, .35);
  color: #f4ecdd;
  backdrop-filter: blur(6px);
}

.ld-btn-glass:hover {
  background: rgba(244, 236, 221, .16);
  border-color: var(--brand);
  color: #fff;
}

.ld-scroll {
  position: absolute;
  z-index: 2;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  color: rgba(231, 211, 168, .8);
  text-decoration: none;
  animation: ldBob 2.4s var(--ease) infinite;
}

@keyframes ldBob {
  0%, 100% { transform: translate(-50%, 0); }
  50%      { transform: translate(-50%, 6px); }
}

.ld-section {
  padding: clamp(56px, 9vw, 104px) clamp(16px, 4vw, 48px);
  max-width: 1240px;
  margin: 0 auto;
}

.ld-section-head {
  max-width: 560px;
  margin-bottom: 34px;
}

.ld-eyebrow {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--brand-ink);
  margin-bottom: 10px;
}

.ld-section-head h2 {
  font-family: var(--font-serif);
  font-size: clamp(28px, 3.6vw, 40px);
  font-weight: 500;
  line-height: 1.1;
  margin: 0 0 10px;
}

.ld-section-head p {
  color: var(--text-muted);
  font-size: 14px;
  margin: 0;
}

/* First tile spans two rows so the grid reads as a spread, not a
   spreadsheet of thumbnails. */
.ld-gallery {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: clamp(150px, 18vw, 240px);
  gap: 12px;
}

.ld-tile {
  position: relative;
  margin: 0;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: #14110f;
}

.ld-tile:first-child { grid-column: span 2; grid-row: span 2; }

.ld-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform .8s var(--ease), filter .8s var(--ease);
}

.ld-tile:hover img { transform: scale(1.05); filter: brightness(1.06); }

.ld-features { padding-top: 0; }

.ld-feature-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
}

.ld-feature {
  padding: 24px 22px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.ld-feature i {
  font-size: 17px;
  color: var(--brand);
  margin-bottom: 16px;
  display: block;
}

.ld-feature h3 {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 6px;
}

.ld-feature p {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-muted);
  margin: 0;
}

.ld-foot {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 22px clamp(16px, 4vw, 48px) 32px;
  border-top: 1px solid var(--border);
  font-size: 11.5px;
  color: var(--text-muted);
}

.ld-foot a { color: var(--brand-ink); text-decoration: none; }
.ld-foot a:hover { text-decoration: underline; }

@media (max-width: 900px) {
  .ld-gallery { grid-template-columns: repeat(2, 1fr); grid-auto-rows: clamp(140px, 38vw, 220px); }
  .ld-feature-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 560px) {
  .ld-nav-brand span { display: none; }
  .ld-hero-veil {
    background: linear-gradient(180deg, rgba(20, 17, 15, .45) 0%, rgba(20, 17, 15, .35) 40%, rgba(20, 17, 15, .88) 100%);
  }
  .ld-hero-actions .btn { flex: 1 1 auto; justify-content: center; }
  .ld-feature-grid { grid-template-columns: 1fr; }
  .ld-foot { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  .ld-scroll { animation: none; }
  .ld-tile img { transition: none; }
}

html:has(.landing) { scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) { html:has(.landing) { scroll-behavior: auto; } }

/* Over the photo the light theme's near-black primary disappears; the
   hero and nav always use the gold button. */
.ld-hero .btn-primary,
.ld-nav .btn-primary {
  background: var(--brand);
  color: var(--text-on-brand);
  border-color: var(--brand);
}

.ld-hero .btn-primary:hover,
.ld-nav .btn-primary:hover {
  background: var(--brand-soft);
  border-color: var(--brand-soft);
}

/* ---- Dashboard cards (templates/core/home.html, core/dashboard/_*.html) ----
   Two-column card grid; wide cards span both. Charts are Chart.js canvases
   themed from these tokens by static/core/js/dashboard.js. */
.dash-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
}
.dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
  margin-bottom: 24px;
}
.dash-card {
  background: var(--surface);
  /* Section wrapper: no frame of its own; its fill and heading group the
     cards inside, which carry the hairline. Transparent keeps the box size. */
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  padding: 16px 18px 18px;
  min-width: 0;
  scroll-margin-top: calc(var(--header-h) + 12px);
}
.dash-card.is-wide { grid-column: 1 / -1; }
.dash-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.dash-card-title {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin: 0;
  flex: 1;
  min-width: 0;
}
.dash-card-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-ink);
  white-space: nowrap;
}
.dash-card-link i { font-size: 9px; margin-left: 2px; }
.dash-card-lede { font-size: 12px; color: var(--text-muted); margin: -4px 0 12px; }
.dash-foot { font-size: 11px; color: var(--text-faint); margin: 10px 0 0; }
.dash-card .kpi-grid.dash-kpis { margin-bottom: 0; grid-template-columns: repeat(auto-fit, minmax(min(200px, 100%), 1fr)); }
.dash-card .table-scroll { width: 100%; }
.dash-card .dash-actions { margin-bottom: 0; }
.dash-card .dash-seq-grid { margin-bottom: 0; }

/* Needs your attention */
.dash-card[data-key="attention"] { border-left: 4px solid var(--brand); }
.dash-attention {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 10px;
}
.dash-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--tone-bg, var(--surface-2));
  color: var(--text);
  text-decoration: none;
  transition: transform var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
a.dash-alert:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); text-decoration: none; }
.dash-alert-icon {
  flex: 0 0 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--tone, var(--brand));
  background: var(--surface);
}
.dash-alert-body { flex: 1; min-width: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: baseline; }
.dash-alert-count { font-family: var(--font-mono); font-size: 20px; color: var(--tone, var(--text)); line-height: 1; }
.dash-alert-label { font-size: 12px; font-weight: 600; }
.dash-alert-body small { grid-column: 1 / -1; font-size: 10.5px; color: var(--text-muted); margin-top: 2px; }
.dash-alert-go { font-size: 10px; color: var(--text-faint); }
/* Faint text misses 4.5:1 on the dark status tints these alerts use. */
[data-theme="dark"] .dash-alert.tone-warn .dash-alert-go,
[data-theme="dark"] .dash-alert.tone-danger .dash-alert-go,
[data-theme="dark"] .dash-alert.tone-ok .dash-alert-go,
[data-theme="dark"] .dash-alert.tone-info .dash-alert-go {
  color: var(--text-muted);
}
.tone-danger { --tone: var(--danger); --tone-bg: var(--danger-bg); }
.tone-warn { --tone: var(--warn); --tone-bg: var(--warn-bg); }
.tone-info { --tone: var(--info); --tone-bg: var(--info-bg); }
.tone-ok { --tone: var(--ok); --tone-bg: var(--ok-bg); }
.tone-text-danger { color: var(--danger); }
.dash-all-clear { margin: 0; font-size: 13px; color: var(--ok); }
.dash-all-clear i { margin-right: 6px; }

/* Charts */
.dash-chart { position: relative; height: 220px; }
.dash-chart-lg { height: 280px; }
.dash-chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  font-size: 11.5px;
  margin: -4px 0 10px;
}
.dash-seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
}
.dash-seg button {
  border: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  cursor: pointer;
}
.dash-seg button:hover { color: var(--text); }
.dash-seg button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.chart-fallback { width: 100%; font-size: 12px; margin-top: 8px; }
.chart-fallback td, .chart-fallback th { padding: 4px 6px; text-align: left; }
/* Once Chart.js has drawn, the number table stays for screen readers only. */
.dash-card { position: relative; }
.dash-card.is-charted .chart-fallback {
  display: block;  /* a table ignores width/overflow and would widen the page */
  min-width: 0;    /* the shared 640px table floor still applied while clipped */
  position: absolute;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
.dash-card:not(.is-charted) canvas { display: none; }
.dash-card:not(.is-charted) .dash-chart { height: auto; }
.dash-donut-wrap { display: grid; grid-template-columns: 180px 1fr; gap: 20px; align-items: center; }
.dash-chart-donut { height: 180px; }
.dash-chart-legend { display: grid; gap: 8px; }
.dash-chart-legend > div {
  display: grid;
  grid-template-columns: 10px 1fr auto 42px;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}
.dash-chart-legend small { color: var(--text-muted); text-align: right; }
.mix-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.tone-bg-ok { background: var(--ok); }
.tone-bg-info { background: var(--info); }
.tone-bg-warn { background: var(--warn); }
.tone-bg-neutral { background: var(--neutral); }
.tone-bg-brand { background: var(--brand); }
.tone-bg-violet { background: var(--violet); }
.tone-bg-sales { background: var(--c-sales); }
.tone-bg-teal { background: var(--c-teal); }
.tone-bg-gold { background: var(--c-gold); }
.tone-bg-c4 { background: var(--c-4); }
.tone-bg-c5 { background: var(--c-5); }
.tone-bg-c7 { background: var(--c-7); }

/* Compact tables inside cards. The shared 640px table floor pushes these
   chart cards past the phone width; they wrap their own columns instead. */
.dash-mini-table { width: 100%; min-width: 0; border-collapse: collapse; font-size: 12px; }
.dash-mini-table th {
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-faint);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.dash-mini-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.dash-mini-table tr:last-child td { border-bottom: 0; }
.dash-details { margin-top: 10px; }
.dash-details summary {
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--brand-ink);
  padding: 4px 0;
}
.dash-age-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.dash-age-strip span {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--tone-bg);
  color: var(--tone);
}

/* Arrivals pipeline */
.dash-pipeline { display: flex; align-items: stretch; gap: 8px; margin-bottom: 12px; }
.dash-stage {
  flex: 1;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.dash-stage strong { font-family: var(--font-mono); font-size: 22px; line-height: 1.1; }
.dash-stage small { font-size: 10.5px; color: var(--text-muted); }
.dash-stage.is-busy { border-color: var(--border-strong); background: var(--brand-dim); }
.dash-stage.is-stale { border-color: var(--warn); background: var(--warn-bg); }
.dash-stage-arrow { align-self: center; color: var(--text-faint); font-size: 11px; }

/* Customize mode */
.dash-edit-bar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px 16px;
  align-items: center;
  padding: 12px 16px;
  margin-bottom: 16px;
  border: 1px dashed var(--brand);
  border-radius: var(--radius-lg);
  background: var(--brand-dim);
  font-size: 12px;
}
.dash-edit-bar[hidden] { display: none; }
.dash-edit-actions { display: flex; gap: 8px; }
.dash-tray { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.dash-tray .kpi-label { margin-right: 4px; }
.dash-tray-item {
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.dash-tray-item:hover { border-color: var(--brand); color: var(--brand-ink); }
.dash-card-tools { display: none; gap: 4px; }
.dash-editing .dash-card-tools { display: inline-flex; }
.dash-tool {
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
}
.dash-tool:hover, .dash-tool:focus-visible { color: var(--brand-ink); border-color: var(--brand); }
.dash-drag { cursor: grab; }
.dash-editing .dash-card:not([data-fixed]) { outline: 1px dashed var(--border-strong); outline-offset: 3px; }
.dash-card.is-dragging { opacity: .45; }

@media (max-width: 900px) {
  .dash-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-edit-bar { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .dash-card { padding: 14px 14px 16px; }
  .dash-donut-wrap { grid-template-columns: 1fr; }
  .dash-chart-donut { height: 200px; }
  .dash-chart-lg { height: 240px; }
  .dash-pipeline { flex-direction: column; }
  .dash-stage-arrow { transform: rotate(90deg); }
  .dash-attention { grid-template-columns: 1fr; }
}

/* Chart series palette — shared with the pj-accounting report so both apps
   read the same: steel blue = sales, teal = money in / available, gold = gold.
   Colours follow meaning, not series order. The stock-status extras stay
   warm: c-4 warm grey (sold, finished), c-5 plum (in transit), c-7 copper
   (new arrival). Dark values are the lighter steps that keep 3:1 on the
   dark surface. */
[data-theme="light"] {
  --c-sales: #426c91;
  --c-teal: #0f766e;
  --c-gold: #a87a2b;
  --c-4: #6e695c;
  --c-5: #795274;
  --c-7: #9a4f2b;
}
[data-theme="dark"] {
  --c-sales: #8fb3d6;
  --c-teal: #2dd4bf;
  --c-gold: #e0b341;
  --c-4: #beb6a4;
  --c-5: #d0a3c9;
  --c-7: #e0a07c;
}
:root { --font-mono: 'Geist Mono', ui-monospace, monospace; }

/* Figures on dashboard cards: mono, like the accounting report's KPIs. */
.dash-card .kpi-card { padding: 14px 16px; }
.dash-card .kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.dash-card .kpi-num {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  line-height: 1.15;
}
.dash-card .kpi-sub { font-size: 11.5px; }
.dash-alert-count, .dash-stage strong { font-family: var(--font-mono); font-weight: 600; letter-spacing: -0.03em; }
.dash-alert-count { font-size: 20px; }
.dash-stage strong { font-size: 22px; }
.dash-card .mono { font-family: var(--font-mono); font-size: 11.5px; }

/* ---------- Design + piece detail pages (catalogue/product_detail, item_detail) ---------- */
.detail-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  margin-bottom: 16px;
}
.detail-hero-media .pg { margin-bottom: 0; }
.detail-hero-media .pg-stage { height: clamp(260px, 34vw, 460px); }
.detail-nophoto {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  color: var(--text-muted);
  text-align: center;
  background: radial-gradient(ellipse at center, var(--surface) 0%, var(--neutral-bg) 80%);
}
.detail-nophoto i { font-size: 34px; color: var(--text-faint); }
.detail-nophoto p { margin: 0; font-size: 12.5px; }

.detail-hero-info { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.detail-eyebrow {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--brand-ink);
}
.detail-title {
  margin: -6px 0 0;
  font-family: var(--font-serif);
  font-size: clamp(24px, 2.6vw, 34px);
  font-weight: 600;
  line-height: 1.15;
  color: var(--text);
  overflow-wrap: anywhere;
}
.detail-idline { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.detail-barcode {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 4px 10px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--brand-dim);
}
.detail-copy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  vertical-align: middle;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.detail-copy:hover { color: var(--brand-ink); border-color: var(--brand); }
.detail-copy.is-copied { color: var(--ok); border-color: var(--ok); }
.detail-codes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.detail-codes:empty { display: none; }
.detail-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.detail-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--neutral-bg);
  color: var(--text);
  font-size: 11.5px;
  font-weight: 500;
}
.detail-chip i { color: var(--text-muted); font-size: 10.5px; }

.detail-facts {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  margin: 0;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  background: var(--border);
  overflow: hidden;
}
.detail-facts > div { padding: 12px 14px; background: var(--panel); min-width: 0; }
.detail-facts dt {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.detail-facts dd { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.detail-facts dd .cell-muted { font-size: 11px; font-weight: 400; }

.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.detail-stock { display: flex; flex-direction: column; gap: 8px; }
.detail-stock-head { display: flex; justify-content: space-between; font-size: 13px; }
.detail-stock-head strong { font-family: var(--font-mono); font-size: 18px; }
.detail-ok { color: var(--ok); }
.detail-stockbar {
  display: flex;
  height: 10px;
  border-radius: var(--radius-pill);
  overflow: hidden;
  background: var(--neutral-bg);
}
.detail-stockbar .seg { display: block; height: 100%; min-width: 3px; transition: filter var(--t-fast); }
.detail-stockbar .seg:hover { filter: brightness(1.12); }
.detail-stock-legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11.5px; }
.detail-stock-legend a { display: inline-flex; align-items: center; gap: 6px; color: var(--text-muted); text-decoration: none; }
.detail-stock-legend a:hover { color: var(--text); }
.detail-stock-legend b { color: var(--text); font-family: var(--font-mono); }
.detail-stock-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }
.seg.tone-ok, .detail-stock-legend i.tone-ok { background: var(--ok); }
.seg.tone-info, .detail-stock-legend i.tone-info { background: var(--info); }
.seg.tone-warn, .detail-stock-legend i.tone-warn { background: var(--warn); }
.seg.tone-neutral, .detail-stock-legend i.tone-neutral { background: var(--neutral); }
.seg.tone-violet, .detail-stock-legend i.tone-violet { background: var(--violet); }

/* alerts */
.detail-alerts { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.detail-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--neutral-bg);
  font-size: 12.5px;
}
.detail-alert > i { font-size: 14px; }
.detail-alert-text { flex: 1; min-width: 0; }
.detail-alert-text span { color: var(--text-muted); }
.detail-alert-link { white-space: nowrap; font-weight: 600; font-size: 12px; text-decoration: none; color: inherit; }
.detail-alert.tone-danger { background: var(--danger-bg); border-left-color: var(--danger); }
.detail-alert.tone-danger > i, .detail-alert.tone-danger .detail-alert-link { color: var(--danger); }
.detail-alert.tone-warn { background: var(--warn-bg); border-left-color: var(--warn); }
.detail-alert.tone-warn > i, .detail-alert.tone-warn .detail-alert-link { color: var(--warn); }
.detail-alert.tone-info { background: var(--info-bg); border-left-color: var(--info); }
.detail-alert.tone-info > i, .detail-alert.tone-info .detail-alert-link { color: var(--info); }
.detail-alert.tone-neutral { border-left-color: var(--neutral); }
.detail-alert.tone-neutral > i { color: var(--neutral); }

/* tabs */
.detail-tabs {
  position: sticky;
  top: var(--header-h);
  z-index: 5;
  display: flex;
  gap: 4px;
  margin: 8px 0 16px;
  padding: 0 2px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  overflow-x: auto;
  scrollbar-width: none;
}
.detail-tabs::-webkit-scrollbar { display: none; }
.detail-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 11px 14px;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: color var(--t-fast), border-color var(--t-fast);
}
.detail-tab:hover { color: var(--text); }
.detail-tab.is-active { color: var(--brand-ink); border-bottom-color: var(--brand); }
.detail-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: -2px; border-radius: var(--radius-sm); }
.detail-tab-count {
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--neutral-bg);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
}
.detail-tab.is-active .detail-tab-count { background: var(--brand-dim); color: var(--brand-ink); }
.detail-panel { margin-bottom: 28px; scroll-margin-top: calc(var(--header-h) + 56px); }
.detail-panel-title {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
}
html.detail-tabs-on .detail-panel { display: none; }
html.detail-tabs-on .detail-panel.is-active { display: block; animation: detail-fade var(--t-med) var(--ease); }
html.detail-tabs-on .detail-panel-title { display: none; }
@keyframes detail-fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* panel content */
.detail-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.detail-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.detail-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; }
.detail-subhead {
  margin-bottom: 10px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
}
.detail-subhead-row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.detail-link { font-size: 12px; font-weight: 600; text-decoration: none; }
.detail-panel-foot { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); font-size: 12px; font-weight: 600; }
.detail-panel-foot a { text-decoration: none; }
.detail-spec { width: 100%; min-width: 0; border-collapse: collapse; font-size: 12.5px; table-layout: fixed; }
.detail-spec th {
  width: 42%;
  padding: 7px 12px 7px 0;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  text-align: left;
  vertical-align: top;
}
.detail-spec td { padding: 7px 0; border-bottom: 1px solid var(--border); overflow-wrap: anywhere; }
.detail-spec tr:last-child th, .detail-spec tr:last-child td { border-bottom: none; }
.detail-desc { margin: 0; font-size: 13px; line-height: 1.6; }
.detail-note { margin: 12px 0 0; font-size: 12px; color: var(--text-muted); }
.detail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 28px 12px;
  color: var(--text-muted);
  text-align: center;
}
.detail-empty i { font-size: 22px; color: var(--text-faint); }
.detail-empty p { margin: 0; font-size: 12.5px; max-width: 46ch; }

.detail-price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.detail-price { padding: 12px 14px; border-radius: var(--radius); background: var(--neutral-bg); }
.detail-price .l { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.detail-price .v { margin-top: 4px; font-size: 18px; font-weight: 600; }
.detail-price .s { margin-top: 2px; font-size: 11px; color: var(--text-muted); }
.detail-price.is-ok { background: var(--ok-bg); } .detail-price.is-ok .v { color: var(--ok); }
.detail-price.is-danger { background: var(--danger-bg); } .detail-price.is-danger .v { color: var(--danger); }

.detail-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.detail-kpi { padding: 10px 12px; border-radius: var(--radius); background: var(--neutral-bg); min-width: 0; }
.detail-kpi .n { font-size: 16px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.detail-kpi .l { margin-top: 2px; font-size: 10.5px; color: var(--text-muted); }

.detail-locrow {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(60px, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  color: inherit;
  font-size: 12.5px;
  text-decoration: none;
}
.detail-locrow:last-child { border-bottom: none; }
.detail-locrow:hover .detail-locname { color: var(--brand-ink); }
.detail-locname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-locbar { height: 6px; border-radius: var(--radius-pill); background: var(--neutral-bg); overflow: hidden; }
.detail-locbar > span { display: block; height: 100%; border-radius: inherit; background: var(--border-strong); }
.detail-locbar .avail { display: block; height: 100%; background: var(--ok); border-radius: inherit; }
.detail-locnum { white-space: nowrap; font-size: 12px; }

/* filter chips (timeline kinds, piece status) */
.detail-chips-bar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.detail-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 11.5px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: all var(--t-fast);
}
.detail-chip-btn span { font-family: var(--font-mono); font-weight: 500; opacity: .8; }
.detail-chip-btn:hover { color: var(--text); border-color: var(--border-strong); }
.detail-chip-btn.is-active { color: var(--brand-ink); border-color: var(--brand); background: var(--brand-dim); }
.detail-toolbar { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px; }
.detail-toolbar .detail-chips-bar { margin-bottom: 0; }
.detail-toolbar-right { display: flex; align-items: center; gap: 8px; }
.table-wrap.is-compact td, .table-wrap.is-compact th { padding-top: 5px; padding-bottom: 5px; }

/* timeline */
.tl-list { list-style: none; margin: 0; padding: 0; position: relative; }
.tl-day {
  margin: 14px 0 6px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-faint);
}
.tl-list > .tl-day:first-child { margin-top: 0; }
.tl-item { position: relative; display: flex; gap: 12px; padding: 0 0 14px; }
.tl-item::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 28px;
  bottom: 0;
  width: 1px;
  background: var(--border);
}
.tl-item:last-child::before { display: none; }
.tl-dot {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 27px;
  height: 27px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11px;
}
.tl-item.tone-ok .tl-dot { background: var(--ok-bg); color: var(--ok); border-color: transparent; }
.tl-item.tone-info .tl-dot { background: var(--info-bg); color: var(--info); border-color: transparent; }
.tl-item.tone-warn .tl-dot { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.tl-item.tone-danger .tl-dot { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.tl-item.tone-muted { opacity: .6; }
.tl-body { flex: 1; min-width: 0; padding-top: 3px; }
.tl-title { font-size: 13px; font-weight: 600; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; }
.tl-title a { color: inherit; }
.tl-title a:hover { color: var(--brand-ink); }
.tl-barcode { font-size: 11px; font-weight: 500; color: var(--text-muted) !important; }
.tl-detail { margin-top: 2px; font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }
.tl-meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; font-size: 11px; color: var(--text-faint); }
.tl-kind { font-weight: 600; text-transform: uppercase; letter-spacing: .05em; font-size: 10px; }

/* Where a record came from: copied from iadmin, or done in this system. */
.src-tag {
  display: inline-block; padding: 1px 6px; border-radius: var(--radius-sm);
  font-size: 10px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  line-height: 1.5; vertical-align: middle; white-space: nowrap;
  border: 1px solid currentColor;
}
.src-tag.is-iadmin { color: var(--warn); background: var(--warn-bg); }
.src-tag.is-here { color: var(--brand-strong); background: var(--brand-soft); }
[data-filter-key].is-filtered-out, [data-filter-divider].is-filtered-out { display: none; }

/* sibling pieces */
.detail-piece-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.detail-piece {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  background: var(--panel);
  color: inherit;
  text-decoration: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}
.detail-piece:hover { border-color: var(--brand); box-shadow: var(--shadow-sm); transform: translateY(-1px); }
.detail-piece-code { font-size: 13px; font-weight: 600; }
.detail-piece-loc { font-size: 11.5px; color: var(--text-muted); }

@media (max-width: 1100px) {
  .detail-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .detail-hero { grid-template-columns: 1fr; gap: 16px; }
  .detail-grid-2, .detail-grid-3, .detail-cols { grid-template-columns: 1fr; }
  body:has(.detail-actions) { padding-bottom: 60px; }
  .detail-actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: var(--bg);
    border-top: 1px solid var(--border);
    box-shadow: 0 -6px 18px rgba(0, 0, 0, .06);
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .detail-actions .btn { flex: 0 0 auto; }
}
@media (max-width: 520px) {
  .detail-facts { grid-template-columns: 1fr; }
  .detail-locrow { grid-template-columns: minmax(0, 1fr) auto; }
  .detail-locbar { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  html.detail-tabs-on .detail-panel.is-active { animation: none; }
  .detail-piece:hover { transform: none; }
}

/* =========================================================================
   SPLIT PANE — list on the left, selected record on the right.
   Markup: .split > .split-list (> .split-toolbar, .split-rows > a.split-row,
   .table-foot) + .split-detail. Above 1000px the frame locks to the
   viewport and each pane scrolls on its own; every flex/grid child in the
   chain needs min-height:0 or the inner overflow never triggers.
   ========================================================================= */
.split {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.split-list {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-right: 1px solid var(--border);
}
.split-toolbar {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.split-toolbar .fbar-input { min-width: 0; }
.split-rows { flex: 1; overflow-y: auto; }
.split-row {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
  transition: background var(--t-fast);
}
.split-row:hover { background: var(--bg-2); }
.split-row.active { background: var(--brand-dim); box-shadow: inset 3px 0 0 var(--brand); }
.split-row-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.split-row-title { font-family: var(--font-mono); font-size: 13.5px; font-weight: 600; }
.split-row-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin: 3px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.split-row-meta { display: flex; gap: 10px; font-size: 11px; color: var(--text-faint); }
.split-row-meta .split-row-amt { margin-left: auto; color: var(--text); }
.split-empty-list { padding: 16px; font-size: 12.5px; color: var(--text-muted); }
.split-list .table-foot { border-top: 1px solid var(--border); background: var(--surface-2); }

.split-detail { min-width: 0; padding: 20px 24px; }
.split-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.split-eyebrow { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); }
.split-title { font-family: var(--font-mono); font-size: 28px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; margin-top: 2px; }
.split-headmeta { font-size: 13px; color: var(--text-muted); margin-top: 6px; }
.split-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.split-tots { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.split-tot { border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 10px 16px; background: var(--surface); }
.split-tot-v { font-family: var(--font-mono); font-size: 18px; font-weight: 600; margin-top: 2px; font-variant-numeric: tabular-nums; }
.split-tot-v.accent { color: var(--brand-strong); }
.split-tot-v.warn { color: var(--warn); }
.split-tot-v.ok { color: var(--ok); }
.split-tot-v.muted { color: var(--text-faint); }

.split-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 260px;
  height: 100%;
  color: var(--text-muted);
}
.split-empty i { font-size: 32px; color: var(--text-faint); }

@media (max-width: 1000px) {
  .split { grid-template-columns: 1fr; }
  .split-list { border-right: none; border-bottom: 1px solid var(--border); }
  .split-rows { max-height: 50vh; }
}

@media (min-width: 1001px) {
  body:has(.split) { overflow: hidden; }
  body:has(.split) .app-shell { height: 100vh; min-height: 0; overflow: hidden; }
  body:has(.split) .main { min-height: 0; }
  body:has(.split) .content { min-height: 0; overflow: hidden; display: flex; flex-direction: column; padding: 18px 0 0; }
  body:has(.split) .content > .page-head,
  body:has(.split) .content > .panel { margin-left: 24px; margin-right: 24px; }
  body:has(.split) .split { flex: 1; min-height: 0; border-width: 1px 0 0; border-radius: 0; }
  body:has(.split) .split-list { min-height: 0; }
  body:has(.split) .split-detail { min-height: 0; overflow-y: auto; }
  body:has(.split) .split-head {
    position: sticky;
    top: -20px;
    z-index: 5;
    margin: -20px -24px 16px;
    padding: 20px 24px 12px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
  }
}

/* Full-screen list: add .fill-table to a page's one main table (a .table-wrap,
   a padding:0 .panel, or a wrapper holding a .table-wrap) and it fills the
   window below the filters, edge to edge, scrolling inside with the header
   pinned. .fill-foot marks a pager that sits after it. Desktop only.
   .edge-table is the same edge-to-edge look without the fixed height, for
   pages whose filters are too tall to leave room for a scrolling box. */
@media (min-width: 1001px) {
  .content > .edge-table { margin-left: -24px; margin-right: -24px; border-width: 1px 0; border-radius: 0; }
  /* Pagers stay at the bottom of the window while their table is on screen.
     overflow: clip (not hidden) so the wrap is not a scroll box, which would stop sticky. */
  .content > .edge-table:has(> .table-foot) { overflow: clip; }
  .edge-table > .table-foot,
  .content > .pl-pager {
    position: sticky; bottom: 0; z-index: 3;
    background: var(--surface);
    box-shadow: 0 -1px 0 var(--border);
  }
  .edge-table > .table-foot { border-top: 0; padding-left: 24px; padding-right: 24px; }
  .content > .pl-pager { margin: 0 -24px; padding: 8px 24px; }
  body:has(.content > .fill-table) { overflow: hidden; }
  body:has(.content > .fill-table) .app-shell { height: 100vh; min-height: 0; overflow: hidden; }
  body:has(.content > .fill-table) .main { min-height: 0; }
  body:has(.content > .fill-table) .content { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; padding-bottom: 0; }
  body:has(.content > .fill-table) .content > * { flex-shrink: 0; }
  body:has(.content > .fill-table) .content > .fill-table {
    /* A hard 320px floor plus the filters overflowed a short window, so the
       page and the table both scrolled and the pager sat below the fold.
       min-height 0 then let a tall header (gold stock with the add form)
       shrink the scroll area to nothing and clip every row. min(320px, 50vh)
       keeps about three rows on a 1366×768 desktop and yields to half the
       viewport on a shorter window. Phones never enter this block.
       flex-shrink 0 is what holds that floor: the box stays in normal flow
       under the form, and the page scrolls to it. A sticky bottom layer
       covered the add-gold fields while tabbing. flex-grow still fills
       leftover space, so a short page does not gain an empty 320px slab. */
    flex: 1 0 min(320px, 50vh);
    min-height: min(320px, 50vh);
    margin: 0 -24px !important;
    border-width: 1px 0 0;
    border-radius: 0;
    overflow: auto;
  }
  .content > .fill-table:has(.table-scroll) { display: flex; flex-direction: column; overflow: hidden; }
  .fill-table > .table-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; border-width: 1px 0 0; border-radius: 0; }
  .fill-table .table-scroll { flex: 1; min-height: 0; overflow: auto; }
  .fill-table > .table-foot { flex: 0 0 auto; }
  .fill-table thead th { position: sticky; top: 0; z-index: 2; }
  .fill-table tfoot td { position: sticky; bottom: 0; z-index: 2; background: var(--surface); box-shadow: 0 -1px 0 var(--border); }
  body:has(.content > .fill-table) .content > .fill-foot {
    margin: 0 -24px !important;
    padding: 8px 24px;
    border-top: 1px solid var(--border);
    background: var(--surface);
  }
}

@media print {
  body:has(.content > .fill-table), body:has(.content > .fill-table) .app-shell,
  body:has(.content > .fill-table) .main, body:has(.content > .fill-table) .content,
  .fill-table, .fill-table .table-scroll {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  .content > .edge-table { margin-left: 0; margin-right: 0; border-width: 1px; }
  .edge-table > .table-foot, .content > .pl-pager { position: static; box-shadow: none; }
  .per-page, .rpt-tabs { display: none !important; }
}

@media print {
  body:has(.split), body:has(.split) .app-shell, body:has(.split) .main, body:has(.split) .content,
  .split, .split-detail {
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
  }
  .split { display: block !important; border: none !important; }
  .split-list { display: none !important; }
  .split-detail { padding: 0 !important; }
  .split-head { position: static !important; margin: 0 0 12px !important; padding: 0 !important; border: none !important; background: transparent !important; }
}

/* Photo history: status chips + floating-photo queue */
.pl-sum-danger .pl-sum-n { color: var(--danger); }
.ph-chips { margin-bottom: 10px; }
@media (min-width: 1101px) { .ph-chips { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
.ph-search { display: flex; gap: 8px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.ph-search .pl-search { flex: 1 1 280px; max-width: 420px; }
.ph-filters { margin-bottom: 14px; }
.ph-date {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}
.ph-date .field { width: auto; }
.ph-batch { flex: 0 1 7rem; min-width: 6.5rem; max-width: 8rem; }
.ph-approve-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 13px;
}
.ph-blocks { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 12px; font-size: 12.5px; }
.ph-blocks > i { color: var(--warn); margin-top: 2px; }
.ph-block { display: inline-block; margin: 0 10px 4px 6px; }
.ph-queue-meta { font-size: 12px; margin: 0 0 10px; }
.ph-queue { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.ph-card { background: var(--surface); border: 1px solid var(--border-subtle); border-radius: var(--radius-lg); padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.ph-card.is-ready { border-color: color-mix(in srgb, var(--ok) 45%, var(--border)); }
.ph-card.is-check { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.ph-card.is-done { opacity: .6; }
.ph-card-head { display: flex; justify-content: space-between; gap: 8px; }
.ph-code { font-size: 15px; font-weight: 600; }
.ph-code-none { color: var(--warn); }
.ph-card-sub { font-size: 11.5px; margin-top: 2px; }
.ph-hint { display: flex; gap: 8px; align-items: flex-start; font-size: 12px; padding: 7px 9px; border-radius: var(--radius); background: var(--surface-2, rgba(127,127,127,.08)); }
.ph-hint > i { margin-top: 2px; }
.ph-hint-ok { color: var(--ok); }
.ph-hint-ok a { color: inherit; text-decoration: underline; }
.ph-hint-warn { color: var(--warn); }
.ph-hint-muted { color: var(--text-muted); }
.ph-maybe { display: flex; gap: 6px; flex-wrap: wrap; }
.ph-maybe-btn { display: inline-flex; gap: 6px; align-items: baseline; font-size: 12px; padding: 4px 8px; border: 1px dashed var(--border); border-radius: var(--radius); background: transparent; color: var(--text); cursor: pointer; }
.ph-maybe-btn:hover { border-style: solid; border-color: var(--accent, var(--border)); }
.ph-thumbs { display: flex; gap: 6px; flex-wrap: wrap; }
.ph-thumb { position: relative; margin: 0; width: 64px; height: 64px; border-radius: var(--radius); overflow: hidden; background: var(--surface-2, rgba(127,127,127,.08)); }
.ph-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ph-thumb-x { position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%; border: 0; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; cursor: pointer; opacity: 0; transition: opacity .12s; }
.ph-thumb:hover .ph-thumb-x, .ph-thumb-x:focus-visible { opacity: 1; }
@media (hover: none) { .ph-thumb-x { opacity: 1; } }
.ph-assign { display: flex; gap: 6px; align-items: center; margin-top: auto; }
.ph-assign .field { flex: 1; min-width: 0; }
.ph-danger { color: var(--danger); }
.ph-pager { margin-top: 12px; }
.ph-batches { margin-top: 16px; }
.ph-batches > summary { cursor: pointer; margin: 0; }
.ph-batches[open] > summary { margin-bottom: 10px; }

/* Toasts — fixed under the sticky topbar so short landscape phones still see them.
   Also styles the JS fallback `.toast-stack-fixed` (no #content).
   Extra top offset clears typical .page-head-actions (How this works) without
   raising z-index above header menus / modals (15 stays intentional). */
.toast-stack,
.toast-stack-fixed {
  position: fixed;
  top: calc(56px + env(safe-area-inset-top, 0px) + 56px);
  right: max(12px, env(safe-area-inset-right, 0px));
  left: auto;
  /* Below sticky topbar (20) and sidebar (30) stacking contexts so open
     menus, the drawer, and modals stay reachable over flash messages. */
  z-index: 15;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(400px, calc(100vw - 24px));
  max-height: min(48vh, 320px);
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0;
  pointer-events: none;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.toast-stack .toast,
.toast-stack-fixed .toast {
  pointer-events: auto;
  box-shadow: var(--shadow-sm);
}
.toast {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--panel); font-size: 13px;
}
.toast-body { flex: 1; white-space: pre-line; min-width: 0; }
.toast-success { border-color: var(--ok); color: var(--ok); background: var(--ok-bg); }
.toast-info { border-color: var(--info); color: var(--info); background: var(--info-bg); }
.toast-warning { border-color: var(--warn); color: var(--warn); background: var(--warn-bg); }
.toast-error { border-color: var(--danger); color: var(--danger); background: var(--danger-bg); }
/* Dark: soft tone-on-wash body text washes out (same reason .toast-announce
   .toast-excerpt already uses --text). Keep border on the tone; deepen the
   wash slightly so severity still reads. Close inherits color. */
[data-theme="dark"] .toast-success,
[data-theme="dark"] .toast-info,
[data-theme="dark"] .toast-warning,
[data-theme="dark"] .toast-error {
  color: var(--text);
  border-left-width: 3px;
}
[data-theme="dark"] .toast-success {
  background: color-mix(in srgb, var(--ok) 24%, var(--panel));
}
[data-theme="dark"] .toast-info {
  background: color-mix(in srgb, var(--info) 24%, var(--panel));
}
[data-theme="dark"] .toast-warning {
  background: color-mix(in srgb, var(--warn) 24%, var(--panel));
}
[data-theme="dark"] .toast-error {
  background: color-mix(in srgb, var(--danger) 24%, var(--panel));
}
.toast-close {
  background: transparent; border: 0; color: inherit; cursor: pointer;
  padding: 0;
  width: 44px; height: 44px; margin: -8px -8px -8px 0;
  line-height: 1; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius); flex: 0 0 auto;
}
.toast-close:hover,
.toast-close:focus-visible {
  background: color-mix(in srgb, currentColor 12%, transparent);
  outline: none;
}
@media (max-width: 560px) {
  .toast-stack,
  .toast-stack-fixed {
    left: max(12px, env(safe-area-inset-left, 0px));
    right: max(12px, env(safe-area-inset-right, 0px));
    width: auto;
  }
}
.toast-announce .toast-title { display: block; }
.toast-announce .toast-excerpt {
  display: block; margin: 2px 0 4px; color: var(--text); font-weight: 400;
}
.toast-announce a { font-weight: 600; }
.field-invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 11.5px; margin-top: 2px; }
.master-form { max-width: 560px; }
.master-form .auth-field { margin-bottom: 12px; }
.master-form label { display: block; font-size: 12px; margin-bottom: 4px; }
.master-form .field { width: 100%; }
.master-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 16px; }
.confirm-dialog {
  border: 1px solid var(--border-subtle); border-radius: var(--radius);
  background: var(--panel); color: var(--text); padding: 18px 18px 14px;
  max-width: 420px; width: calc(100% - 32px);
  margin: auto; /* the global reset zeroes margin, which pins <dialog> top-left */
}
.confirm-dialog::backdrop { background: var(--overlay, rgba(0, 0, 0, .45)); }
.confirm-dialog h2 { font-size: 16px; margin: 0 0 8px; }
.confirm-dialog p { margin: 0 0 12px; font-size: 13px; white-space: pre-line; }
.confirm-type { display: block; font-size: 12.5px; margin-bottom: 12px; }
.confirm-type[hidden] { display: none; }
.confirm-type .field { display: block; width: 100%; margin-top: 6px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }
.confirm-dialog[data-variant="danger"] h2 { color: var(--danger); }
/* Solid red for the one button that does the destructive thing. */
.btn-danger.btn-danger-solid,
.btn-danger.btn-danger-solid:hover {
  background: var(--danger); color: #fff; border-color: var(--danger);
}
.btn-danger.btn-danger-solid:hover { filter: brightness(.92); }
/* Dark theme's red is light, so white text would wash out on it. */
[data-theme="dark"] .btn-danger.btn-danger-solid { color: #1a1210; }
@media (max-width: 479.98px) {
  .confirm-actions { flex-direction: column-reverse; align-items: stretch; }
  .confirm-actions .btn { width: 100%; justify-content: center; }
}

/* Shared spinner. Always inside a .pj-status (role=status) with text, so
   screen readers hear the words and the ring itself stays aria-hidden. */
.pj-status { display: inline-flex; align-items: center; gap: 6px; }
.pj-spinner {
  display: inline-block; flex: none; width: 16px; height: 16px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: pj-spin .7s linear infinite;
  vertical-align: -0.15em;
}
.pj-spinner-sm { width: 12px; height: 12px; border-width: 2px; }
.pj-spinner-lg { width: 28px; height: 28px; border-width: 3px; }
@keyframes pj-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .pj-spinner { animation-duration: 2.4s; }
}
form[data-busy] [aria-busy="true"] { cursor: progress; opacity: .85; }

/* Sidebar count beside a link (e.g. Waiting for PY). */
.nav-count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px;
  border-radius: 9px; background: var(--warn-bg); color: var(--warn);
  font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
}

/* What's new, the dismissible bar, and the bell's two sections. */
.update-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin: 0 0 12px; padding: 10px 12px; border: 1px solid var(--warn); border-radius: var(--radius);
  background: var(--warn-bg); color: var(--warn);
}
.update-banner-maintenance { background: var(--danger-bg); color: var(--danger); border-color: var(--danger); }
.update-banner form { margin: 0; }
.update-banner a { color: inherit; font-weight: 600; margin-left: 8px; }
.update-list { display: flex; flex-direction: column; gap: 8px; }
.update-card {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  border: 1px solid var(--border-subtle); border-radius: var(--radius); background: var(--panel);
}
.update-card > a {
  display: flex; gap: 10px; align-items: flex-start; flex: 1; min-width: 0;
  color: inherit; text-decoration: none;
}
.update-card.is-unread { border-color: var(--brand); }
.update-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex: 0 0 8px; background: transparent; }
.update-card.is-unread .update-dot { background: var(--brand); }
.update-title { display: block; font-weight: 600; }
.update-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 4px; font-size: 12px; }
.update-body { font-size: 14px; line-height: 1.55; }
.update-body h2, .update-body h3 { font-size: 16px; margin: 14px 0 6px; }
.update-body p { margin: 0 0 8px; }
.update-body ul, .update-body ol { margin: 0 0 8px 1.2em; }
.update-body pre, .update-body code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.update-body pre { padding: 8px 10px; background: var(--bg-2); border-radius: var(--radius-sm); overflow: auto; }
.update-preview { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }
.update-groups { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 6px; }
.fbar-check { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.notif-section-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-faint); padding: 8px 10px 2px;
}
.notif-row-form { margin: 0; }
button.notif-row {
  width: 100%; border: 0; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer;
}

/* Unified Approvals page */
.appr-chips { grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.appr-chips .pl-sum-l i { margin-right: 4px; opacity: .7; }
.appr-filters .appr-date {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted); white-space: nowrap;
}
.appr-type { white-space: nowrap; }
.appr-type i { margin-right: 4px; opacity: .75; }
.appr-sub { font-size: 12px; margin-top: 2px; max-width: 36rem; }
.appr-facts {
  list-style: none; margin: 4px 0 0; padding: 0;
  display: flex; flex-wrap: wrap; gap: 4px 10px;
  font-size: 12px; color: var(--text-muted); max-width: 40rem;
}
.appr-facts li {
  position: relative;
  padding-left: 0;
}
.appr-facts li + li::before {
  content: "·";
  margin-right: 10px;
  color: var(--text-faint);
}
.appr-person { font-weight: 550; }
.appr-role { font-size: 12px; margin-top: 1px; }
.appr-summary {
  display: flex; gap: 12px; align-items: flex-start; min-width: 0;
}
.appr-summary-text { min-width: 0; flex: 1; }
.appr-media {
  display: flex; gap: 6px; flex-shrink: 0;
}
.appr-thumb {
  position: relative;
  width: 64px; height: 64px;
  padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2); overflow: hidden;
  cursor: zoom-in; color: var(--text-faint);
}
.appr-thumb img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.appr-thumb.is-missing,
.appr-thumb:disabled {
  cursor: default; opacity: .85;
}
.appr-thumb-ph {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.appr-thumb-tag {
  position: absolute; left: 0; right: 0; bottom: 0;
  font-size: 9px; font-weight: 650; letter-spacing: .02em;
  text-transform: uppercase; text-align: center;
  padding: 2px 0; background: rgba(0,0,0,.55); color: #fff;
}
.appr-actions {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  margin-top: 8px; max-width: none;
}
.appr-actions form { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.appr-reject-form {
  display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px;
  width: 100%;
}
.appr-reject-form[hidden] { display: none !important; }
.appr-reject-form .field { flex: 1; min-width: 8rem; max-width: 16rem; }

.appr-bulk-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px;
  margin: 0 0 12px; padding: 10px 12px;
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
}
.appr-bulk-select-all {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 550; cursor: pointer;
}
.appr-bulk-count { font-size: 12.5px; color: var(--text-muted); }
.appr-bulk-actions { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.appr-bulk-actions[hidden],
.appr-bulk-reject[hidden] { display: none !important; }
.appr-bulk-reject {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  width: 100%;
}
.appr-bulk-reject .field { flex: 1; min-width: 10rem; }

.appr-cards { display: none; }
.appr-card {
  background: var(--surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 12px; margin-bottom: 10px;
}
.appr-card-head {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin-bottom: 10px;
}
.appr-card-check { display: inline-flex; align-items: center; }
.appr-card-body {
  display: flex; gap: 12px; align-items: flex-start;
}
.appr-card-meta {
  display: grid; gap: 4px; margin: 8px 0 0; font-size: 12.5px;
}
.appr-card-meta > div { display: flex; gap: 8px; }
.appr-card-meta dt {
  min-width: 4.5rem; color: var(--text-faint); font-weight: 550;
}
.appr-card-meta dd { margin: 0; color: var(--text-muted); }
.appr-cards-foot {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: center; gap: 8px; margin-top: 8px;
  font-size: 12.5px; color: var(--text-muted);
}

/* Lightbox */
.appr-lb {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(10, 8, 6, .88); padding: 24px;
}
.appr-lb[hidden] { display: none !important; }
.appr-lb-figure {
  margin: 0; display: grid; justify-items: center; gap: 10px;
  max-width: min(1100px, 100%);
}
.appr-lb-figure > img,
.appr-lb-pair img {
  max-width: 100%; max-height: calc(100vh - 140px);
  object-fit: contain; border-radius: var(--radius); background: #111;
}
.appr-lb-pair {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  width: min(100%, 1100px);
}
.appr-lb-pair span {
  display: block; text-align: center; color: #ccc; font-size: 12px; margin-top: 6px;
}
.appr-lb figcaption { color: #eee; text-align: center; font-size: 13px; }
.appr-lb-meta { color: #bbb; font-size: 12px; margin-top: 2px; }
.appr-lb-close {
  position: absolute; top: 14px; right: 14px;
  width: 40px; height: 40px; border: 0; border-radius: 999px;
  background: rgba(255,255,255,.14); color: #fff; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.appr-lb-close:hover { background: rgba(255,255,255,.22); }
html.appr-lb-lock { overflow: hidden; }

[data-theme="dark"] .appr-thumb {
  background: var(--bg-2);
  border-color: var(--border);
}
[data-theme="dark"] .appr-bulk-bar,
[data-theme="dark"] .appr-card {
  background: var(--surface);
  border-color: var(--border-subtle);
}

@media (max-width: 640px) {
  .appr-filters .appr-date { width: 100%; }
  .appr-filters .appr-date .field { flex: 1; min-width: 0; }
  .appr-actions { flex-direction: column; align-items: stretch; }
  .appr-actions form,
  .appr-reject-form { width: 100%; }
  .appr-reject-form .field { max-width: none; }
  .appr-desktop { display: none; }
  .appr-cards { display: block; }
  .appr-lb-pair { grid-template-columns: 1fr; }
  .appr-thumb { width: 72px; height: 72px; }
  .appr-bulk-bar { position: sticky; top: 0; z-index: 5; }
}
@media (max-width: 360px) {
  .appr-chips { grid-template-columns: 1fr 1fr; }
  .appr-card-body { flex-direction: column; }
}

/* —— QC / vault scan panel: the product tracker's layout on every scan page —— */
/* Barcodes + removed | gauge + actions | details, like tracker/scan.html. */
.qcp-grid { display: grid; grid-template-columns: 1fr 0.8fr 1.1fr; gap: 16px; margin-bottom: 16px; }
.qcp-split { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.qcp-gauge-col { display: flex; flex-direction: column; align-items: center; justify-content: center; }
.qcp-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.qcp-list {
  list-style: none; margin: 8px 0 0; padding: 0; max-height: 300px; overflow: auto;
  border: 1px solid var(--border); border-radius: 8px; min-height: 120px; font-size: 12.5px;
}
.qcp-list:empty::before { content: attr(data-empty); display: block; padding: 10px; color: var(--text-muted); }
.qcp-list li { padding: 5px 10px; border-bottom: 1px solid var(--border); }
.qcp-list li:last-child { border-bottom: 0; }
.qcp-removed li { color: var(--danger, #a33); }
.qcp-removed li .mono { color: var(--text); }
.qcp-details label { display: block; margin-bottom: 10px; }
.qcp-details .field { width: 100%; }
@media (max-width: 980px) {
  .qcp-grid, .qcp-split { grid-template-columns: 1fr; }
}

/* —— Inbound / Outbound stage stepper —— */
/* Every step is a fixed equal column, circle on top, so the circles line up
   down the page; the connector runs from the previous circle to this one. */
.mv-steps {
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  min-width: 460px; margin: 0; padding: 4px 0 2px; list-style: none;
}
.mv-step {
  position: relative; display: flex; flex-direction: column; align-items: center;
  text-align: center; padding: 0 6px; font-size: 12px; line-height: 1.3; color: var(--text-muted);
}
.mv-step::before {
  content: ""; position: absolute; top: 11px; left: -50%; right: 50%;
  height: 2px; background: var(--border); z-index: 0;
}
.mv-step:first-child::before { display: none; }
.mv-step.is-done::before, .mv-step.is-current::before { background: var(--ok, #467536); }
.mv-step-dot {
  position: relative; z-index: 1; width: 24px; height: 24px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
  border: 1px solid var(--border); background: var(--bg-2); font-size: 11px; font-weight: 600;
  margin-bottom: 4px;
}
.mv-step.is-done .mv-step-dot { color: var(--ok, #467536); border-color: var(--ok, #467536); }
.mv-step.is-current { color: var(--text); font-weight: 600; }
.mv-step.is-current .mv-step-dot {
  background: var(--accent, #1a6b4a); color: #fff; border-color: transparent;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent, #1a6b4a) 22%, transparent);
}
.mv-step-note { display: block; font-size: 11px; font-weight: 400; color: var(--text-muted); overflow-wrap: anywhere; }

/* —— First-login onboarding wizard —— */
.ob-wrap { max-width: 640px; margin: 0 auto; padding: 0 4px 24px; }
.ob-panel { max-width: 100%; }
.ob-stepper {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px 0;
  margin: 0 0 18px; padding: 10px 0;
}
.ob-step {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-muted);
}
.ob-step-dot {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--bg-2);
  font-size: 11px; font-weight: 600; flex-shrink: 0;
}
.ob-step.is-current { color: var(--text); }
.ob-step.is-current .ob-step-dot {
  background: var(--accent, #1a6b4a); color: #fff; border-color: transparent;
}
.ob-step.is-done .ob-step-dot {
  background: var(--bg-2); color: var(--ok, #1a6b4a); border-color: var(--ok, #1a6b4a);
}
.ob-step-line {
  flex: 1 1 12px; min-width: 8px; max-width: 28px; height: 1px;
  background: var(--border); margin: 0 4px;
}
.ob-replay-banner { font-size: 12px; margin: -8px 0 12px; }
.ob-list { margin: 0 0 20px; padding-left: 20px; line-height: 1.9; }
.ob-actions {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; align-items: center;
}
.ob-actions .btn { min-height: 44px; }
.ob-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.ob-avatar-row {
  display: flex; align-items: center; gap: 14px; margin-bottom: 18px; flex-wrap: wrap;
}
.ob-avatar-row .avatar-lg {
  width: 56px; height: 56px; border-radius: 50%; object-fit: cover;
}
.ob-inline-check {
  display: inline-flex; align-items: center; gap: 6px;
  margin-left: 10px; font-size: 12px;
}
.ob-readonly { background: var(--bg-2); }
.ob-bell-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 4px; }
.ob-bell-row {
  display: flex; align-items: center; gap: 8px; font-size: 13px; min-height: 36px;
}
.ob-checklist { list-style: none; margin: 0; padding: 0; }
.ob-check-item {
  border-top: 1px solid var(--border); padding: 14px 0;
}
.ob-check-item:first-child { border-top: 0; padding-top: 0; }
.ob-check-title { font-weight: 600; font-size: 14px; margin-bottom: 2px; }
.ob-check-desc { font-size: 12.5px; margin-bottom: 8px; line-height: 1.45; }
.ob-check-actions {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.ob-inline-form { display: inline-flex; flex-wrap: wrap; gap: 6px; margin: 0; }
.ob-check-item.status-done .ob-check-title { color: var(--ok, #1a6b4a); }

[data-theme="dark"] .ob-step.is-current .ob-step-dot {
  background: var(--accent, #3d9b6e);
}
[data-theme="dark"] .ob-readonly { background: var(--bg-2); }

@media (max-width: 560px) {
  .ob-grid { grid-template-columns: 1fr; }
  .ob-step-label { display: none; }
  .ob-step.is-current .ob-step-label { display: inline; }
  .ob-actions { flex-direction: column; align-items: stretch; }
  .ob-actions .btn { width: 100%; justify-content: center; }
}
@media (max-width: 360px) {
  .ob-wrap { padding: 0 0 20px; }
  .ob-step-line { max-width: 16px; }
}

.ob-tour-blurb {
  font-size: 13.5px; line-height: 1.5; margin: 0 0 14px;
  padding: 10px 12px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--border);
}
.ob-check-progress { font-size: 12px; margin: 0 0 10px; }
.ob-role-hint { font-size: 10.5px; margin-left: 6px; vertical-align: middle; }
.ob-check-item.status-visited .ob-check-title { color: var(--text); }

.ob-review { margin: 0 0 8px; }
.ob-review > div {
  display: grid; grid-template-columns: 140px 1fr; gap: 8px;
  padding: 8px 0; border-top: 1px solid var(--border); font-size: 13px;
}
.ob-review > div:first-child { border-top: 0; }
.ob-review dt { color: var(--text-muted); margin: 0; }
.ob-review dd { margin: 0; }
@media (max-width: 480px) {
  .ob-review > div { grid-template-columns: 1fr; gap: 2px; }
}

/* Footer credit (base.html + login card) */
/* Footer at the window bottom on short pages, after the content on long ones.
   Not sticky or fixed: .main fills the viewport (header + .content), .content
   is a column, and the credit takes the leftover space above it. */
.app-shell { min-height: 100dvh; }
.main { min-height: 100vh; min-height: 100dvh; }
.content { display: flex; flex-direction: column; min-width: 0; overflow-x: clip; }
.content > * { flex-shrink: 0; }
.content > .app-credit { margin-top: auto; }
/* The credit sits flush with the window bottom: no padding gap below it. */
.content:has(> .app-credit) { padding-bottom: 0; }
@media print {
  .app-shell, .main { min-height: 0 !important; }
  .content { display: block !important; }
}

.app-credit {
  margin-bottom: 0;
  padding: 5px 8px;
  text-align: center;
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.auth-card .app-credit {
  margin-top: 18px;
  padding: 4px 0 0;
}

@media print {
  .app-credit {
    display: none !important;
  }
}
.app-credit-link {
  color: inherit;
  text-decoration: none;
  border-radius: 2px;
}

.app-credit-link:hover,
.app-credit-link:focus-visible {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.app-credit-link:focus-visible {
  outline: 2px solid var(--text-muted);
  outline-offset: 2px;
}

.app-version {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Reseller directory: chips filter the table; a narrow screen swaps in cards. */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 2px 0 12px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
  text-decoration: none;
  white-space: nowrap;
}
.chip:hover { border-color: var(--text-muted); }
.chip.is-on {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}
.chip-count { font-weight: 650; }
.chip:not(.is-on) .chip-count { color: var(--text-muted); }
.chip-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--surface-2);
  color: var(--text);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1;
}
.chip.is-on .chip-mark { background: var(--surface); color: var(--text); }
.chip-mark img { width: 100%; height: 100%; object-fit: contain; display: block; }
.reseller-search { margin: 0 0 12px; }
.reseller-search .field { width: 100%; }
.reseller-bulk { display: flex; justify-content: flex-end; margin: 0 0 8px; }
.several-groups { font-style: italic; }
.col-check { width: 36px; text-align: center; }
.col-menu { width: 44px; text-align: right; }
.row-menu { position: relative; display: inline-block; }
.row-menu > summary {
  list-style: none;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--radius);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-weight: 700;
  letter-spacing: .08em;
}
.row-menu > summary::-webkit-details-marker { display: none; }
.row-menu[open] > summary { background: var(--surface-2); color: var(--text); }
.row-menu-pop {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  z-index: 6;
  min-width: 168px;
  padding: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.row-menu-pop a {
  display: block;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--text);
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.row-menu-pop a:hover { background: var(--surface-2); }
.reseller-cards { display: none; }
.dupe-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: var(--radius-pill);
  background: var(--warn-bg);
  color: var(--warn);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0;
  text-transform: none;
  text-decoration: none;
  white-space: nowrap;
  vertical-align: 1px;
}
a.dupe-badge:hover { color: var(--warn); }
.dupe-badge.is-on { box-shadow: inset 0 0 0 1px var(--warn); }
.reseller-name {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.reseller-name .dupe-badge { margin-left: 0; }

@media (max-width: 640px) {
  .reseller-cards { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
  .reseller-card {
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 12px 14px;
  }
  .reseller-card-meta,
  .reseller-card-money,
  .reseller-card-actions { font-size: 13px; margin-top: 3px; }
  .reseller-card-meta,
  .reseller-card-actions { color: var(--text-muted); }
  .reseller-card-actions a { color: var(--text); font-weight: 650; text-decoration: none; }
  .reseller-card-actions a + a::before { content: " · "; color: var(--text-muted); font-weight: 500; }
  .reseller-bulk { display: none; }
  .fill-table:has(.reseller-rows) {
    background: transparent;
    border: 0;
    overflow: visible;
  }
  .fill-table:has(.reseller-rows) .table-scroll { display: none; }
  .fill-table:has(.reseller-rows) .table-foot {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
  }
}

/* Scanner-only fields (static/core/js/scanner_only.js) */
.scanner-only-hint { display:block; margin-top:4px; font-size:12px; font-weight:600; color:var(--danger); }
.scanner-only-hint[hidden] { display:none; }

/* New arrivals / Outbound QC scan box (static/core/js/qc_scan.js) */
.qc-scan-row { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.qc-scan-row .field { flex:1; min-width:min(100%,200px); }
.qc-scan-row .scanner-only-hint { flex-basis:100%; margin:0; }
.qc-scan-state { font-size:12px; margin-top:6px; }
.qc-scan-log, .qc-pick-list { list-style:none; margin:8px 0 0; padding:0; max-height:220px; overflow:auto; font-size:12.5px; }
.qc-scan-log:empty, .qc-pick-list:empty { display:none; }
.qc-scan-log li, .qc-pick-list li { display:flex; gap:6px; align-items:baseline; padding:3px 6px; border-bottom:1px solid var(--border); }
.qc-log-ok .qc-log-text { color:var(--ok); }
.qc-log-err .qc-log-text { color:var(--danger); font-weight:600; }
.qc-log-wait .qc-log-text, .qc-log-info .qc-log-text { color:var(--muted, inherit); opacity:.8; }
.qc-pick-list { max-height:300px; }
.qc-pick-note { color:var(--danger); font-weight:600; }
.qc-pick-remove { margin-left:auto; background:none; border:0; color:inherit; cursor:pointer; font-size:16px; line-height:1; padding:0 4px; }
/* In the tracker-style scan panel the lists stay visible as boxes, like the tracker's textarea. */
.qcp-list.qc-scan-log:empty, .qcp-list.qc-pick-list:empty { display:block; }
.qcp-list.qc-scan-log, .qcp-list.qc-pick-list, .qcp-removed { min-height:260px; max-height:340px; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip:rect(0,0,0,0); white-space:nowrap; border:0; }
[data-inflight="1"] { cursor: progress; }

/* ---------- Manage employee access / Manage access ---------- */
.access-row-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.access-row-actions form { margin: 0; }

.access-perms-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 12px;
  margin: 0 0 10px;
}
.access-perms-search { flex: 1 1 14rem; min-width: 0; margin: 0; }
.access-perms-search .fbar-input,
.access-perms-search .field { width: 100%; }
.access-state-chips { margin: 0; }
.access-perms-count { font-size: 12.5px; margin-left: auto; }

/* Category tabs: wrap on wide screens, one swipeable row on phones. Sticks under the header. */
.access-tabs {
  position: sticky;
  top: calc(var(--header-h, 56px) + env(safe-area-inset-top, 0px));
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 14px;
  padding: 8px 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border-subtle);
}
.access-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--t-fast), border-color var(--t-fast), background var(--t-fast), opacity var(--t-fast);
}
.access-tab:hover { color: var(--text); border-color: var(--border-strong); }
.access-tab:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.access-tab-count {
  font-size: 11px;
  font-weight: 500;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--neutral-bg);
  color: var(--text-faint);
}
.access-tab.has-granted .access-tab-count { background: var(--brand-dim); color: var(--brand-ink); }
.access-tab.is-active { color: var(--brand-ink); border-color: var(--brand); background: var(--brand-dim); }
.access-tab.is-active .access-tab-count { background: var(--surface); color: var(--brand-ink); }
.access-tab.is-dim { opacity: .45; }

.access-cat {
  margin: 0 0 20px;
  scroll-margin-top: calc(var(--header-h, 56px) + env(safe-area-inset-top, 0px) + 64px);
}
.is-tabbed .access-cat:not(.is-active) { display: none; }
.is-tabbed.is-searching .access-cat { display: block; }
.is-tabbed.is-searching .access-cat.is-filtered-out { display: none; }
.access-cat [data-access-row].is-filtered-out { display: none; }
.access-cat-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  margin: 0 0 8px;
}
.access-cat-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: var(--fs-h3, 18px);
  font-weight: var(--fw-regular, 400);
  color: var(--text);
}
.access-cat-meta { font-size: 12.5px; }
.access-cat-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

/* One permission per row: tap anywhere on it to tick. Name over description so it reads on a phone. */
.access-list {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.access-list > li + li { border-top: 1px solid var(--border-subtle); }
.access-item {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin: 0;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--t-fast);
}
.access-item:hover { background: var(--neutral-bg); }
.access-item.is-locked { cursor: default; }
.access-item.is-locked:hover { background: transparent; }
.access-item input[type=checkbox] {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--brand);
  cursor: inherit;
}
[data-access-on="1"] > .access-item { box-shadow: inset 3px 0 0 var(--brand); }
.access-item-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.access-item-name { font-size: 13.5px; font-weight: 600; color: var(--text); }
.access-item-desc { font-size: 12.5px; line-height: 1.55; color: var(--text-muted); max-width: 80ch; }
.access-item.is-locked .access-item-name { color: var(--text-muted); }
.access-cat-empty { margin: 8px 0 0; font-size: 12.5px; }
.access-perms-empty { margin: 12px 0; }

/* Manage access: settings above the permission tabs */
.access-setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.access-setup-grid > .panel { margin: 0; }
.access-note { margin: 0 0 10px; font-size: 12.5px; }
.access-copy { margin-bottom: 16px; }
.access-copy > summary,
.access-help > summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.access-copy[open] > summary { margin-bottom: 12px; }
.access-help { margin: 10px 0 0; font-size: 12.5px; }
.access-help > summary { font-size: 12.5px; color: var(--text-muted); }
.access-help[open] > summary { margin-bottom: 6px; }
.access-help p { margin: 0; color: var(--text-muted); line-height: 1.55; }
.access-groups { display: flex; flex-wrap: wrap; gap: 8px; }
.access-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: 13px;
  cursor: pointer;
}
.access-group:has(input:checked) { border-color: var(--brand); background: var(--brand-dim); color: var(--brand-ink); }
.access-group input { accent-color: var(--brand); margin: 0; }
.access-group .cell-muted { font-size: 12px; }
.access-dirty { font-size: 12.5px; }
.access-dirty.is-dirty { color: var(--warn); font-weight: 600; }

.access-save-bar {
  position: sticky;
  bottom: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin-top: 8px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom, 0px));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(6px);
}
.access-donor-form .field { width: 100%; }

@media (max-width: 720px) {
  .access-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    margin-left: -16px;
    margin-right: -16px;
    padding: 8px 16px;
    scroll-padding: 0 16px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .access-tabs::-webkit-scrollbar { display: none; }
  .access-perms-count { margin-left: 0; }
  .access-item { padding: 12px; }
  .access-cat-tools { margin-left: 0; }
  .access-save-bar .btn { flex: 1 1 auto; justify-content: center; }

  /* Employee list: one card per person */
  .access-emp-table thead { display: none; }
  .access-emp-table,
  .access-emp-table tbody,
  .access-emp-table td { display: block; width: 100%; }
  .access-emp-table { min-width: 0; }
  .access-emp-table tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 6px 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle);
  }
  .access-emp-table td { padding: 0; border: 0; }
  .access-emp-table td.col-optional { display: block; }
  .access-emp-table .access-emp-name { grid-column: 1; }
  .access-emp-table .access-emp-code { grid-column: 2; grid-row: 1; text-align: right; }
  .access-emp-table .access-emp-groups,
  .access-emp-table .access-emp-role,
  .access-emp-table .access-emp-status,
  .access-emp-table .access-emp-actions { grid-column: 1 / -1; }
  .access-emp-table .access-emp-groups:has(> .cell-muted:only-child),
  .access-emp-table .access-emp-role:has(> .cell-muted:only-child) { display: none; }
  .access-emp-table .access-row-actions .btn { flex: 1 1 auto; justify-content: center; }
}

@media print {
  .access-perms-toolbar,
  .access-tabs,
  .access-cat-tools,
  .access-save-bar { display: none !important; }
  .is-tabbed .access-cat,
  .access-cat.is-filtered-out { display: block !important; }
  .access-cat [data-access-row].is-filtered-out { display: list-item !important; }
}
