/* ═══════════════════════════════════════════════════════════════
   Interior Moderna — Modern Theme
   Ultra-clean, architectural ops dashboard redesign
   Loaded last — overrides all prior stylesheets
   ═══════════════════════════════════════════════════════════════ */

/* ── Design tokens ── */
:root {
  /* Content backgrounds — warm off-white */
  --bg: #f5f4ef;
  --surface: #ffffff;
  --surface-2: #efede8;
  --surface-3: #e7e5e0;

  /* Borders */
  --border: #e3e1db;
  --border-hover: #cac8c2;

  /* Text */
  --text: #181816;
  --text-muted: #6b6963;
  --text-dim: #a09d97;

  /* Accent — warm tan */
  --accent: #a67c52;
  --accent-dim: rgba(166, 124, 82, 0.10);

  /* Status */
  --green: #16a34a;
  --green-dim: rgba(22, 163, 74, 0.09);
  --red: #dc2626;
  --red-dim: rgba(220, 38, 38, 0.08);
  --yellow: #c97a06;
  --yellow-dim: rgba(201, 122, 6, 0.09);
  --blue: #2563eb;
  --blue-dim: rgba(37, 99, 235, 0.08);
  --purple: #7c3aed;
  --purple-dim: rgba(124, 58, 237, 0.08);
  --emerald: #059669;
  --emerald-dim: rgba(5, 150, 105, 0.09);
  --orange: #ea6c00;
  --orange-dim: rgba(234, 108, 0, 0.09);

  /* Radius */
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05), 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.07), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 8px 28px rgba(0, 0, 0, 0.09), 0 2px 6px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.13), 0 4px 16px rgba(0, 0, 0, 0.07);

  /* Sidebar tokens — light mode: white panel matching main content */
  --sidebar-bg: var(--surface);
  --sidebar-border: var(--border);
  --sidebar-text: var(--text-muted);
  --sidebar-text-hover: var(--text);
  --sidebar-text-active: var(--text);
  --sidebar-hover-bg: var(--surface-2);
  --sidebar-active-bg: var(--surface-2);
  --sidebar-section-title: var(--text-dim);

  /* Alias fixes — maps legacy/view-specific var names → design tokens */
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);
  --surface-1: var(--surface);
  --surface-raised: var(--surface);
  --surface-alt: var(--surface-2);       /* legacy dark-surface alias */
  --bg-hover: var(--surface-2);
  --hover-bg: var(--surface-2);          /* analytics-dash chart track — also override in dark */
  --card-bg: var(--surface);
  --bg-secondary: var(--surface-2);
  --primary: var(--accent);
  --danger: var(--red);
  --danger-dim: var(--red-dim);
  --success: var(--green);
  --warning: var(--yellow);
  --info: var(--blue);
  --bg-card: var(--surface);
  --bg-primary: var(--bg);
  --bg-tertiary: var(--surface-3);
  --bg2: var(--surface-2);
  --border-color: var(--border);
  --border-light: var(--border);
  --danger-color: var(--red);
  --surface-hover: var(--surface-2);

  /* Semantic status dims (aliases to the color dims) */
  --success-dim: var(--green-dim);
  --warning-dim: var(--yellow-dim);
  --info-dim: var(--blue-dim);

  /* ── Spacing scale (4px base) ──
     The app previously had NO spacing tokens — every padding/margin was a
     magic number, which is the main reason rhythm drifts view to view. New
     work should reach for these; existing magic numbers get migrated over time. */
  --space-0: 0;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;

  /* ── Type scale ──
     Note: --text/--text-muted/--text-dim above are COLORS (legacy naming).
     These --fs-* tokens are the font-SIZE scale. */
  --fs-2xs: 10px;
  --fs-xs: 11px;
  --fs-sm: 12px;
  --fs-base: 13px;
  --fs-md: 14px;
  --fs-lg: 16px;
  --fs-xl: 18px;
  --fs-2xl: 22px;
  --fs-3xl: 28px;

  /* ── Font weights ── */
  --fw-normal: 400;
  --fw-medium: 500;
  --fw-semibold: 600;
  --fw-bold: 700;

  /* ── Line heights ── */
  --leading-tight: 1.2;
  --leading-normal: 1.45;
  --leading-relaxed: 1.6;

  /* ── Motion tokens ──
     The app had ~14 distinct one-off transition durations + duplicate easings.
     These are the canonical set; new work references them. */
  --dur-fast: 0.12s;
  --dur: 0.18s;
  --dur-slow: 0.3s;
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-decel: cubic-bezier(0.32, 0.72, 0, 1);
}

/* ─────────────────────────────────────────────────────────────
   GLOBAL BASE
   ───────────────────────────────────────────────────────────── */

body {
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ─────────────────────────────────────────────────────────────
   LAYOUT
   ───────────────────────────────────────────────────────────── */

.app {
  grid-template-columns: 224px 1fr;
  grid-template-rows: auto minmax(0, 1fr);
}

/* Hide mobile bottom nav on desktop — mobile.css (media-gated) re-shows it on ≤768px */
.mobile-bottom-nav {
  display: none;
}

/* ─────────────────────────────────────────────────────────────
   HEADER
   ───────────────────────────────────────────────────────────── */

.header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  padding: 8px 20px;
  min-height: 52px;
  height: auto;
}

.header-left {
  flex: 0 1 auto;
  min-width: 0;
  gap: 12px;
}

.header-left > div {
  min-width: 0;
}

.header-right {
  flex: 1 1 720px;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 10px;
}

.header-status-group,
.header-action-group,
.header-account-group {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.header-status-group {
  flex: 1 1 420px;
}

.header-action-group,
.header-account-group {
  flex: 0 1 auto;
}

.logo {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2.2px;
  text-transform: uppercase;
  color: var(--text);
  white-space: nowrap;
}

.logo-sub {
  font-size: 9px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 500;
  margin-top: 2px;
  white-space: nowrap;
}

.refresh-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 5px 11px;
  transition: all 0.14s ease;
  letter-spacing: 0;
}

.refresh-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}

.sync-now-btn {
  background: transparent;
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--blue);
}

.sync-now-btn:hover {
  background: var(--blue-dim);
  border-color: var(--blue);
}

.sync-status {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 10.5px;
  color: var(--text-dim);
  gap: 5px;
  white-space: nowrap;
}

.sync-dot {
  width: 5px;
  height: 5px;
}

.notification-bell-container {
  display: flex;
  align-items: center;
}

.notification-bell-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  flex-shrink: 0;
}

.notification-badge {
  top: -2px;
  right: -1px;
}

.notification-panel {
  width: min(360px, calc(100vw - 24px));
  max-width: calc(100vw - 24px);
}

.header-freshness-wrap {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  white-space: nowrap;
}

.header-freshness-label {
  font-size: 11px;
  color: var(--text-muted);
}

#data-freshness-dot,
.header-freshness-dot {
  width: 8px;
  height: 8px;
  min-width: 8px;
  min-height: 8px;
  border-radius: 50%;
  display: block;
  background: #6b7280;
  transition: background 0.3s;
  flex-shrink: 0;
}

.freshness-tooltip,
.health-popover,
.api-health-panel {
  max-width: calc(100vw - 24px);
}

.freshness-tooltip {
  width: min(320px, calc(100vw - 24px));
}

.live-indicator {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  gap: 5px;
  font-size: 10.5px;
  color: var(--text-dim);
  white-space: nowrap;
}

.live-indicator.active {
  border-color: rgba(22, 163, 74, 0.18);
}

.live-indicator.refreshing {
  border-color: rgba(166, 124, 82, 0.2);
}

.health-dot-wrap {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  flex-shrink: 0;
}

.health-dot {
  width: 8px;
  height: 8px;
}

.api-health-wrap {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.api-health-panel {
  width: min(440px, calc(100vw - 24px));
}

/* ═══════════════════════════════════════════════════════════
   R1 DESIGN — Unified header status rail
   The freshness / sync / live / health / API indicators were six
   separate floating pills, reading as a scattered row of "rainbow"
   dots. Group them into one calm segmented instrument rail: a single
   hairline-bordered surface with thin dividers between segments.
   Status colour stays on the inner dots (where it carries meaning).
   Visual only — no markup or behaviour change. Desktop only; the
   whole group is hidden under 768px (mobile.css).
   ═══════════════════════════════════════════════════════════ */
.header-status-group {
  flex: 0 1 auto;
  gap: 0;
  flex-wrap: nowrap;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}
.header-status-group > .notification-bell-container,
.header-status-group > .header-freshness-wrap,
.header-status-group > .sync-status,
.header-status-group > .live-indicator,
.header-status-group > .health-dot-wrap,
.header-status-group > .api-health-wrap {
  border: none;
  background: transparent;
  box-shadow: none;
  min-height: 30px;
  border-radius: 999px;
}
/* the bell / health are bordered circles in their own right — flatten
   them into the rail too */
.header-status-group .notification-bell-btn,
.header-status-group > .health-dot-wrap {
  border: none;
  background: transparent;
  box-shadow: none;
}
/* hairline dividers between segments (every segment after the first) */
.header-status-group > .header-freshness-wrap,
.header-status-group > .sync-status,
.header-status-group > .live-indicator,
.header-status-group > .health-dot-wrap,
.header-status-group > .api-health-wrap {
  border-left: 1px solid var(--border);
}

/* Sign out button */
.refresh-btn,
.sign-out-btn {
  min-height: 34px;
  border-radius: 6px;
  font-size: 10.5px;
  padding: 4px 10px;
  white-space: nowrap;
}

.shell-search-btn {
  gap: 6px;
  display: inline-flex;
  align-items: center;
}

.theme-toggle-btn {
  width: 34px;
  height: 34px;
}

.user-info {
  min-height: 34px;
  padding-left: 12px;
  gap: 8px;
}

.view-as-switcher {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
}

.view-mode-indicator {
  min-height: 34px;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────
   SIDEBAR — DARK
   ───────────────────────────────────────────────────────────── */

.sidebar {
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 0 0 28px;
  overflow-y: auto;
}

.sidebar > .nav-section:first-of-type {
  margin-top: 4px;
}

/* Nav section containers */
.nav-section {
  margin-bottom: 2px;
}

/* Section header (collapsible title row) */
.nav-section-header {
  padding: 5px 16px;
  transition: background 0.14s;
}

.nav-section-header:hover {
  background: rgba(255, 255, 255, 0.03);
}

.nav-section-title {
  font-size: 9.5px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--sidebar-section-title);
  padding: 0;
  margin: 0;
}

.nav-section-arrow {
  color: var(--sidebar-section-title);
  font-size: 8px;
}

/* Section items container */
.nav-section-items {
  padding: 1px 10px;
}

.nav-section-items.collapsed {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* Nav items */
.nav-item {
  color: var(--sidebar-text);
  padding: 6px 10px;
  border-radius: 6px;
  gap: 9px;
  font-size: 12.5px;
  margin: 1px 0;
  transition: background 0.12s, color 0.12s;
}

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

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  font-weight: 500;
}

.nav-item.active::before {
  background: var(--accent);
  left: -10px;
  width: 2.5px;
  border-radius: 0 2px 2px 0;
}

.nav-item .icon {
  font-size: 13px;
  opacity: 0.65;
  width: 17px;
}

.nav-item.active .icon {
  opacity: 1;
}

/* Nav badges */
.nav-item .badge {
  background: var(--red-dim);
  color: var(--red);
  border-radius: 8px;
  font-size: 9.5px;
  padding: 1px 6px;
}

.nav-item .badge.green {
  background: var(--green-dim);
  color: var(--green);
}

/* Pinned section */
.nav-section-pinned {
  border-bottom: 1px solid var(--sidebar-border);
  padding-bottom: 6px;
  margin-bottom: 6px;
}

.nav-section-pinned .nav-section-title {
  color: rgba(166, 124, 82, 0.6);
}

/* Dark sidebar scrollbar */
.sidebar::-webkit-scrollbar {
  width: 4px;
}
.sidebar::-webkit-scrollbar-thumb {
  background: #2a2a27;
  border-radius: 2px;
}
.sidebar::-webkit-scrollbar-thumb:hover {
  background: #3a3a37;
}

/* ─────────────────────────────────────────────────────────────
   MAIN CONTENT AREA
   ───────────────────────────────────────────────────────────── */

.main {
  background: var(--bg);
  padding: 22px 24px;
  padding-bottom: 80px;
}

/* ─────────────────────────────────────────────────────────────
   PAGE HEADER
   ───────────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 18px;
}

.page-header--compact {
  margin-bottom: 12px;
}

.page-title {
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 3px;
  font-weight: 400;
  letter-spacing: 0;
}

.compact-copy-hidden {
  display: none !important;
}

/* Data freshness bar */
.data-freshness {
  font-size: 10.5px;
  margin: -2px 0 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  letter-spacing: 0;
}

/* ─────────────────────────────────────────────────────────────
   STAT CARDS
   ───────────────────────────────────────────────────────────── */

.stats-row {
  gap: 10px;
  margin-bottom: 18px;
}

/* KPI card grid — base layout. Several views inject their own (often unscoped)
   .kpi-grid rule, so a view loaded BEFORE one of those would lose its grid and
   stack the cards vertically. This base rule guarantees the grid everywhere;
   per-view injected styles still override gap/margin. (mobile.css narrows the
   column count under media queries.) */
.kpi-grid { display: grid; gap: var(--space-4); }
.kpi-grid-3 { grid-template-columns: repeat(3, 1fr); }
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-5 { grid-template-columns: repeat(5, 1fr); }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.stat-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.stat-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.1;
}

