/* ═══════════════════════════════════════════════════════════════════════════
   @nobul/ui — component CSS (v2026.9.0) — Phase 2: full component library
   (+ 2026.9.0: header icon-bar, .btn-table-text, table typography standard)

   Phase 1 shipped the skeleton sections ui.js renders (toast, dialog,
   shortcut help, skeletons, empty states, field errors, view states) —
   those sections are UNCHANGED below (two hardcoded toast colours were
   swapped for the identical-valued tokens; zero visual change).

   Phase 2 adds the component layer, all token-driven:
     • Buttons — the full 9-level hierarchy per .docs/nobul-button-hierarchy.md
       (+ .option-btn selectable-choice pattern)
     • Badges — the tone system per .docs/nobul-badge-standards.md
       (success/warning/danger/info/neutral; NO domain classes)
     • Forms — .form-field/.form-label/.form-control, the locked --cb-size
       checkbox (24px default, .checkbox-sm 18px dense), toggle switch
     • Tables — .table shell, .table-wrap, zebra/dense options, focusable
       rows, opt-in .table-cards-mobile responsive transform (from people)
     • Cards, filter bar, page header

   Accent colour: components resolve their accent through
   var(--primary, var(--brand-accent)) so apps that already define --primary
   keep their exact colour, and pure-package consumers pick up the per-app
   overrides/<app>.css accent.

   Requires tokens.css (or an app stylesheet defining the same custom
   properties) to be loaded first. Everything here is additive — apps whose
   own CSS already styles a class identically simply win on specificity/order.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Scrollbars (Safety reference) ─────────────────────────────────────── */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
}
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background-color: var(--gray-300);
  border: 2px solid transparent;
  border-radius: 9999px;
  background-clip: padding-box;
}
*::-webkit-scrollbar-thumb:hover { background-color: var(--gray-400); }

/* ── Toast (engine v2 — reference visual) ───────────────────────────────────
   Solid saturated type fill + white text + white circular icon badge.
   Deliberately theme-invariant (same decision as v1): no dark-mode rules.
   The type fill flows through the private --_toast-fill custom property so
   the badge glyph picks up the same hue (--cb-size pattern).
   The --warn token only reaches 3.19:1 under white text, so the warning
   fill uses the component token --toast-warn — defaulting to the shared
   amber-700 strong-warning token (5.02:1 with white; WCAG AA). Apps may
   override the custom property.                                           */
.toast-container {
  position: fixed; bottom: 20px; right: 20px; z-index: var(--z-toast, 2000);
  display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; /* clicks between/around toasts fall through */
}
.toast {
  --_toast-fill: var(--info);
  pointer-events: auto;
  padding: 12px 14px;
  background: var(--_toast-fill); color: #fff;
  border-radius: var(--radius-md, 8px);
  font-size: 12px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: toast-in .25s var(--ease);
  min-width: 300px; max-width: 380px;
  display: flex; align-items: flex-start; gap: var(--space-2-5, 10px);
  transition: opacity .3s var(--ease), transform .3s var(--ease);
}
.toast-success { --_toast-fill: var(--success); }
.toast-error   { --_toast-fill: var(--danger); }
.toast-warning { --_toast-fill: var(--toast-warn, var(--warn-strong)); }
.toast-info    { --_toast-fill: var(--info); }
@keyframes toast-in { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
.toast-out { opacity: 0; transform: translateY(8px); }
.toast-icon {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: 50%;
  background: #fff; color: var(--_toast-fill);
  display: inline-flex; align-items: center; justify-content: center;
}
.toast-content { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.toast-title { font-size: 13px; font-weight: 700; line-height: 1.3; }
.toast-body { font-size: 12.5px; line-height: 1.4; color: rgba(255,255,255,.92); overflow-wrap: anywhere; }
.toast-close, .toast-action {
  background: transparent; border: none; color: inherit; cursor: pointer;
  font: inherit; font-weight: 600; padding: 4px 8px; border-radius: var(--radius-sm);
  transition: background var(--motion-med);
}
.toast-close { padding: 2px 6px; font-size: var(--fs-2xl); line-height: 1; opacity: .7; }
.toast-close:hover,
.toast-action:hover { background: rgba(255,255,255,.15); opacity: 1; }

/* ── Dialog (expenses overlays.css) ─────────────────────────────────────── */
.dialog-overlay {
  display: none; position: fixed; inset: 0; z-index: var(--z-modal, 600);
  background: var(--overlay-bg);
  align-items: center; justify-content: center;
}
#dialog-overlay { z-index: var(--z-confirm, 1900); }
.dialog-overlay.open { display: flex; }
.dialog-box {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 24px; width: min(420px, 90vw);
  box-shadow: var(--shadow-lg);
}
.dialog-title { font-size: 15px; font-weight: 700; margin-bottom: 8px; }
.dialog-message { font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.dialog-checklist { display: grid; gap: 8px; margin-top: 12px; color: var(--text); }
.dialog-checklist-item {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface-alt);
  font-size: 13px; line-height: 1.35;
}
.dialog-checklist-item input { margin-top: 2px; flex: 0 0 auto; }
.dialog-input, .dialog-textarea {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--gray-200); border-radius: var(--radius-sm);
  font: inherit; font-size: 13px; margin-bottom: 12px;
  background: var(--surface); color: var(--text);
}
.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Keyboard shortcut help overlay (expenses overlays.css) ─────────────── */
.shortcut-help {
  position: fixed; inset: 0; z-index: 3000;
  background: var(--overlay-bg);
  display: flex; align-items: center; justify-content: center;
}
.shortcut-help-card {
  background: var(--surface); color: var(--text);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
  min-width: 340px; max-width: 420px; padding: var(--space-5);
}
.shortcut-help-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: var(--fs-xl); font-weight: 700; margin-bottom: var(--space-3);
}
.shortcut-help-card dl {
  display: grid; grid-template-columns: auto 1fr; gap: var(--space-2) var(--space-4); margin: 0;
}
.shortcut-help-card dt { font-size: var(--fs-sm); display: flex; gap: 4px; align-items: center; }
.shortcut-help-card dd { font-size: var(--fs-base); margin: 0; color: var(--text-muted); }
.shortcut-help-group { margin: 10px 0 4px; font-size: var(--fs-sm); font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--gray-500); }
.shortcut-help-group:first-of-type { margin-top: 0; }
.shortcut-help-card kbd {
  display: inline-block; padding: 2px 6px;
  background: var(--gray-100); color: var(--text);
  border: 1px solid var(--gray-300); border-bottom-width: 2px;
  border-radius: 4px; font-family: var(--font-mono); font-size: var(--fs-xs);
}

/* ── Skeleton loaders (expenses skeletons.css) ──────────────────────────── */
.skel {
  background: linear-gradient(90deg, var(--gray-100) 0%, var(--gray-200) 50%, var(--gray-100) 100%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
}
@keyframes skel-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skel-stat-tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-4); }
.skel-card-stack { display: flex; flex-direction: column; gap: var(--space-2); }
.skel-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-3); }

/* ── Empty states (expenses empty-states.css) ───────────────────────────── */
.empty-state {
  text-align: center; padding: 40px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-size: 16px; color: var(--text); margin-bottom: 8px; }
.empty-state p { font-size: 13px; max-width: 400px; margin: 0 auto; }

.empty-state-rich {
  display: flex; flex-direction: column; align-items: center;
  padding: var(--space-8) var(--space-5); text-align: center; gap: var(--space-2);
}
.empty-state-icon { color: var(--gray-300); margin-bottom: var(--space-2); }
.empty-state-rich h3 { font-size: var(--fs-2xl); font-weight: 600; color: var(--text); }
.empty-state-rich p { font-size: var(--fs-base); color: var(--text-muted); max-width: 360px; margin: 0; line-height: 1.5; }
.empty-state-rich .btn { margin-top: var(--space-3); }

/* ── Inline field errors (expenses forms.css) ───────────────────────────── */
.form-control.has-error,
input[type=checkbox].has-error { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger-ring-rgba); }
.field-error {
  font-size: var(--fs-sm); color: var(--danger); margin-top: var(--space-1);
  display: flex; align-items: center; gap: var(--space-1); font-weight: 500;
}
.field-error::before { content: '!'; display: inline-flex; align-items: center; justify-content: center; width: 14px; height: 14px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 10px; font-weight: 700; flex-shrink: 0; }

/* ── View states (modelled on finance style.css .view-state*) ───────────── */
.view-state {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: var(--space-2);
  padding: var(--space-6) var(--space-4);
  text-align: center;
}
.view-state-icon { color: var(--gray-400); }
.view-state-title { font-size: var(--fs-lg); font-weight: 600; color: var(--gray-700); }
.view-state-hint  { font-size: var(--fs-md); color: var(--gray-500); max-width: 420px; }
.view-state-error .view-state-title { color: var(--danger); }
.view-state-action { margin-top: var(--space-2); }
.view-state-spinner {
  width: 28px; height: 28px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--brand-accent, var(--gray-500));
  border-radius: 50%;
  animation: view-state-spin .8s linear infinite;
}
@keyframes view-state-spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════════════════════════
   PHASE 2 — component library
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Buttons — 9-level hierarchy (.docs/nobul-button-hierarchy.md) ────────
   Colour communicates action INTENT, not module identity. Status belongs in
   badges, never in buttons. Base sourced from expenses buttons.css +
   safety style.css (fix branch), accent made token-driven.               ── */
