/* ============================================================
   Olumi ERP — design system
   Light theme · Poppins + Spectral · Olumi Direction 1 (Moonstone & Lavender)
   ============================================================ */

:root {
  --iris: #6e79a6;
  --iris-600: #5a6694;
  --iris-700: #4b5680;
  --iris-tint: #eef0f7;
  --iris-tint-2: #e4e8f3;
  --focus-ring: rgba(110, 121, 166, 0.4);

  --app-bg: #f5f6fa;
  --surface: #ffffff;
  --border: #e4e7f0;
  --border-strong: #d8dbe0;

  --text: #262b3c;
  --text-soft: #5b6172;
  --text-muted: #656f99;

  /* Olumi brand tokens (Direction 1 — Moonstone & Lavender) */
  --hero: #aeb7d6;
  --glow: #c5ccea;
  --warm: #e9e1d3;
  --accent: #6e5a78;
  --tint: #dee2ef;

  --green: #1f9d6b;
  --green-bg: #e6f5ee;
  --amber: #b6791d;
  --amber-bg: #fbf1de;
  --red: #c2453f;
  --red-bg: #fbe9e8;
  --gray-pill: #6b7280;
  --gray-bg: #f0f1f4;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(20, 24, 38, 0.04), 0 1px 3px rgba(20, 24, 38, 0.04);
  --shadow-md: 0 4px 16px rgba(20, 24, 38, 0.08);
  --shadow-lg: 0 10px 40px rgba(20, 24, 38, 0.16);

  /* ---- Depth (elevation layer) — additive tiers ---- */
  --shadow-xs: 0 1px 2px rgba(20, 24, 38, 0.04);   /* resting rows / inputs */
  --shadow-hover: 0 6px 20px rgba(20, 24, 38, 0.1); /* interactive card lift target */
  --surface-2: #fbfbfc;                             /* tokenised app off-white */

  /* ---- Motion system (elevation layer) ----
     The brand breath ("the ripple breathes, the surface settles"): one decel
     easing carries the whole app so it settles with a single voice. */
  --ease-ripple: cubic-bezier(0.16, 1, 0.3, 1);    /* brand decel — surfaces settle */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);   /* symmetric — hovers, toggles */
  --ease-exit: cubic-bezier(0.4, 0, 1, 1);         /* accelerate — things leaving */

  --dur-1: 120ms;        /* micro: hover, press, focus ring, tab/nav tint */
  --dur-2: 180ms;        /* small: pills, chips, row hover, input focus */
  --dur-3: 240ms;        /* medium: card/KPI mount, drawer/modal in */
  --dur-4: 320ms;        /* large: route/view transition, page settle */
  --dur-breathe: 2400ms; /* ambient brand breath loop (matches Lottie ~2.25s) */

  --lift-1: 1px;         /* press nudge */
  --lift-2: 12px;        /* mount translate-up distance */
  --stagger: 70ms;       /* per-item delay in a mount stagger (cap the count) */

  --sidebar-w: 240px;
  --topbar-h: 60px;

  --font: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Spectral', Georgia, 'Times New Roman', serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--app-bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  font-family: inherit;
  cursor: pointer;
}

::selection {
  background: var(--iris-tint-2);
}

/* ---------- App shell ---------- */
.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 16px;
}

.brand-mark {
  /* logo-big rule: err large on every mark placement */
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: block;
}

.brand-name {
  font-family: var(--font);
  font-weight: 200;
  text-transform: lowercase;
  letter-spacing: 0.18em;
  font-size: 17px;
}

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

.nav {
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 12px 12px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-weight: 500;
  font-size: 13.5px;
  border: none;
  background: transparent;
  text-align: left;
  width: 100%;
  position: relative;
  transition: background var(--dur-1) var(--ease-standard),
    color var(--dur-1) var(--ease-standard);
}

/* Active accent: a left ripple-tint bar that grows via transform: scaleY (GPU),
   never width/height. Inert until .active because it scales from 0. */
.nav-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 7px;
  bottom: 7px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--iris);
  transform: scaleY(0);
  transform-origin: center;
  transition: transform var(--dur-2) var(--ease-ripple);
}

.nav-item:hover {
  background: var(--gray-bg);
  color: var(--text);
}

.nav-item.active {
  background: var(--iris-tint);
  color: var(--iris-600);
  font-weight: 600;
}

.nav-item.active::before {
  transform: scaleY(1);
}

.nav-item.active .nav-ico {
  color: var(--iris);
}

.nav-item:disabled,
.nav-item.soon {
  cursor: default;
  opacity: 0.55;
}

.nav-item:disabled:hover,
.nav-item.soon:hover {
  background: transparent;
  color: var(--text-soft);
}

.nav-ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.nav-item.active .nav-ico,
.nav-item:hover .nav-ico {
  color: currentColor;
}

.sidebar-foot {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 500;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid #f0e0c0;
  padding: 4px 9px;
  border-radius: 999px;
}

.demo-chip .pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber);
}

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

.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border);
  background: rgba(247, 248, 250, 0.85);
  backdrop-filter: saturate(180%) blur(8px);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 20;
}

/* .page-title removed — the topbar no longer renders a title span
   (main.js change); the semantic heading lives in .page-head h1. */

.topbar-search {
  margin-left: auto;
  position: relative;
}

.topbar-search input {
  width: 240px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 12px 0 32px;
  font-size: 13px;
  color: var(--text);
  transition: border-color 0.12s, box-shadow 0.12s;
}

.topbar-search input:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.topbar-search .s-ico {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #8a93bd, var(--iris));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}

/* ---------- Content ---------- */
/* HYBRID width policy (set via .is-wide from main.js):
   - default (forms / dashboards): centered, comfortable reading max-width;
   - .is-wide (dense / table views): use the full column width.
   Both center with margin-inline:auto so the content is NEVER left-pinned —
   no dead grey gutter on wide monitors at any view. */
.content {
  padding: 24px 32px;
  width: 100%;
  /* Fill modern screens: forms/dashboards use the room instead of stranding the
     content in a 1200px column with dead grey gutters on either side. Caps only
     on true ultra-wide (>~1740px content) so line lengths never run away. */
  max-width: 1680px;
  margin-inline: auto;
}
.content.is-wide {
  max-width: none;
}

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

.page-head h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 300;
  letter-spacing: -0.01em;
  margin: 0;
}

.page-head p {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 13.5px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: background var(--dur-1) var(--ease-standard),
    border-color var(--dur-1) var(--ease-standard),
    box-shadow var(--dur-1) var(--ease-standard),
    transform var(--dur-1) var(--ease-standard);
}

/* Button icons render via a raw <svg viewBox="0 0 24 24"> with no intrinsic
   width/height — constrain them so they don't expand to the SVG default size
   (≈300×150) and overlap the label (was breaking the Generate/Export buttons). */
.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

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

.btn:active {
  transform: translateY(var(--lift-1));
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.btn-primary {
  background: var(--iris);
  color: #fff;
  border-color: var(--iris);
}

.btn-primary:hover {
  background: var(--iris-600);
  /* settle-up only for the primary CTA — transform-only, restored on leave/press */
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(var(--lift-1));
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
}

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

.btn-sm {
  height: 30px;
  padding: 0 10px;
  font-size: 12.5px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.card-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.card-head .sub {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 450;
}

/* ---------- KPI cards ---------- */
/* Single auto-fit declaration → continuous reflow (4→3→2→1 columns) with no
   stepped breakpoint jumps. See also .profile-cards / .grid-cards. */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

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

.kpi-label {
  font-size: 12.5px;
  color: var(--text-soft);
  font-weight: 500;
}

.kpi-ico {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: var(--iris-tint);
  color: var(--iris);
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-ico svg {
  width: 16px;
  height: 16px;
}

.kpi-value {
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.kpi-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
}

.kpi-meta.warn {
  color: var(--amber);
}

.kpi-meta.bad {
  color: var(--red);
}

/* ---------- Tables ---------- */
/* Bounded scroll region: the table scrolls BOTH ways inside its own card. This
   keeps the sticky thead (top:0) pinned just under the page topbar instead of
   sliding away on page scroll, and lets the sticky identity column (left:0) stay
   put on horizontal scroll. The max-height only engages for genuinely long
   tables — short ones render at their natural height, unaffected. */
.table-wrap {
  overflow: auto;
  border-radius: var(--radius);
  max-height: calc(100vh - var(--topbar-h) - 56px);
}

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.tbl thead th {
  position: sticky;
  /* The header pins to the TOP of its scroll region. .table-wrap is a bounded
     scroll container (max-height below), so the table scrolls INSIDE its card
     and the header stays pinned at the wrapper top — which sits just under the
     page topbar — instead of sliding away/under the translucent topbar. Solid
     background so scrolling rows never read through it; z-index keeps it above
     body cells (and below the page topbar, z 20). */
  top: 0;
  background: var(--surface-2);
  text-align: left;
  font-weight: 600;
  font-size: 11.5px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 5;
}

table.tbl tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}

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

table.tbl tbody tr {
  transition: background 0.1s;
}

table.tbl tbody tr.clickable {
  cursor: pointer;
}

table.tbl tbody tr.clickable:hover {
  background: var(--iris-tint);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* Numeric column headers must sit RIGHT, over their right-aligned values — the
   `table.tbl thead th` rule (specificity 0,1,3) was out-ranking a bare th.num,
   so number columns showed a left header above right-aligned figures (read as
   "misaligned"). This selector (0,2,3) wins. */
table.tbl thead th.num,
th.num {
  text-align: right;
}

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

.strong {
  font-weight: 600;
}

.cell-name {
  font-weight: 550;
  color: var(--text);
}

.cell-sub {
  font-size: 11.5px;
  color: var(--text-muted);
}

.mono {
  font-family: ui-monospace, 'SF Mono', Menlo, monospace;
  font-size: 12px;
  letter-spacing: -0.01em;
}

/* ---------- Table pagination (DataTable pageSize) ---------- */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.table-pagination .tp-info {
  font-size: 12px;
  color: var(--text-muted);
}
.table-pagination .tp-btns {
  display: flex;
  gap: 8px;
}
.table-pagination .tp-btns button {
  height: 28px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
}
.table-pagination .tp-btns button:hover:not(:disabled) {
  background: var(--gray-bg);
  color: var(--text);
}
.table-pagination .tp-btns button:disabled {
  opacity: 0.45;
  cursor: default;
}
.table-pagination .tp-btns button:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ---------- Compact table density (DataTable density='compact') ---------- */
.tbl.tbl-compact th,
.tbl.tbl-compact td {
  padding-top: 6px;
  padding-bottom: 6px;
}

/* ---------- Pills / badges ---------- */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 550;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

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

.pill-green {
  color: #157a52;
  background: var(--green-bg);
}
.pill-amber {
  color: #8a5a12;
  background: var(--amber-bg);
}
.pill-red {
  color: #c2453f;
  background: var(--red-bg);
}
.pill-gray {
  color: var(--gray-pill);
  background: var(--gray-bg);
}

/* ---------- Swatches ---------- */
.swatches {
  display: inline-flex;
  align-items: center;
}

.swatch {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 1.5px solid var(--surface);
  box-shadow: 0 0 0 1px var(--border-strong);
  margin-left: -4px;
}

.swatch:first-child {
  margin-left: 0;
}

.swatch-lg {
  width: 20px;
  height: 20px;
}

/* ---------- Toolbar / filters ---------- */
.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-box {
  position: relative;
  flex: 0 0 auto;
}

.search-box input {
  width: 260px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 12px 0 34px;
  font-size: 13px;
}

.search-box input:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.search-box .s-ico {
  position: absolute;
  left: 11px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 15px;
  height: 15px;
  pointer-events: none;
}

.select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 30px 0 12px;
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238a90a0' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.select:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.chk {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  user-select: none;
}

.chk input {
  accent-color: var(--iris);
  width: 15px;
  height: 15px;
}

.spacer {
  flex: 1;
}

.result-count {
  font-size: 12.5px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ---------- Summary bar (inventory) ---------- */
.summary-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 16px;
  box-shadow: var(--shadow-sm);
}

.summary-cell {
  padding: 14px 18px;
  border-right: 1px solid var(--border);
}

.summary-cell:last-child {
  border-right: none;
}

.summary-cell .lab {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
}

.summary-cell .val {
  font-size: 20px;
  font-weight: 600;
  margin-top: 4px;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
}

/* Tablet step: 4-up summary bar goes 2-up before it squeezes (collapses to
   1-up at 560px via the phone block above). */
@media (max-width: 820px) {
  .summary-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- Grid layouts ---------- */
/* minmax(0,…) on every track so a wide child (table, long string, chart) can
   shrink instead of blowing the column out past the viewport — applied in the
   BASE rule, not behind a media query, so it holds at ALL widths. */
.two-col {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

/* compact key/value grid for profile/detail panels */
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 18px;
  font-size: 13px;
  color: var(--text);
}
.detail-grid .muted {
  margin-bottom: 2px;
}

/* Direct children of every multi-track grid get min-width:0 in the BASE so a
   wide cell/string/chart can shrink rather than force the track (and the page)
   wide. No media wrapper — this must hold at all widths. */
.two-col > *,
.md > *,
.split > *,
.prod-page-grid > * {
  min-width: 0;
}

/* ---------- Recent products list ---------- */
.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
}

.list-row:last-child {
  border-bottom: none;
}

.list-row .meta {
  min-width: 0;
  flex: 1;
}

.list-row .meta .nm {
  font-weight: 550;
  font-size: 13px;
}

.list-row .meta .sb {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ---------- Drawer ---------- */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 38, 0.32);
  z-index: 100;
  display: flex;
  justify-content: flex-end;
  animation: fade 0.16s ease;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

.drawer {
  width: 620px;
  max-width: 94vw;
  height: 100%;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  animation: slidein 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slidein {
  from {
    transform: translateX(24px);
    opacity: 0.4;
  }
}

.drawer-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.drawer-head .title {
  flex: 1;
  min-width: 0;
}

.drawer-head h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.drawer-head .sub {
  color: var(--text-muted);
  font-size: 12.5px;
  margin-top: 3px;
}

.drawer-close {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.drawer-close:hover {
  background: var(--gray-bg);
}

.drawer-body {
  padding: 22px;
  overflow: auto;
  flex: 1;
}

.drawer-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--surface-2);
}

.section-title {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 22px 0 10px;
}

.section-title:first-child {
  margin-top: 0;
}

/* inline checkbox + label (e.g. "Import / Bill of Entry") */
.row-inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
}
.row-inline input[type='checkbox'] {
  width: 15px;
  height: 15px;
  accent-color: var(--iris);
  cursor: pointer;
}

/* Report sub-nav chips + report table */
.report-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.report-nav .rchip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-soft);
  border-radius: 999px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
}
.report-nav .rchip:hover {
  border-color: var(--border-strong);
}
.report-nav .rchip.on {
  background: var(--iris-tint);
  border-color: var(--iris);
  color: var(--iris-600);
}
.report-table {
  width: 100%;
  border-collapse: collapse;
}
.report-table td,
.report-table th {
  padding: 8px 18px;
  font-size: 13px;
}
.report-table th {
  text-align: left;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}