.stat-detail {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 5px;
}

/* ─────────────────────────────────────────────────────────────
   TABLE
   ───────────────────────────────────────────────────────────── */

.table-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}

th {
  background: var(--surface-2);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
}

th:hover {
  color: var(--text-muted);
}

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

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

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

/* ─────────────────────────────────────────────────────────────
   STATUS PILLS / BADGES
   ───────────────────────────────────────────────────────────── */

.pill {
  padding: 3px 8px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.2px;
  display: inline-block;
}

/* Container Ship Hold picklists — auto-created from a container receive
   close, units are pre-ordered + need to ship today. Orange = urgency
   (matches the warning palette without screaming red). 2026-05-26. */
.pl-ship-hold-pill {
  background: #ea580c;
  color: #fff;
  margin-left: 6px;
}
[data-theme="dark"] .pl-ship-hold-pill {
  background: #f97316;
  color: #fff;
}

/* ─────────────────────────────────────────────────────────────
   TOOLBAR / FILTERS
   ───────────────────────────────────────────────────────────── */

.toolbar {
  gap: 8px;
  margin-bottom: 14px;
}

.search-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  padding: 7px 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
  color: var(--text);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.10);
  outline: none;
}

.filter-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 13px;
  transition: all 0.14s;
}

.filter-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}

.filter-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

.filter-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--text);
  padding: 7px 12px;
  outline: none;
  transition: border-color 0.14s;
}

.filter-select:focus {
  border-color: var(--border-hover);
}

.form-input {
  font-size: 13px;
}

@media (max-width: 768px) {
  .search-input,
  .filter-select,
  .form-input {
    font-size: 16px !important;
  }
}

/* Toggle group */
.toggle-group {
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow: hidden;
}

.toggle-btn {
  background: var(--surface);
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 500;
  padding: 6px 13px;
  border-right: 1px solid var(--border);
  transition: all 0.14s;
}

.toggle-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.toggle-btn.active {
  background: var(--text);
  color: var(--surface);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────────────────────── */

.action-btn {
  background: var(--text);
  border: 1px solid var(--text);
  color: var(--surface);
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0;
  cursor: pointer;
  transition: all 0.14s ease;
}

.action-btn:hover {
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* Expand button in table rows */
.expand-btn {
  border-radius: 4px;
  color: var(--text-dim);
  transition: all 0.14s;
}

.expand-btn:hover {
  background: var(--surface-2);
  color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────
   PAGINATION
   ───────────────────────────────────────────────────────────── */

.pagination {
  padding: 11px 14px;
  font-size: 11.5px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.pagination-btns button {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 500;
  padding: 4px 11px;
  transition: all 0.14s;
}

.pagination-btns button:hover:not(:disabled) {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}

/* ─────────────────────────────────────────────────────────────
   LOADING / SPINNER
   ───────────────────────────────────────────────────────────── */

.spinner {
  border-color: var(--border);
  border-top-color: var(--accent);
  width: 18px;
  height: 18px;
}

/* Skeleton shimmer — warmer tones */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
}

/* ─────────────────────────────────────────────────────────────
   SCROLLBARS (content area)
   ───────────────────────────────────────────────────────────── */

::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: #d4d1cb;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: #b8b5af;
}

/* ─────────────────────────────────────────────────────────────
   LOGIN SCREEN
   ───────────────────────────────────────────────────────────── */

.login-overlay {
  background: #0f0f0e;
}

.login-card {
  background: #1a1a18;
  border: 1px solid #2a2a27;
  border-radius: 14px;
  padding: 44px 40px;
  width: 360px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

.login-logo {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: #f0ede8;
  margin-bottom: 4px;
}

.login-subtitle {
  font-size: 11px;
  letter-spacing: 0.8px;
  color: #5a5a57;
  text-transform: uppercase;
  margin-bottom: 32px;
}

.login-card input[type="password"] {
  background: #111110;
  border: 1px solid #2a2a27;
  border-radius: 8px;
  color: #f0ede8;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.login-card input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.15);
}

.login-card input[type="password"]::placeholder {
  color: #3a3a37;
  letter-spacing: 3px;
}

.login-card button {
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  transition: opacity 0.14s, transform 0.14s;
}

.login-card button:hover:not(:disabled) {
  opacity: 0.92;
  transform: translateY(-1px);
}

.login-error {
  color: #f87171;
}

/* ─────────────────────────────────────────────────────────────
   NOTIFICATION BELL (header)
   ───────────────────────────────────────────────────────────── */

/* .jarvis-notification-bell — full definition later in file (line ~1263) */

/* ─────────────────────────────────────────────────────────────
   HEALTH / STATUS DOTS (header)
   ───────────────────────────────────────────────────────────── */

.health-popover {
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

.freshness-tooltip {
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  border-color: var(--border);
}

/* ─────────────────────────────────────────────────────────────
   CRITICAL ALERT BANNER
   ───────────────────────────────────────────────────────────── */

#critical-alerts-banner {
  background: #991b1b;
}

/* ─────────────────────────────────────────────────────────────
   MOBILE
   ───────────────────────────────────────────────────────────── */

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

  .sidebar {
    width: 256px;
    box-shadow: 4px 0 32px rgba(0, 0, 0, 0.6);
  }

  .main {
    padding: 14px;
  }
}

/* ─────────────────────────────────────────────────────────────
   MODAL / OVERLAY PANELS
   ───────────────────────────────────────────────────────────── */

.modal-backdrop {
  background: rgba(0, 0, 0, 0.5);
}

.modal {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────────────────
   VIEW FADE-IN ANIMATION
   ───────────────────────────────────────────────────────────── */

/* viewFadeIn — defined once later in "BETTER PAGE TRANSITION" section */

/* ─────────────────────────────────────────────────────────────
   SECTION CARDS (panel / card wrappers used across views)
   ───────────────────────────────────────────────────────────── */

.card,
[class*="-card"]:not(.login-card):not(.stat-card) {
  border-radius: var(--radius);
}

/* ─────────────────────────────────────────────────────────────
   SIDEBAR MOBILE OVERLAY
   ───────────────────────────────────────────────────────────── */

.sidebar-overlay {
  background: rgba(0, 0, 0, 0.65);
}

/* ─────────────────────────────────────────────────────────────
   COMMAND PALETTE / GLOBAL SEARCH
   ───────────────────────────────────────────────────────────── */

/* .command-palette — full definition later in file (line ~1851) */

/* ─────────────────────────────────────────────────────────────
   EMPTY STATES
   ───────────────────────────────────────────────────────────── */

/* .empty-state — full definition later in file (line ~3432) */

/* ─────────────────────────────────────────────────────────────
   APPROVAL QUEUE / ACTION ITEMS special accent
   ───────────────────────────────────────────────────────────── */

.action-row:hover td {
  background: rgba(166, 124, 82, 0.04);
}

/* ─────────────────────────────────────────────────────────────
   TABS
   ───────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.tab {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.14s, border-color 0.14s;
  letter-spacing: 0;
  margin-bottom: -1px;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────
   SIDE PANEL (detail drawer)
   ───────────────────────────────────────────────────────────── */

.side-panel-overlay {
  background: rgba(0, 0, 0, 0.35);
}

.side-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.1);
  width: 440px;
}

.side-panel-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.side-panel-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

.side-panel-email {
  font-size: 11.5px;
  color: var(--text-muted);
}

.close-btn {
  color: var(--text-dim);
  font-size: 20px;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.14s, color 0.14s;
}

.close-btn:hover {
  background: var(--surface-2);
  color: var(--text);
}

.side-panel-stats {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  gap: 1px;
}

.sp-stat {
  background: var(--surface);
  padding: 12px 10px;
}

.sp-stat-val {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.sp-stat-label {
  font-size: 9px;
  letter-spacing: 0.6px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-top: 2px;
}

.side-panel-section {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}

.sp-section-title {
  font-size: 9.5px;
  letter-spacing: 0.9px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.sp-order-card {
  border-bottom: 1px solid var(--border);
  padding: 8px 0;
}

.sp-order-note {
  background: var(--accent-dim);
  border-radius: 5px;
  padding: 4px 8px;
  font-size: 11px;
}

/* ─────────────────────────────────────────────────────────────
   ROW DETAIL EXPANSION PANEL
   ───────────────────────────────────────────────────────────── */

.row-detail-panel {
  background: var(--bg);
  border-radius: var(--radius);
  margin: 4px 12px 4px;
  border: 1px solid var(--border);
  padding: 14px 16px;
}

.row-detail-section {
  margin-bottom: 12px;
}

.row-detail-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 5px;
}

/* ─────────────────────────────────────────────────────────────
   NOTE EDITOR POPUP
   ───────────────────────────────────────────────────────────── */

.note-editor-popup {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

.note-editor-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
}

.note-textarea {
  background: var(--bg);
  border: none;
  color: var(--text);
  font-size: 12.5px;
  line-height: 1.6;
}

.note-textarea::placeholder {
  color: var(--text-dim);
}

.note-editor-footer {
  border-top: 1px solid var(--border);
  padding: 8px 12px;
}

.note-save-btn {
  background: var(--accent) !important;
  color: #fff !important;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 14px;
}

/* ─────────────────────────────────────────────────────────────
   MORNING BRIEF CARDS
   ───────────────────────────────────────────────────────────── */

.brief-grid {
  gap: 12px;
  margin-bottom: 16px;
}

.brief-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.18s, border-color 0.18s;
}

.brief-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

.brief-card.urgent {
  border-color: var(--red);
  border-width: 1px;
  box-shadow: 0 0 0 1px var(--red), var(--shadow-xs);
}

.brief-card.stale {
  border-color: var(--yellow);
  opacity: 0.75;
}

.brief-card-title {
  font-size: 9.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 10px;
}

.brief-metric {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.8px;
  line-height: 1.1;
}

.brief-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* .brief-urgent-item — full definition later in file */

.brief-agent-dot {
  background: var(--surface-2);
  border-radius: 6px;
  padding: 5px 8px;
  font-size: 11.5px;
}

/* Aging / SLA bars */
.aging-bar-track {
  background: var(--surface-2);
  border-radius: 4px;
  height: 18px;
}

/* ─────────────────────────────────────────────────────────────
   TREND INDICATORS
   ───────────────────────────────────────────────────────────── */

.trend-up {
  color: var(--green);
  font-size: 10.5px;
  font-weight: 600;
}

.trend-down {
  color: var(--red);
  font-size: 10.5px;
  font-weight: 600;
}

.trend-flat {
  color: var(--text-dim);
  font-size: 10.5px;
}

/* ─────────────────────────────────────────────────────────────
   FORM INPUTS (modal forms)
   ───────────────────────────────────────────────────────────── */

.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.10);
}

.form-input::placeholder {
  color: var(--text-dim);
}

/* ─────────────────────────────────────────────────────────────
   ACTIVITY FEED
   ───────────────────────────────────────────────────────────── */

.feed-item {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.12s;
  gap: 10px;
}

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

.feed-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  font-size: 13px;
  flex-shrink: 0;
}

.feed-desc {
  font-size: 12.5px;
}