.btn {
  /* component-scoped accent resolution (see file header) */
  --accent: var(--primary, var(--brand-accent, var(--brand-ink)));
  --accent-strong: var(--primary-dk, var(--brand-accent-strong, var(--accent)));
  --accent-foreground: var(--primary-foreground, var(--brand-accent-foreground, #fff));
  --accent-strong-foreground: var(--primary-dk-foreground, var(--brand-accent-strong-foreground, var(--accent-foreground)));
  --btn-ring: var(--accent); /* danger variants override */
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  height: 40px; padding: 0 var(--space-4);
  border: 1px solid transparent; border-radius: var(--radius);
  font-family: var(--font); font-size: var(--fs-md); font-weight: 600;
  cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow);
  transition: all var(--motion-med) var(--ease);
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--btn-ring); }
.btn:disabled, .btn[disabled], .btn.btn-loading { opacity: .5; cursor: not-allowed; }
/* Busy is not disabled: keep the button legible while it works. */
.btn.btn-loading { opacity: .85; cursor: wait; }
/* Disabled buttons stay hoverable so their data-tip can explain WHY they are
   disabled; native <button disabled> already blocks activation. Links and
   loading buttons still need the pointer cut. */
a.btn[disabled], .btn.btn-loading { pointer-events: none; }

/* Level 1 — main action for the page/panel/modal/workflow step */
.btn-primary { background: var(--accent); color: var(--accent-foreground); }
.btn-primary:hover:not(:disabled) { background: var(--accent-strong); color: var(--accent-strong-foreground); }

/* Level 2 — positive business-state transition (Approve, Verify, Mark Paid) */
.btn-success { background: var(--success); color: var(--success-foreground); }
.btn-success:hover:not(:disabled) { background: var(--success-strong); color: var(--success-strong-foreground); }

/* Level 3 — cautious workflow transition (Escalate, Suspend, Reopen) */
.btn-warning { background: var(--warn); color: var(--warn-foreground); }
.btn-warning:hover:not(:disabled) { background: var(--warn-strong); color: var(--warn-strong-foreground); }

/* Level 4 — standard non-destructive action (Edit, Open, Export) */
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--gray-300); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-100); border-color: var(--gray-400); }

/* Level 5 — low-emphasis supporting action (View Notes, Show Details) */
.btn-ghost { background: transparent; color: var(--text-muted); border-color: transparent; box-shadow: none; }
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--text); }

/* Level 6 — confirmed destructive action (Delete Record, Reject Claim) */
.btn-danger { background: var(--danger); color: var(--danger-foreground); --btn-ring: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-dk); color: var(--danger-dk-foreground); }

/* Level 7 — inline destructive action (Remove Attachment, Delete Row) */
.btn-danger-secondary { background: var(--surface); color: var(--danger); border-color: var(--danger); --btn-ring: var(--danger); }
.btn-danger-secondary:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger-dk); border-color: var(--danger-dk); }

/* Level 8 — interface utility, icon only, 32px square */
.btn-icon { width: 32px; height: 32px; padding: 0; font-size: var(--fs-xl); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted); border-color: var(--gray-200); }
.btn-icon:hover:not(:disabled) { background: var(--gray-100); color: var(--text); }

/* Level 9 — dense table operation, icon only, 28px square, tooltip required */
.btn-table { width: 28px; height: 28px; min-width: 28px; padding: 0; font-size: var(--fs-sm); border-radius: var(--radius-sm); background: var(--surface); color: var(--text-muted); border-color: var(--gray-200); }
.btn-table:hover:not(:disabled) { background: var(--gray-100); color: var(--text); box-shadow: var(--shadow-md); }
.btn-table:active:not(:disabled) { transform: scale(.95); }

/* Level 9, text variant — compact table action where NO icon is obvious
   (Recalculate, Extend, Assign…). Same 28px row discipline as .btn-table
   (sizing source: finance margins/temps .btn-xs); neutral secondary look,
   no heavy shadow. NEVER put .btn-primary/.btn-success/full-size buttons
   inside table rows — see the "Buttons In Tables" section of
   .docs/nobul-button-hierarchy.md. Markup: class="btn btn-table-text".   */
.btn-table-text {
  height: 28px; min-height: 28px; max-height: 28px;
  padding: 0 8px;
  font-size: var(--fs-sm); font-weight: 600;
  border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-muted); border-color: var(--gray-200);
  box-shadow: none;
}
.btn-table-text:hover:not(:disabled) { background: var(--gray-100); color: var(--text); border-color: var(--gray-300); }
.btn-table-text:active:not(:disabled) { transform: scale(.95); }
/* Inline destructive text variant — red text, soft danger hover */
.btn-table-text.danger { color: var(--danger); --btn-ring: var(--danger); }
.btn-table-text.danger:hover:not(:disabled) { background: var(--danger-bg); color: var(--danger-dk); border-color: var(--danger); }

/* Compact size for forms and secondary toolbars */
.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--fs-sm); }

/* Loading slot — NobulUI.withBusy adds one spinner and freezes the button's
   measured minimum width for the duration of the operation. */
.btn-spinner {
  display: inline-block; width: 16px; height: 16px; flex: 0 0 16px;
  box-sizing: border-box;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: btn-spin .7s linear infinite;
  transform-origin: 50% 50%;
}
.btn-icon.btn-loading > :not(.btn-spinner),
.btn-table.btn-loading > :not(.btn-spinner) { display: none; }
@keyframes btn-spin { to { transform: rotate(360deg); } }

/* Shared activity ring for everything that is not a button: busy lines, file
   rows, inline "Loading…" text, view states. currentColor by default so it
   takes the line's tone; -accent draws the ring on a neutral surface.
   Sizes: -sm 12px beside text, 16px default, -lg 28px for view states. */
.nui-spinner {
  display: inline-block; width: 16px; height: 16px; flex: 0 0 16px;
  box-sizing: border-box; vertical-align: -3px;
  border: 2px solid currentColor; border-right-color: transparent;
  border-radius: 50%; animation: btn-spin .7s linear infinite;
  transform-origin: 50% 50%;
}
.nui-spinner-sm { width: 12px; height: 12px; flex-basis: 12px; vertical-align: -2px; }
.nui-spinner-lg { width: 28px; height: 28px; flex-basis: 28px; border-width: 3px; }
.nui-spinner-accent { border-color: var(--gray-200); border-top-color: var(--brand-accent, var(--gray-500)); }
/* Reduced motion slows the rings instead of stopping them: a static
   three-quarter circle reads as a broken glyph, and a 16px element turning
   once every 1.6s is well inside what reduced-motion users tolerate. */
@media (prefers-reduced-motion: reduce) {
  .btn-spinner, .nui-spinner, .view-state-spinner { animation-duration: 1.6s; }
}

/* ── Portalled action menu (NobulUI.mountActionMenu) ─────────────────────
   The menu is moved to the active top layer while open, so table/card/modal
   overflow cannot clip it. Apps own the menu labels and click handlers. */
.nobul-action-menu {
  --action-menu-accent: var(--primary, var(--brand-accent, var(--brand-ink)));
  position: fixed;
  box-sizing: border-box;
  z-index: var(--z-dropdown);
  min-width: 180px;
  max-width: min(280px, calc(100vw - 16px));
  max-height: calc(100vh - 16px);
  overflow-y: auto;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}
.nobul-action-menu[hidden] { display: none; }
.nobul-action-menu-item {
  display: flex;
  box-sizing: border-box;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 32px;
  padding: 6px 9px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--fs-base);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.nobul-action-menu-item:hover { background: var(--surface-alt); }
.nobul-action-menu-item:focus-visible {
  outline: none;
  background: var(--surface-alt);
  box-shadow: inset 0 0 0 2px var(--action-menu-accent);
}
.nobul-action-menu-item[disabled],
.nobul-action-menu-item[aria-disabled="true"] { opacity: .46; cursor: not-allowed; }
.nobul-action-menu-item.danger { color: var(--danger); }
.nobul-action-menu-separator { height: 1px; margin: 4px 5px; background: var(--border); }

/* ── Option buttons — selectable choices, NOT workflow actions ────────────
   Markup: <button class="btn option-btn" aria-pressed="true|false">. Selected
   state uses accent border + soft fill (never .btn-primary swaps). Pattern
   per the Option Buttons section of the button contract; implementation
   modelled on safety's fix-branch style.css.                             ── */
.option-btn { background: var(--surface); color: var(--text-muted); border-color: var(--gray-200); box-shadow: none; }
.option-btn:hover:not(:disabled) { background: var(--gray-100); color: var(--text); }
.option-btn.selected,
.option-btn[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
  font-weight: 600;
}

/* ── Header icon-bar (.docs/nobul-header-standards.md) ────────────────────
   The standard icon button for the app header bar. ALL eight apps have DARK
   brand header bars, so header iconography is white-on-translucent in BOTH
   page themes (expenses' shipped pattern — the reference implementation).
   Icons come from NobulUI.HEADER_ICONS (16px stroke-currentColor, so the
   glyph inherits the button's #fff and can never render black on the dark
   bar); theme toggles mount via NobulUI.mountThemeToggle().
   Markup: <button class="header-icon-btn" title="…" aria-label="…">.      */
.header-icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; min-width: 32px; padding: 0; flex: 0 0 auto;
  background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  color: #fff;
  font: inherit; cursor: pointer;
  transition: background var(--motion-med) var(--ease);
}
.header-icon-btn:hover:not(:disabled) { background: rgba(255,255,255,.14); }
.header-icon-btn:active:not(:disabled) { transform: scale(.95); }
.header-icon-btn:focus-visible { outline: 2px solid rgba(255,255,255,.7); outline-offset: 2px; }
.header-icon-btn:disabled { opacity: .5; cursor: not-allowed; }
.header-icon-btn svg { width: 16px; height: 16px; display: block; }

/* Canonical desktop header row. Apps retain their own grid/search/navigation
   layout; these classes own the dimensions and brand treatment that must not
   drift between shells. Responsive layouts may wrap below app breakpoints. */