.report-table td.num,
.report-table th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.report-table tr.rt-sub td {
  background: var(--surface-2);
  font-weight: 600;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
  letter-spacing: 0.02em;
}

.field input,
.field select {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 11px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
}

/* Number fields: hide the up/down spinner arrows everywhere — type the value
   directly (founder preference). Applies app-wide, not just .field inputs. */
input[type='number'] {
  -moz-appearance: textfield;
  appearance: textfield;
}
input[type='number']::-webkit-outer-spin-button,
input[type='number']::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* ---- Input focus settle (elevation layer) — standardise the named text inputs
   to motion tokens + a 1px transform-only lift on focus. The existing per-input
   :focus colour/ring rules above/elsewhere are untouched; this only adds the
   transition timing and the tiny settle. ---- */
.field input,
.field select,
.field textarea,
.search-box input,
.topbar-search input,
.cell-input {
  transition: border-color var(--dur-1) var(--ease-standard),
    box-shadow var(--dur-1) var(--ease-standard),
    transform var(--dur-1) var(--ease-standard);
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-box input:focus,
.topbar-search input:focus {
  transform: translateY(-0.5px);
}

.field .static-val {
  height: 36px;
  display: flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
}

/* ---------- Variant matrix ---------- */
.matrix-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
}

table.matrix {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.matrix th,
table.matrix td {
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
}

table.matrix th:last-child,
table.matrix td:last-child {
  border-right: none;
}

table.matrix tr:last-child td {
  border-bottom: none;
}

table.matrix thead th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11.5px;
  color: var(--text-soft);
}

table.matrix .size-th,
table.matrix .size-cell {
  text-align: left;
  font-weight: 600;
  background: var(--surface-2);
  white-space: nowrap;
}

.matrix-color-head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  justify-content: center;
}

.cell-input {
  width: 54px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 6px;
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: transparent;
  color: var(--text);
  font-family: inherit;
  font-weight: 500;
}

.cell-input:hover {
  border-color: var(--border-strong);
  background: var(--surface);
}

.cell-input:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--surface);
}

td.cell-low {
  background: var(--amber-bg);
}
td.cell-low .cell-input {
  color: var(--amber);
  font-weight: 600;
}
td.cell-out {
  background: var(--red-bg);
}
td.cell-out .cell-input {
  color: var(--red);
  font-weight: 600;
}

.matrix-foot td {
  background: var(--surface-2);
  font-weight: 600;
}

/* ---------- Misc ---------- */
.empty {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.placeholder .ph-ico {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--iris-tint);
  color: var(--iris);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.placeholder .ph-ico svg {
  width: 24px;
  height: 24px;
}

.placeholder h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 300;
}

.placeholder p {
  margin: 0;
  color: var(--text-soft);
  max-width: 380px;
  font-size: 13.5px;
}

.color-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
  margin-right: 12px;
}

.tag {
  display: inline-flex;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-soft);
  background: var(--gray-bg);
  padding: 2px 8px;
  border-radius: 6px;
}

/* ============================================================
   Spine additions — Money, Toggle, Tabs, sortable headers,
   Modal, swatch metadata, SVG charts, P&L rows, pricing panel
   ============================================================ */

/* ---------- Money ---------- */
.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.money-dec {
  font-size: 0.78em;
  opacity: 0.78;
}
.money-cur {
  font-size: 0.78em;
  color: var(--text-muted);
  margin-left: 2px;
  font-weight: 500;
}

/* ---------- Button danger ---------- */
.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover {
  filter: brightness(0.94);
}

/* ---------- Sortable table headers ---------- */
th.th-sortable {
  cursor: pointer;
  user-select: none;
}
th.th-sortable:hover {
  color: var(--text-soft);
}
.sort-caret {
  font-size: 8px;
  margin-left: 4px;
  color: var(--iris);
  vertical-align: middle;
}

/* ---------- Tabs ---------- */
.tabs {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--gray-bg);
  border-radius: 9px;
  margin-bottom: 4px;
}
.tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 13px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  /* tint only — never transition the active pill's box-shadow (large-surface risk) */
  transition: color var(--dur-1) var(--ease-standard),
    background var(--dur-1) var(--ease-standard);
}
.tab:hover {
  color: var(--text);
}
.tab.active {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}
.tab-count {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--gray-bg);
  border-radius: 999px;
  padding: 1px 6px;
}
.tab.active .tab-count {
  background: var(--iris-tint);
  color: var(--iris-600);
}

/* ---------- Toggle switch ---------- */
.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track {
  width: 38px;
  height: 22px;
  border-radius: 999px;
  background: var(--border-strong);
  position: relative;
  transition: background 0.15s ease;
  flex-shrink: 0;
}
.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease;
}
.toggle input:checked + .toggle-track {
  background: var(--iris);
}
.toggle input:checked + .toggle-track .toggle-thumb {
  transform: translateX(16px);
}
.toggle input:focus-visible + .toggle-track {
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.toggle-label {
  font-size: 13px;
  color: var(--text-soft);
  font-weight: 500;
}
.vat-row {
  padding: 4px 0 2px;
}

/* ---------- Field hint ---------- */
.field-hint {
  font-size: 11px;
  color: var(--text-muted);
}

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 38, 0.4);
  backdrop-filter: blur(2px);
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade 0.16s ease;
}
.modal {
  background: var(--surface);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  max-width: 94vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  animation: pop 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes pop {
  from {
    transform: scale(0.97);
    opacity: 0.5;
  }
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.modal-body {
  padding: 20px;
  overflow: auto;
}
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: var(--surface-2);
}

/* ---------- Swatch metadata (swatch.js) ---------- */
.sw-chip {
  display: inline-block;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}
/* swatch chip backed by a physical swatch PHOTO (atelier colour-fidelity render;
   PRINT fabrics use the photo as AI ground truth). hex shows as an overlap dot. */
.sw-chip-photo {
  position: relative;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}
.sw-chip-photo .sw-chip-dot {
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--surface);
  box-shadow: 0 0 0 0.5px var(--border-strong);
}
.sw-btn {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
}
.sw-row {
  display: flex;
  align-items: center;
  gap: 11px;
}
.sw-meta {
  min-width: 0;
}
.sw-label {
  font-size: 13px;
  font-weight: 550;
  display: flex;
  align-items: center;
  gap: 7px;
}
.sw-abbr {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--iris-600);
  background: var(--iris-tint);
  padding: 1px 6px;
  border-radius: 5px;
}
.sw-chips {
  display: flex;
  gap: 6px;
  margin-top: 3px;
  flex-wrap: wrap;
}
.sw-tag {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 5px;
  background: var(--gray-bg);
  color: var(--text-soft);
}
.sw-tag.cream {
  background: #f6f1e7;
  color: #8a6d3b;
}
.sw-tag.pantone {
  background: var(--iris-tint);
  color: var(--iris-600);
  border: 1px solid var(--iris-tint-2);
}
.sw-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sw-pick {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-soft);
}
.sw-pick.on {
  border-color: var(--iris);
  background: var(--iris-tint);
  color: var(--iris-600);
}

/* ---------- Charts (SVG, hand-rolled) ---------- */
.chart {
  display: flex;
  flex-direction: column;
}
.chart-svg {
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: block;
}
.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
.chart-baseline {
  stroke: var(--border-strong);
  stroke-width: 1.2;
  shape-rendering: crispEdges;
}
.chart-empty {
  position: relative;
}
.chart-empty-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12.5px;
  color: var(--text-muted);
  pointer-events: none;
}
.chart-xaxis {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10.5px;
  color: var(--text-muted);
}
.chart-xaxis span {
  flex: 1;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chart-donut {
  display: flex;
  align-items: center;
  gap: 20px;
}
.donut-svg {
  width: 130px;
  height: 130px;
  flex-shrink: 0;
}
.donut-legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
}
.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-label {
  color: var(--text-soft);
  flex: 1;
}
.legend-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ---------- Chart export bar (PNG/PDF, hover-reveal) ---------- */
.chart-frame {
  position: relative;
}
.chart-export {
  position: absolute;
  top: -2px;
  right: 0;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.chart-frame:hover .chart-export {
  opacity: 1;
}
.chart-export-btn {
  font: 600 10px var(--font);
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px 7px;
  cursor: pointer;
}
.chart-export-btn:hover {
  background: var(--iris-tint);
  color: var(--iris-600);
  border-color: var(--iris);
}

/* ---------- P&L rows (finance) ---------- */
.pl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.pl-row:last-child {
  border-bottom: none;
}
.pl-row.accent {
  background: var(--iris-tint);
}
.pl-row .num {
  font-variant-numeric: tabular-nums;
}

/* ---------- Recommended-price panel (product drawer) ---------- */
.rec-panel {
  margin-top: 16px;
  border: 1px solid var(--iris-tint-2);
  background: var(--iris-tint);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.rec-label {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--iris-600);
}
.rec-value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-top: 2px;
}
.rec-break {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 11.5px;
  color: var(--text-soft);
  align-items: center;
}