.feed-meta {
  font-size: 10.5px;
  color: var(--text-muted);
}

.feed-filter-btn {
  border-radius: 20px;
  font-size: 11px;
  padding: 3px 11px;
  transition: all 0.14s;
}

.feed-filter-btn.active {
  background: var(--text);
  border-color: var(--text);
  color: var(--surface);
}

/* ─────────────────────────────────────────────────────────────
   JARVIS NOTIFICATION PANEL
   ───────────────────────────────────────────────────────────── */

.jarvis-notif-wrap {
  position: relative;
}

.jarvis-notification-bell {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  color: var(--text-muted);
  transition: background 0.14s, color 0.14s;
}

.jarvis-notification-bell:hover {
  background: var(--surface-2);
  color: var(--text);
}

.jarvis-notification-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 380px;
}

.jarvis-notif-panel-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}

.jarvis-notif-panel-title {
  font-size: 12.5px;
  font-weight: 600;
}

.jarvis-notif-dismiss-all {
  font-size: 10.5px;
  color: var(--text-muted);
  border-radius: 5px;
  padding: 3px 8px;
  transition: all 0.14s;
}

.jarvis-notif-dismiss-all:hover {
  background: var(--surface-2);
  color: var(--text);
}

.jarvis-notification-item {
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
  transition: background 0.12s;
}

.jarvis-notification-item:hover {
  background: var(--bg-hover);
}

.jarvis-notification-item.unread {
  background: rgba(166, 124, 82, 0.03);
}

/* Priority border indicators */
.jarvis-notification-item.priority-border-critical { border-left-color: var(--red); }
.jarvis-notification-item.priority-border-high { border-left-color: var(--yellow); }
.jarvis-notification-item.priority-border-warning { border-left-color: var(--yellow); }
.jarvis-notification-item.priority-border-medium { border-left-color: var(--blue); }
.jarvis-notification-item.priority-border-low { border-left-color: var(--border); }
.jarvis-notification-item.priority-border-info { border-left-color: var(--blue); }

.jarvis-notif-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: 12px;
}

.jarvis-notif-title {
  font-size: 12px;
  font-weight: 500;
}

.jarvis-notif-message {
  font-size: 11px;
  color: var(--text-muted);
}

.jarvis-notif-meta {
  font-size: 10px;
  color: var(--text-dim);
}

.jarvis-notif-cluster-item {
  background: var(--surface-2);
  border-radius: 5px;
  font-size: 11px;
}

/* ─────────────────────────────────────────────────────────────
   JARVIS GLOBAL CHAT PANEL
   ───────────────────────────────────────────────────────────── */

.jarvis-global-panel {
  background: var(--surface);
  border-left: 1px solid var(--border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.09);
  width: 420px;
}

.jg-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 18px;
}

.jg-header-icon {
  background: linear-gradient(135deg, #a67c52 0%, #c9a96e 100%);
  border-radius: 9px;
  width: 34px;
  height: 34px;
  font-size: 15px;
}

.jg-header-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.2px;
}

.jg-header-sub {
  font-size: 10.5px;
  color: var(--text-muted);
}

.jg-header-btn {
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 8px;
  transition: all 0.14s;
}

.jg-header-btn:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}

#jg-messages {
  background: var(--bg);
  padding: 16px 16px;
  gap: 12px;
}

.jg-msg-bubble {
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.6;
  padding: 10px 13px;
}

.jg-msg-user .jg-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 3px;
}

.jg-msg-assistant .jg-msg-bubble {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 3px;
}

.jg-suggested-action {
  border-radius: 16px;
  font-size: 11px;
  padding: 3px 10px;
}

.jg-data-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow-xs);
}

/* Input area */
.jg-input-area {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px 14px;
}

.jg-input {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  transition: border-color 0.14s, box-shadow 0.14s;
  resize: none;
  outline: none;
}

.jg-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(166, 124, 82, 0.10);
}

.jg-send-btn {
  background: var(--accent);
  border: none;
  border-radius: 7px;
  color: #fff;
  width: 32px;
  height: 32px;
  transition: opacity 0.14s, transform 0.14s;
}

.jg-send-btn:hover:not(:disabled) {
  opacity: 0.9;
  transform: scale(1.05);
}

/* Typing indicator dots */
.jg-typing-dot {
  background: var(--text-dim);
  border-radius: 50%;
}

/* ─────────────────────────────────────────────────────────────
   APPROVAL BUTTONS
   ───────────────────────────────────────────────────────────── */

.jarvis-approve-btn {
  background: var(--green-dim);
  border: 1px solid rgba(22, 163, 74, 0.25);
  color: var(--green);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.14s;
}

.jarvis-approve-btn:hover {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
}

.jarvis-reject-btn {
  background: var(--red-dim);
  border: 1px solid rgba(220, 38, 38, 0.2);
  color: var(--red);
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 12px;
  cursor: pointer;
  transition: all 0.14s;
}

.jarvis-reject-btn:hover {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}

.jarvis-ask-btn,
.jarvis-ask-inline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 10px;
  cursor: pointer;
  transition: all 0.14s;
}

.jarvis-ask-btn:hover,
.jarvis-ask-inline:hover {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border-hover);
}

/* ─────────────────────────────────────────────────────────────
   ACTION ITEMS KANBAN (ai2-*)
   ───────────────────────────────────────────────────────────── */

.ai2-board {
  gap: 10px;
}

.ai2-col {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.ai2-col-over {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(166, 124, 82, 0.2);
}

.ai2-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.ai2-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

.ai2-priority-pill {
  border-radius: 4px;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 6px;
  letter-spacing: 0.3px;
}

/* ─────────────────────────────────────────────────────────────
   GORGIAS TICKET CARDS
   ───────────────────────────────────────────────────────────── */

.gorgias-ticket-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s;
  margin-bottom: 8px;
}

.gorgias-ticket-card:hover {
  box-shadow: var(--shadow-sm);
}

.ticket-header {
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
}

.sentiment-badge {
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
}

.message-bubble {
  border-radius: 10px;
  padding: 9px 12px;
  font-size: 12.5px;
  line-height: 1.5;
}

.message-customer .message-bubble {
  background: var(--surface-2);
  border-bottom-left-radius: 2px;
}

.message-agent .message-bubble {
  background: var(--accent-dim);
  border-bottom-right-radius: 2px;
}

/* ─────────────────────────────────────────────────────────────
   JOURNEY / ORDER TIMELINE MODAL
   ───────────────────────────────────────────────────────────── */

.journey-overlay {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.journey-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.journey-node {
  transition: transform 0.15s;
}

.journey-node:hover {
  transform: scale(1.03);
}

/* ─────────────────────────────────────────────────────────────
   VIEW-AS SWITCHER (header)
   ───────────────────────────────────────────────────────────── */

.view-as-switcher {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 3px;
  gap: 2px;
}

.view-as-btn {
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 11px;
  transition: all 0.14s;
}

/* ─────────────────────────────────────────────────────────────
   API HEALTH INDICATOR (header)
   ───────────────────────────────────────────────────────────── */

.api-health-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
}

/* ─────────────────────────────────────────────────────────────
   LABEL GENERATOR PROVIDER TOGGLE
   ───────────────────────────────────────────────────────────── */

/* ─────────────────────────────────────────────────────────────
   MARGIN BAR (mini progress bar)
   ───────────────────────────────────────────────────────────── */

.margin-bar {
  background: var(--surface-2);
  border-radius: 3px;
  height: 5px;
}

.margin-bar-fill {
  border-radius: 3px;
}

/* ─────────────────────────────────────────────────────────────
   CONFIDENCE / PROGRESS BARS
   ───────────────────────────────────────────────────────────── */

.confidence-bar,
.confidence-bar-fill {
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────────────────────────────────────
   DECISIONS DASHBOARD CARDS
   ───────────────────────────────────────────────────────────── */

.decisions-card-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.decisions-card-item:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

.decision-type-badge,
.decision-status-badge {
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 600;
  padding: 2px 7px;
  letter-spacing: 0.2px;
}

/* ─────────────────────────────────────────────────────────────
   CHANNEL / MARKETING CARDS
   ───────────────────────────────────────────────────────────── */

.channel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s, border-color 0.15s;
}

.channel-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
}

/* ─────────────────────────────────────────────────────────────
   EVENT LOG ACTOR BADGES
   ───────────────────────────────────────────────────────────── */

.el-badge-ai,
.el-badge-claude,
.el-badge-human {
  border-radius: 5px;
  font-size: 9.5px;
  font-weight: 700;
  padding: 2px 7px;
  letter-spacing: 0.3px;
}

/* ─────────────────────────────────────────────────────────────
   SUPPLIER SCORECARD METRICS
   ───────────────────────────────────────────────────────────── */

.score-bar-track {
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}

.score-bar-fill {
  border-radius: 3px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─────────────────────────────────────────────────────────────
   GLOBAL SEARCH / COMMAND PALETTE
   ───────────────────────────────────────────────────────────── */

.command-palette {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

/* ─────────────────────────────────────────────────────────────
   MISC VIEW CONTAINERS (Jarvis intel panels)
   ───────────────────────────────────────────────────────────── */

/* Common panel wrapper used by logistics, customer, finance panels */
.jarvis-logistics-panel,
.jarvis-customer-panel,
.jarvis-finance-panel,
.jarvis-inventory-panel,
.jarvis-marketing-panel,
.jarvis-pnl-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}

/* ─────────────────────────────────────────────────────────────
   LIVE INDICATOR (header)
   ───────────────────────────────────────────────────────────── */

.live-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--green);
  animation: livePulse 2.5s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ─────────────────────────────────────────────────────────────
   PRINT OVERRIDES
   ───────────────────────────────────────────────────────────── */

/* print rules consolidated below */

/* ═══════════════════════════════════════════════════════════════
   DARK MODE
   Full dark theme — activated via [data-theme="dark"] on <html>
   Respects system preference via JS; persisted in localStorage
   ═══════════════════════════════════════════════════════════════ */

:root[data-theme="dark"] {
  color-scheme: dark;

  /* Backgrounds */
  --bg: #111110;
  --surface: #1c1c1a;
  --surface-2: #242421;
  --surface-3: #2c2c29;

  /* Borders */
  --border: #313130;
  --border-hover: #424240;

  /* Text */
  --text: #f0ede8;
  --text-muted: #8a8780;
  --text-dim: #56544f;

  /* Accent — slightly warmer/brighter in dark */
  --accent: #c09a6a;
  --accent-dim: rgba(192, 154, 106, 0.13);
  /* --accent-alpha and --accent-bg removed (unused) */

  /* Status colors — brighter/more saturated for dark bg */
  --green: #4ade80;
  --green-dim: rgba(74, 222, 128, 0.12);
  --red: #f87171;
  --red-dim: rgba(248, 113, 113, 0.12);
  --yellow: #fbbf24;
  --yellow-dim: rgba(251, 191, 36, 0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96, 165, 250, 0.12);
  --purple: #a78bfa;
  --purple-dim: rgba(167, 139, 250, 0.12);
  --emerald: #34d399;
  --emerald-dim: rgba(52, 211, 153, 0.12);
  --orange: #fb923c;
  --orange-dim: rgba(251, 146, 60, 0.12);

  /* Shadows — more dramatic on dark */
  --shadow-xs: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.55);
  --shadow-xl: 0 20px 60px rgba(0, 0, 0, 0.65);

  /* Sidebar — deeper in dark mode */
  --sidebar-bg: #0a0a09;
  --sidebar-border: #1a1a18;
  --sidebar-text: #908e89;  /* raised from #5a5855 — was 3:1, now ~5.5:1 on #0a0a09 */
  --sidebar-text-hover: #9a9790;
  --sidebar-text-active: #f0ede8;
  --sidebar-hover-bg: rgba(255, 255, 255, 0.04);
  --sidebar-active-bg: rgba(255, 255, 255, 0.07);
  --sidebar-section-title: #5a5a58;

  /* Aliases */
  --text-primary: var(--text);
  --text-secondary: var(--text-muted);
  --surface-1: var(--surface);
  --surface-raised: var(--surface);
  --bg-hover: rgba(255, 255, 255, 0.04);
  --hover-bg: rgba(255, 255, 255, 0.04);
  --card-bg: var(--surface);
  --bg-secondary: var(--surface-2);
  --primary: var(--accent);
  --danger: var(--red);
  --danger-dim: var(--red-dim);
  --success: var(--green);
  --warning: var(--yellow);
  --info: var(--blue);
  --bg-card: var(--surface);
  --bg-primary: var(--bg);
  --bg-tertiary: var(--surface-3);
  --bg2: var(--surface-2);
  --border-color: var(--border);
  --border-light: var(--border);
  --danger-color: var(--red);
  --surface-hover: var(--surface-2);
}