.nobul-header-row {
  box-sizing: border-box;
  min-height: 56px;
  padding: 8px 20px;
  border-bottom: 0;
  box-shadow: none;
}
.nobul-header-brand {
  display: inline-flex; align-items: center; gap: 12px; min-width: 0;
  border: 0; background: transparent; color: inherit; padding: 0;
  font: inherit; text-align: left; text-decoration: none;
}
.nobul-header-logo {
  display: block; width: auto; height: 38px; max-width: 112px;
  object-fit: contain; flex: 0 0 auto;
}
.nobul-header-label {
  min-width: 0; padding-left: 0; border-left: 0; color: #fff;
  font-size: 14px; font-weight: 400; line-height: 1; white-space: nowrap;
}
.nobul-header-actions {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 8px; min-width: 0;
}

/* Theme-toggle icon swap — moon shown in light, sun shown in dark.
   Pure CSS keyed on BOTH html dark hooks (data-theme + .dark class), so the
   correct icon shows even before JS settles. mountThemeToggle injects the
   pair; markup shipping its own copies gets the same swap for free.       */
svg.ti-sun { display: none; }
[data-theme="dark"] .ti-sun,
.dark .ti-sun { display: block; }
[data-theme="dark"] .ti-moon,
.dark .ti-moon { display: none; }

/* ── Badges — tone system (.docs/nobul-badge-standards.md) ────────────────
   Five tones only. NO domain classes in the package: apps map their domain
   states ("Approved" → success, "Pending" → info…) in code. Deep tint text
   colours are deliberate values (badge-on-tint contrast), not token dupes. */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px;
  border-radius: 999px;                 /* pill */
  font-family: var(--font); font-size: var(--fs-md); font-weight: 600;
  line-height: 1.5; white-space: nowrap;
  border: 1px solid transparent;
}
.badge svg { width: 10px; height: 10px; display: block; }
.badge-sm { padding: 1px 8px; font-size: var(--fs-sm); }
.badge[hidden] { display: none; }
.badge-success { background: var(--success-bg); color: var(--badge-success-text); }
.badge-warning { background: var(--warn-bg);    color: var(--warn-text); }
.badge-danger  { background: var(--danger-bg);  color: var(--badge-danger-text); }
.badge-info    { background: var(--info-bg);    color: var(--badge-info-text); }
.badge-neutral { background: var(--gray-100);   color: var(--gray-600); border-color: var(--gray-200); }

/* ── Forms ────────────────────────────────────────────────────────────────
   .form-field is the canonical wrapper; .form-group is kept as an alias for
   the markup ui.js form-error helpers already target.                    ── */
:where(
  input:not([type]),
  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="url"],
  input[type="tel"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  input[type="time"],
  input[type="datetime-local"],
  input[type="month"],
  input[type="week"],
  input[type="file"],
  select,
  textarea
) {
  font: inherit;
  color: var(--text);
  background-color: var(--surface);
}
:where(input, textarea)::placeholder {
  color: var(--text-muted);
  opacity: 1;
}
:where(input:-webkit-autofill, textarea:-webkit-autofill, select:-webkit-autofill) {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  box-shadow: 0 0 0 1000px var(--surface) inset;
}
:where(input[type="file"])::file-selector-button {
  min-height: 32px;
  margin-inline-end: var(--space-2);
  padding: 0 var(--space-2-5);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font: inherit;
  color: var(--text);
  background: var(--surface-alt);
  cursor: pointer;
}
:where(input[type="file"])::file-selector-button:hover {
  border-color: var(--gray-300);
  background: var(--surface-hover);
}
.form-field,
.form-group { margin-bottom: var(--space-3); }
.form-label {
  display: block;
  font-size: var(--fs-lg); font-weight: 600;   /* contract: labels ≥ 14px */
  color: var(--text-label);
  margin-bottom: var(--space-1);
}
.form-control {
  width: 100%;
  height: 40px;
  padding: 0 var(--space-3);
  border: 1px solid var(--gray-200); border-radius: var(--radius);
  font: inherit; font-size: var(--fs-lg);
  background: var(--surface); color: var(--text);
  transition: border-color var(--motion-med) var(--ease), box-shadow var(--motion-med) var(--ease);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary, var(--brand-accent));
  box-shadow: 0 0 0 2px var(--focus-ring-rgba, rgba(15,23,42,.12));
}
.form-control:disabled { opacity: .5; cursor: not-allowed; }
.form-control-sm { height: 32px; font-size: var(--fs-md); padding: 0 var(--space-2-5); }
textarea.form-control { height: auto; padding: var(--space-2) var(--space-3); resize: vertical; min-height: 60px; }
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%239ca3af'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
}

/* Checkbox — the LOCKED spec from the button contract (Form Controls):
   a true square in every layout context. Do not relax the min/max locks.
   Everything (box, tick, radius) scales off ONE knob, --cb-size:
     • default 24px — forms, settings, access grids
     • .checkbox-sm  — 18px, the ONLY sanctioned dense size (filter bars,
       table rows); or set --cb-size: 18px on a container whose checkbox
       markup is generated. Never hand-size a checkbox any other way —
       fixed-px overrides desync the tick, and accent-color is dead under
       appearance:none. */
input[type="checkbox"] {
  --_cb: var(--cb-size, 24px);
  appearance: none; -webkit-appearance: none;
  width: var(--_cb); height: var(--_cb);
  min-width: var(--_cb); min-height: var(--_cb);
  max-width: var(--_cb); max-height: var(--_cb); aspect-ratio: 1 / 1;
  flex: 0 0 var(--_cb); box-sizing: border-box; padding: 0;
  border: 2px solid var(--gray-300);
  border-radius: calc(var(--_cb) * .25); /* 6px at 24px */
  background: var(--surface); cursor: pointer;
  display: inline-block; position: relative; vertical-align: middle;
  transition: background var(--motion-med), border-color var(--motion-med);
}
input[type="checkbox"].checkbox-sm { --cb-size: 18px; }
input[type="checkbox"]:checked {
  background: var(--primary, var(--brand-accent));
  border-color: var(--primary, var(--brand-accent));
}
input[type="checkbox"]:checked::after {
  content: '';
  position: absolute; left: 50%; top: 48%;
  width: calc(var(--_cb) * .25); height: calc(var(--_cb) * .46); /* 6×11 at 24px */
  border: solid #fff; border-width: 0 2px 2px 0;
  transform: translate(-50%, -50%) rotate(45deg);
  transform-origin: 50% 50%;
}
input[type="checkbox"]:hover:not(:disabled) { border-color: var(--primary, var(--brand-accent)); }
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--primary, var(--brand-accent)); outline-offset: 2px; box-shadow: none;
}
input[type="checkbox"]:disabled { opacity: .5; cursor: not-allowed; }
/* 10px label spacing — both markup patterns supported */
label:has(input[type="checkbox"]) {
  display: inline-flex;
  align-items: center;
  gap: 10px !important;   /* override legacy inline label gaps below 10px */
  min-height: 24px;
  font-size: var(--fs-lg); /* contract: labels ≥ 14px */
}
label:has(input[type="checkbox"]) input[type="checkbox"] { margin: 0 !important; }
input[type="checkbox"] + label { margin-left: 10px; vertical-align: middle; font-size: var(--fs-lg); }

/* Toggle switch — for persistent on/off settings (Active, Enabled,
   Published, Visible…) per the button contract. Same element, different
   class: <input type="checkbox" class="toggle-switch">.                  */
input[type="checkbox"].toggle-switch {
  width: 40px; min-width: 40px; max-width: 40px; flex: 0 0 40px;
  height: 24px; aspect-ratio: auto;
  border: 2px solid transparent; border-radius: 999px;
  background: var(--gray-300);
  transition: background var(--motion-med) var(--ease);
}
input[type="checkbox"].toggle-switch::after {
  content: '';
  position: absolute; top: 50%; left: 2px;
  width: 16px; height: 16px; border: none; border-radius: 50%;
  background: #fff; box-shadow: var(--shadow);
  transform: translateY(-50%);
  transition: left var(--motion-med) var(--ease);
}
input[type="checkbox"].toggle-switch:checked { background: var(--primary, var(--brand-accent)); border-color: transparent; }
input[type="checkbox"].toggle-switch:checked::after {
  left: 18px;
  width: 16px; height: 16px; border: none;
  transform: translateY(-50%);
}