/* ---------- Card grid (blends) ---------- */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
  gap: 16px;
}

/* ---------- Misc tone helpers ---------- */
.amber {
  color: var(--amber);
}
.green {
  color: var(--green);
}
.red {
  color: var(--red);
}

/* ============================================================
   Management module — leave bars, payslip, bank file, chips
   ============================================================ */

/* thin progress bar (leave balance, sell-through, etc.) */
.mini-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--gray-bg);
  overflow: hidden;
  min-width: 84px;
}
.mini-bar > span {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: var(--iris);
}
.mini-bar.warn > span {
  background: var(--amber);
}
.mini-bar.bad > span {
  background: var(--red);
}
.bar-cell {
  display: flex;
  align-items: center;
  gap: 8px;
}
.bar-cell .bar-num {
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-soft);
  white-space: nowrap;
}

/* inline editable check pill used in payroll +5/+15 columns */
.chk {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  color: var(--text-soft);
}
.chk input {
  accent-color: var(--iris);
  width: 14px;
  height: 14px;
}

/* a soft inset stat row (subtotals, grand total) */
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 18px;
  font-size: 13px;
  border-top: 1px solid var(--border);
}
.stat-row.total {
  background: var(--iris-tint);
  font-weight: 600;
}
.stat-row .num {
  font-variant-numeric: tabular-nums;
}

/* payslip preview */
.payslip {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.payslip-head {
  padding: 14px 16px;
  background: var(--iris-tint);
  border-bottom: 1px solid var(--border);
}
.payslip-head .who {
  font-weight: 600;
  font-size: 15px;
}
.payslip-head .meta {
  font-size: 12px;
  color: var(--text-soft);
  margin-top: 2px;
}
.payslip-line {
  display: flex;
  justify-content: space-between;
  padding: 7px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.payslip-line.sub {
  color: var(--text-soft);
}
.payslip-line.net {
  background: var(--surface);
  font-weight: 600;
  font-size: 14px;
  border-top: 2px solid var(--border-strong);
}
.payslip-grp {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 16px 4px;
}

/* master-detail split (payslips) */
.split {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
}
.pick-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  max-height: 560px;
  overflow-y: auto;
}
.pick-row {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
}
.pick-row:hover {
  background: var(--app-bg);
}
.pick-row.active {
  background: var(--iris-tint);
  box-shadow: inset 3px 0 0 var(--iris);
}
.pick-row .sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* small toolbar control group on the right */
.spacer {
  flex: 1;
}

/* doc-expiry / leave detail chips */
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--gray-bg);
  color: var(--text-soft);
}
.chip.warn {
  background: var(--amber-bg);
  color: var(--amber);
}
.chip.bad {
  background: var(--red-bg);
  color: var(--red);
}
.chip.ok {
  background: var(--green-bg);
  color: var(--green);
}

/* ---- drawer footer actions ---- */
.drawer-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}
.drawer-actions .left,
.drawer-actions .right {
  display: flex;
  gap: 10px;
}

/* ============================================================
   Customers — analytics extras (segment movers, profile bar)
   ============================================================ */
/* "What moves per segment" — three side-by-side mini-leaderboards. */
.seg-products {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0;
}
.seg-product-col {
  padding: 16px 18px;
  border-right: 1px solid var(--border);
}
.seg-product-col:last-child {
  border-right: none;
}
.seg-product-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.seg-product-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  font-size: 13px;
}
.seg-rank {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 5px;
  background: var(--iris-tint);
  color: var(--iris);
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
}
.seg-pname {
  flex: 1;
  color: var(--text);
}
.seg-units {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-soft);
}
/* Profile drawer summary bar packs 6 cells → 3 columns, two rows. */
.summary-bar.profile-bar {
  grid-template-columns: repeat(3, 1fr);
}
.summary-bar.profile-bar .summary-cell:nth-child(3n) {
  border-right: none;
}
.summary-bar.profile-bar .summary-cell:nth-child(-n + 3) {
  border-bottom: 1px solid var(--border);
}

@media (max-width: 1080px) {
  .seg-products {
    grid-template-columns: 1fr;
  }
  .seg-product-col {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}

/* ============================================================
   Blends module — colour rows, qty steppers, swatch-usage ref
   ============================================================ */
.blend-colours {
  display: flex;
  flex-direction: column;
}
.blend-colour-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.blend-colour-row:last-child {
  border-bottom: none;
}

/* qty stepper (-0.5 / value / +0.5) */
.qty-stepper {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface);
}
.qty-stepper .qbtn {
  width: 28px;
  height: 30px;
  border: none;
  background: var(--app-bg);
  color: var(--text-soft);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.qty-stepper .qbtn:hover {
  background: var(--iris-tint);
  color: var(--iris-600);
}
.qty-stepper .qinput {
  width: 56px;
  height: 30px;
  border: none;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: center;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
}
.qty-stepper .qinput:focus {
  outline: none;
}

/* colour disclaimer (atelier verbatim) */
.colour-disclaimer {
  margin-top: 14px;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--text-muted);
  background: var(--app-bg);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
}

/* "how a swatch renders across the app" reference */
.swatch-usage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.su-cell {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  background: var(--surface);
}
.su-cap {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 9px;
  display: flex;
  align-items: center;
}
.su-code {
  margin: 0;
  font-family: var(--font-mono, ui-monospace, 'SF Mono', Menlo, monospace);
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--text-soft);
  background: var(--app-bg);
  border-radius: 7px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}

/* blend card hero photo / placeholder */
.blend-hero {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  flex-shrink: 0;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  background-color: var(--app-bg);
}
.blend-hero svg {
  width: 20px;
  height: 20px;
}

/* ---- Full-page blend RECORD layout (manage blend) ----------------------
   The blend page lays properties (a narrow left column) beside the colour
   list (a wider right column) so the full page width is used — not a tall
   narrow scroll. Collapses to one column on tablets/phones (handled below). */
.blend-page-grid {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 28px;
  align-items: start;
}
.blend-page-side,
.blend-page-main {
  min-width: 0;
}

/* ---- Blend MANAGE = truly full-sized (no inner scroll box) --------------
   Founder ask: "blends manage needs to be full sized — no need to scroll
   anything [inside]." RecordPage's shared .fp-body is flex:1 + overflow-y:auto
   inside a height:100% panel, which traps content in a viewport-height
   scrollbox. Scope an override to ONLY the manage view (via the
   .blend-manage-page marker) so the page sizes to its content and any
   scrolling is the normal page scroll on the overlay — RecordPage stays
   unchanged for every other editor. */
.fp-overlay:has(.blend-manage-page) {
  overflow-y: auto;             /* the page itself scrolls if content is tall */
}
.fp-overlay:has(.blend-manage-page) .fp-panel {
  height: auto;                 /* grow to content instead of pinning to 100vh */
  min-height: 100%;
}
.fp-overlay:has(.blend-manage-page) .fp-body {
  flex: 0 0 auto;               /* no flex-grow shrink-wrap; just take content */
  overflow-y: visible;          /* kill the cramped inner scrollbar */
}

/* ---- Full-page blend / colour EDITOR layout ----------------------------
   Editors (BlendForm / ColourForm) put the photo or live swatch preview on a
   left rail and the field grid on the right, filling the page width. */
.blend-form-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) 1fr;
  gap: 28px;
  align-items: start;
}
.blend-form-side,
.blend-form-main {
  min-width: 0;
}

/* archived state — cards + colour rows dimmed, with an Archived chip */
.card.is-archived,
.blend-colour-row.is-archived {
  opacity: 0.62;
}
.archived-chip {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: var(--gray-bg);
  border: 1px solid var(--border);
  padding: 1px 7px;
  border-radius: 5px;
}

/* swatch photo uploader inside the colour form */
.swatch-photo-field {
  display: flex;
  align-items: center;
  gap: 12px;
}
.swatch-photo-preview {
  width: 56px;
  height: 56px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  background-color: var(--app-bg);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

/* ============================================================
   Products view — view-mode toggle, gallery, full product page
   ============================================================ */

/* ---- selectable pill (colours / sizes / gender) ---- */
.chk-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  user-select: none;
  transition: border-color 0.12s, background 0.12s, color 0.12s;
}
.chk-pill:hover {
  border-color: var(--border-strong);
}
.chk-pill.on {
  border-color: var(--iris);
  background: var(--iris-tint);
  color: var(--iris-600);
  font-weight: 600;
}
.chk-pill .swatch {
  box-shadow: 0 0 0 1px var(--border-strong);
}

/* Removable chip — a CURRENT colour/size on a product. Add is via a dropdown;
   removal is ONLY this explicit ✕ (so a stray tap can't wipe a stock column). */
.rm-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: var(--iris-600);
  height: 36px;
  padding: 0 6px 0 12px;
  border: 1px solid var(--iris);
  border-radius: var(--radius-sm);
  background: var(--iris-tint);
  user-select: none;
}
.rm-chip .swatch {
  box-shadow: 0 0 0 1px var(--border-strong);
}
.rm-chip-label {
  display: inline-flex;
  align-items: center;
}
.rm-chip-x {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--iris-600);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.rm-chip-x svg {
  width: 14px;
  height: 14px;
}
.rm-chip-x:hover:not(:disabled) {
  background: var(--red-bg);
  color: var(--red);
}
.rm-chip-x:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.chip-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.dotsep {
  color: var(--text-muted);
  margin: 0 2px;
}

/* ---- segmented control (Table / Gallery) ---- */
.seg {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  background: var(--gray-bg);
  border-radius: 9px;
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px;
  border: none;
  background: transparent;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-soft);
}
.seg-btn svg {
  width: 15px;
  height: 15px;
}
.seg-btn:hover {
  color: var(--text);
}
.seg-btn.on {
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  box-shadow: var(--shadow-sm);
}

/* ---- gallery ---- */
.prod-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.prod-card {
  display: flex;
  flex-direction: column;
  text-align: left;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow 0.14s ease, transform 0.14s ease, border-color 0.14s ease;
}
.prod-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
  transform: translateY(-2px);
}
.prod-card-img {
  position: relative;
  aspect-ratio: 3 / 4;
  background: linear-gradient(135deg, #f3f4f8, #e9ebf3);
  overflow: hidden;
}
.prod-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.prod-card-ph {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--iris);
  opacity: 0.55;
}
.prod-card-ph svg {
  width: 40px;
  height: 40px;
}
.prod-card-stockbadge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 10.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--green);
  box-shadow: var(--shadow-sm);
}
.prod-card-stockbadge.low {
  color: var(--amber);
}
.prod-card-stockbadge.out {
  color: var(--red);
}
.prod-card-statusbadge {
  position: absolute;
  top: 8px;
  left: 8px;
}
.prod-card-body {
  padding: 11px 13px 13px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.prod-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.prod-card-sku {
  color: var(--text-muted);
  font-size: 11px;
}
.prod-card-name {
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
.prod-card-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}
.prod-card-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-top: 2px;
}
.prod-card-price {
  font-weight: 600;
  font-size: 14px;
}
.prod-card-blend {
  font-size: 11px;
  font-weight: 500;
  color: var(--iris-600);
  background: var(--iris-tint);
  padding: 2px 8px;
  border-radius: 6px;
}

/* card is a div+role=button now: keep button-like affordances */
.prod-card {
  width: 100%;
  cursor: pointer;
}
.prod-card:focus-visible {
  outline: 2px solid var(--iris);
  outline-offset: 2px;
}
.prod-card.is-archived {
  opacity: 0.62;
  background: var(--app-bg);
}
.prod-card.is-archived:hover {
  opacity: 1;
}

/* duplicate + row-actions overlay on a gallery card */
.prod-card-actions {
  position: absolute;
  bottom: 8px;
  right: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  opacity: 0;
  transition: opacity 0.14s ease;
}
.prod-card:hover .prod-card-actions,
.prod-card:focus-within .prod-card-actions {
  opacity: 1;
}

/* small square icon button reused in table + gallery action cells */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-soft);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.icon-btn:hover {
  background: var(--iris-tint);
  color: var(--iris-600);
  border-color: var(--border-strong);
}