/* ── Dark mode specific element overrides ── */

[data-theme="dark"] body {
  background: var(--bg);
}

[data-theme="dark"] .header {
  background: var(--surface);
  border-bottom-color: var(--border);
}

/* Table headers use surface-2 (already variable but need to ensure no bleed) */
[data-theme="dark"] th {
  background: var(--surface-2);
  color: var(--text-dim);
}

[data-theme="dark"] td {
  border-bottom-color: var(--border);
}

/* Jarvis chat message area */
[data-theme="dark"] #jg-messages {
  background: var(--bg);
}

[data-theme="dark"] .jg-msg-assistant .jg-msg-bubble {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

/* Morning brief cards */
[data-theme="dark"] .brief-card.urgent {
  box-shadow: 0 0 0 1px var(--red), 0 0 16px rgba(248, 113, 113, 0.15);
}

/* Notification panel */
[data-theme="dark"] .jarvis-notification-panel {
  background: var(--surface);
  border-color: var(--border);
}

[data-theme="dark"] .jarvis-notification-item.unread {
  background: rgba(192, 154, 106, 0.04);
}

/* Note textarea */
[data-theme="dark"] .note-textarea {
  background: var(--surface-2);
  color: var(--text);
}

/* Row detail */
[data-theme="dark"] .row-detail-panel {
  background: var(--surface-2);
  border-color: var(--border);
}

/* Command palette */
[data-theme="dark"] .command-palette {
  background: var(--surface);
  border-color: var(--border);
}

/* Journey modal */
[data-theme="dark"] .journey-modal {
  background: var(--surface);
  border-color: var(--border);
}

/* Side panel */
[data-theme="dark"] .side-panel {
  background: var(--surface);
  border-color: var(--border);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.4);
}

[data-theme="dark"] .side-panel-header {
  background: var(--surface);
  border-bottom-color: var(--border);
}

[data-theme="dark"] .sp-stat {
  background: var(--surface);
}

[data-theme="dark"] .side-panel-stats {
  background: var(--border);
}

/* Toolbar inputs */
[data-theme="dark"] .search-input,
[data-theme="dark"] .filter-select {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .filter-btn {
  background: var(--surface-2);
  border-color: var(--border);
}

[data-theme="dark"] .toggle-btn {
  background: var(--surface-2);
  border-right-color: var(--border);
}

[data-theme="dark"] .toggle-group {
  border-color: var(--border);
}

/* Pagination */
[data-theme="dark"] .pagination-btns button {
  background: var(--surface-2);
  border-color: var(--border);
}

/* Login — already dark, keep as is but tweak */
[data-theme="dark"] .login-overlay {
  background: #0a0a09;
}

[data-theme="dark"] .login-card {
  background: #161614;
  border-color: #262624;
}

/* Scrollbars in dark */
[data-theme="dark"] ::-webkit-scrollbar-thumb {
  background: #303030;
}

[data-theme="dark"] ::-webkit-scrollbar-thumb:hover {
  background: #404040;
}

/* Gorgias ticket */
[data-theme="dark"] .message-customer .message-bubble {
  background: var(--surface-2);
}

[data-theme="dark"] .message-agent .message-bubble {
  background: rgba(192, 154, 106, 0.1);
}

/* Kanban */
[data-theme="dark"] .ai2-col {
  background: var(--surface-2);
  border-color: var(--border);
}

[data-theme="dark"] .ai2-card {
  background: var(--surface);
  border-color: var(--border);
}

/* ═══════════════════════════════════════════════════════════════
   THEME TOGGLE BUTTON
   ═══════════════════════════════════════════════════════════════ */

.theme-toggle-btn {
  width: 34px;
  height: 34px;
  border-radius: 7px;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding: 0;
  transition: background 0.14s, border-color 0.14s, color 0.14s, transform 0.14s;
}

.theme-toggle-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
  transform: rotate(12deg);
}

.theme-toggle-btn:active {
  transform: rotate(20deg) scale(0.93);
}

/* Sun icon visible in light mode, hidden in dark */
.theme-toggle-btn .icon-sun { display: block; }
.theme-toggle-btn .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle-btn .icon-moon { display: block; }

/* ═══════════════════════════════════════════════════════════════
   SMOOTH THEME TRANSITIONS
   Applied to specific elements — not * (too broad)
   ═══════════════════════════════════════════════════════════════ */

body,
.header,
.sidebar,
.main,
.stat-card,
.brief-card,
.table-container,
.side-panel,
.nav-item,
.filter-btn,
.toggle-btn,
.action-btn,
.refresh-btn,
.theme-toggle-btn,
.pill,
.channel-card,
.gorgias-ticket-card,
.jarvis-notification-panel,
.jarvis-notification-item,
.command-palette,
.journey-modal,
.login-card,
.row-detail-panel,
.note-editor-popup,
.ai2-card,
.ai2-col,
.jg-msg-bubble,
.search-input,
.filter-select,
.form-input,
th, td {
  transition:
    background-color 0.22s ease,
    border-color 0.22s ease,
    color 0.18s ease,
    box-shadow 0.22s ease;
}

/* Exclude elements where transition would look wrong */
.spinner,
.sync-dot,
.live-dot,
.health-dot,
.freshness-dot,
.agent-dot,
.skeleton,
.bar-fill,
.confidence-bar-fill,
.margin-bar-fill,
[class$="-fill"] {
  transition: none !important;
}

/* ═══════════════════════════════════════════════════════════════
   STAT CARDS — calm & uniform (uses CSS :has())
   Premium dashboards keep cards visually uniform and let semantic color
   live in the VALUE text (.stat-value.green/red/…), not in card chrome.
   The previous build drew a bright 2px top border per value-color, which
   turned every stat grid into a rainbow and read as "admin template."
   We now keep a restrained top accent ONLY for genuine attention states
   (red / yellow caution); positive + informational cards stay neutral so
   the eye goes to what actually needs action. The colored numbers are
   untouched, so no at-a-glance signal is lost.
   ═══════════════════════════════════════════════════════════════ */

.stat-card:has(.stat-value.red) {
  border-top: 2px solid var(--red);
}

.stat-card:has(.stat-value.yellow) {
  border-top: 2px solid var(--yellow);
}

/* Brief cards: same restraint — accent only for attention states. */
.brief-card:has(.brief-metric.red)    { border-top: 2px solid var(--red); }
.brief-card:has(.brief-metric.yellow) { border-top: 2px solid var(--yellow); }

/* ═══════════════════════════════════════════════════════════════
   GLASSMORPHISM — Notification panel + Command palette
   ═══════════════════════════════════════════════════════════════ */

.jarvis-notification-panel,
.api-health-panel,
.health-popover,
.freshness-tooltip {
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  background: rgba(255, 255, 255, 0.88) !important;
}

[data-theme="dark"] .jarvis-notification-panel,
[data-theme="dark"] .api-health-panel,
[data-theme="dark"] .health-popover,
[data-theme="dark"] .freshness-tooltip {
  background: rgba(28, 28, 26, 0.88) !important;
  border-color: rgba(255, 255, 255, 0.08) !important;
}

/* ═══════════════════════════════════════════════════════════════
   TABULAR NUMBERS — system-wide for all numeric data
   ═══════════════════════════════════════════════════════════════ */

.stat-value,
.brief-metric,
td,
.sp-stat-val,
.fin-card-gross,
.fin-net-value {
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════
   MODERN FOCUS STATES — replaces browser default outlines
   ═══════════════════════════════════════════════════════════════ */

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

button:focus-visible,
.nav-item:focus-visible,
.filter-btn:focus-visible,
.toggle-btn:focus-visible,
.action-btn:focus-visible,
.refresh-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ═══════════════════════════════════════════════════════════════
   CRITICAL / URGENT GLOW EFFECTS
   ═══════════════════════════════════════════════════════════════ */

/* Pills with glow on urgent states */
.pill.out,
.pill.high,
.pill.claim,
.pill.chargeback {
  box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.25);
}

[data-theme="dark"] .pill.out,
[data-theme="dark"] .pill.high,
[data-theme="dark"] .pill.claim,
[data-theme="dark"] .pill.chargeback {
  box-shadow: 0 0 6px rgba(248, 113, 113, 0.3);
}

/* Critical alert banner pulse */
#critical-alerts-banner {
  animation: criticalPulse 3s ease-in-out infinite;
}

@keyframes criticalPulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 2px 20px rgba(153, 27, 27, 0.4); }
}

/* ═══════════════════════════════════════════════════════════════
   ANIMATED GRADIENT SIDEBAR LOGO AREA
   ═══════════════════════════════════════════════════════════════ */

/* Subtle branded top section of sidebar */
.sidebar::before {
  content: none;
}

/* ═══════════════════════════════════════════════════════════════
   ENHANCED SKELETON LOADING
   ═══════════════════════════════════════════════════════════════ */

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    var(--surface-3) 40%,
    var(--surface-2) 80%
  );
  background-size: 200% 100%;
  animation: shimmer 1.8s ease-in-out infinite;
  border-radius: 5px;
}

/* ═══════════════════════════════════════════════════════════════
   DATA UPDATE FLASH — applied via JS when values change
   ═══════════════════════════════════════════════════════════════ */

@keyframes valueFlash {
  0% { background: transparent; }
  25% { background: rgba(166, 124, 82, 0.15); border-radius: 4px; }
  100% { background: transparent; }
}

/* ═══════════════════════════════════════════════════════════════
   ENHANCED TABLE — alternating row micro-tint
   ═══════════════════════════════════════════════════════════════ */

/* Very subtle alternating rows for long tables */
tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.012);
}

[data-theme="dark"] tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.012);
}

/* Override for rows that have explicit hover */
tbody tr:hover td {
  background: var(--bg-hover) !important;
}

/* Tabular figures across data cells so currency/quantity columns line up at
   a consistent glyph width instead of wobbling. Affects only digit glyphs —
   harmless on text cells. */
#mainContent th,
#mainContent td {
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════
   PILL REFINEMENTS — outlined style for dark mode
   ═══════════════════════════════════════════════════════════════ */