/* ── Tables ───────────────────────────────────────────────────────────────
   .table is the canonical shell; .data-table is an alias for the class the
   apps (and ui.js skelTable) already emit. Dropdown menus inside .table-wrap
   must be portaled (see the select standard).

   TYPOGRAPHY STANDARD (.docs/nobul-table-standards.md): ONE body size per
   table — th are 11px uppercase letter-spaced muted + nowrap; td are 13px
   (var(--fs-base)) at a single line-height. Do not mix font sizes inside
   one table body; secondary detail belongs in a muted SECOND LINE or the
   detail view, not a smaller font in the same cell. Numeric cells take
   .cell-num (tabular figures, right-aligned).                            ── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table,
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-base);
  line-height: 1.45;                     /* the ONE table line-height */
  background: var(--surface);
}
.table th,
.data-table th {
  text-align: left;
  padding: var(--space-2-5) var(--space-3);
  font-size: var(--fs-sm); font-weight: 600;
  color: var(--text-label);
  text-transform: uppercase; letter-spacing: .03em;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td,
.data-table td {
  padding: var(--space-2-5) var(--space-3);
  font-size: var(--fs-base);             /* explicit: cells never inherit ad-hoc sizes */
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
/* Cell utilities */
.cell-num { font-variant-numeric: tabular-nums; text-align: right; }
.cell-wrap { white-space: normal; overflow-wrap: anywhere; }
.table tbody tr:hover,
.data-table tbody tr:hover { background: var(--gray-50); }
/* Zebra option */
.table-zebra tbody tr:nth-child(even) { background: var(--surface-alt); }
.table-zebra tbody tr:hover { background: var(--gray-50); }
/* Dense option */
.table-dense th, .table-dense td { padding: var(--space-1) var(--space-2); font-size: var(--fs-md); }
/* Keyboard-focusable rows (j/k nav + Enter-to-open lists) */
.table tr[tabindex]:focus-visible,
.data-table tr[tabindex]:focus-visible {
  outline: 2px solid var(--primary, var(--brand-accent));
  outline-offset: -2px;
  background: var(--surface-hover);
}

/* Responsive card-table transform — OPT-IN via .table-cards-mobile on the
   table. Cells need data-label="Column". Pattern from people app.css.    ── */
@media (max-width: 720px) {
  .table-cards-mobile { min-width: 0; }
  .table-cards-mobile thead { display: none; }
  .table-cards-mobile,
  .table-cards-mobile tbody,
  .table-cards-mobile tr,
  .table-cards-mobile td { display: block; width: 100%; }
  .table-cards-mobile tr {
    border-bottom: 1px solid var(--border);
    padding: var(--space-2-5) 0;
  }
  .table-cards-mobile td {
    border-bottom: 0;
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: var(--space-2-5);
    padding: 7px var(--space-3);
  }
  .table-cards-mobile td::before {
    content: attr(data-label);
    color: var(--text-muted);
    font-size: var(--fs-sm);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .06em;
  }
  .table-cards-mobile td:first-child::before { align-self: center; }
}

/* ── Cards ────────────────────────────────────────────────────────────────
   Default clips content; add .card-visible when the card hosts a select
   menu that cannot portal yet (per the select standard's overflow rules). */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-visible { overflow: visible; }
.card-header {
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-base); font-weight: 600; color: var(--text);
}
.card-body { padding: var(--space-4); }

/* ── Filter bar — 32px compact controls, stable widths ────────────────────
   Select standard: filter selects keep a stable min width (160–220px) and
   must not resize when the selected value changes.                       ── */
.filter-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}
.filter-bar .form-control,
.filter-bar select,
.filter-bar input[type="search"],
.filter-bar input[type="text"] {
  height: 32px; width: auto;
  font-size: var(--fs-md);
  min-width: 160px; max-width: 220px;
}
.filter-bar .btn { height: 32px; padding: 0 var(--space-3); font-size: var(--fs-sm); }
.filter-bar .ss-wrap { width: auto; min-width: 160px; max-width: 220px; }
.filter-bar .ss-trigger { height: 32px; font-size: var(--fs-md); }

/* ── Page header — title + count slot + actions row ───────────────────────
   Count slot renders the "Showing N of M" convention.                    ── */
.page-header {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: var(--space-2) var(--space-3);
  margin-bottom: var(--space-4);
}
.page-title { font-size: var(--fs-4xl); font-weight: 700; color: var(--text); margin: 0; }
.page-count { font-size: var(--fs-base); color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

/* ── Settings shell ───────────────────────────────────────────────────────
   Shared landing shell only. Apps own the actual settings panels, routes,
   permissions and validation.                                            ── */
.settings-shell {
  display: grid;
  grid-template-columns: minmax(160px, 220px) minmax(0, 1fr);
  gap: var(--space-4);
}
.settings-shell-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}
.settings-shell-nav-btn {
  width: 100%;
  min-height: 36px;
  padding: 0 var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}
.settings-shell-nav-btn:hover { background: var(--gray-100); color: var(--text); }
.settings-shell-nav-btn-active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
  box-shadow: var(--shadow);
}
.settings-shell-main { min-width: 0; }
.settings-shell-panels,
.settings-shell-panels .settings-shell-main {
  min-height: 0;
}
.settings-shell-content {
  min-height: 0;
  height: 100%;
  overflow: auto;
}
.settings-shell-heading {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
}
.settings-shell-heading h2 {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-3xl);
}
.settings-shell-kicker {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.settings-shell-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-3);
}
.settings-shell-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-height: 148px;
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.settings-shell-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-2);
}
.settings-shell-card-title {
  margin: 0;
  color: var(--text);
  font-size: var(--fs-lg);
  line-height: 1.3;
}
.settings-shell-chip {
  flex: 0 0 auto;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gray-100);
  color: var(--text-muted);
  font-size: var(--fs-sm);
  font-weight: 700;
}
.settings-shell-card-desc {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--fs-base);
  line-height: 1.45;
}
.settings-shell-meta {
  margin-top: auto;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
}
.settings-shell-card-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: var(--space-1);
}
.settings-shell-empty {
  padding: var(--space-6);
  color: var(--text-muted);
  text-align: center;
}
/* Shared Changelog panel */
.settings-changelog { display: grid; gap: var(--space-4); }
.settings-changelog-entry { border-bottom: 1px solid var(--border); padding-bottom: var(--space-3); }
.settings-changelog-entry:last-child { border-bottom: none; padding-bottom: 0; }
.settings-changelog-date { font-size: var(--fs-sm); color: var(--text-muted); }
.settings-changelog-title { font-size: var(--fs-lg); margin: 2px 0 var(--space-1); }
.settings-changelog-items { margin: 0; padding-left: 18px; font-size: var(--fs-md); color: var(--text); }
.settings-changelog-items li { margin: 2px 0; }
.settings-changelog-error { font-size: var(--fs-md); color: var(--text-muted); }

/* Shared System Health cards — badge-toned status per nobul-badge-standards */
.settings-health-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--space-3); }
.settings-health-card {
  display: flex; align-items: center; gap: var(--space-2-5);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-3);
}
.settings-health-dot { width: 10px; height: 10px; flex: 0 0 10px; border-radius: 999px; background: var(--gray-300); }
.settings-health-card[data-status="ok"] .settings-health-dot { background: var(--success); }
.settings-health-card[data-status="warn"] .settings-health-dot { background: var(--warning, var(--warn)); }
.settings-health-card[data-status="down"] .settings-health-dot { background: var(--danger); }
.settings-health-meta { min-width: 0; }
.settings-health-label { font-size: var(--fs-md); font-weight: 600; }
.settings-health-status { font-size: var(--fs-sm); color: var(--text-muted); }

/* Settings form kit — the ONLY sanctioned markup inside settings panels.
   Controls inside .settings-field-control use the existing contracts
   (.form-control, SearchableSelect/ssField, checkbox spec, .btn-*).
   Inline styles in settings panels are a contract violation. */
.settings-section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: var(--space-4);
  margin-bottom: var(--space-4);
}
.settings-section-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--space-2); margin-bottom: var(--space-3); }
.settings-section-head h3 { font-size: var(--fs-lg); margin: 0; }
.settings-section-note { font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }
.settings-section-toggle {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font: inherit; background: none; border: none; padding: 0; cursor: pointer;
  color: inherit;
}
.settings-section-toggle::before {
  content: ''; width: 8px; height: 8px; flex: 0 0 8px;
  border: solid var(--text-muted); border-width: 0 2px 2px 0;
  transform: rotate(-45deg); transition: transform var(--motion-med) var(--ease);
}
.settings-section-open > .settings-section-head .settings-section-toggle::before { transform: rotate(45deg); }
.settings-section-collapsible:not(.settings-section-open) > .settings-section-body { display: none; }
.settings-section-collapsible:not(.settings-section-open) > .settings-section-head { margin-bottom: 0; }
.settings-section-body { display: grid; gap: var(--space-3); }
.settings-field {
  display: grid; grid-template-columns: 220px minmax(0, 1fr);
  gap: var(--space-1) var(--space-4); align-items: start;
}
.settings-field-label { font-size: var(--fs-md); font-weight: 600; color: var(--text); padding-top: 7px; }
.settings-field-control { min-width: 0; }
.settings-field-help { grid-column: 2; font-size: var(--fs-sm); color: var(--text-muted); margin: 0; }
@media (max-width: 720px) {
  .settings-field { grid-template-columns: 1fr; }
  .settings-field-help { grid-column: 1; }
}

/* Settings dialog — THE one large settings surface (design: one consistent
   dialog, dimmed backdrop, app shell stays mounted underneath). Chrome is
   owned by NobulUI.openSettingsDialog; apps supply only panel content. */
.settings-dialog-overlay {
  position: fixed; inset: 0; z-index: var(--z-modal, 600);
  display: flex; align-items: center; justify-content: center;
  background: var(--overlay-bg);
}
.settings-dialog {
  display: flex; flex-direction: column;
  width: min(1200px, 96vw); height: min(860px, 92vh);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg); overflow: hidden;
}
.settings-dialog-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}
.settings-dialog-head h2 { font-size: var(--fs-xl); margin: 0; }
.settings-dialog-close {
  font: inherit; font-size: 20px; line-height: 1; cursor: pointer;
  background: none; border: none; color: var(--text-muted);
  padding: 4px 8px; border-radius: var(--radius-sm);
}
.settings-dialog-close:hover { background: var(--gray-100); color: var(--text); }
.settings-dialog-body { flex: 1; min-height: 0; overflow: hidden; padding: var(--space-4); }
.settings-dialog-body > .settings-shell-panels { height: 100%; }
.settings-dialog-body .settings-shell-nav { min-width: 0; min-height: 0; overflow-y: auto; }
.settings-dialog-body .settings-shell-nav-btn { flex-shrink: 0; }
.settings-dialog-body .settings-shell-main { overflow: hidden; }
.settings-dialog-body .settings-shell-content-modules { display: flex; flex-direction: column; overflow: hidden; }
.settings-dialog-body .settings-module-nav { flex-shrink: 0; }
.settings-dialog-body .settings-module-panel { flex: 1; min-height: 0; overflow: auto; }
@media (max-width: 720px) {
  .settings-dialog { width: 100vw; height: 100dvh; border-radius: 0; }
  .settings-dialog-body > .settings-shell-panels { grid-template-rows: auto minmax(0, 1fr); }
  .settings-dialog-body .settings-shell-nav { overflow-y: hidden; }
}