/* table action cell: keep duplicate + ⋯ together, right-aligned */
.row-action-cell {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* archived row name treatment in the table */
.cell-name.is-archived {
  color: var(--text-muted);
  text-decoration: line-through;
  text-decoration-color: var(--border-strong);
}
.cell-name.is-archived .tag {
  text-decoration: none;
  margin-left: 6px;
}

/* archived banner on the full product page */
.archived-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 12px 0 0;
  padding: 10px 14px;
  font-size: 12.5px;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
}
.link-btn {
  border: none;
  background: none;
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--iris-600);
  cursor: pointer;
  text-decoration: underline;
}

/* ---- full product page ---- */
.prod-page-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.save-flash {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--green);
  background: var(--green-bg);
  padding: 5px 11px;
  border-radius: 999px;
  animation: fade 0.2s ease;
}
.save-flash svg {
  width: 14px;
  height: 14px;
}

.prod-page-grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.prod-images {
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
}
.prod-cover {
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, #f3f4f8, #e9ebf3);
  border: 1px solid var(--border);
}
.prod-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.prod-cover-ph {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--iris);
}
.prod-cover-ph svg {
  width: 40px;
  height: 40px;
  opacity: 0.6;
}
.prod-cover-ph span {
  font-size: 12px;
  color: var(--text-muted);
}
.prod-thumbs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}
.prod-thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--gray-bg);
}
.prod-thumb.is-cover {
  border-color: var(--iris);
  box-shadow: 0 0 0 2px var(--iris-tint-2);
}
.prod-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.thumb-cover-tag {
  position: absolute;
  bottom: 3px;
  left: 3px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  background: var(--iris);
  padding: 1px 5px;
  border-radius: 4px;
}
.thumb-actions {
  position: absolute;
  top: 3px;
  right: 3px;
  display: flex;
  gap: 3px;
  opacity: 0;
  transition: opacity 0.12s;
}
.prod-thumb:hover .thumb-actions {
  opacity: 1;
}
.thumb-btn {
  width: 20px;
  height: 20px;
  border-radius: 5px;
  border: none;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
}
.thumb-btn svg {
  width: 12px;
  height: 12px;
}
.thumb-btn.danger:hover {
  color: var(--red);
}
.prod-img-add {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.prod-img-add input {
  flex: 1;
  min-width: 120px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 11px;
  font-size: 12.5px;
  color: var(--text);
}
.prod-img-add input:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.prod-detail-head {
  margin-bottom: 4px;
}
.prod-name-input {
  width: 100%;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  font-family: inherit;
  padding: 4px 8px;
  margin: -4px -8px 4px;
}
.prod-name-input:hover {
  border-color: var(--border);
}
.prod-name-input:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
  background: var(--surface);
}
.prod-detail-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--text-muted);
}

.sku-field {
  display: flex;
  gap: 6px;
}
.sku-field input {
  flex: 1;
  min-width: 0;
}

.prod-desc {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 9px 11px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
}
.prod-desc:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

/* matrix per-variant SKU + row totals */
.cell-sku {
  font-size: 9.5px;
  color: var(--text-muted);
  margin-top: 1px;
  white-space: nowrap;
}
table.matrix td.row-total,
table.matrix th:last-child {
  background: var(--surface-2);
  font-weight: 600;
}
.matrix-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted);
}

/* count chip inside the Active|Archived segment + a normal-case sub on a
   section title (used for "N selected" next to Colours/Sizes). */
.seg-btn .seg-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 2px;
  font-size: 11px;
  font-weight: 600;
  border-radius: 9px;
  background: var(--gray-bg);
  color: var(--text-soft);
}
.seg-btn.on .seg-count {
  background: var(--iris-tint);
  color: var(--iris-600);
}
.section-title .sub {
  margin-left: 8px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
}

/* ---- Taxonomy manager (Manage taxonomy modal) ---- */
.taxo-manager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.taxo-pane {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 14px;
  display: flex;
  flex-direction: column;
}
.taxo-pane-head {
  margin-bottom: 10px;
}
.taxo-pane-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.taxo-pane-sub {
  margin-top: 2px;
  font-size: 11.5px;
  color: var(--text-muted);
}
.taxo-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 168px;
  overflow-y: auto;
  margin-bottom: 10px;
}
.taxo-item {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--app-bg);
  font-size: 13px;
}
.taxo-item-name {
  color: var(--text);
  font-weight: 500;
}
.taxo-item-meta {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
}
.taxo-empty {
  padding: 8px 2px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.taxo-add {
  display: flex;
  gap: 8px;
  align-items: center;
}
.taxo-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 10px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
}
.taxo-input:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--iris-tint);
}
.taxo-error {
  margin-top: 8px;
  font-size: 12px;
  color: var(--red);
}
@media (max-width: 720px) {
  .taxo-manager {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Finance module — drawers, totals, mini-tables, payments
   ============================================================ */
.small {
  font-size: 11.5px;
}

/* key/value strip used in drawers + report margins */
.kv-row {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  padding: 4px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.kv-row > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.kv-lab {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* totals breakdown box (invoices, bills, expenses) */
.totals-box {
  margin-top: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 6px 14px;
}
.totals-box .t-row,
.t-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 0;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
.totals-box .t-row:last-child {
  border-bottom: none;
}
.t-row.grand {
  border-top: 1px solid var(--border-strong);
  font-size: 14px;
}

/* payments list inside drawers */
.pay-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pay-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}
.link-danger {
  background: none;
  border: none;
  color: var(--red);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  padding: 2px 4px;
  font-family: inherit;
}
.link-danger:hover {
  text-decoration: underline;
}

/* mini editable table (invoice maker lines + charges) */
.mini-table {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}
.mini-row {
  display: flex;
  align-items: center;
  gap: 7px;
}
.mini-row input,
.mini-row select {
  height: 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  padding: 0 9px;
  font-size: 12.5px;
  color: var(--text);
  font-family: inherit;
}
.mini-row input:focus,
.mini-row select:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.mini-row .grow {
  flex: 1 1 auto;
  min-width: 0;
}
.mini-total {
  width: 78px;
  text-align: right;
  font-size: 12.5px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* active/paused chip toggle (recurring) */
.chip-toggle {
  border: 1px solid var(--border-strong);
  background: var(--gray-bg);
  color: var(--text-soft);
  border-radius: 99px;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 11px;
  cursor: pointer;
  font-family: inherit;
}
.chip-toggle.on {
  border-color: transparent;
  background: var(--green-bg);
  color: var(--green);
}

.hint-amber {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--amber);
  background: var(--amber-bg);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
}

.pl-row.rule {
  border-top: 1px solid var(--border-strong);
}

/* ============================================================
   Marketing module — CRM pipeline, campaign cards, content
   calendar, attribution leaderboard, community, budget
   ============================================================ */

/* inline chart legend row (spend vs revenue, channels) */
.chart-legend-row,
.content-legend {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.lg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-soft);
}
.lg-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ---- Creator CRM pipeline funnel ---- */
.crm-funnel {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
}
.crm-stage {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  border: none;
  border-right: 1px solid var(--border);
  background: var(--surface);
  text-align: left;
  transition: background 0.12s;
}
.crm-stage:last-child {
  border-right: none;
}
.crm-stage:hover {
  background: var(--app-bg);
}
.crm-stage.on {
  background: var(--iris-tint);
  box-shadow: inset 0 -2px 0 var(--iris);
}
.crm-stage-count {
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.crm-stage-label {
  font-size: 12px;
  color: var(--text-soft);
  font-weight: 500;
}
.crm-stage.on .crm-stage-label {
  color: var(--iris-600);
}

@media (max-width: 1080px) {
  .crm-funnel {
    grid-template-columns: repeat(2, 1fr);
  }
  .crm-stage {
    border-bottom: 1px solid var(--border);
  }
}

/* clickable status pill (gifting stage advance) */
.link-status {
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
}

/* ---- Campaign cards ---- */
.camp-card {
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.camp-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.camp-name {
  font-weight: 600;
  font-size: 15px;
  letter-spacing: -0.01em;
}
.camp-window {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}
.camp-budget {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.camp-budget-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 500;
}
.camp-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.camp-stats > div {
  padding: 10px 12px;
  border-right: 1px solid var(--border);
}
.camp-stats > div:last-child {
  border-right: none;
}
.camp-stat-val {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.camp-stat-lab {
  font-size: 10.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ---- Content calendar ---- */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}
@media (max-width: 1080px) {
  .cal-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.cal-day {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 140px;
  display: flex;
  flex-direction: column;
}
.cal-day.today {
  border-color: var(--iris);
  box-shadow: 0 0 0 2px var(--iris-tint-2);
}
.cal-day-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 9px 11px;
  border-bottom: 1px solid var(--border);
}
.cal-dow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cal-date {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
}
.cal-day.today .cal-dow,
.cal-day.today .cal-date {
  color: var(--iris-600);
}
.cal-items {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  flex: 1;
}
.cal-item {
  border: 1px solid var(--border);
  border-left: 3px solid var(--iris);
  border-radius: 6px;
  padding: 7px 9px;
  background: var(--surface-2);
}
.cal-item-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}
.cal-type {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.cal-item-title {
  font-size: 12px;
  font-weight: 550;
  line-height: 1.3;
  color: var(--text);
}
.cal-item-meta {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.cal-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 14px 0;
  opacity: 0.5;
}
.cal-item {
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.cal-item:hover {
  border-color: var(--border-strong);
  background: #fff;
}
.cal-item.archived {
  opacity: 0.5;
}
.cal-add {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.cal-add:hover {
  background: var(--iris-tint);
  color: var(--iris-600);
}

/* ---- Overview: attribution leaderboard rows ---- */
.lead-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.lead-row:last-child {
  border-bottom: none;
}
.lead-name {
  flex: 1;
  min-width: 0;
}

/* ---- Attribution: winners-to-boost ---- */
.boost-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
}
@media (max-width: 1080px) {
  .boost-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
.boost-card {
  padding: 16px 18px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.boost-card:last-child {
  border-right: none;
}
.boost-handle {
  font-weight: 600;
  font-size: 13.5px;
}
.boost-code {
  font-size: 12px;
  color: var(--iris-600);
}
.boost-metrics {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0 6px;
}

/* ---- Community: ambassador perks ---- */
.amb-perks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 18px;
}
.amb-perk {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
}
.amb-perk .chip {
  flex-shrink: 0;
  min-width: 64px;
  justify-content: center;
}

/* ============================================================================
   SHARED CRUD KIT — EntityForm, RowActions menu, ArchiveToggle, multiselect,
   color + image fields. Used by every module so CRUD is visually consistent.
   ============================================================================ */
.entity-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  resize: vertical;
  background: #fff;
}
.entity-form textarea:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.field label .req {
  color: var(--red);
  margin-left: 2px;
}

/* multiselect chips */
.multiselect {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ms-chip {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-soft);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s ease;
}
.ms-chip:hover {
  border-color: var(--iris);
  color: var(--iris-600);
}
.ms-chip.on {
  background: var(--iris-tint);
  border-color: var(--iris);
  color: var(--iris-600);
}

/* color field */
.color-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.color-field input[type='color'] {
  width: 40px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: #fff;
}

/* image field */
.image-field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.image-preview {
  width: 100%;
  max-width: 160px;
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--app-bg);
}
.image-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.image-empty {
  width: 100%;
  max-width: 160px;
  aspect-ratio: 1;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12.5px;
  background: var(--app-bg);
}

/* RowActions ⋯ menu */
.row-actions {
  position: relative;
  display: inline-flex;
}
.row-actions-btn {
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.row-actions-btn:hover {
  background: var(--app-bg);
  border-color: var(--border);
  color: var(--text);
}
.row-actions-menu {
  /* position:fixed so the menu escapes table/overflow clipping; ui.js sets
     inline top/left from the trigger's getBoundingClientRect (flips upward
     when the trigger sits low in the viewport). z-index sits above sticky
     table headers (z:1) and the topbar (z:20). */
  position: fixed;
  z-index: 200;
  min-width: 140px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  display: flex;
  flex-direction: column;
}
.row-action-item {
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--text);
  border-radius: 6px;
  cursor: pointer;
  font-family: var(--font);
}
.row-action-item:hover {
  background: var(--app-bg);
}
.row-action-item.danger {
  color: var(--red);
}
.row-action-item.danger:hover {
  background: var(--red-bg);
}

/* ArchiveToggle (smaller track than the settings Toggle) */
.archive-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}
.archive-toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.toggle-track.sm {
  width: 32px;
  height: 18px;
}
.toggle-track.sm .toggle-thumb {
  width: 14px;
  height: 14px;
}
.archive-toggle input:checked + .toggle-track.sm {
  background: var(--iris);
}
.archive-toggle input:checked + .toggle-track.sm .toggle-thumb {
  transform: translateX(14px);
}

/* ============================================================
   Payroll module — run table, BBK box, inline editors, badges
   ============================================================ */
.payroll-view .bad {
  color: var(--red);
}
.payroll-view .ok {
  color: var(--green);
}
.payroll-view .accent {
  color: var(--iris);
}

/* run table */
.run-table th,
.run-table td {
  white-space: nowrap;
  vertical-align: top;
}
.run-table .grp-row td {
  background: var(--iris-tint);
  color: var(--iris-600);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 7px 18px;
}
.run-table .sub-row td {
  background: var(--surface-2);
  font-weight: 600;
  border-top: 1px solid var(--border);
}
.run-table .grand-row td {
  background: var(--iris-tint);
  font-weight: 700;
  border-top: 2px solid var(--iris);
}
.run-table .grand-row td.num {
  color: var(--iris-600);
}
.run-table .prepaid-row td {
  background: #f5f7fb;
  border-bottom: 1px solid var(--border);
}
.run-table tbody tr:not(.grp-row):not(.sub-row):not(.prepaid-row) {
  border-bottom: 1px solid var(--border);
}

/* inline editors inside the run table */
.inp-sm {
  width: 66px;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 600;
  text-align: right;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
}
.inp-sm:focus {
  outline: none;
  border-color: var(--iris);
  box-shadow: 0 0 0 3px var(--focus-ring);
}
.inp-pair {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
}
.inp-notes {
  margin-top: 5px;
  width: 100%;
  max-width: 200px;
  padding: 4px 7px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 11.5px;
  font-family: var(--font);
  color: var(--text);
  background: var(--surface);
}
.mini-chk {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
}
.mini-chk input {
  accent-color: var(--iris);
  width: 13px;
  height: 13px;
}
.run-table input[type='checkbox'] {
  accent-color: var(--iris);
  width: 15px;
  height: 15px;
}
.hint-warn {
  font-size: 11px;
  font-weight: 600;
  color: var(--amber);
}
.rep-row td {
  background: var(--surface-2);
}

/* ============================================================
   AI Design Studio
   ============================================================ */

/* 9-preset mode bar */
.ai-modes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(116px, 1fr));
  gap: 10px;
}
.ai-mode {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
  padding: 14px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  transition: all 0.12s ease;
  text-align: center;
}
.ai-mode:hover { border-color: var(--border-strong); background: var(--iris-tint); }
.ai-mode.on {
  border-color: var(--iris);
  background: var(--iris-tint);
  box-shadow: 0 0 0 1px var(--iris) inset;
}
.ai-mode-ico { color: var(--text-soft); display: flex; }
.ai-mode.on .ai-mode-ico { color: var(--iris); }
.ai-mode-ico svg { width: 20px; height: 20px; }
.ai-mode-lab { font-size: 12px; font-weight: 600; color: var(--text); line-height: 1.2; }

/* field labels inside the studio panel */
.ai-field-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
  margin-bottom: 6px;
}

/* reference upload */
.ai-ref { display: flex; flex-direction: column; gap: 10px; }
.ai-ref-prev {
  width: 100%;
  max-width: 220px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
}
.ai-ref-prev img { width: 100%; display: block; }
.ai-ref-empty {
  padding: 22px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  text-align: center;
  color: var(--text-muted);
  font-size: 12.5px;
  background: var(--app-bg);
}

/* fabric meta line */
.ai-fabric-meta { display: flex; gap: 10px; align-items: center; margin-top: 8px; flex-wrap: wrap; font-size: 12px; }

/* colour swatch chooser */
.ai-swatch-row { display: flex; flex-wrap: wrap; gap: 8px; }
.ai-swatch {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 5px 10px 5px 6px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-size: 12.5px;
}
.ai-swatch:hover { border-color: var(--border-strong); }
.ai-swatch.on { border-color: var(--iris); background: var(--iris-tint); }
.ai-swatch-chip { width: 16px; height: 16px; border-radius: 50%; border: 1px solid rgba(0,0,0,0.12); }
.ai-swatch-lab { font-weight: 500; color: var(--text); }
.ai-swatch-detail { margin-top: 10px; }

/* brief / prompt textarea */
.ai-brief {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 13px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  box-sizing: border-box;
}
.ai-brief:focus { outline: none; border-color: var(--iris); box-shadow: 0 0 0 3px var(--focus-ring); }

/* quality + aspect controls */
.ai-controls { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.ai-aspect-row { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-aspect {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-soft);
}
.ai-aspect.on { border-color: var(--iris); background: var(--iris-tint); color: var(--iris-600); }

.ai-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.ai-error {
  background: var(--red-bg);
  color: var(--red);
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
}

/* editable plan block */
.ai-plan {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--app-bg);
}
.ai-plan-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
}