[data-theme="dark"] .pill.unfulfilled  { background: rgba(251, 191, 36, 0.15);  color: #fbbf24; }
[data-theme="dark"] .pill.fulfilled    { background: rgba(74, 222, 128, 0.12);  color: #4ade80; }
[data-theme="dark"] .pill.in_transit   { background: rgba(96, 165, 250, 0.12);  color: #60a5fa; }
[data-theme="dark"] .pill.low          { background: rgba(248, 113, 113, 0.12); color: #f87171; }
[data-theme="dark"] .pill.out          { background: rgba(248, 113, 113, 0.15); color: #f87171; }
[data-theme="dark"] .pill.ok           { background: rgba(74, 222, 128, 0.12);  color: #4ade80; }
[data-theme="dark"] .pill.high         { background: rgba(248, 113, 113, 0.15); color: #f87171; }
[data-theme="dark"] .pill.medium       { background: rgba(251, 191, 36, 0.13);  color: #fbbf24; }
[data-theme="dark"] .pill.booked       { background: rgba(251, 191, 36, 0.13);  color: #fbbf24; }
[data-theme="dark"] .pill.arrived      { background: rgba(74, 222, 128, 0.12);  color: #4ade80; }
[data-theme="dark"] .pill.partially_fulfilled { background: rgba(96, 165, 250, 0.12); color: #60a5fa; }

/* ═══════════════════════════════════════════════════════════════
   ENHANCED HOVER ROW HIGHLIGHT (table rows w/ actions)
   ═══════════════════════════════════════════════════════════════ */

tr.clickable {
  cursor: pointer;
}

tr.clickable:hover td {
  background: var(--bg-hover) !important;
}

/* ═══════════════════════════════════════════════════════════════
   SIDEBAR ACTIVE ITEM — gradient glow
   ═══════════════════════════════════════════════════════════════ */

.nav-item.active {
  position: relative;
}

/* Subtle warm glow behind active item */
.nav-item.active::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 6px;
  background: radial-gradient(ellipse at left center, rgba(192, 154, 106, 0.12), transparent 70%);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
   ENHANCED APPROVAL / ACTION BUTTONS
   ═══════════════════════════════════════════════════════════════ */

/* Approve button — filled green on hover */
.jarvis-approve-btn {
  position: relative;
  overflow: hidden;
}

.jarvis-approve-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--green);
  opacity: 0;
  transition: opacity 0.14s;
}

.jarvis-approve-btn:hover::before { opacity: 1; }
.jarvis-approve-btn:hover { color: #fff; border-color: var(--green); }
.jarvis-approve-btn span { position: relative; z-index: var(--z-base); }

/* ═══════════════════════════════════════════════════════════════
   ENHANCED BADGE ANIMATION
   ═══════════════════════════════════════════════════════════════ */

.nav-item .badge {
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-item:hover .badge {
  transform: scale(1.1);
}

/* ═══════════════════════════════════════════════════════════════
   STAT CARD NUMBER — gradient text for accent values
   ═══════════════════════════════════════════════════════════════ */

/* Accent-colored stat values get gradient text treatment */
.stat-value.accent {
  background: linear-gradient(135deg, var(--accent) 0%, #d4a96a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

[data-theme="dark"] .stat-value.accent {
  background: linear-gradient(135deg, #c09a6a 0%, #e8c084 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ═══════════════════════════════════════════════════════════════
   HERO BRIEF CARD — full-width morning brief emphasis
   ═══════════════════════════════════════════════════════════════ */

.brief-card.full-width {
  background: linear-gradient(
    135deg,
    var(--surface) 0%,
    color-mix(in srgb, var(--surface) 96%, var(--accent) 4%) 100%
  );
  border-color: var(--border);
  position: relative;
  overflow: hidden;
}

.brief-card.full-width::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
}

/* ═══════════════════════════════════════════════════════════════
   JARVIS FAB BUTTON — enhanced
   ═══════════════════════════════════════════════════════════════ */

.jarvis-floating-btn {
  box-shadow: 0 4px 16px rgba(166, 124, 82, 0.35), 0 1px 4px rgba(0,0,0,0.1) !important;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.2s ease !important;
}

.jarvis-floating-btn:hover {
  transform: scale(1.08) !important;
  box-shadow: 0 8px 28px rgba(166, 124, 82, 0.45), 0 2px 8px rgba(0,0,0,0.15) !important;
}

[data-theme="dark"] .jarvis-floating-btn {
  box-shadow: 0 4px 20px rgba(192, 154, 106, 0.4), 0 1px 4px rgba(0,0,0,0.3) !important;
}

/* ═══════════════════════════════════════════════════════════════
   ENHANCED EMPTY STATES
   ═══════════════════════════════════════════════════════════════ */

/* Legacy ghost-icon child rule. Layout/padding for .empty-state is
   owned by the centered flex block further down (~line 3385); only the
   .icon child styling lives here. Opacity raised 0.15 → 0.4 so the icon
   is actually visible (was a near-invisible ghost). */
.empty-state .icon {
  font-size: 44px;
  opacity: 0.4;
  margin-bottom: 14px;
  display: block;
}

.empty-state h3,
.empty-state p {
  color: var(--text-muted);
}

/* ═══════════════════════════════════════════════════════════════
   BETTER PAGE TRANSITION ANIMATION
   ═══════════════════════════════════════════════════════════════ */

@keyframes viewFadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Faster, crisper page transitions */
.main > *:not(.loading):not(.spinner):not(#loginScreen) {
  animation: viewFadeIn 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ═══════════════════════════════════════════════════════════════
   PRINT
   ═══════════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════════════════════════════
   AUDIT BUG FIXES — v3
   All issues found in comprehensive 5-agent audit
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   FIX: prefers-reduced-motion
   Disables all animations/transitions for motion-sensitive users
   ───────────────────────────────────────────────────────────── */

@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;
  }

  .skeleton {
    animation: none !important;
    background: var(--surface-2) !important;
  }

  .sync-dot,
  .live-dot,
  .health-dot,
  .freshness-dot,
  .agent-dot,
  #critical-alerts-banner {
    animation: none !important;
  }

  .main > *:not(.loading):not(.spinner) {
    animation: none !important;
  }
}

/* ─────────────────────────────────────────────────────────────
   FIX: .btn-active — !important override (dashboard.css uses
   !important so we must too)
   ───────────────────────────────────────────────────────────── */

.btn-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

[data-theme="dark"] .btn-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

.decisions-pill-active {
  background: var(--accent) !important;
  color: #fff !important;
  border-color: var(--accent) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: color:#000 on buttons — all become invisible in dark mode
   These buttons have colored backgrounds (accent/green/purple)
   and need white text, not black
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .scan-mode-btn.active.mode-in,
[data-theme="dark"] .mo-step-num,
[data-theme="dark"] .wjs-run-btn,
[data-theme="dark"] .ret-btn-label:hover,
[data-theme="dark"] .ret-btn-close:hover,
[data-theme="dark"] .pck-confirm-btn:hover,
[data-theme="dark"] .pck-done-close-btn:hover,
[data-theme="dark"] .ret-filter-btn.active,
[data-theme="dark"] .um-modal-save.yellow,
[data-theme="dark"] .mo-reconnect-btn:hover,
[data-theme="dark"] .note-save-btn,
[data-theme="dark"] .login-card button {
  color: #fff !important;
}

/* SEO grade badges — dark text on colored bg is fine in light mode,
   but need white in dark mode */
[data-theme="dark"] .seo-grade-a,
[data-theme="dark"] .seo-grade-b,
[data-theme="dark"] .seo-grade-c {
  color: #fff !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Light badge backgrounds — invisible in dark mode
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .rl-svc-badge {
  background: rgba(255, 255, 255, 0.07) !important;
  border-color: rgba(255, 255, 255, 0.12) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .rl-svc-badge.rl-svc-warn {
  background: var(--yellow-dim) !important;
  border-color: rgba(251, 191, 36, 0.25) !important;
  color: var(--yellow) !important;
}

[data-theme="dark"] .rl-rate-rec {
  background: var(--green-dim) !important;
  border-color: rgba(74, 222, 128, 0.2) !important;
  color: var(--green) !important;
}

[data-theme="dark"] .rl-conf-med {
  background: var(--yellow-dim) !important;
  color: var(--yellow) !important;
}

[data-theme="dark"] .rl-conf-low {
  background: var(--red-dim) !important;
  color: var(--red) !important;
}

[data-theme="dark"] .rl-rates-freight-warn {
  background: var(--yellow-dim) !important;
  color: var(--yellow) !important;
}

[data-theme="dark"] .lbl-result-order-badge {
  background: var(--blue-dim) !important;
  color: var(--blue) !important;
  border-color: rgba(96, 165, 250, 0.2) !important;
}

[data-theme="dark"] .hub-judgeme-btn {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .hub-judgeme-btn:hover {
  background: var(--surface-3) !important;
  color: var(--text) !important;
}

[data-theme="dark"] .rf-horizon-btn {
  background: var(--surface-2) !important;
  border-color: var(--border) !important;
  color: var(--text-muted) !important;
}

[data-theme="dark"] .hub-cp-order-status.unfulfilled {
  background: rgba(251, 191, 36, 0.12) !important;
  color: var(--yellow) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: .jg-entity-link — hardcoded #a67c52 (light-mode tan)
   Should use the CSS variable so dark mode gets the brighter
   accent value
   ───────────────────────────────────────────────────────────── */

.jg-entity-link {
  color: var(--accent) !important;
}

.jg-entity-link:hover {
  color: var(--accent) !important;
  opacity: 0.8;
}

.jg-dollar {
  color: var(--green) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: VIP customer card hardcoded gold color (#b8860b)
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .jcp-summary-card.vip,
[data-theme="dark"] .jcp-profile-card.vip {
  color: var(--yellow) !important;
  border-left-color: var(--yellow) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Minimum font sizes — 8px elements raised to 10px
   ───────────────────────────────────────────────────────────── */

/* .state-tile .tile-count (dashboard.css line 1974 — 8px) */
.state-tile .tile-count {
  font-size: 10px !important;
}

/* .rev-bar-lbl (dashboard.css line 4039 — 8px) */
.rev-bar-lbl {
  font-size: 10px !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Missing :focus-visible on interactive elements
   Covers the worst accessibility gaps found in audit
   ───────────────────────────────────────────────────────────── */

/* Table header sort buttons */
.matrix-table thead th.loc-col:focus-visible,
.matrix-table tbody td.title-cell:focus-visible,
table th:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 3px;
}

/* View-specific filter and action buttons */
.ret-filter-btn:focus-visible,
.hub-action-btn:focus-visible,
.wizard-toggle-btn:focus-visible,
.hr-toggle-btn:focus-visible,
.feed-filter-btn:focus-visible,
.tab:focus-visible,
.expand-btn:focus-visible,
.note-icon:focus-visible,
.jarvis-approve-btn:focus-visible,
.jarvis-reject-btn:focus-visible,
.jarvis-ask-btn:focus-visible,
.close-btn:focus-visible,
.nav-section-header:focus-visible,
.ai2-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Z-index — standardize stacking hierarchy
   Prevents sidebar from appearing above modals on some views
   ───────────────────────────────────────────────────────────── */

/* Sidebar at --z-header was documented — ensure modals beat it */
.journey-overlay,
.side-panel-overlay {
  z-index: var(--z-overlay) !important;
}

.journey-modal {
  z-index: calc(var(--z-overlay) + 1) !important;
}

.side-panel {
  z-index: calc(var(--z-overlay) + 2) !important;
}

/* Command palette sits above everything */
.command-palette {
  z-index: calc(var(--z-palette) + 1) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Dark mode — nav-section-title black text
   (dashboard.css line 899 has color: #000 in some contexts)
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .nav-section-title {
  color: var(--sidebar-section-title) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: .sr-row-selected — !important defensive override
   ───────────────────────────────────────────────────────────── */

.sr-row-selected {
  background: color-mix(in srgb, var(--accent) 8%, transparent) !important;
}

[data-theme="dark"] .sr-row-selected {
  background: rgba(192, 154, 106, 0.1) !important;
}

/* ─────────────────────────────────────────────────────────────
   FIX: Dark mode — Jarvis marketing & finance panel badges
   ───────────────────────────────────────────────────────────── */

[data-theme="dark"] .jarvis-marketing-panel .jm-header-badge {
  color: #fff !important;
}

[data-theme="dark"] .jm-rec-card {
  background: var(--surface-2);
  border-color: var(--border);
}

/* ─────────────────────────────────────────────────────────────
   FUTURE-PROOF: cursor:not-allowed on all disabled states
   ───────────────────────────────────────────────────────────── */

button:disabled,
input:disabled,
select:disabled,
textarea:disabled,
[disabled] {
  cursor: not-allowed !important;
  opacity: 0.45 !important;
}

/* ─────────────────────────────────────────────────────────────
   ENHANCEMENT: Table padding bump — 10px → 12px for readability
   ───────────────────────────────────────────────────────────── */

td {
  padding: 11px 14px;
}

th {
  padding: 11px 14px;
}

/* ─────────────────────────────────────────────────────────────
   ENHANCEMENT: Active row left border accent on click
   ───────────────────────────────────────────────────────────── */

tr.expanded-row td:first-child {
  border-left: 2px solid var(--accent);
}

/* ─────────────────────────────────────────────────────────────
   ENHANCEMENT: Sidebar search hint (bottom of sidebar)
   Subtle "⌘K to search" reminder
   ───────────────────────────────────────────────────────────── */

.sidebar::after {
  content: '⌘K to search';
  display: block;
  text-align: center;
  font-size: 10px;
  color: var(--sidebar-section-title);
  padding: 12px 0 4px;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

/* ─────────────────────────────────────────────────────────────
   ENHANCEMENT: Jarvis floating button glow pulse in dark mode
   ───────────────────────────────────────────────────────────── */

@media (prefers-reduced-motion: no-preference) {
  [data-theme="dark"] .jarvis-floating-btn {
    animation: fabGlow 4s ease-in-out infinite;
  }

  @keyframes fabGlow {
    0%, 100% { box-shadow: 0 4px 20px rgba(192, 154, 106, 0.4); }
    50%       { box-shadow: 0 4px 28px rgba(192, 154, 106, 0.6), 0 0 0 3px rgba(192, 154, 106, 0.1); }
  }
}

/* ═══════════════════════════════════════════════════════════════
   PART 5 — UI ENHANCEMENTS
   Sidebar live search · Recently visited · Global toasts ·
   Page progress bar · Button press states · Modal animations ·
   Skeleton loaders · Empty state CTAs
   ═══════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────
   SIDEBAR LIVE SEARCH
   ───────────────────────────────────────────────────────────── */

/* search icon */
/* Highlight matched text in nav items during search */
.nav-highlight {
  background: rgba(192,154,106,0.35);
  color: #fff;
  border-radius: 2px;
  padding: 0 1px;
}

/* Slash-key hint below search */
/* ─────────────────────────────────────────────────────────────
   RECENTLY VISITED SECTION
   ───────────────────────────────────────────────────────────── */

#sidebar-recent {
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding-bottom: 4px;
  margin-bottom: 4px;
}

#sidebar-recent .nav-section-title {
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255,255,255,0.25);
  padding: 8px 14px 4px;
}

/* ─────────────────────────────────────────────────────────────
   GLOBAL TOAST SYSTEM
   ───────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  width: 320px;
  max-width: calc(100vw - 40px);
}

.im-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface-2, #fff);
  border: 1px solid var(--border, #e0ddd7);
  border-radius: 9px;
  padding: 11px 14px;
  font-size: 13px;
  color: var(--text, #1a1917);
  box-shadow: 0 4px 20px rgba(0,0,0,0.12), 0 1px 4px rgba(0,0,0,0.06);
  pointer-events: all;
  /* enter: start invisible and shifted */
  opacity: 0;
  transform: translateY(10px) scale(0.97);
  transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34,1.56,0.64,1);
  will-change: transform, opacity;
  border-left: 3px solid var(--accent, #c09a6a);
}

.im-toast--visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.im-toast__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  color: currentColor;
  opacity: 0.85;
}

.im-toast__msg {
  flex: 1;
  line-height: 1.45;
}

.im-toast__close {
  background: none;
  border: none;
  color: var(--text-muted, #7a7770);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
  transition: color 0.1s;
}
.im-toast__close:hover { color: var(--text, #1a1917); }

/* Type variants */
.im-toast--success { border-left-color: var(--green); }
.im-toast--success .im-toast__icon { color: var(--green); }

.im-toast--error { border-left-color: var(--red); }
.im-toast--error .im-toast__icon { color: var(--red); }

.im-toast--warning { border-left-color: var(--yellow); }
.im-toast--warning .im-toast__icon { color: var(--yellow); }

.im-toast--info { border-left-color: var(--accent, #c09a6a); }
.im-toast--info .im-toast__icon { color: var(--accent, #c09a6a); }

/* Dark mode toasts */
[data-theme="dark"] .im-toast {
  background: var(--surface-2, #1e1e1b);
  border-color: var(--border, #2e2e2a);
  color: var(--text, #e8e5e0);
  box-shadow: 0 4px 24px rgba(0,0,0,0.45);
}

[data-theme="dark"] .im-toast__close { color: var(--text-muted, #908e89); }
[data-theme="dark"] .im-toast__close:hover { color: var(--text, #e8e5e0); }

/* ─────────────────────────────────────────────────────────────
   PAGE PROGRESS BAR
   ───────────────────────────────────────────────────────────── */

#page-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: linear-gradient(90deg, var(--accent, #c09a6a), #e8c080);
  z-index: var(--z-jarvis);
  pointer-events: none;
  border-radius: 0 2px 2px 0;
  box-shadow: 0 0 8px rgba(192,154,106,0.5);
}

@media (prefers-reduced-motion: reduce) {
  #page-progress-bar { transition: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   BUTTON PRESS STATES (all interactive buttons)
   ───────────────────────────────────────────────────────────── */

.btn:active,
.refresh-btn:active,
.sync-now-btn:active,
.theme-toggle-btn:active,
.sign-out-btn:active,
.jarvis-notif-dismiss-all:active,
.wjs-run-btn:active,
.hub-action-btn:active,
.filter-btn:active,
button[class*="-btn"]:active {
  transform: translateY(1px) scale(0.99);
  transition: transform 0.06s ease !important;
}

@media (prefers-reduced-motion: reduce) {
  .btn:active,
  button[class*="-btn"]:active { transform: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   MODAL OPEN/CLOSE ANIMATIONS (journey modal, side panel)
   ───────────────────────────────────────────────────────────── */

/* Journey modal — scale + fade in */
.journey-modal {
  animation: modalIn 0.22s cubic-bezier(0.34,1.4,0.64,1) both;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* Overlay fade */
.journey-overlay {
  animation: overlayIn 0.18s ease both;
}

@keyframes overlayIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* Side panel slide-in from right */
.side-panel {
  animation: sidePanelIn 0.22s cubic-bezier(0.4,0,0.2,1) both;
}

@keyframes sidePanelIn {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .journey-modal,
  .journey-overlay,
  .side-panel { animation: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   SKELETON LOADING STATES
   Usage: add class="skeleton-line" or "skeleton-block" to elements
   Use renderSkeletonTable(rows, cols) from JS.
   ───────────────────────────────────────────────────────────── */

@keyframes skeletonShimmer {
  0%   { background-position: -400px 0; }
  100% { background-position:  400px 0; }
}

.skeleton-line,
.skeleton-block,
.skeleton-table-row td {
  background: linear-gradient(
    90deg,
    var(--surface-2, #f0eee8) 25%,
    var(--bg-hover, #e8e6e0) 50%,
    var(--surface-2, #f0eee8) 75%
  );
  background-size: 800px 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
  border-radius: 4px;
  color: transparent !important;
  user-select: none;
}

.skeleton-line {
  display: block;
  height: 14px;
  margin-bottom: 8px;
  width: 100%;
}
.skeleton-line.short { width: 40%; }
.skeleton-line.medium { width: 65%; }

.skeleton-block {
  display: block;
  height: 80px;
  width: 100%;
  border-radius: 8px;
}

/* Skeleton table */
.skeleton-table-row td {
  height: 15px;
  padding: 10px 12px;
  border-bottom: 1px solid transparent;
}

/* Dark skeleton */
[data-theme="dark"] .skeleton-line,
[data-theme="dark"] .skeleton-block,
[data-theme="dark"] .skeleton-circle,
[data-theme="dark"] .skeleton-table-row td {
  background: linear-gradient(
    90deg,
    var(--surface-2, #222220) 25%,
    var(--bg-hover, #2a2a27) 50%,
    var(--surface-2, #222220) 75%
  );
  background-size: 800px 100%;
  animation: skeletonShimmer 1.6s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-line,
  .skeleton-block,
  .skeleton-table-row td { animation: none !important; }
}

/* ─────────────────────────────────────────────────────────────
   ENHANCED EMPTY STATES
   ───────────────────────────────────────────────────────────── */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 64px 32px;
  text-align: center;
  gap: 12px;
}

/* Gallery-grade empty state: the icon becomes a framed "object of presence"
   (a calm circular surface tile) instead of a faded glyph. Covers both the
   modern `.empty-state-icon` and the legacy `.empty-state .icon` markup so
   every view's empty/error state reads the same. */
.empty-state-icon,
.empty-state .icon {
  font-size: var(--fs-2xl);
  line-height: 1;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  opacity: 1;
  margin: 0 0 var(--space-2);
}
.empty-state-icon svg,
.empty-state .icon svg {
  width: 22px;
  height: 22px;
}

.empty-state-title {
  font-size: var(--fs-lg);
  font-weight: var(--fw-semibold);
  letter-spacing: -0.01em;
  color: var(--text, #1a1917);
  margin: 0;
}

.empty-state-desc {
  font-size: var(--fs-base);
  color: var(--text-dim, #7a7770);
  max-width: 340px;
  line-height: var(--leading-relaxed);
  margin: 0;
}

.empty-state-cta {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-5);
  background: var(--accent, #c09a6a);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--fs-base);
  font-weight: var(--fw-medium);
  cursor: pointer;
  transition: background var(--dur) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
  font-family: inherit;
}
.empty-state-cta:hover { background: var(--accent-hover, #a8845a); }
.empty-state-cta:active { transform: translateY(1px); }

[data-theme="dark"] .empty-state-title { color: var(--text, #e8e5e0); }
[data-theme="dark"] .empty-state-desc  { color: var(--text-muted, #908e89); }

/* ─────────────────────────────────────────────────────────────
   NAV SECTION ITEMS — smooth collapse transition
   ───────────────────────────────────────────────────────────── */

.nav-section-items {
  overflow: hidden;
  transition: max-height 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ─────────────────────────────────────────────────────────────
   MICRO-POLISH: Card hover lift
   ───────────────────────────────────────────────────────────── */

/* .stat-card transition/hover — consolidated into base rule (line ~381) */

@media (prefers-reduced-motion: reduce) {
  .stat-card { transition: none !important; }
  .stat-card:hover { transform: none; }
}

/* ─────────────────────────────────────────────────────────────
   MICRO-POLISH: Pill active click ripple
   ───────────────────────────────────────────────────────────── */

.filter-pill {
  position: relative;
  overflow: hidden;
}

.filter-pill:active::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.2);
  border-radius: inherit;
  animation: pillRipple 0.3s ease forwards;
}

@keyframes pillRipple {
  from { opacity: 1; }
  to   { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .filter-pill:active::after { display: none; }
}

/* ─────────────────────────────────────────────────────────────
   MICRO-POLISH: Table sort indicator
   ───────────────────────────────────────────────────────────── */

th[data-sort] { cursor: pointer; user-select: none; }

th[data-sort]::after {
  content: ' ↕';
  font-size: 10px;
  opacity: 0.3;
  transition: opacity 0.12s;
}
th[data-sort="asc"]::after  { content: ' ↑'; opacity: 0.7; }
th[data-sort="desc"]::after { content: ' ↓'; opacity: 0.7; }
th[data-sort]:hover::after  { opacity: 0.6; }

/* ─────────────────────────────────────────────────────────────
   MICRO-POLISH: Responsive sidebar search on narrow viewports
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  #toast-container { bottom: 16px; right: 12px; left: 12px; width: auto; }
}

/* ═══════════════════════════════════════════════════════════════
   ANALYTICS DASHBOARD — Museum-grade KPI + chart redesign
   ═══════════════════════════════════════════════════════════════ */

.ana-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 28px;
}

.ana-kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-xs);
  border-left: 3px solid var(--border);
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.18s;
}
.ana-kpi-card:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}
.ana-kpi-card.kpi-revenue    { border-left-color: var(--green); }
.ana-kpi-card.kpi-orders     { border-left-color: var(--blue); }
.ana-kpi-card.kpi-aov        { border-left-color: var(--accent); }
.ana-kpi-card.kpi-week       { border-left-color: var(--emerald); }
.ana-kpi-card.kpi-week-orders{ border-left-color: var(--purple); }

.ana-kpi-value {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text);
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.ana-kpi-label {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 6px;
}

.ana-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-xs);
}

.ana-section-title {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

/* Revenue chart bars */
.ana-chart-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 440px;
  overflow-y: auto;
}
.ana-chart-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  padding: 3px 0;
  border-radius: 4px;
  transition: background 0.12s;
}
.ana-chart-row:hover {
  background: var(--surface-2);
}
.ana-chart-date {
  width: 48px;
  text-align: right;
  color: var(--text-dim);
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  flex-shrink: 0;
}
.ana-chart-bar-wrap {
  flex: 1;
  height: 20px;
  background: var(--surface-2);
  border-radius: 4px;
  overflow: hidden;
}
.ana-chart-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #c8a06a);
  border-radius: 4px;
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
  min-width: 2px;
}
.ana-chart-val {
  width: 76px;
  text-align: right;
  color: var(--text);
  font-family: var(--font-mono, monospace);
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}


/* Anomaly alerts */
.ana-anomalies-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 440px;
  overflow-y: auto;
}
.ana-anomaly-row {
  padding: 12px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--text-dim);
  transition: box-shadow 0.15s;
}
.ana-anomaly-row:hover {
  box-shadow: var(--shadow-sm);
}
.ana-anomaly-header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ana-anomaly-metric {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
}
.ana-anomaly-time {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
  font-variant-numeric: tabular-nums;
}
.ana-anomaly-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.45;
}
.ana-anomaly-values {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
  font-family: var(--font-mono, monospace);
  font-variant-numeric: tabular-nums;
}

/* ═══════════════════════════════════════════════════════════════
   MORNING BRIEF — Modernized card grid + components
   ═══════════════════════════════════════════════════════════════ */

.ana-summarize-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 5px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.ana-summarize-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.brief-card.full-width {
  grid-column: 1 / -1;
}

.mb-card-clickable {
  cursor: pointer;
  transition: box-shadow 0.18s, border-color 0.18s, transform 0.18s;
}
.mb-card-clickable:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.brief-agent-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px 4px 8px;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

.agent-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.agent-dot.ok    { background: var(--green); box-shadow: 0 0 4px var(--green); }
.agent-dot.error { background: var(--red); box-shadow: 0 0 4px var(--red); }
.agent-dot.stale { background: var(--yellow); }

.sla-alert {
  margin-top: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  background: var(--red-dim);
  color: var(--red);
  display: flex;
  align-items: center;
  gap: 6px;
}
.sla-alert.ok {
  background: var(--green-dim);
  color: var(--green);
}
.sla-count {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.mb-stockout-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 5px 0;
  font-size: 12px;
  border-bottom: 1px solid var(--border);
}
.mb-stockout-row:last-child {
  border-bottom: none;
}
.mb-stockout-sku {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--text-muted);
  min-width: 100px;
  flex-shrink: 0;
}

.jarvis-ask-footer {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}
.jarvis-ask-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.14s;
  font-family: inherit;
}
.jarvis-ask-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim);
}

/* Brief urgent items */
.brief-urgent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.brief-urgent-item:last-child { border-bottom: none; }

.mb-dismiss-btn {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  opacity: 0.5;
  transition: opacity 0.12s, color 0.12s;
}
.mb-dismiss-btn:hover {
  opacity: 1;
  color: var(--red);
}

/* ═══════════════════════════════════════════════════════════════
   CUSTOMER HUB — Modernized inbox + compose
   ═══════════════════════════════════════════════════════════════ */

.hub-container {
  display: grid;
  grid-template-columns: 320px 1fr 280px;
  height: calc(100vh - 52px);
  overflow: hidden;
}

.hub-sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hub-sidebar-header {
  padding: 16px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.hub-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.2px;
}

.hub-header-stats {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 11px;
}
.hub-stat-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.hub-stat-badge.priority {
  background: var(--red-dim);
  color: var(--red);
}
.hub-stat-badge.open {
  background: var(--accent-dim, rgba(166,124,82,0.1));
  color: var(--accent);
}
.hub-stat-label {
  color: var(--text-dim);
  font-size: 11px;
}
.hub-stat-sep {
  color: var(--text-dim);
  font-size: 10px;
}

/* View tabs */
.hub-view-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  padding: 0 8px;
  overflow-x: auto;
}
.hub-view-tab {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.14s, border-color 0.14s;
  font-family: inherit;
}
.hub-view-tab:hover {
  color: var(--text);
}
.hub-view-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* Channel filter bar */
.hub-channel-bar {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}
.hub-ch-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 16px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.14s;
  font-family: inherit;
  white-space: nowrap;
}
.hub-ch-btn:hover {
  background: var(--surface-2);
}
.hub-ch-btn.active {
  background: var(--accent-dim, rgba(166,124,82,0.1));
  color: var(--accent);
  border-color: var(--accent);
}

/* Search */
.hub-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.14s, box-shadow 0.14s;
}
.hub-search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim, rgba(166,124,82,0.1));
}

/* Ticket list */
.hub-ticket-list {
  flex: 1;
  overflow-y: auto;
}

/* Main thread area */
.hub-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

.hub-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 12px;
  padding: 40px;
}
.hub-empty-icon {
  color: var(--text-dim);
  opacity: 0.4;
}
.hub-empty-text {
  font-size: 14px;
  color: var(--text-dim);
  font-weight: 500;
}

/* Compose area */
.hub-compose {
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.hub-mode-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  font-size: 11px;
  border-bottom: 1px solid var(--border);
}
.hub-mode-bar.draft {
  background: var(--yellow-dim);
}
.hub-mode-bar.live {
  background: var(--green-dim);
}
.hub-mode-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  font-size: 10px;
}
.hub-mode-bar.draft .hub-mode-indicator { color: var(--yellow); }
.hub-mode-bar.live .hub-mode-indicator  { color: var(--green); }

.hub-mode-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.hub-mode-bar.draft .hub-mode-dot { background: var(--yellow); }
.hub-mode-bar.live .hub-mode-dot  { background: var(--green); }

.hub-mode-toggle {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.14s;
}
.hub-mode-toggle:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.hub-compose-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.hub-compose-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.14s;
  font-family: inherit;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
}
.hub-compose-btn:hover {
  border-color: var(--border-hover);
  background: var(--surface-2);
  color: var(--text);
}
/* AI Draft button gets accent treatment */
.hub-compose-btn:first-child {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-dim, rgba(166,124,82,0.08));
}
.hub-compose-btn:first-child:hover {
  background: var(--accent);
  color: #fff;
}

.hub-textarea {
  width: 100%;
  min-height: 100px;
  padding: 12px 14px;
  border: none;
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  line-height: 1.55;
  resize: vertical;
}
.hub-textarea:focus {
  outline: none;
}

.hub-compose-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  border-top: 1px solid var(--border);
}
.hub-compose-left {
  display: flex;
  gap: 4px;
}

.hub-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: inherit;
  transition: all 0.14s;
}
.hub-action-btn:hover {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text);
}
.hub-action-btn.escalate:hover {
  background: var(--red-dim);
  border-color: var(--red);
  color: var(--red);
}
.hub-action-btn.resolve:hover {
  background: var(--green-dim);
  border-color: var(--green);
  color: var(--green);
}

.hub-send-btn {
  padding: 7px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.14s;
  font-family: inherit;
}
.hub-send-btn.draft {
  background: var(--surface-2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.hub-send-btn.draft:hover {
  background: var(--surface-3);
  color: var(--text);
}
.hub-send-btn.live {
  background: var(--accent);
  color: #fff;
}
.hub-send-btn.live:hover {
  filter: brightness(1.1);
}

/* Customer panel */
.hub-customer-panel {
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 16px;
}
.hub-customer-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}

/* Assignee select */
.hub-assignee-wrap {
  margin-left: auto;
}
.hub-assignee-select {
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}

/* Thread wrap */
.hub-thread-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.hub-thread-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.hub-thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 18px;
}

/* Modals */
.hub-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
}
.hub-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  max-width: 480px;
  width: 90%;
  max-height: 70vh;
  overflow: hidden;
}
.hub-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}
.hub-modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
}
.hub-modal-body {
  padding: 16px 18px;
  overflow-y: auto;
  max-height: 50vh;
}

/* Snooze options */
.hub-snooze-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.hub-snooze-opt {
  padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: all 0.14s;
}
.hub-snooze-opt:hover {
  background: var(--accent-dim, rgba(166,124,82,0.08));
  border-color: var(--accent);
}
.hub-snooze-custom {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hub-snooze-custom label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}
.hub-snooze-custom input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 13px;
}

/* Follow-up badge */
.hub-fu-badge {
  margin-left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 5px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Hub loading msg */
.hub-loading-msg {
  padding: 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
}

/* ─── Dark mode overrides for new hub styles ─── */
[data-theme="dark"] .hub-sidebar { background: var(--surface); }
[data-theme="dark"] .hub-compose { background: var(--surface); }
[data-theme="dark"] .hub-customer-panel { background: var(--surface); }
[data-theme="dark"] .hub-thread-header { background: var(--surface); }
[data-theme="dark"] .hub-modal { background: var(--surface); }
[data-theme="dark"] .hub-search { background: var(--bg); }
[data-theme="dark"] .hub-textarea { background: var(--surface); }

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE: Hub collapses to single column on mobile
   ═══════════════════════════════════════════════════════════════ */

@media (max-width: 960px) {
  .hub-container {
    grid-template-columns: 1fr;
  }
  .hub-customer-panel {
    display: none;
  }
}

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

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE: Tablet (1024px)
   ───────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
  /* Scale down font sizes slightly */
  body { font-size: 12.5px; }

  /* Reduce grid gaps */
  .stat-grid,
  .stats-row {
    gap: 10px;
  }

  /* Charts should never overflow */
  .acc-chart-container,
  .cust-rev-chart,
  .cust-freq-chart,
  .sla-volume-chart,
  .hub-analytics-charts,
  canvas {
    max-width: 100%;
  }

  /* Finance grids collapse earlier */
  .fin-income-grid,
  .fin-pl-grid { grid-template-columns: repeat(2, 1fr); }

  /* Location layout stack */
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE: Mobile (768px)
   ───────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Font size scale-down for mobile */
  body { font-size: 13px; }
  .page-title { font-size: 16px; }
  .page-subtitle { font-size: 12px; }
  .stat-value { font-size: 20px; }
  .stat-label { font-size: 11px; }

  /* Padding reduction */
  .main { padding: 10px; padding-bottom: 80px; }
  .card { padding: 12px; }
  .stat-card { padding: 10px; }

  /* ALL tables: horizontal scroll wrapper */
  .table-container,
  .table-scroll,
  .rev-table-scroll,
  [class*="-table-wrap"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .table-container table,
  .table-scroll table,
  .rev-table-scroll table,
  .main table {
    min-width: 580px;
  }

  /* Grid layouts collapse to single column */
  .fin-income-grid,
  .fin-pl-grid,
  .fin-exp-layout,
  .hub-analytics-charts,
  .ret-form-grid-3,
  .rcv-body-cols.rcv-has-po {
    grid-template-columns: 1fr !important;
  }

  /* Finance category row stack */
  .fin-cat-row { grid-template-columns: 1fr; gap: 4px; }

  /* Charts responsive */
  .acc-chart-container,
  .cust-rev-chart,
  .cust-freq-chart,
  .sla-volume-chart,
  .hub-analytics-charts,
  canvas {
    max-width: 100%;
    overflow-x: auto;
  }
  .cust-rev-chart,
  .cust-freq-chart {
    height: auto;
    min-height: 120px;
  }

  /* Modals: full-width on mobile */
  .modal-480,
  .modal-680,
  .modal-420,
  .modal-380,
  .modal-320,
  .rcv-po-picker-modal,
  .hub-modal,
  .hub-return-modal,
  .cp-modal {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    margin: 12px auto;
  }

  /* Customer hub layout */
  .hub-container { grid-template-columns: 1fr; }
  .hub-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); max-height: 40vh; }
  .hub-customer-panel { display: none; }

  /* Responder sidebar stacks below */
  .responder-sidebar { width: 100%; }

  /* Reduce header padding */
  .header { padding: 0 10px; }
  .header-right { gap: 4px; }

  /* Toolbars stack */
  .toolbar,
  .lbl-tools-row {
    flex-direction: column;
    align-items: stretch;
  }
  .lbl-tools-row > * { flex: none; }

  /* Tab groups scroll horizontally */
  .tab-group,
  .tabs,
  [class*="-tabs"],
  [class*="-tab-group"] {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap;
    white-space: nowrap;
  }

  /* Morning brief grid */
  .mb-pl-grid { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ─────────────────────────────────────────────────────────────
   RESPONSIVE: Small Mobile (480px)
   ───────────────────────────────────────────────────────────── */

@media (max-width: 1360px) {
  .header {
    padding-inline: 16px;
  }

  .header-status-group {
    flex-basis: 320px;
  }

  .header-right {
    gap: 6px 8px;
  }

  .shell-search-btn .shell-kbd,
  .header-freshness-label,
  .api-health-label,
  .sync-status span,
  .live-indicator span {
    display: none;
  }

  .header-freshness-wrap,
  .sync-status,
  .live-indicator,
  .api-health-wrap {
    padding-inline: 9px;
  }
}

@media (max-width: 1120px) {
  .header {
    align-items: flex-start;
    gap: 8px 12px;
  }

  .header-right {
    flex-basis: 100%;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    justify-content: stretch;
    gap: 8px 10px;
  }

  .header-status-group,
  .header-action-group,
  .header-account-group {
    width: auto;
  }

  .header-status-group {
    grid-column: 1 / -1;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .header-action-group,
  .header-account-group {
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .header-status-group::-webkit-scrollbar {
    display: none;
  }

  .header-action-group {
    grid-column: 2;
  }

  .header-account-group {
    grid-column: 3;
  }

  .user-info {
    border-left: none;
    padding-left: 0;
  }
}

@media (max-width: 980px) {
  .header-freshness-wrap,
  .sync-status,
  .api-health-wrap {
    display: none;
  }

  .header-right {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .header-status-group {
    gap: 6px;
  }

  .header-action-group {
    grid-column: 1;
    justify-content: flex-start;
  }

  .header-account-group {
    grid-column: 2;
  }

  .view-mode-indicator {
    display: none;
  }
}

@media (max-width: 860px) {
  .header-status-group {
    display: none;
  }

  .header-right {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px 8px;
  }

  .header-action-group,
  .header-account-group {
    width: auto;
  }

  .view-as-switcher {
    display: none !important;
  }

  .user-name {
    display: none;
  }
}

@media (max-width: 480px) {
  body { font-size: 13px; }

  .main { padding: 8px; padding-bottom: 72px; }

  /* Everything single column */
  .stat-grid,
  .stats-row,
  .mb-pl-grid {
    grid-template-columns: 1fr !important;
  }

  /* Morning brief top3 compact */
  .mb-top3-container { padding: 12px; }
  .mb-top3-item { padding: 8px 10px; }

  /* Table min-width smaller for tiny screens */
  .table-container table,
  .table-scroll table,
  .main table {
    min-width: 480px;
  }

  /* Modals truly full-width */
  .modal-480,
  .modal-680,
  .modal-420,
  .modal-380,
  .modal-320,
  .rcv-po-picker-modal,
  .hub-modal,
  .hub-return-modal {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    border-radius: var(--radius-sm);
  }

  /* Charts tighter */
  .cust-rev-chart,
  .cust-freq-chart {
    min-height: 100px;
    gap: 8px;
  }
  .acc-chart-body { height: 140px; }

  /* Header even more compact */
  .header { padding: 0 8px; }
  .logo { font-size: 12px; letter-spacing: 0.8px; }
}

/* ─────────────────────────────────────────────────────────────
   PRINT — hide toast + progress bar
   ───────────────────────────────────────────────────────────── */

@media print {
  .sidebar, .header, .theme-toggle-btn,
  #toast-container, #page-progress-bar,
  .main { padding: 0 !important; }
  .app { display: block !important; }
  [data-theme="dark"] { filter: invert(1) hue-rotate(180deg); }
}

/* ─────────────────────────────────────────────────────────────
   iOS-STYLE TOGGLE SWITCH (.im-switch)
   Used on the Returns Stock refurbished row to flip a unit between
   "listed on Shopify" and "not listed" in one click. Replaces the
   old List for Sale / Unlist button pair. Keep the DOM minimal —
   a single <button> with ::after for the thumb — so it works in
   any table cell without extra wrapper structure.
   ───────────────────────────────────────────────────────────── */
.im-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
  padding: 0;
  /* Use a concrete mid-grey for the OFF track instead of surface-2 —
     surface-2 matched the card/hover background on Returns Stock and
     made the toggle disappear on hover. A hard 1px border keeps the
     track visible against any background. */
  background: #cbd5e1;
  border: 1px solid #94a3b8;
  border-radius: 12px;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
  flex-shrink: 0;
  vertical-align: middle;
}

.im-switch:hover {
  background: #b6c0cc;
  border-color: #64748b;
}

.im-switch::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 1px;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform 150ms ease;
}

.im-switch.on {
  background: #2563eb;
  border-color: #1d4ed8;
}

.im-switch.on:hover {
  background: #1d4ed8;
  border-color: #1e40af;
}

.im-switch.on::after {
  transform: translateX(18px);
}

.im-switch.disabled,
.im-switch[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.im-switch:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.im-switch-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  user-select: none;
}

.im-switch-label.on {
  color: #16a34a;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
   MODERNIZATION LAYER (2026-06-17) — micro-interactions & depth
   Additive only. The global prefers-reduced-motion rule earlier in
   this file zeroes every transition below for motion-sensitive users.
   ═══════════════════════════════════════════════════════════════ */
:root {
  --ease-out: cubic-bezier(0.32, 0.72, 0, 1);
  --motion-fast: 0.13s;
  --motion: 0.2s;
}

/* Consistent, smooth interaction feedback across every control */
button, .btn, .nav-item, .filter-btn, .toggle-btn, .action-btn, .refresh-btn,
.pill, .badge, a, input, select, textarea, summary,
[role="button"], [data-action],
[class*="-card"][onclick], [class*="-card"][role="button"],
.mb-kpi-card, .cp-agent-card, .stat-card {
  transition: background-color var(--motion) ease,
              border-color var(--motion) ease,
              color var(--motion) ease,
              box-shadow var(--motion) ease,
              transform var(--motion-fast) var(--ease-out),
              opacity var(--motion) ease;
}

/* Tactile press feedback on buttons */
button:active:not(:disabled), .btn:active:not(:disabled),
.filter-btn:active, .action-btn:active, .refresh-btn:active,
[role="button"]:active {
  transform: translateY(1px);
}

/* Inputs: clearer accent focus ring */
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}

/* Interactive cards lift on hover — modern, responsive depth */
[class*="-card"][onclick]:hover,
[class*="-card"][role="button"]:hover,
.mb-kpi-card:hover,
.cp-agent-card:hover,
a[class*="-card"]:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Smooth table-row hover */
tbody tr { transition: background-color var(--motion) ease; }

/* Modern thin scrollbars */
* { scrollbar-width: thin; scrollbar-color: var(--border-hover) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 8px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); background-clip: padding-box; }

/* Smooth in-page anchor scrolling (reduced-motion override above wins for opt-outs) */
html { scroll-behavior: smooth; }

/* ═══════════════════════════════════════════════════════════
   Theme crossfade — active ONLY during the ~280ms toggle.
   toggleTheme() adds `.theme-anim` to <html>, flips data-theme, then
   removes the class. Scoping the transition to that temporary class means
   normal interactions are never slowed, and the whole surface (backgrounds,
   borders, text, icon fills, shadows) eases between light/dark instead of
   hard-cutting in a single frame.
   ═══════════════════════════════════════════════════════════ */
html.theme-anim,
html.theme-anim * {
  transition: background-color .26s ease, border-color .26s ease,
              color .26s ease, fill .26s ease, box-shadow .26s ease !important;
}
@media (prefers-reduced-motion: reduce) {
  html.theme-anim,
  html.theme-anim * { transition: none !important; }
}

/* ═══════════════════════════════════════════════════════════
   Route-load skeleton — shown by loadView() on navigation instead of a
   centered spinner. A layout-matched placeholder (title + stat tiles +
   rows) means content arrives into the same shape, killing the
   blank-then-pop flash and reducing layout shift. Uses the existing
   .skeleton shimmer. Respects prefers-reduced-motion via .skeleton's own
   reduced-motion opt-out elsewhere in this file.
   ═══════════════════════════════════════════════════════════ */
.view-skeleton { padding: 10px 4px 24px; }
.view-skeleton .vsk-title { height: 28px; width: 220px; margin: 6px 0 20px; }
.view-skeleton .vsk-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}
.view-skeleton .vsk-stat { height: 84px; }
.view-skeleton .vsk-row { height: 46px; margin-bottom: 10px; }
@media (max-width: 900px) { .view-skeleton .vsk-stats { grid-template-columns: repeat(2, 1fr); } }

/* ═══════════════════════════════════════════════════════════
   CANONICAL BADGES — Tier 1
   Unifies the 165 color-named badges onto tokenized colors and adds SEMANTIC
   aliases (success/warning/danger/info/neutral) so new code expresses meaning,
   not color. Shape is applied to the semantic + color-named variants but NOT
   to bare `.badge` (which the nav-count bubbles rely on for their own circular
   layout). Loads last, so these win over the scattered legacy definitions.
   ═══════════════════════════════════════════════════════════ */
.badge-green,  .badge-success { background: var(--success-dim); color: var(--green);  }
.badge-red,    .badge-danger  { background: var(--danger-dim);  color: var(--red);    }
.badge-yellow, .badge-warning { background: var(--warning-dim); color: var(--yellow); }
.badge-blue,   .badge-info    { background: var(--info-dim);    color: var(--blue);   }
.badge-purple                 { background: var(--purple-dim);  color: var(--purple); }
.badge-accent                 { background: var(--accent-dim);  color: var(--accent); }
.badge-gray, .badge-grey, .badge-neutral {
  background: var(--surface-2); color: var(--text-muted);
}
/* Consistent pill shape for the color-named + semantic variants. Excludes bare
   `.badge` so contextual badges (nav counts, inbox headers) keep their layout. */
.badge-green, .badge-red, .badge-yellow, .badge-blue, .badge-purple,
.badge-accent, .badge-gray, .badge-grey, .badge-neutral,
.badge-success, .badge-danger, .badge-warning, .badge-info {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  line-height: 1.5;
  letter-spacing: 0.01em;
  white-space: nowrap;
  vertical-align: middle;
}

/* ═══════════════════════════════════════════════════════════
   Tier 2 — generalized overlay/modal motion + consistent close controls
   Only the command palette + journey modal animated their entrance before;
   most of the ~34 modal/drawer families popped in instantly. Apply an
   OPACITY-ONLY fade (never a transform — so it can't fight a modal's own
   centering transform) to the common generic families. Reduced-motion safe.
   ═══════════════════════════════════════════════════════════ */
.modal-overlay,
.drawer-overlay,
.modal-backdrop { animation: overlayIn 0.16s ease both; }
.modal,
.modal-content,
.modal-card,
.drawer-panel { animation: overlayIn 0.18s ease both; }
@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .drawer-overlay, .modal-backdrop,
  .modal, .modal-content, .modal-card, .drawer-panel { animation: none !important; }
}

/* Consistent close control across modals/drawers/panels (glyph stays whatever
   the markup uses; this unifies size, hit-area, color, and hover). */
.modal-close,
.drawer-close,
.panel-close,
.btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard),
              color var(--dur-fast) var(--ease-standard);
}
.modal-close:hover,
.drawer-close:hover,
.panel-close:hover,
.btn-close:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* Button tail — fold color/size one-offs onto the canonical semantics so the
   button family reads consistently (the base .btn/.btn-primary/etc. are fine). */
.btn-green   { background: var(--green); color: #fff; border-color: var(--green); }
.btn-red     { background: var(--red);   color: #fff; border-color: var(--red); }
.btn-small   { padding: 3px 8px; font-size: var(--fs-xs); border-radius: var(--radius-sm); }

/* ═══════════════════════════════════════════════════════════
   Tier 2 — sticky data-table headers
   Long P&L / inventory / cashflow tables lost their header on scroll, and the
   sticky snippet was copy-pasted per-view with drifting z-index/background.
   One canonical rule on .data-table. Opaque background + inset shadow border
   (border-bottom doesn't render reliably on a sticky cell under
   border-collapse). Short tables never scroll, so this is invisible there.
   ═══════════════════════════════════════════════════════════ */
.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
}

/* ═══════════════════════════════════════════════════════════
   A11y — keyboard focus safety net
   The app has 40+ :focus-visible rules but several controls (notably the
   support inbox inputs in inbox-v2.css) strip their outline with no keyboard
   replacement. This generic ring applies ONLY where a more specific
   :focus-visible rule doesn't already win, and ONLY for keyboard focus
   (:focus-visible never matches mouse clicks), so it never disturbs the
   designed states or mouse interaction.
   ═══════════════════════════════════════════════════════════ */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible,
[role="button"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Support inbox (inbox-v2) strips input/button outlines on :focus with no
   keyboard replacement (audit P1). Restore a ring for KEYBOARD focus only —
   !important + :focus-visible beats the more-specific `.iv2-*:focus{outline:none}`
   without affecting mouse focus. */
[class*="iv2-"]:focus-visible,
.iv2 input:focus-visible,
.iv2 textarea:focus-visible,
.iv2 button:focus-visible {
  outline: 2px solid var(--accent) !important;
  outline-offset: 1px;
}