.settings-module-nav {
  display: flex;
  gap: 2px;
  margin-bottom: var(--space-4);
  padding-bottom: var(--space-2);
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--gray-300) transparent;
  border-bottom: 1px solid var(--border);
}
.settings-module-nav::-webkit-scrollbar,
.settings-shell-nav::-webkit-scrollbar { height: 4px; }
.settings-module-nav::-webkit-scrollbar-track,
.settings-shell-nav::-webkit-scrollbar-track { background: transparent; }
.settings-module-nav::-webkit-scrollbar-thumb,
.settings-shell-nav::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 9999px; }
.settings-module-nav-btn {
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  padding: 7px 14px;
  font: inherit;
  font-size: var(--fs-sm);
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.settings-module-nav-btn:hover { background: var(--gray-100); color: var(--text); }
.settings-module-panel { min-width: 0; }
/* Canonical active class; `.active` kept as a legacy alias until the apps'
   hand-rolled module navs are deleted (settings-unification phases 2-3). */
.settings-module-nav-btn-active,
.settings-module-nav-btn.active { background: var(--primary, var(--brand-accent)); color: #fff; }
.settings-module-nav-btn-active:hover,
.settings-module-nav-btn.active:hover { background: var(--primary, var(--brand-accent)); color: #fff; }
@media (max-width: 720px) {
  .settings-shell { grid-template-columns: 1fr; }
  .settings-shell-nav {
    flex-direction: row;
    overflow-x: auto;
    padding-bottom: var(--space-1);
    scrollbar-width: thin;
    scrollbar-color: var(--gray-300) transparent;
  }
  .settings-shell-nav-btn {
    width: auto;
    white-space: nowrap;
  }
}

/* ── Layout helpers emitted by ui.js skeleton builders ────────────────────
   (skelStatGrid/skelAnalytics render these grids; .skel-block is sized
   inline — the bare rule just anchors the class for the CSS contract.)   ── */
.skel-block { display: block; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); }
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-3); }

/* ── Header avatar menu (NobulUI.mountAvatarMenu) ──────────────────────────
   Chip lives in a dark brand-bar header; --nam-* vars default to translucent
   white so it matches the header's buttons (light border on dark). A
   light-header app overrides --nam-*. The popover drops onto the page and uses
   page tokens, so it is dark-mode correct. */
.nobul-avatar-menu { position: relative; display: inline-block; }
.nobul-avatar-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 230px;
  box-sizing: border-box; height: 32px; padding: 2px 8px 2px 2px; font: inherit; cursor: pointer;
  color: var(--nam-fg, #fff);
  background: var(--nam-bg, rgba(255, 255, 255, .10));
  border: 1px solid var(--nam-border, rgba(255, 255, 255, .20));
  border-radius: var(--radius-sm);
  transition: background .15s, border-color .15s;
}
.nobul-avatar-chip:hover {
  background: var(--nam-bg-hover, rgba(255, 255, 255, .18));
  border-color: var(--nam-border-hover, rgba(255, 255, 255, .34));
}
.nobul-avatar {
  flex: 0 0 auto; width: 26px; height: 26px; border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--nam-avatar-bg, rgba(255, 255, 255, .22));
  color: var(--nam-fg, #fff); font-size: 11px; font-weight: 700;
}
.nobul-avatar-id { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; line-height: 1.18; text-align: left; }
.nobul-avatar-name { font-size: 12.5px; font-weight: 650; max-width: 158px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nobul-avatar-email { font-size: 10.5px; opacity: .72; max-width: 158px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nobul-avatar-caret { flex: 0 0 auto; opacity: .7; margin-left: 1px; }
.nobul-avatar-popover {
  display: none; position: absolute; top: calc(100% + 6px); right: 0;
  min-width: 220px; padding: 12px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg); z-index: var(--z-confirm, 1900);
}
.nobul-avatar-popover.open { display: block; }
.nobul-avatar-role {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-muted);
}
.nobul-avatar-viewas { margin-top: 12px; }
.nobul-avatar-viewas[hidden] { display: none; }
.nobul-avatar-viewas-label { display: block; font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.nobul-avatar-viewas-select { width: 100%; }
.nobul-avatar-signout-row { margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--border); }
.nobul-avatar-signout {
  display: block; width: 100%; text-align: left; box-sizing: border-box;
  padding: 7px 8px; font: inherit; font-size: 13px; cursor: pointer;
  color: var(--text); background: none; border: none; border-radius: 6px; text-decoration: none;
  transition: background .12s, color .12s;
}
.nobul-avatar-signout:hover { background: var(--surface-alt); color: var(--danger); }

/* App switcher — header "Pulse" control as a split button. Two joined segments
   (main link + caret) using the same --nam-* header vars as the avatar chip,
   so it sits correctly on every app's dark header; the menu uses page tokens
   like the popover. .nobul-header-split is the same visual primitive for an
   app-owned main action + menu; apps can pair it with mountActionMenu. */
.nobul-appswitch,
.nobul-header-split { position: relative; display: inline-flex; align-items: stretch; height: 32px; }
.nobul-appswitch .nobul-appswitch-main,
.nobul-appswitch .nobul-appswitch-caret,
.nobul-header-split .nobul-header-split-main,
.nobul-header-split .nobul-header-split-caret {
  box-sizing: border-box; height: 32px; min-height: 32px;
  font: inherit; cursor: pointer; line-height: 1;
  color: var(--nam-fg, #fff);
  background: var(--nam-bg, rgba(255, 255, 255, .10));
  border: 1px solid var(--nam-border, rgba(255, 255, 255, .20));
  transition: background .15s, border-color .15s;
}
.nobul-appswitch-main,
.nobul-header-split-main {
  display: inline-flex; align-items: center;
  padding: 6px 12px; font-size: 13px; font-weight: 600;
  text-decoration: none;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm); border-right-width: 0;
}
.nobul-appswitch-caret,
.nobul-header-split-caret {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 8px; border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  border-left: 1px solid var(--nam-border, rgba(255, 255, 255, .28));
}
/* No other apps -> the main is a solo button (identical to the old link). */
.nobul-appswitch-main:only-child,
.nobul-header-split-main:only-child { border-radius: var(--radius-sm); border-right-width: 1px; }
.nobul-appswitch-main:hover,
.nobul-appswitch-caret:hover,
.nobul-header-split-main:hover,
.nobul-header-split-caret:hover { background: var(--nam-bg-hover, rgba(255, 255, 255, .18)); }
.nobul-header-split button:disabled { opacity: .5; cursor: not-allowed; }
.nobul-header-split .btn-loading { cursor: wait; }
.nobul-appswitch-caret svg,
.nobul-header-split-caret svg { opacity: .85; transition: transform .15s; }
.nobul-appswitch-caret[aria-expanded="true"] svg,
.nobul-header-split-caret[aria-expanded="true"] svg { transform: rotate(180deg); }

.nobul-appswitch-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0;
  min-width: 200px; padding: 6px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-lg, 12px);
  box-shadow: var(--shadow-lg); z-index: var(--z-confirm, 1900);
}
.nobul-appswitch-menu.open { display: block; }
.nobul-appswitch-menu-label {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--text-muted); padding: 4px 10px 6px;
}
.nobul-appswitch .nobul-appswitch-item {
  display: block; padding: 8px 10px; border-radius: 8px;
  color: var(--text); text-decoration: none; font-size: 13px; white-space: nowrap;
}
.nobul-appswitch-item:hover { background: var(--surface-alt); }

/* ===== Tooltip ==========================================================
   The hover/focus tooltip standard (lifted from the safety dashboard
   pills). Two tiers, one visual language:

   1. RICH panel — structured content (head row, uppercase section labels,
      message blocks). Markup via NobulUI.tooltip():
        <span class="nui-tip" tabindex="0">TRIGGER
          <span class="nui-tip-panel" role="tooltip">
            <span class="nui-tip-head"><span>TITLE</span>[badge]</span>
            <span class="nui-tip-label">SECTION</span>
            <span class="nui-tip-message">text</span>
          </span>
        </span>

   2. SIMPLE attribute tip — one-line hints via data-tip="text" on any
      element (replaces native title= tooltips). Same panel styling via
      ::after.

   Both show on hover AND keyboard focus, and are tokenised/dark-correct.
   NobulUI.initTooltips() flips either tier away from viewport edges via
   data-tip-place="below" / data-tip-align="left|right". */