/* results gallery */
.ai-result-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.ai-result { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.ai-result-img { position: relative; background: var(--app-bg); }
.ai-result-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.ai-result-badge {
  position: absolute; top: 7px; left: 7px;
  background: rgba(15,18,28,0.7); color: #fff;
  font-size: 10.5px; font-weight: 600;
  padding: 2px 7px; border-radius: 999px;
}
.ai-result-body { padding: 10px 11px 11px; }
.ai-result-title { font-size: 12.5px; font-weight: 600; color: var(--text); line-height: 1.3; }
.ai-result-meta { font-size: 11px; color: var(--text-muted); margin: 4px 0 9px; display: flex; align-items: center; gap: 2px; flex-wrap: wrap; }
.ai-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; border: 1px solid rgba(0,0,0,0.12); }
.ai-result-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-mini-btn {
  flex: 1;
  min-width: 0;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-soft);
}
.ai-mini-btn:hover { border-color: var(--border-strong); }
.ai-mini-btn.primary { background: var(--iris); border-color: var(--iris); color: #fff; }
.ai-mini-btn:disabled { opacity: 0.5; cursor: default; }

/* loading */
.ai-loading { display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 30px 0; }
.ai-spinner {
  width: 30px; height: 30px;
  border: 3px solid var(--iris-tint-2);
  border-top-color: var(--iris);
  border-radius: 50%;
  animation: ai-spin 0.8s linear infinite;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }

/* thumbnails in tables */
.ai-thumb {
  width: 48px; height: 56px;
  border-radius: 6px;
  background-size: cover;
  background-position: center;
  border: 1px solid var(--border);
}

/* save modal grid */
.ai-save-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* preview modal */
.ai-preview { display: flex; gap: 16px; align-items: flex-start; }
.ai-preview img { width: 260px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.ai-preview-meta { flex: 1; display: flex; flex-direction: column; gap: 9px; font-size: 13px; }
.ai-preview-meta .muted { display: inline-block; min-width: 96px; }
.ai-prompt-block {
  margin-top: 14px;
  padding: 12px;
  background: var(--app-bg);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--text-soft);
  line-height: 1.5;
}

/* library gallery */
.ai-search {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 7px 11px;
  font: inherit;
  font-size: 13px;
  width: 200px;
  background: var(--surface);
}
.ai-search:focus { outline: none; border-color: var(--iris); box-shadow: 0 0 0 3px var(--focus-ring); }
.ai-lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; }
.ai-lib-card { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.ai-lib-card.archived { opacity: 0.7; }
.ai-lib-img { position: relative; background-size: cover; background-position: center; background-color: var(--app-bg); }
.ai-lib-arch { position: absolute; top: 7px; right: 7px; background: var(--text-muted); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 7px; border-radius: 999px; }
.ai-lib-body { padding: 11px 12px 12px; position: relative; }
.ai-lib-name { font-size: 13px; font-weight: 600; color: var(--text); line-height: 1.3; padding-right: 28px; }
.ai-lib-tags { display: flex; gap: 5px; flex-wrap: wrap; margin: 7px 0; }
.ai-lib-tags .muted-tag { background: var(--app-bg); color: var(--text-muted); }
.ai-lib-product { font-size: 12px; color: var(--iris-600); font-weight: 600; text-decoration: none; }
.ai-lib-product:hover { text-decoration: underline; }
.ai-lib-actions { position: absolute; top: 8px; right: 8px; }

/* The Paintress chat */
.ai-chat { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--app-bg); overflow: hidden; }
.ai-chat-thread { max-height: 230px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ai-chat-hello { display: flex; gap: 10px; align-items: flex-start; color: var(--text-soft); font-size: 13px; }
.ai-chat-hello b { color: var(--text); }
.ai-chat-ico { color: var(--iris); flex: 0 0 auto; display: inline-flex; }
.ai-bubble { max-width: 86%; padding: 8px 12px; border-radius: 14px; font-size: 13px; line-height: 1.45; white-space: pre-wrap; }
.ai-bubble.user { align-self: flex-end; background: var(--iris); color: #fff; border-bottom-right-radius: 4px; }
.ai-bubble.assistant { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 4px; }
.ai-bubble.typing { color: var(--text-muted); font-style: italic; }
.ai-chat-input { display: flex; gap: 8px; align-items: flex-end; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); }
.ai-chat-input textarea { flex: 1; resize: vertical; min-height: 38px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font: inherit; font-size: 13px; background: var(--surface); color: var(--text); }
.ai-chat-input textarea:focus { outline: none; border-color: var(--iris); box-shadow: 0 0 0 3px var(--focus-ring); }
.ai-chat-send { display: flex; flex-direction: column; gap: 6px; }

/* house model picker */
.ai-model-row { display: flex; gap: 8px; flex-wrap: wrap; }
.ai-model { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 64px; padding: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; }
.ai-model.on { border-color: var(--iris); box-shadow: 0 0 0 2px var(--focus-ring); }
.ai-model img { width: 44px; height: 44px; border-radius: 10px; object-fit: cover; }
.ai-model-lab { font-size: 11px; font-weight: 600; color: var(--text-soft); }
.ai-model-none { width: 44px; height: 44px; border-radius: 10px; display: flex; align-items: center; justify-content: center; background: var(--app-bg); color: var(--text-muted); font-size: 11px; }

/* per-preset toggles */
.ai-toggles { display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px dashed var(--border); border-radius: var(--radius-sm); background: var(--app-bg); }
.ai-check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-soft); cursor: pointer; }
.ai-embel { display: flex; align-items: center; gap: 10px; }

/* OUTPUT + UPSCALER — compact inline segmented toggles (Standard/HD and
   Real-ESRGAN/Clarity), matching the live atelier's controls row. Small, inline,
   iris-accented when active. Wraps onto two rows on narrow viewports. */
.ai-seg-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; }
.ai-seg-group { display: inline-flex; align-items: center; gap: 8px; }
.ai-seg-label {
  font-size: 10.5px; font-weight: 700; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.ai-seg {
  display: inline-flex; gap: 3px; padding: 3px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--app-bg);
}
.ai-seg-btn {
  padding: 5px 12px; border: none; border-radius: 6px; background: transparent;
  color: var(--text-soft); font-size: 12px; font-weight: 600; line-height: 1;
  cursor: pointer; transition: background .12s, color .12s; white-space: nowrap;
}
.ai-seg-btn:hover { color: var(--text); }
.ai-seg-btn.on { background: var(--iris); color: #fff; }

/* extra reference thumbnails (up to 4) beside the main reference garment */
.ai-ref-extras { display: flex; gap: 6px; flex-wrap: wrap; }
.ai-ref-extra { position: relative; display: inline-block; }
.ai-ref-extra img { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; border: 1px solid var(--border); display: block; }
.ai-ref-x {
  position: absolute; top: -6px; right: -6px; width: 17px; height: 17px; border-radius: 50%;
  border: 1px solid #fff; background: var(--red); color: #fff; font-size: 11px; line-height: 1;
  padding: 0; cursor: pointer; font-weight: 700; display: flex; align-items: center; justify-content: center;
}

@media (max-width: 900px) {
  .ai-controls { grid-template-columns: 1fr; }
  .ai-save-grid { grid-template-columns: 1fr; }
  .ai-preview { flex-direction: column; }
  .ai-preview img { width: 100%; }
}

/* ============================================================================
   HR view — profile (inline edit), documents, certificate
   ========================================================================== */
.avatar.avatar-lg {
  width: 52px;
  height: 52px;
  font-size: 18px;
}

/* In-page profile navigation — employee profile lives inside the Team page */
.record-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.record-nav-pager { display: flex; align-items: center; gap: 8px; }
.rn-arrow { width: 30px; height: 30px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; font-size: 12px; line-height: 1; display: inline-flex; align-items: center; justify-content: center; }
.rn-arrow:hover:not(:disabled) { border-color: var(--iris); color: var(--iris); }
.rn-arrow:disabled { opacity: 0.4; cursor: default; }

/* Profile header strip */
.hr-profile .profile-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.hr-profile .profile-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Inline-edit field grid inside a profile card */
.inline-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 18px;
}
.inline-field { min-width: 0; }
.inline-field > .muted {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
}

/* The clickable value that turns into an input */
.inline-value {
  display: inline-block;
  max-width: 100%;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: 3px 6px;
  margin: -3px -6px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  text-align: left;
  cursor: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.inline-value:hover { background: var(--iris-tint); }
.inline-value.is-empty { color: var(--text-muted); font-style: italic; }

.inline-input,
.inline-select {
  width: 100%;
  border: 1px solid var(--iris);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font: inherit;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 0 0 3px var(--iris-tint);
  outline: none;
}
.inline-select {
  border-color: var(--border-strong);
  box-shadow: none;
  cursor: pointer;
}

/* ============================================================================
   SHARED FOUNDATION — full-page editor (RecordPage) + reusable redesign
   patterns. Olumi palette throughout (iris primary, never Naseem green).
   Other modules build on these classes. Added for the ERP redesign.
   ============================================================================ */

/* ---- RecordPage: full-bleed editor overlay (drop-in for Drawer) ---- */
.fp-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;               /* above the sidebar (z 20) / drawer (z 100) */
  background: var(--app-bg);
  animation: fade 0.16s ease;
}
.fp-panel {
  max-width: 1100px;
  margin: 0 auto;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.fp-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--app-bg);
}
.fp-back { flex-shrink: 0; }
.fp-titles { min-width: 0; }
.fp-titles h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.fp-sub {
  margin-top: 2px;
  font-size: 13px;
  color: var(--text-muted);
}
.fp-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.fp-body {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ---- Employee / record card grid (clickable cards with a chevron) ---- */
.emp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.emp-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.emp-card:hover {
  border-color: var(--iris);
  box-shadow: var(--shadow-sm);
}
.emp-card .emp-body { flex: 1; min-width: 0; }
.emp-card .emp-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emp-card .emp-sub {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.emp-card .emp-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.emp-card .emp-chev {
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1;
}
.emp-card:hover .emp-chev { color: var(--iris); }

/* ---- Division group header e.g. "OPERATIONS · 4" ---- */
.div-head {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--iris);
  margin: 22px 0 10px;
}
.div-head:first-child { margin-top: 0; }

/* ---- Employee-profile card grid ---- */
.profile-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

/* ---- Pill tab variant: solid iris active pill ---- */
.tabs.tabs--pill {
  background: var(--iris-tint);
  border-radius: 16px;
  padding: 5px;
  gap: 4px;
}
.tabs.tabs--pill .tab {
  background: transparent;
  border-radius: 10px;
  color: var(--text-muted);
  box-shadow: none;
}
.tabs.tabs--pill .tab:hover { color: var(--text); }
.tabs.tabs--pill .tab.active {
  background: var(--iris);
  color: #fff;
  box-shadow: none;
}
.tabs.tabs--pill .tab.active .tab-count {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
}

/* ---- Master-detail grid (list + detail panel) ---- */
.md {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 16px;
}
.md-list { min-width: 0; }
.md-detail { min-width: 0; }

/* ============================================================================
   HR AREA — 2026 polish pass (scoped). Spacious, aligned, token-based, iris.
   Fixes the cramped flush-to-edge card bodies, gives the roster + profile real
   breathing room, and replaces ad-hoc inline notice cards with .hr-note.
   ============================================================================ */

/* ---- View width: HR is a WIDE surface — let it use the full content area ---- */
.hr-view { width: 100%; }

/* ---- Inline notice (replaces ad-hoc background:var(--iris-tint) cards) ---- */
.hr-note {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-soft);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 14px;
}
.hr-note strong { color: var(--text); font-weight: 600; }
.hr-note-iris { background: var(--iris-tint); border-color: transparent; }
.hr-note-amber { background: var(--amber-bg); border-color: transparent; color: var(--amber); }
.hr-note-amber strong { color: var(--amber); }

/* ---- KPI strip + roster spacing ---- */
.hr-view .kpi-grid { margin-bottom: 4px; }

/* ---- Roster cards: roomier, with a clear hover lift ---- */
.hr-view .emp-grid {
  grid-template-columns: repeat(auto-fill, minmax(232px, 1fr));
  gap: 14px;
}
.hr-view .emp-card { padding: 15px 16px; gap: 13px; border-radius: var(--radius); }
.hr-view .emp-card:hover { transform: translateY(-1px); }
.hr-view .emp-card .emp-name { font-size: 14.5px; }
.hr-view .emp-card .emp-sub { margin-top: 1px; }
.hr-view .emp-card .emp-chev { font-size: 18px; opacity: 0.6; }

/* ---- Division section header: cleaner, with an underline rule ---- */
.hr-view .div-head {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.08em;
  margin: 26px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.hr-view .div-head:first-child { margin-top: 4px; }

/* ============================================================================
   PROFILE — the core fix: card bodies were flush to the edge (the "2006" look).
   Give every card body real padding, align the inline-edit grids, and make the
   identity header a proper padded strip.
   ============================================================================ */

/* Identity header strip — .profile-head is a bare .card, so pad it. */
.hr-profile .profile-head {
  padding: 18px 20px;
  margin-bottom: 16px;
}
.hr-profile .profile-name { font-size: 19px; }
.hr-profile .profile-head .cell-sub { margin-top: 3px; }

/* Every card body in the profile gets consistent padding. .card-head already
   pads itself + draws the divider; non-head children are the body, which had
   NONE before — this is what made it feel cramped. The identity header
   (.profile-head) is padded separately above, so it's excluded here. */
.hr-profile .card:not(.profile-head) > .card-head { padding: 14px 18px; }
.hr-profile .card:not(.profile-head) > *:not(.card-head) { padding-left: 18px; padding-right: 18px; }
.hr-profile .card:not(.profile-head) > *:not(.card-head):first-child { padding-top: 16px; }
.hr-profile .card:not(.profile-head) > *:not(.card-head):last-child { padding-bottom: 16px; }
/* A card-head immediately followed by body content: add a little top breathing. */
.hr-profile .card:not(.profile-head) > .card-head + * { padding-top: 14px; }

/* Inline-edit grids: align label/value rows, give them air. */
.hr-profile .inline-grid { gap: 14px 22px; }
.hr-profile .detail-grid { gap: 14px 22px; }
.hr-profile .inline-field > .muted,
.hr-profile .detail-grid .muted {
  font-size: 11px;
  letter-spacing: 0.4px;
  color: var(--text-muted);
}
.hr-profile .inline-field .strong { font-size: 14px; font-weight: 600; }

/* Profile card grid: a touch more gap, never below a readable min. */
.hr-profile .profile-cards {
  grid-template-columns: repeat(auto-fit, minmax(264px, 1fr));
  gap: 16px;
}

/* Status / chip rows inside cards align to a comfortable baseline. */
.hr-profile .chip-row { gap: 8px; align-items: center; }

/* stat-rows (Payroll history, Loans, OT, Violations) — even rhythm + hairline
   divider. Horizontal padding comes from the card-body rule above so the rows
   align with the card head; here we only set vertical rhythm + the divider. */
.hr-profile .card .stat-row {
  padding-top: 9px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--border);
}
.hr-profile .card .stat-row:last-of-type { border-bottom: none; }

/* Summary bar under the action row breathes from the buttons above it. */
.hr-profile .summary-bar { margin-top: 16px; }

/* ---- chip-toggle: iris "on" state (keep the light iris theme, not green) ---- */
.hr-profile .chip-toggle { padding: 5px 13px; font-size: 12px; }
.hr-profile .chip-toggle.on { background: var(--iris-tint); color: var(--iris-600, var(--iris)); }

/* ---- Inline value/inputs sit a touch larger for tap targets on the profile - */
.hr-profile .inline-value { font-size: 14px; padding: 4px 7px; }

/* ---- Phone: single-column profile grids, full-width roster cards ---- */
@media (max-width: 640px) {
  .hr-profile .inline-grid,
  .hr-profile .detail-grid { grid-template-columns: 1fr; }
  .hr-profile .profile-head { gap: 12px; }
  .hr-profile .profile-head .toolbar { width: 100%; }
  .hr-profile .profile-head .toolbar .btn { flex: 1; }
  .hr-view .emp-grid { grid-template-columns: 1fr; }
}

/* ============================================================================
   ELEVATION LAYER — motion + brand-depth (additive)
   "The ripple breathes, the surface settles." All keyframes below touch ONLY
   transform/opacity (GPU). Tables and long lists are never given .stagger-item
   so they are inert by construction. Ripples are STATIC images at low opacity.
   See _deploy/ELEVATION-SPEC.md.
   ============================================================================ */

/* ---- Route / view transition (native View Transitions API) ---- */
::view-transition-old(root) {
  animation: vt-out var(--dur-2) var(--ease-exit) both;
}
::view-transition-new(root) {
  animation: vt-in var(--dur-4) var(--ease-ripple) both;
}
@keyframes vt-out {
  to { opacity: 0; transform: translateY(-4px); }
}
@keyframes vt-in {
  from { opacity: 0; transform: translateY(16px); }
}

/* ---- Fallback crossfade (no View Transitions API): a fresh keyed DOM node per
   route gets .view-enter and plays once. Scoped to the view container so it
   never cascades into table rows. ---- */
.view-enter {
  /* `backwards` (not `both`): the entrance looks identical, but the element
     reverts to transform:none AFTER it finishes. `both` left a held identity
     matrix (a non-none transform), which makes .view-enter the containing block
     for any position:fixed descendant — that trapped the RecordPage overlay
     (ui.RecordPage) into a small box and created a phantom inner scroll. */
  animation: viewEnter var(--dur-4) var(--ease-ripple) backwards;
}
@keyframes viewEnter {
  from { opacity: 0; transform: translateY(16px); }
}

/* ---- Mount stagger primitive — the ONE stagger mechanism app-wide.
   JS sets --i per item; CSS owns the keyframe. Apply ONLY to cards / KPIs /
   short lists / empty states — NEVER table rows, matrix cells, report rows,
   bankfile rows, pick-list rows, payslip lines. one-shot (both), no will-change. ---- */
.stagger-item {
  /* `backwards` not `both` — same reason as .view-enter: never leave a held
     identity-matrix transform that would establish a containing block. */
  animation: riseIn var(--dur-4) var(--ease-ripple) backwards;
  animation-delay: calc(min(var(--i, 0), 8) * var(--stagger));
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(var(--lift-2)); }
}

/* ---- Ambient ripple texture — subtle, low-opacity, STATIC background image.
   The ripple field never animates (animating hundreds of <circle>s = perf death);
   the living mark is the breathe Lottie, not the ripple. Per-surface override via
   the --ripple-* vars. Content rides above on z-index:1. ---- */