.nui-tip { position: relative; display: inline-flex; cursor: help; }
.nui-tip:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
.nui-tip:hover, .nui-tip:focus { z-index: 30; }
.nui-tip-panel {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 6px);
  z-index: 40;
  display: block;
  width: min(380px, calc(100vw - 56px));
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-weight: 400;
  text-align: left;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s, visibility .12s;
}
.nui-tip:hover > .nui-tip-panel,
.nui-tip:focus > .nui-tip-panel,
.nui-tip:focus-within > .nui-tip-panel { opacity: 1; visibility: visible; }
.nui-tip[data-tip-place="below"] > .nui-tip-panel { top: calc(100% + 6px); bottom: auto; }
.nui-tip[data-tip-align="right"] > .nui-tip-panel { right: 0; left: auto; transform: none; }
.nui-tip[data-tip-align="left"] > .nui-tip-panel { left: 0; right: auto; transform: none; }
.nui-tip-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.nui-tip-head > span:first-child,
.nui-tip-label {
  display: block;
  color: var(--gray-500);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.nui-tip-label { margin-top: 8px; padding-top: 7px; border-top: 1px solid var(--gray-200); }
.nui-tip-label:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.nui-tip-message { display: block; margin-top: 3px; line-height: 1.45; white-space: normal; }
/* A panel that is only a message (a disabled reason) sizes to its text and
   centres over the trigger like a plain tip instead of opening a 380px box. */
.nui-tip-panel:not(:has(.nui-tip-head, .nui-tip-label)) { width: max-content; max-width: min(380px, calc(100vw - 56px)); text-align: center; }

[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% + 6px);
  z-index: 40;
  width: max-content;
  max-width: min(280px, calc(100vw - 56px));
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-size: 11.5px;
  font-weight: 500;
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .12s .05s, visibility .12s .05s;
}
[data-tip]:hover::after,
[data-tip]:focus-visible::after { opacity: 1; visibility: visible; }
[data-tip=""]::after { display: none; }
[data-tip-place="below"]::after { top: calc(100% + 6px); bottom: auto; }
[data-tip-align="right"]::after { right: 0; left: auto; transform: none; }
[data-tip-align="left"]::after { left: 0; right: auto; transform: none; }

/* Portal mode (initTooltips): the tip renders in a fixed float on <body>,
   escaping overflow clipping; the in-place CSS fallback display switches
   off so nothing renders twice. */
.nui-tips-js [data-tip]::after { content: none; }
.nui-tips-js .nui-tip > .nui-tip-panel { display: none; }
.nui-tip-float {
  position: fixed;
  z-index: 10000;
  display: none;
  max-width: min(280px, calc(100vw - 56px));
  padding: 6px 10px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
  text-align: center;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s;
}
.nui-tip-float.open { opacity: 1; }
/* Multi-line data-tip text keeps its line breaks and reads left-aligned. */
.nui-tip-float-multi {
  text-align: left;
  white-space: pre-line;
}
/* data-tip-title floats reuse the structured panel classes. */
.nui-tip-float > .nui-tip-head { margin-bottom: 3px; }
.nui-tip-float > .nui-tip-message {
  display: block;
  text-align: left;
  font-weight: 400;
  white-space: pre-line;
}
.nui-tip-float-rich {
  width: min(380px, calc(100vw - 56px));
  max-width: none;
  padding: 10px 12px;
  font-size: var(--fs-md);
  font-weight: 400;
  text-align: left;
}
/* Multi-line "Label: value" tips render as a two-column table; values sit
   flush right in tabular figures so amounts line up. */