.has-ripple {
  position: relative;
}
.has-ripple::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: var(--ripple-img, url('../assets/brand/olumi-watermark.svg'))
    var(--ripple-pos, center) / var(--ripple-size, 520px) no-repeat;
  opacity: var(--ripple-op, 0.04);
  -webkit-mask-image: radial-gradient(closest-side, #000 60%, transparent);
  mask-image: radial-gradient(closest-side, #000 60%, transparent);
}
.has-ripple > * {
  position: relative;
  z-index: 1;
}
/* The rule above forces position:relative on EVERY .has-ripple child to layer
   it above the ripple ::before — but that silently clobbered the sidebar's
   `position: sticky` (equal specificity, later in source), so the nav scrolled
   away with the page. Restore sticky on desktop with a higher-specificity,
   width-scoped rule. The ≤1024 off-canvas drawer (position:fixed) is untouched. */
@media (min-width: 1025px) {
  .app.has-ripple > .sidebar {
    position: sticky;
    top: 0;
    align-self: start;
    z-index: 5;
  }
}

/* Per-surface ripple placements (whisper-quiet, opacity 0.03–0.06). */
/* App backdrop — one ripple pinned to the viewport, texture you feel not see.
   Uses position:fixed (its own composited layer) instead of
   background-attachment:fixed, which would force a full-area repaint on EVERY
   scroll frame of the (document-level) scroll container — measurable jank on the
   tall is-wide data views. position:fixed keeps the pin visually identical while
   the compositor handles it for free (60fps guard). */
.app.has-ripple::before,
.content.has-ripple::before {
  --ripple-img: url('../assets/brand/olumi-watermark.svg');
  --ripple-pos: right -80px bottom -80px;
  --ripple-size: 520px;
  --ripple-op: 0.035;
  position: fixed;
  -webkit-mask-image: none;
  mask-image: none;
}
/* Empty state — full ripple field behind the placeholder, radial-masked. */
.placeholder.has-ripple::before {
  --ripple-img: url('../assets/brand/ripples.svg');
  --ripple-pos: center;
  --ripple-size: 440px;
  --ripple-op: 0.06;
}
/* Sidebar footer — a small whisper anchored to the bottom. */
.sidebar-foot.has-ripple::before {
  --ripple-img: url('../assets/brand/olumi-watermark.svg');
  --ripple-pos: left bottom;
  --ripple-size: 180px;
  --ripple-op: 0.05;
  -webkit-mask-image: none;
  mask-image: none;
}

/* ---- Card hover-lift — ONLY for interactive cards (those that open a drawer /
   are clickable). transform is animated (cheap); shadow is swapped as a discrete
   value, never transitioned on the big surface. ---- */
.kpi.clickable,
.kpi[role='button'],
.grid-cards .card.clickable,
.prod-card {
  transition: transform var(--dur-2) var(--ease-ripple);
}
.kpi.clickable:hover,
.kpi[role='button']:hover,
.grid-cards .card.clickable:hover,
.prod-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

/* ---- Breathe Lottie / mark placements — LARGE per the logo-big rule.
   The <lottie-player> (or static <img> fallback under reduced-motion) is mounted
   by motion.js; these size + center it inside each brand moment. ---- */
/* motion.js emits class `.breathe-mark` on BOTH the <lottie-player> (.is-live)
   and the static <img> fallback (.is-static); target that class so the static
   reduced-motion / no-Lottie path is sized + the chip-reset below fires too. */
.boot-screen .breathe-mark,
.boot-screen lottie-player {
  width: 88px;
  height: 88px;
  display: block;
}
.login-emblem .breathe-mark,
.login-emblem lottie-player {
  width: 80px;
  height: 80px;
  display: block;
}
.placeholder .ph-ico .breathe-mark,
.placeholder .ph-ico lottie-player {
  width: 60px;
  height: 60px;
  display: block;
}
/* When the breathing mark fills the icon chip, drop the chip's tint fill so the
   mark reads cleanly (logo-big). Fires for both the live player and the static
   <img> fallback (both carry .breathe-mark). */
.placeholder .ph-ico:has(.breathe-mark),
.placeholder .ph-ico:has(lottie-player) {
  width: auto;
  height: auto;
  background: transparent;
  border-radius: 0;
}

/* ============================================================
   Accessibility — respect prefers-reduced-motion (global guard)
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  /* Elevation layer — fully neutralise non-essential motion. */
  .stagger-item,
  .view-enter,
  ::view-transition-old(root),
  ::view-transition-new(root) {
    animation: none !important;
  }
  /* Drop ambient ripple texture entirely under reduced motion. */
  .has-ripple::before {
    opacity: 0 !important;
  }
}

/* ============================================================================
   RESPONSIVE FOUNDATION — phone (~390px), tablet (~768/1024px), desktop.
   Added last so these rules win on equal specificity. Goals:
   (a) content fluid, never wider than the viewport;
   (b) every wide table/matrix scrolls inside its card (no page-wide overflow);
   (c) card grids reflow via auto-fit/minmax, stacking to 1 col on phones;
   (d) sidebar collapses to a slim icon rail < ~820px (CSS-only, no JS), .main
       fills the width;
   (e) overlays (.fp-panel/.modal/.drawer) go full-width on small screens, .md
       stacks < ~820px; .fp-bar / .tabs wrap;
   (f) paddings shrink at small breakpoints;
   (g) nothing overflows its container (min-width:0 on flex children).
   Breakpoints: 1080 / 820 / 560px.
   ============================================================================ */

/* ---- Global overflow guards (apply at every width) ---- */
/* NOTE: deliberately NOT setting overflow-x:hidden on html/body — that turns
   them into scroll containers and silently breaks the position:sticky topbar,
   sidebar and table headers. We prevent page-wide overflow at the source
   instead: wide tables scroll inside their cards and flex children get
   min-width:0 (below). */
img,
svg,
canvas,
video {
  max-width: 100%;
}
/* Flex/grid children must be allowed to shrink so long content (tables, code,
   long names) scrolls inside its card instead of forcing the page wide. */
.main,
.content,
.md-list,
.md-detail,
.fp-titles,
.list-row .meta,
.lead-name,
.seg-pname {
  min-width: 0;
}

/* Wrap EVERY wide table so it scrolls horizontally inside its card rather than
   pushing the page wide. .table-wrap / .matrix-wrap already do this; add the
   report table + payroll run table + cert preview, and make tables keep their
   natural width inside the scroller. */
.table-wrap,
.matrix-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
/* Many-column tables keep a sensible minimum so columns don't crush; the
   surrounding scroller (.table-wrap / .matrix-wrap or the block-scroller below)
   provides horizontal scroll on narrow screens. */
.table-wrap > .report-table,
.table-wrap > .run-table {
  min-width: 640px;
}
/* A bare .report-table / .run-table not already inside a scroller becomes its
   own horizontal scroller (common case: it sits directly in a .card). The
   per-table min-width is intentionally NOT set here — the element itself is the
   scroll viewport, so its inner content (cells) drives the scrollable width. */
.card > .report-table,
.card > .run-table {
  display: block;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ---- Sticky identity column on wide interactive tables (finding 5) --------
   When a many-column table is scrolled sideways inside its wrapper, the first
   (identity) column stays pinned so each row keeps its label/context. `inherit`
   lets the cell adopt its row's own background (white body rows, tinted group/
   total rows) so the pinned cell never shows transparent overlap. A real bg
   token is forced on the header cell since thead has its own colour.
   A full row→stacked-card layout would need per-cell data-labels in the view
   markup (not editable here) — that remains a follow-up; sticky-column +
   guaranteed scroll are done now. */
.tbl thead th:first-child,
.tbl tbody td:first-child,
.report-table thead th:first-child,
.report-table tbody td:first-child,
.run-table thead th:first-child,
.run-table tbody td:first-child {
  position: sticky;
  left: 0;
  background: inherit;
  z-index: 2;
}
/* Header corner cell is sticky on BOTH axes — above body cells (z 2) and above
   the other header cells (thead z 5) so nothing peeks through the corner. */
.tbl thead th:first-child {
  background: var(--surface-2);
  z-index: 6;
}
/* Body cells inherit transparent by default; give the common (untinted) body
   rows an explicit white so the pinned column reads as solid while scrolling. */
.tbl tbody tr td:first-child,
.report-table tbody tr td:first-child {
  background: var(--surface);
}
/* Tinted run-table rows keep their own colour on the pinned cell. */
.run-table .grp-row td:first-child,
.run-table .grand-row td:first-child {
  background: var(--iris-tint);
}
.run-table .sub-row td:first-child { background: var(--surface-2); }
.run-table .prepaid-row td:first-child { background: #f5f7fb; }
.run-table tbody tr:not(.grp-row):not(.sub-row):not(.grand-row):not(.prepaid-row) td:first-child {
  background: var(--surface);
}
/* Clickable .tbl rows tint on hover — keep the pinned cell in sync so it doesn't
   look detached from its row. */
.tbl tbody tr.clickable:hover td:first-child {
  background: var(--iris-tint);
}

/* (Card-grid auto-fit now lives in the BASE rules — .kpi-grid / .profile-cards
   / .grid-cards — so there are no duplicate breakpoint declarations here.) */

/* ---- Off-canvas sidebar drawer (≤1024px) ---------------------------------
   The hamburger (.nav-toggle) in the topbar toggles `.app.nav-open`, sliding the
   full LABELLED sidebar in over a backdrop. Closes on nav-click (main.js) and on
   backdrop-click. Hidden/inert above the tablet breakpoint. */
.nav-toggle {
  display: none; /* shown only ≤1024px (below) */
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
}
.nav-toggle:hover { background: var(--gray-bg); }
.nav-toggle:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--focus-ring);
}
/* CSS-only hamburger glyph (3 bars) so no icon dependency is needed. */
.nav-toggle-bars,
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  position: relative;
}
.nav-toggle-bars::before,
.nav-toggle-bars::after {
  content: '';
  position: absolute;
  left: 0;
}
.nav-toggle-bars::before { top: -6px; }
.nav-toggle-bars::after { top: 6px; }

/* Backdrop is inert/hidden until the drawer is open at the drawer breakpoint. */
.nav-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 38, 0.4);
  z-index: 90;
  animation: fade 0.16s ease;
}

/* ---- ≤1080px : small desktop — padding trims only ---- */
@media (max-width: 1080px) {
  .content {
    padding: 20px;
  }
  .topbar {
    padding: 0 16px;
  }
  .fp-bar {
    padding: 14px 20px;
  }
  .fp-body {
    padding: 20px;
  }
}

/* ---- ≤1024px : ONE tablet breakpoint — sidebar→drawer + ALL multi-pane
   layouts collapse to a single column together (no 820–1080 dead-band). ---- */
@media (max-width: 1024px) {
  /* Single-column main: the sidebar no longer takes a grid track; it becomes a
     fixed off-canvas drawer toggled by the hamburger. */
  .app {
    grid-template-columns: 1fr;
  }
  .nav-toggle {
    display: inline-flex;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--sidebar-w);
    max-width: 86vw;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    box-shadow: var(--shadow-lg);
  }
  .app.nav-open .sidebar {
    transform: translateX(0);
  }
  .app.nav-open .nav-backdrop {
    display: block;
  }
  @media (prefers-reduced-motion: reduce) {
    .sidebar { transition: none; }
  }

  /* EVERY multi-pane grid collapses to one column at the SAME breakpoint. */
  .two-col,
  .md,
  .split,
  .prod-page-grid,
  .ai-controls,
  .ai-save-grid,
  .inline-grid,
  .swatch-usage,
  .detail-grid,
  .blend-page-grid,
  .blend-form-grid,
  .ai-preview {
    grid-template-columns: 1fr;
  }
  .ai-preview {
    flex-direction: column;
  }
  .ai-preview img {
    width: 100%;
  }

  /* Overlays go (near) full-width */
  .fp-panel {
    max-width: 100%;
  }
  .modal {
    width: 100% !important;
    max-width: 100%;
  }
  .drawer {
    width: 100% !important;
    max-width: 100%;
  }

  /* Tab bars + record-page bar wrap instead of overflowing */
  .tabs {
    display: flex;
    flex-wrap: wrap;
  }
  .fp-bar {
    flex-wrap: wrap;
  }
  .fp-actions {
    margin-left: 0;
    width: 100%;
    flex-wrap: wrap;
  }

  /* Toolbars / page head wrap cleanly; search inputs go fluid */
  .search-box,
  .search-box input,
  .topbar-search,
  .topbar-search input,
  .ai-search {
    width: 100%;
    max-width: 100%;
  }
}