.nui-tip-float-table { text-align: left; }
.nui-tip-table { display: grid; grid-template-columns: auto auto; column-gap: 14px; row-gap: 2px; align-items: baseline; }
.nui-tip-key { color: var(--gray-600); font-weight: 500; }
.nui-tip-val { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nui-tip-float-rich .nui-tip-table { margin-top: 4px; font-size: var(--fs-sm); }

/* ═══════════════════════════════════════════════════════════════════════════
   PATTERN LIBRARY — promoted from the review palettes (2026-09)
   Every class below ships with the package and is the shared standard; the
   palettes only compose them. Behaviour lives in ui.js (mountSegmented,
   mountTabs, mountAccordion, mountRating, mountPopup, mountPagination,
   mountTableSort, mountBulkSelect, mountReorder, mountDropzone,
   mountStepperInput, mountDateRange, mountNotificationBell, statusLine).
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Choice controls — checkbox / radio inside a labelled hit area ─────── */
.choice-list { display: grid; gap: 6px; }
.choice-control {
  display: inline-flex; align-items: center; gap: 10px;
  min-height: 40px; padding: 6px 4px;
  color: var(--text); cursor: pointer; font-size: var(--fs-base);
}
.choice-control.compact { min-height: 28px; padding: 3px 2px; font-size: var(--fs-md); }
.choice-control input[type="checkbox"]:not(.toggle-switch) { --cb-size: 20px; }
.choice-control.compact input[type="checkbox"]:not(.toggle-switch) { --cb-size: 16px; }
.choice-copy { min-width: 0; }
.choice-copy strong, .choice-copy span { display: block; }
.choice-copy strong { font-size: inherit; font-weight: 650; }
.choice-copy span { margin-top: 1px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 400; }
.choice-control.is-error { color: var(--danger); }
.choice-control.is-error input { border-color: var(--danger) !important; }
.choice-control:has(input:disabled) { cursor: not-allowed; opacity: .62; }
.choice-control input[type="radio"] {
  --radio-size: 20px;
  appearance: none; -webkit-appearance: none;
  width: var(--radio-size); height: var(--radio-size); min-width: var(--radio-size);
  margin: 0; border: 2px solid var(--gray-300); border-radius: 50%;
  background: var(--surface); cursor: pointer;
  box-shadow: inset 0 0 0 4px var(--surface);
}
.choice-control.compact input[type="radio"] { --radio-size: 16px; box-shadow: inset 0 0 0 3px var(--surface); }
.choice-control input[type="radio"]:checked { border-color: var(--primary, var(--brand-accent)); background: var(--primary, var(--brand-accent)); }
.choice-control input[type="radio"]:focus-visible { outline: 2px solid var(--primary, var(--brand-accent)); outline-offset: 2px; }
.choice-control input[type="checkbox"]:indeterminate { background: var(--primary, var(--brand-accent)); border-color: var(--primary, var(--brand-accent)); }
.choice-control input[type="checkbox"]:indeterminate::after {
  content: ''; position: absolute; top: 50%; left: 22%; right: 22%; height: 2px;
  border: 0; background: #fff; transform: translateY(-50%);
}
.radio-card {
  align-items: flex-start; width: min(100%, 440px); padding: 12px;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.radio-card:has(input:checked) { border-color: var(--primary, var(--brand-accent)); box-shadow: 0 0 0 2px var(--focus-ring-rgba, rgba(15,23,42,.12)); }
.switch-row {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px;
  max-width: 500px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px;
}
.switch-row label { min-width: 0; }

/* ── Segmented control — exclusive choice that takes effect immediately ── */
.segmented-control {
  --segment-count: 2; --segment-index: 0;
  position: relative; display: inline-grid;
  grid-template-columns: repeat(var(--segment-count), minmax(0, 1fr));
  width: fit-content; max-width: 100%; padding: 3px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-alt); box-shadow: inset 0 1px 2px rgba(15,23,42,.04);
}
.segmented-control[aria-disabled="true"] { opacity: .58; }
.segmented-option, .period-toggle-opt {
  position: relative; z-index: 1; min-height: 30px; min-width: 70px; padding: 0 12px;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-muted);
  cursor: pointer; font: inherit; font-size: var(--fs-md); font-weight: 650; white-space: nowrap;
}
.segmented-option:hover:not(:disabled), .period-toggle-opt:hover:not(:disabled) { color: var(--text); }
.segmented-option:focus-visible, .period-toggle-opt:focus-visible { outline: 2px solid var(--primary, var(--brand-accent)); outline-offset: 1px; }
.segmented-option[aria-pressed="true"], .period-toggle-opt[aria-pressed="true"] {
  background: var(--primary, var(--brand-accent)); color: var(--primary-foreground, #fff); box-shadow: var(--shadow);
}
.segmented-option:disabled, .period-toggle-opt:disabled { opacity: .42; cursor: not-allowed; }
.segmented-control.has-thumb .segmented-option[aria-pressed="true"],
.segmented-control.has-thumb .period-toggle-opt[aria-pressed="true"] { background: transparent; box-shadow: none; }
.segmented-option[data-tone="positive"][aria-pressed="true"] { background: var(--success-strong); }
.segmented-option[data-tone="warning"][aria-pressed="true"] { background: var(--warn-strong); }
.segmented-option[data-tone="negative"][aria-pressed="true"] { background: var(--danger); }
.segmented-thumb, .period-toggle-thumb {
  position: absolute; z-index: 0; top: 3px; bottom: 3px; left: 3px;
  width: calc((100% - 6px) / var(--segment-count));
  border-radius: 6px; background: var(--primary, var(--brand-accent)); box-shadow: 0 1px 3px rgba(15,23,42,.18);
  transform: translateX(calc(var(--segment-index) * 100%));
  transition: transform .18s ease; pointer-events: none;
}
.segmented-control.is-narrow { width: 100%; }
.segmented-control.is-narrow .segmented-option { min-width: 0; white-space: normal; line-height: 1.15; }

/* ── Rating scale — one required choice across five tones ─────────────── */
.rating-group { display: inline-grid; grid-template-columns: repeat(5, 40px); gap: 5px; max-width: 100%; }
.rating-option {
  display: grid; place-items: center; width: 40px; height: 40px; padding: 0;
  border: 2px solid var(--gray-200); border-radius: 8px; background: var(--surface);
  color: var(--text-muted); cursor: pointer; font: inherit; font-weight: 800;
}
.rating-option:nth-child(1) { --rating-tone: var(--danger); }
.rating-option:nth-child(2) { --rating-tone: var(--warn-strong); }
.rating-option:nth-child(3) { --rating-tone: var(--warn); }
.rating-option:nth-child(4) { --rating-tone: var(--success-strong); }
.rating-option:nth-child(5) { --rating-tone: var(--success); }
.rating-option:hover:not(:disabled) { border-color: var(--rating-tone); color: var(--rating-tone); }
.rating-option:focus-visible { outline: 2px solid var(--rating-tone); outline-offset: 2px; }
.rating-option[aria-checked="true"] { border-color: var(--rating-tone); background: var(--rating-tone); color: #fff; box-shadow: var(--shadow); }
.rating-group[aria-invalid="true"] .rating-option { border-color: var(--danger); }
.rating-group[aria-readonly="true"] { opacity: .78; }
.rating-group[aria-readonly="true"] .rating-option { cursor: default; }
.rating-scale-labels { display: flex; justify-content: space-between; width: 220px; max-width: 100%; margin-top: 5px; color: var(--text-muted); font-size: var(--fs-xs); }

/* ── Input shell — affixes, inline actions and the number stepper ─────── */
.input-shell {
  display: flex; align-items: center; min-width: 0; height: 40px;
  border: 1px solid var(--gray-200); border-radius: var(--radius); background: var(--surface); overflow: hidden;
}
.input-shell:focus-within { border-color: var(--primary, var(--brand-accent)); box-shadow: 0 0 0 2px var(--focus-ring-rgba, rgba(15,23,42,.12)); }
.input-shell .form-control { flex: 1; width: 1%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
.input-shell input[type="search"]::-webkit-search-cancel-button { display: none; appearance: none; }
.input-shell .form-control:focus { box-shadow: none; }
.input-affix { flex: 0 0 auto; padding: 0 10px; color: var(--text-muted); font-size: var(--fs-sm); font-weight: 650; }
.input-inline-action {
  flex: 0 0 auto; display: grid; place-items: center; width: 32px; height: 32px; margin-right: 3px; padding: 0;
  border: 0; border-radius: 6px; background: transparent; color: var(--text-muted); cursor: pointer;
}
.input-inline-action:hover { background: var(--surface-alt); color: var(--text); }
.input-inline-action:focus-visible { outline: 2px solid var(--primary, var(--brand-accent)); outline-offset: -1px; }
.input-inline-action svg { width: 15px; height: 15px; }
.input-inline-action.input-inline-text {
  display: inline-flex; width: auto; padding-inline: 8px; color: var(--primary, var(--brand-accent));
  font-size: var(--fs-sm); font-weight: 750; text-decoration: none; white-space: nowrap;
}
.input-inline-action.input-inline-text[aria-disabled="true"] { color: var(--text-muted); pointer-events: none; }
.input-stepper .form-control { text-align: center; appearance: textfield; -moz-appearance: textfield; }
.input-stepper .form-control::-webkit-inner-spin-button, .input-stepper .form-control::-webkit-outer-spin-button { margin: 0; appearance: none; }
.input-stepper .input-inline-action { width: 36px; }
.input-stepper .input-inline-action[disabled] { opacity: .4; cursor: not-allowed; }
.form-control-table { height: 28px; padding-inline: 8px; font-size: var(--fs-sm); }
textarea.form-control { line-height: 1.4; }
textarea.form-control[data-auto-expand] { overflow-y: hidden; }
.calculation-result { display: block; min-height: 14px; margin-top: 5px; color: var(--text); font-size: var(--fs-xs); font-weight: 750; }
.field-help { margin-top: 5px; color: var(--text-muted); font-size: var(--fs-xs); }
.required-flag { margin-left: 4px; color: var(--danger); font-size: var(--fs-xs); font-weight: 750; }

/* ── Verdict pills — Safety's saturated PASS / WARN / FAIL exception ────── */
.safety-verdict {
  display: inline-block; min-width: 36px; padding: 2px 4px; border-radius: 3px;
  font-family: var(--font-mono); font-size: 9px; font-weight: 800; line-height: 1.4; letter-spacing: .05em; text-align: center;
}
.safety-verdict-pass { background: var(--verdict-pass-bg); color: var(--verdict-pass-text); }
.safety-verdict-warn { background: var(--verdict-warn-bg); color: var(--verdict-warn-text); }
.safety-verdict-fail { background: var(--verdict-fail-bg); color: var(--verdict-fail-text); }
.safety-verdict-overall { min-width: 44px; padding: 3px 6px; border: 2px solid currentColor; font-size: 10px; }

/* ── App switcher on a light content surface ───────────────────────────── */
.surface-appswitch .nobul-appswitch-main,
.surface-appswitch .nobul-appswitch-caret { color: var(--text); background: var(--surface); border-color: var(--border); }
.surface-appswitch .nobul-appswitch-main:hover,
.surface-appswitch .nobul-appswitch-caret:hover { background: var(--surface-alt); }
.surface-appswitch .nobul-appswitch-caret { border-left-color: var(--border); }

/* ── Navigation — route links, ARIA tabs, workflow steps, accordion ────── */
.route-nav { display: flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface-alt); }
.route-link { padding: 8px 11px; border: 0; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; font: inherit; font-weight: 650; text-decoration: none; }
.route-link:hover { background: var(--surface-hover); }
.route-link[aria-current="page"] { color: var(--primary-foreground, #fff); background: var(--primary, var(--brand-accent)); }
.tab-list { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.tab-button { min-height: 38px; padding: 0 12px; border: 0; border-bottom: 3px solid transparent; background: transparent; color: var(--text); cursor: pointer; font: inherit; white-space: nowrap; }
.tab-button[aria-selected="true"] { color: var(--primary, var(--brand-accent)); border-bottom-color: var(--primary, var(--brand-accent)); font-weight: 750; }
.tab-button:focus-visible { outline: 2px solid var(--primary, var(--brand-accent)); outline-offset: -2px; }
.tab-panel { padding: 14px 4px 2px; }
.step-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); padding: 0; margin: 0; list-style: none; }
.step { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 8px; align-items: center; min-width: 0; color: var(--text-muted); }
.step:not(:last-child)::after { content: ""; position: absolute; top: 14px; left: 32px; right: 4px; height: 2px; background: var(--border); }
.step-number { z-index: 1; display: grid; place-items: center; width: 28px; height: 28px; border: 2px solid var(--gray-300); border-radius: 50%; background: var(--surface); font-weight: 800; }
.step strong { display: block; color: inherit; font-size: var(--fs-sm); }
.step small { display: block; font-size: var(--fs-xs); }
.step.complete { color: var(--success); }
.step.complete .step-number { color: #fff; border-color: var(--success); background: var(--success); }
.step.complete::after { background: var(--success); }
.step.current { color: var(--primary, var(--brand-accent)); }
.step.current .step-number { border-color: var(--primary, var(--brand-accent)); box-shadow: 0 0 0 3px var(--focus-ring-rgba, rgba(15,23,42,.12)); }
.step.error { color: var(--danger); }
.step.error .step-number { border-color: var(--danger); background: var(--danger-bg); }
.accordion { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); }
.accordion-item + .accordion-item { border-top: 1px solid var(--border); }
.accordion-trigger { width: 100%; min-height: 42px; padding: 9px 12px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0; background: var(--surface); color: var(--text); cursor: pointer; font: inherit; text-align: left; font-weight: 700; }
.accordion-trigger:hover { background: var(--surface-alt); }
.accordion-chevron { display: grid; place-items: center; width: 20px; height: 20px; flex: 0 0 20px; border: 1px solid var(--border); border-radius: 50%; background: var(--surface-alt); color: var(--text-muted); }
.accordion-chevron svg { display: block; width: 16px; height: 16px; transform-origin: center; transition: transform var(--motion-fast, .15s) var(--ease); }
.accordion-trigger[aria-expanded="true"] .accordion-chevron svg { transform: rotate(90deg); }
.accordion-panel { padding: 0 12px 12px; color: var(--text-muted); }
.disclosure-panel { margin-top: 8px; padding: 9px 10px; border-left: 3px solid var(--primary, var(--brand-accent)); border-radius: 0 7px 7px 0; background: var(--surface-alt); color: var(--text-muted); font-size: var(--fs-sm); }

/* ── Filters — search field, compact pickers, popups, chips ────────────── */
.filter-bar.filter-bar-panel { align-items: end; padding: 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-alt); margin-bottom: 0; }
.search-field { position: relative; flex: 1 1 260px; min-width: 180px; }
.search-field input { padding-right: 38px; }
.search-clear { position: absolute; right: 4px; bottom: 4px; width: 24px; height: 24px; padding: 0; border: 0; border-radius: 5px; background: transparent; cursor: pointer; color: var(--text-muted); }
.search-clear:hover { background: var(--surface-hover); color: var(--text); }
.search-field input[type="search"]::-webkit-search-cancel-button { display: none; appearance: none; }
.compact-field { display: grid; gap: 3px; min-width: 120px; }
.compact-field > span { color: var(--text-muted); font-size: var(--fs-xs); font-weight: 700; }
.compact-picker { position: relative; }
.picker-trigger { width: 100%; justify-content: space-between; }
.picker-menu, .saved-menu {
  position: fixed; z-index: var(--z-dropdown, 1800); top: var(--popup-top, 0); left: var(--popup-left, 0);
  min-width: 190px; max-width: calc(100vw - 24px); max-height: calc(100vh - 24px); overflow-y: auto;
  padding: 5px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); box-shadow: var(--shadow-lg);
}
.saved-menu { min-width: 230px; }
.picker-option, .menu-item { width: 100%; padding: 8px 9px; border: 0; border-radius: 6px; background: transparent; color: var(--text); cursor: pointer; font: inherit; text-align: left; }
.picker-option:hover, .picker-option[aria-selected="true"], .menu-item:hover { background: var(--surface-hover); }
.picker-option[aria-selected="true"]::after { content: "✓"; float: right; color: var(--primary, var(--brand-accent)); }
.saved-view { position: relative; }
.menu-item[aria-checked="true"]::before { content: "✓ "; color: var(--primary, var(--brand-accent)); }
.chip-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.filter-chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 3px 4px 3px 9px;
  border: 1px solid color-mix(in srgb, var(--primary, var(--brand-accent)) 35%, var(--border)); border-radius: 999px;
  background: color-mix(in srgb, var(--primary, var(--brand-accent)) 8%, var(--surface)); color: var(--text); font-size: var(--fs-sm);
}
.filter-chip button { display: grid; place-items: center; width: 20px; height: 20px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.filter-chip button:hover { background: color-mix(in srgb, var(--primary, var(--brand-accent)) 14%, transparent); }
.text-button { padding: 4px 5px; border: 0; background: transparent; color: var(--primary, var(--brand-accent)); cursor: pointer; font: inherit; font-weight: 700; }
.option-button-group { display: flex; flex-wrap: wrap; gap: 7px; }

/* ── Tables — sort headers, actionable rows, bulk bar, pagination, sticky ─ */
.table-sort { display: inline-flex; align-items: center; gap: 5px; padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; font-weight: 700; text-transform: inherit; letter-spacing: inherit; }
.sort-glyph { width: 11px; color: var(--gray-400); }
th[aria-sort="ascending"] .sort-glyph::after { content: "↑"; color: var(--primary, var(--brand-accent)); }
th[aria-sort="descending"] .sort-glyph::after { content: "↓"; color: var(--primary, var(--brand-accent)); }
th[aria-sort="none"] .sort-glyph::after { content: "↕"; }
.actionable-row { cursor: pointer; }
.actionable-row:hover td { background: var(--surface-hover); }
.actionable-row:focus-visible { outline: 2px solid var(--primary, var(--brand-accent)); outline-offset: -2px; }
.cell-sub { display: block; margin-top: 2px; color: var(--text-muted); font-size: var(--fs-base); }
.row-actions { display: flex; justify-content: flex-end; gap: 5px; }
.table-editor { width: 100%; min-width: 96px; height: 28px; padding: 0 7px; border: 1px solid var(--gray-200); border-radius: 5px; background: var(--surface); color: var(--text); font: inherit; }
.table-editor:focus { outline: 2px solid var(--primary, var(--brand-accent)); outline-offset: 1px; }
.bulk-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 7px 10px; color: #fff; background: var(--brand-nav, var(--gray-800)); }
.bulk-bar[hidden] { display: none; }
.pagination { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; align-items: center; padding: 10px; border-top: 1px solid var(--border); }
.page-buttons { display: flex; max-width: 100%; gap: 4px; overflow-x: auto; }
.page-button { flex: 0 0 32px; }
.page-button[aria-current="page"], .btn[aria-current="page"] { color: var(--primary-foreground, #fff); border-color: var(--primary, var(--brand-accent)); background: var(--primary, var(--brand-accent)); }
.sticky-wrap { overflow-x: auto; }
.table-sticky-first .col-sticky { position: sticky; left: 0; z-index: 1; background: var(--surface); box-shadow: 6px 0 10px -8px rgba(15,23,42,.45); }
.table-density-compact th, .table-density-compact td { padding-top: 5px; padding-bottom: 5px; }
.table-density-compact .cell-sub { display: none; }
.table-demo { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }

/* ── Status line — idle / busy / saved / warning / error beside a form ─── */
.status-line { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; padding: 5px 10px; border-radius: 8px; font-size: var(--fs-md); font-weight: 600; }
.status-line.block { display: flex; min-height: 40px; padding: 9px 10px; font-size: inherit; font-weight: inherit; }
.status-line.muted { background: var(--surface-alt); color: var(--text-muted); }
.status-line.busy { background: var(--info-bg); color: var(--badge-info-text); }
.status-line.success { background: var(--success-bg); color: var(--badge-success-text); }
.status-line.warning { background: var(--warn-bg); color: var(--warn-text); }
.status-line.error { background: var(--danger-bg); color: var(--badge-danger-text); }
.status-line .text-button { color: inherit; font-weight: 700; text-decoration: underline; }
.status-line .hint { color: inherit; opacity: .8; }

/* ── Notification bell and inbox (on the shared action menu) ───────────── */
.bell-button { position: relative; }
.bell-button svg { width: 18px; height: 18px; }
.bell-badge { position: absolute; top: -5px; right: -5px; display: grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; background: var(--danger); color: #fff; font-size: 10px; font-weight: 800; line-height: 1; }
.bell-badge[hidden] { display: none; }
.inbox-menu { min-width: 340px; }
.inbox-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 12px 6px; color: var(--text-muted); font-size: var(--fs-md); }
.inbox-item { display: grid; grid-template-columns: 10px minmax(0, 1fr); gap: 8px; align-items: start; white-space: normal; text-align: left; }
.inbox-item strong { display: block; font-weight: 500; }
.inbox-item.unread strong { font-weight: 700; }
.inbox-item small { display: block; margin-top: 1px; color: var(--text-muted); font-size: var(--fs-sm); }
.inbox-dot { width: 8px; height: 8px; margin-top: 6px; border-radius: 50%; background: var(--primary, var(--brand-accent)); visibility: hidden; }
.inbox-item.unread .inbox-dot { visibility: visible; }

/* ── Drawer placement for openDialog({ placement: 'drawer' }) ──────────── */
.dialog-overlay.dialog-drawer { justify-content: flex-end; align-items: stretch; }
.dialog-overlay.dialog-drawer .dialog-box { width: min(520px, 94vw) !important; max-height: none !important; height: 100%; border-radius: 0; border-left: 1px solid var(--border); animation: dialog-drawer-in .2s var(--ease); }
@keyframes dialog-drawer-in { from { transform: translateX(30px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .dialog-overlay.dialog-drawer .dialog-box { animation: none; } }

/* ── Uploads — dropzone, file rows, progress ───────────────────────────── */
.dropzone { min-height: 140px; width: 100%; padding: 18px; display: grid; place-items: center; gap: 5px; border: 2px dashed var(--gray-300); border-radius: 11px; background: var(--surface-alt); color: var(--text-muted); cursor: pointer; font: inherit; text-align: center; }
.dropzone:hover, .dropzone.is-dragover { color: var(--primary, var(--brand-accent)); border-color: var(--primary, var(--brand-accent)); background: color-mix(in srgb, var(--primary, var(--brand-accent)) 6%, var(--surface)); }
.dropzone:focus-visible { outline: 3px solid var(--primary, var(--brand-accent)); outline-offset: 3px; }
.dropzone:disabled { opacity: .5; cursor: not-allowed; }
.dropzone[aria-invalid="true"] { border-color: var(--danger); }
.dropzone strong { color: var(--text); }
.file-list { display: grid; gap: 7px; }
.file-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 9px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.file-row strong, .file-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row small { color: var(--text-muted); }
.file-state { display: flex; align-items: center; gap: 6px; font-size: var(--fs-sm); font-weight: 750; }
.file-state.success { color: var(--success); }
.file-state.failure { color: var(--danger); }
.progress-track { height: 7px; overflow: hidden; border-radius: 999px; background: var(--gray-200); }
.progress-track > span { display: block; height: 100%; border-radius: inherit; background: var(--primary, var(--brand-accent)); transition: width .25s var(--ease); }

/* ── Reorder — drag handle plus explicit move buttons ──────────────────── */
.reorder-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.reorder-item { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 48px; padding: 7px 8px; border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.reorder-item.is-dragging { opacity: .45; }
.reorder-item.is-target { border-top: 3px solid var(--primary, var(--brand-accent)); }
.drag-handle { display: grid; place-items: center; width: 28px; height: 28px; color: var(--text-muted); cursor: grab; user-select: none; }
.drag-handle:hover { color: var(--text); }
.drag-handle:active { cursor: grabbing; }
.move-actions { display: flex; gap: 4px; }
.reorder-save-state { min-height: 32px; display: flex; align-items: center; gap: 8px; color: var(--text-muted); }
.reorder-save-state.error { color: var(--danger); }

/* ── Feedback — banners, state cards, metric cards ─────────────────────── */
.banner { display: flex; align-items: flex-start; gap: 9px; padding: 10px 12px; border: 1px solid var(--banner-tone, var(--border)); border-radius: 9px; }
.banner-icon { position: relative; display: block; width: 20px; height: 20px; flex: 0 0 20px; margin-top: 1px; border-radius: 50%; background: #fff; color: var(--banner-tone, var(--text-muted)); }
.banner-icon svg { position: absolute; top: 50%; left: 50%; display: block; width: 24px; height: 24px; max-width: none; transform: translate(-50%, -50%); }
.banner strong { display: block; }
.banner p { margin: 2px 0 0; font-size: var(--fs-sm); }
.banner.info { --banner-tone: var(--info); color: var(--badge-info-text); background: var(--info-bg); }
.banner.success { --banner-tone: var(--success); color: var(--badge-success-text); background: var(--success-bg); }
.banner.warning { --banner-tone: var(--warn-strong); color: var(--warn-text); background: var(--warn-bg); }
.banner.danger { --banner-tone: var(--danger); color: var(--badge-danger-text); background: var(--danger-bg); }
.state-card { min-height: 180px; display: grid; place-items: center; padding: 18px; border: 1px solid var(--border); border-radius: 9px; text-align: center; }
.state-card h4 { margin: 6px 0 3px; }
.state-card p { max-width: 320px; margin: 0 0 10px; color: var(--text-muted); }
.skeleton-card { display: grid; gap: 9px; padding: 12px; border: 1px solid var(--border); border-radius: 9px; }
.skel-line { height: 11px; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.metric-card { padding: 14px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.metric-card span, .metric-card small { display: block; color: var(--text-muted); }
.metric-card strong { display: block; margin: 4px 0 2px; font-size: var(--fs-3xl); }
@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .step-list { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 12px; }
}