/* ---- ≤560px : phones (~390px) ---- */
@media (max-width: 560px) {
  body {
    font-size: 13.5px;
  }
  .content {
    padding: 14px;
  }
  .topbar {
    padding: 0 12px;
    gap: 10px;
  }
  .page-head h1 {
    font-size: 23px;
  }
  .fp-bar {
    padding: 12px 14px;
  }
  .fp-body {
    padding: 14px;
  }
  .fp-titles h2 {
    font-size: 19px;
  }

  /* One-column on phones for fixed-count grids only. .kpi-grid / .profile-cards
     / .grid-cards are auto-fit and already collapse to a single column at this
     width, so they are intentionally NOT re-declared here (finding 9). */
  .summary-bar,
  .prod-gallery,
  .seg-products,
  .crm-funnel,
  .boost-grid,
  .cal-grid,
  .camp-stats,
  .ai-result-grid,
  .ai-lib-grid,
  .ai-modes {
    grid-template-columns: 1fr;
  }

  /* Summary bar: dividers become horizontal when stacked */
  .summary-cell,
  .seg-product-col,
  .boost-card,
  .camp-stats > div,
  .crm-stage {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .summary-cell:last-child,
  .seg-product-col:last-child,
  .boost-card:last-child,
  .camp-stats > div:last-child,
  .crm-stage:last-child {
    border-bottom: none;
  }

  /* Modal/drawer chrome padding trims */
  .modal-body,
  .drawer-body {
    padding: 16px;
  }
  .modal-head,
  .modal-foot,
  .drawer-head,
  .drawer-foot {
    padding-left: 16px;
    padding-right: 16px;
  }

  /* Long unbroken strings (IBANs, emails, codes) wrap rather than overflow */
  .iban,
  .su-code,
  .mono {
    word-break: break-word;
    overflow-wrap: anywhere;
  }

  /* CRUD/edit forms go single-column on phones so inputs aren't crushed. */
  .field-grid {
    grid-template-columns: 1fr;
  }
  .field-grid > .field[style*="grid-column"] {
    grid-column: 1 / -1 !important;
  }

  /* De-clutter the topbar: let it wrap, hide its redundant demo chip
     (the sidebar foot already shows one — scope to the direct child only). */
  .topbar {
    flex-wrap: wrap;
  }
  .topbar > .demo-chip {
    display: none;
  }
}

/* === Overflow handling — fix at the SOURCE, never hide content (finding 1) ===
   The old rule clipped .content (overflow-x:clip) below 1080px, which HID any
   too-wide content with no scrollbar — the #1 "half-baked" symptom. Removed.
   Wide tables already live in scrollable wrappers (.table-wrap / .matrix-wrap),
   grid/flex children carry min-width:0 in their BASE rules (above), and long
   strings wrap via overflow-wrap. So there is nothing to clip — if anything is
   ever wider than the column it gets a SCROLLBAR, never a silent crop. */

/* min-width:0 on grid/flex children at ALL widths (not behind a media query) so
   a wide child can shrink instead of blowing its track out past the viewport. */
.two-col > *,
.grid-cards > *,
.kpi-grid > *,
.profile-cards > *,
.summary-bar > * {
  min-width: 0;
}

/* Long unbroken strings (codes, emails, IBANs) in cells wrap instead of forcing
   the table/page wide — applies everywhere, not just on phones. */
.tbl td,
.report-table td,
.run-table td,
.matrix td,
.detail-grid,
.kpi-value {
  /* break-word (NOT anywhere): break only genuinely-long unbreakable words.
     `anywhere` collapses a cell's min-content to one character, which crushes
     multi-column tables and shatters normal words vertically. With break-word
     columns size to their longest word and .table-wrap scrolls when needed. */
  overflow-wrap: break-word;
}

/* Charts/media never widen the page: shrink, or scroll inside their own card. */
.chart {
  max-width: 100%;
  overflow-x: auto;
}
.chart svg,
.content canvas,
.content img:not([class*='icon']):not(.brand-mark) {
  max-width: 100%;
}

/* Page-level safety net: if some view ever does overflow, give .content a
   horizontal SCROLLBAR (an affordance) — NEVER clip. This does not establish a
   vertical scroll container, so the sticky topbar/headers stay intact. */
.content {
  overflow-x: auto;
}

/* ---------- Auth gate: offline banner + boot screen (added with backend rewire) ---------- */
.offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--amber);
  background: var(--amber-bg);
  border-bottom: 1px solid var(--amber);
  padding: 5px 12px;
}

.boot-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-bg);
}

/* The avatar is now a <button> (sign-out). Keep its circular look unchanged. */
button.avatar {
  cursor: pointer;
  font-family: inherit;
  border: none;
  padding: 0;
}

/* ==========================================================================
   BRAND LIBRARY (views/library.js) — the in-app download centre.
   ERP-styled (existing tokens). Self-contained namespace `.brand-lib`.
   ========================================================================== */
.brand-lib .bl-body { margin-top: 18px; }

.bl-section { margin-bottom: 30px; }
.bl-section-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 14px;
}
.bl-section-head h3 { margin: 0; font-size: 16px; font-weight: 650; color: var(--text); }
.bl-section-head p { margin: 3px 0 0; font-size: 12.5px; color: var(--text-muted); max-width: 60ch; }

.bl-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(196px, 1fr));
}
.bl-grid-motion { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }

.bl-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color .16s ease, box-shadow .16s ease;
}
.bl-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }

.bl-tile {
  aspect-ratio: 1 / 1; width: 100%;
  background: var(--app-bg);
  display: flex; align-items: center; justify-content: center;
  padding: 14px; box-sizing: border-box;
  background-image:
    linear-gradient(45deg, #eef0f5 25%, transparent 25%),
    linear-gradient(-45deg, #eef0f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef0f5 75%),
    linear-gradient(-45deg, transparent 75%, #eef0f5 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.bl-tile.is-ink { background: var(--ink, #262B3C); }
.bl-tile img, .bl-tile object, .bl-tile lottie-player {
  max-width: 100%; max-height: 100%; width: 100%; height: 100%;
  object-fit: contain; display: block; pointer-events: none;
}

.bl-meta { padding: 10px 12px 12px; border-top: 1px solid var(--border); }
.bl-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.bl-name {
  font-size: 13px; font-weight: 600; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bl-dim { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.bl-fmts { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }

/* download chip */
.bl-chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--text-soft);
  text-decoration: none; padding: 3px 8px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  transition: all .14s ease; cursor: pointer; line-height: 1.4;
}
.bl-chip:hover { border-color: var(--iris); color: var(--iris); background: var(--iris-tint); }
.bl-chip-ico { display: inline-flex; }
.bl-chip-ico svg { width: 12px; height: 12px; }
.bl-chip em { font-style: normal; color: var(--text-muted); font-weight: 500; }
.bl-chip:hover em { color: var(--iris); }

/* button-styled anchor (zips / open / download) */
.bl-btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 12.5px; font-weight: 600; color: var(--text-soft);
  text-decoration: none; padding: 7px 13px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
  transition: all .14s ease; cursor: pointer; white-space: nowrap;
}
.bl-btn:hover { border-color: var(--iris); color: var(--iris); background: var(--iris-tint); }
.bl-btn svg { width: 15px; height: 15px; }

.bl-count { margin-left: 6px; font-size: 11px; color: var(--text-muted); font-weight: 600; }

/* ---- motion ---- */
.bl-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 8px; }
.bl-blurb { font-size: 12.5px; color: var(--text-muted); margin: 0 0 16px; }
.lm-archetypes { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 22px; }
.lm-gif {
  width: 130px; height: 130px; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; background: var(--app-bg); display: block;
}
.lm-gif img { width: 100%; height: 100%; object-fit: contain; }
.lm-tier { margin-bottom: 26px; }
.lm-tier-head {
  font-size: 13px; font-weight: 650; color: var(--text); text-transform: capitalize;
  padding-bottom: 8px; margin-bottom: 14px; border-bottom: 1px solid var(--border);
}
.lm-card { overflow: hidden; }
/* Motion scenes are the deep-iris (#6E79A6) colourway — they read crisply on the
   same light transparency ground as the static tiles. The still/sparse tier is
   intentionally minimal; density builds through natural → alive. */
.lm-tile {
  aspect-ratio: 1 / 1; width: 100%; display: block;
  background: var(--app-bg);
  background-image:
    linear-gradient(45deg, #eef0f5 25%, transparent 25%),
    linear-gradient(-45deg, #eef0f5 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #eef0f5 75%),
    linear-gradient(-45deg, transparent 75%, #eef0f5 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}
.lm-tile object { width: 100%; height: 100%; display: block; pointer-events: none; }
.lm-cap {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 10px; border-top: 1px solid var(--border);
}
.lm-recipe {
  font-size: 11px; color: var(--text-soft); text-transform: capitalize;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.lm-dl { display: inline-flex; color: var(--text-muted); flex-shrink: 0; }
.lm-dl:hover { color: var(--iris); }
.lm-dl svg { width: 13px; height: 13px; }

/* ---- colour ---- */
.bl-swatches { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.bl-swatch {
  display: flex; gap: 0; align-items: stretch;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface);
}
.bl-swatch-chip { width: 70px; flex-shrink: 0; border-right: 1px solid var(--border); }
.bl-swatch-body { padding: 10px 12px 11px; min-width: 0; flex: 1; }
.bl-swatch-name { font-size: 13.5px; font-weight: 650; color: var(--text); }
.bl-swatch-role { font-size: 11.5px; color: var(--text-muted); margin: 1px 0 8px; }
.bl-swatch-vals { display: flex; flex-direction: column; gap: 5px; }
.bl-copy {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-family: inherit; font-size: 12px; cursor: pointer;
  padding: 4px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--app-bg); color: var(--text-soft); transition: all .14s ease; width: 100%;
}
.bl-copy:hover { border-color: var(--iris); color: var(--iris); }
.bl-copy .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.bl-copy em { font-style: normal; font-size: 10.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }

/* ---- type ---- */
@font-face { font-family: OlumiPoppins; font-weight: 100; src: url('../assets/brand-library/fonts/Poppins-Thin.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: OlumiPoppins; font-weight: 200; src: url('../assets/brand-library/fonts/Poppins-ExtraLight.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: OlumiPoppins; font-weight: 300; src: url('../assets/brand-library/fonts/Poppins-Light.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: OlumiPoppins; font-weight: 400; src: url('../assets/brand-library/fonts/Poppins-Regular.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: OlumiPoppins; font-weight: 500; src: url('../assets/brand-library/fonts/Poppins-Medium.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: OlumiSpectral; font-weight: 300; src: url('../assets/brand-library/fonts/Spectral-Light.ttf') format('truetype'); font-display: swap; }
@font-face { font-family: OlumiSpectral; font-weight: 400; src: url('../assets/brand-library/fonts/Spectral-Regular.ttf') format('truetype'); font-display: swap; }

.bl-type-list { display: flex; flex-direction: column; gap: 12px; }
.bl-type-card { padding: 18px 18px 0; }
.bl-type-line { font-size: 30px; line-height: 1.2; color: var(--text); text-transform: lowercase; }
.bl-type-aa { font-size: 17px; color: var(--text-soft); margin-top: 4px; }
.bl-type-card .bl-meta { border-top: 1px solid var(--border); margin: 16px -18px 0; padding: 11px 18px 13px; }

/* ---- guidelines ---- */
.bl-pdf { width: 100%; height: 560px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--app-bg); }
.bl-pdf-fallback { padding: 24px; color: var(--text-muted); font-size: 13px; }

@media (max-width: 640px) {
  .bl-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
  .bl-type-line { font-size: 23px; }
  .bl-pdf { height: 420px; }
}
