/* WebCanteen eComm OS — Design Tokens */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Neutrals — slightly cool, paper-like */
  --bg: #fafafa;
  --bg-elev: #ffffff;
  --bg-sunken: #f4f4f5;
  --bg-hover: #f4f4f5;
  --bg-active: #ececef;
  --bg-selected: #eef0ff;

  --border: #e5e5e8;
  --border-strong: #d4d4d8;
  --border-subtle: #efeff2;

  --text: #18181b;
  --text-muted: #52525b;
  --text-subtle: #71717a;
  --text-faint: #a1a1aa;
  --text-inverse: #fafafa;

  /* Brand — refined indigo */
  --brand: #4f46e5;
  --brand-hover: #4338ca;
  --brand-soft: #eef0ff;
  --brand-text: #3730a3;

  /* Stage palette — semantic */
  --stage-intake-bg: #f4f4f5;       --stage-intake-fg: #3f3f46;       --stage-intake-dot: #71717a;
  --stage-warehouse-bg: #fef3c7;    --stage-warehouse-fg: #92400e;    --stage-warehouse-dot: #d97706;
  --stage-awb-bg: #dbeafe;          --stage-awb-fg: #1e40af;          --stage-awb-dot: #2563eb;
  --stage-manifested-bg: #e0e7ff;   --stage-manifested-fg: #3730a3;   --stage-manifested-dot: #4f46e5;
  --stage-pickup-bg: #ede9fe;       --stage-pickup-fg: #5b21b6;       --stage-pickup-dot: #7c3aed;
  --stage-transit-bg: #cffafe;      --stage-transit-fg: #155e75;      --stage-transit-dot: #0891b2;
  --stage-delivered-bg: #d1fae5;    --stage-delivered-fg: #065f46;    --stage-delivered-dot: #059669;
  --stage-exception-bg: #fee2e2;    --stage-exception-fg: #991b1b;    --stage-exception-dot: #dc2626;
  --stage-returned-bg: #fed7aa;     --stage-returned-fg: #9a3412;     --stage-returned-dot: #ea580c;
  --stage-cancelled-bg: #e5e5e8;    --stage-cancelled-fg: #27272a;    --stage-cancelled-dot: #52525b;

  /* Role palette — 8 distinct */
  --role-coo: #7c3aed;
  --role-ops_manager: #4f46e5;
  --role-warehouse: #d97706;
  --role-dispatch: #0891b2;
  --role-returns: #ea580c;
  --role-qc: #db2777;
  --role-finance: #059669;
  --role-support: #64748b;

  /* Semantic */
  --success: #059669;
  --success-soft: #d1fae5;
  --warning: #d97706;
  --warning-soft: #fef3c7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --info: #2563eb;
  --info-soft: #dbeafe;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, monospace;

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

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(24,24,27,0.04);
  --shadow-sm: 0 1px 3px rgba(24,24,27,0.06), 0 1px 2px rgba(24,24,27,0.04);
  --shadow-md: 0 4px 12px rgba(24,24,27,0.08), 0 2px 4px rgba(24,24,27,0.04);
  --shadow-lg: 0 12px 32px rgba(24,24,27,0.12), 0 4px 8px rgba(24,24,27,0.06);
  --shadow-focus: 0 0 0 3px rgba(79,70,229,0.18);

  /* Density */
  --row-h: 40px;
  --row-h-compact: 32px;
  --side-w: 232px;
  --side-w-collapsed: 56px;
  --topbar-h: 52px;
}

[data-density="compact"] {
  --row-h: 32px;
}

[data-theme="warm"] {
  --bg: #fafaf7;
  --bg-sunken: #f5f4ee;
  --brand: #b45309;
  --brand-hover: #92400e;
  --brand-soft: #fef3c7;
  --brand-text: #78350f;
}

[data-theme="slate"] {
  --bg: #f8fafc;
  --bg-sunken: #f1f5f9;
  --brand: #0f766e;
  --brand-hover: #115e59;
  --brand-soft: #ccfbf1;
  --brand-text: #134e4a;
}

* { box-sizing: border-box; }
html, body, #root { height: 100%; margin: 0; }
body {
  font-family: var(--font-sans);
  background: var(--bg-sunken);
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  font-feature-settings: 'cv11', 'ss01';
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: inherit; }
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d4d4d8; border-radius: 10px; border: 2px solid var(--bg-sunken); }
::-webkit-scrollbar-thumb:hover { background: #a1a1aa; }

/* App shell */
.app {
  display: grid;
  grid-template-columns: var(--side-w) 1fr;
  height: 100vh;
  overflow: hidden;
}
.app[data-collapsed="true"] { grid-template-columns: var(--side-w-collapsed) 1fr; }

/* Sidebar */
.sidebar {
  background: #18181b;
  color: #d4d4d8;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #27272a;
  overflow: hidden;
}
.sidebar-brand {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid #27272a;
  flex-shrink: 0;
}
.sidebar-brand .logo {
  width: 24px; height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 12px;
  flex-shrink: 0;
}
.sidebar-brand .name { font-weight: 600; color: #fafafa; font-size: 13px; letter-spacing: -0.01em; white-space: nowrap; }
.sidebar-brand .sub { font-size: 10px; color: #71717a; text-transform: uppercase; letter-spacing: 0.08em; white-space: nowrap; }

.nav-group { padding: 12px 8px 4px; }
.nav-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #71717a;
  padding: 0 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px;
  border-radius: 5px;
  color: #a1a1aa;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.08s, color 0.08s;
}
.nav-item:hover { background: #27272a; color: #fafafa; }
.nav-item.active { background: #27272a; color: #fafafa; }
.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .badge {
  margin-left: auto;
  background: #3f3f46;
  color: #d4d4d8;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 10px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .badge { background: var(--brand); color: white; }

.sidebar-user {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid #27272a;
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  flex-shrink: 0;
}
.sidebar-user:hover { background: #27272a; }
.avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  display: grid; place-items: center;
  font-weight: 600; font-size: 11px;
  color: white;
  flex-shrink: 0;
}
.user-meta { flex: 1; min-width: 0; }
.user-name { color: #fafafa; font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-roles { display: flex; gap: 3px; margin-top: 2px; }

/* Main area */
.main { display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.topbar {
  height: var(--topbar-h);
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 20px;
  gap: 16px;
  flex-shrink: 0;
}
.page-title { font-size: 14px; font-weight: 600; color: var(--text); letter-spacing: -0.01em; }
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--text-subtle); font-size: 12px; }
.crumbs .sep { color: var(--text-faint); }

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 5px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-subtle);
}

.search-trigger {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 5px 10px;
  color: var(--text-subtle);
  font-size: 12px;
  width: 280px;
  cursor: pointer;
  transition: all 0.1s;
}
.search-trigger:hover { background: var(--bg-elev); border-color: var(--border-strong); }
.search-trigger .placeholder { flex: 1; }

.icon-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  position: relative;
  transition: all 0.1s;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }
.icon-btn .dot {
  position: absolute; top: 6px; right: 6px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--bg-elev);
}

/* Page content */
.page {
  flex: 1;
  overflow: auto;
  padding: 24px 32px;
}
.page-narrow { max-width: 1400px; margin: 0 auto; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  transition: all 0.08s;
  white-space: nowrap;
  height: 30px;
}
.btn:hover { background: var(--bg-hover); }
.btn-primary { background: var(--brand); color: white; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-hover); border-color: var(--brand-hover); }
.btn-secondary { background: var(--bg-elev); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--bg-sunken); border-color: var(--text-faint); }
.btn-ghost { color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--bg-sunken); }
.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }
.btn-danger-outline { color: var(--danger); border-color: var(--border-strong); background: var(--bg-elev); }
.btn-danger-outline:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-sm { height: 26px; padding: 4px 8px; font-size: 11px; }
.btn-lg { height: 36px; padding: 8px 16px; font-size: 13px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* Inputs */
.input, .select {
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--bg-elev);
  color: var(--text);
  font-size: 12px;
  outline: none;
  transition: border-color 0.1s, box-shadow 0.1s;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: var(--shadow-focus); }
.input::placeholder { color: var(--text-faint); }
textarea.input { height: auto; padding: 8px 10px; resize: vertical; min-height: 60px; }

.input-group { position: relative; display: inline-flex; align-items: center; }
.input-group .input { padding-left: 30px; }
.input-group .icon { position: absolute; left: 9px; color: var(--text-faint); pointer-events: none; }

/* Badges */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
  line-height: 1.4;
  white-space: nowrap;
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.badge-stage { font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.02em; }
.badge-role { font-size: 10px; padding: 1px 6px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em; }

/* Cards */
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text); }
.card-sub { font-size: 11px; color: var(--text-subtle); }
.card-body { padding: 16px; }

/* KPI */
.kpi {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 4px;
  position: relative;
  overflow: hidden;
}
.kpi-label { font-size: 11px; color: var(--text-subtle); font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.kpi-value { font-size: 24px; font-weight: 600; color: var(--text); letter-spacing: -0.02em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-delta { font-size: 11px; display: flex; align-items: center; gap: 3px; }
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--danger); }
.kpi-delta.neutral { color: var(--text-subtle); }

/* Table */
.table-wrap {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.table thead th {
  background: var(--bg-sunken);
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-subtle);
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  position: sticky;
  top: 0;
  z-index: 1;
}
.table tbody td {
  padding: 0 12px;
  height: var(--row-h);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}
.table tbody tr { transition: background 0.06s; }
.table tbody tr:hover { background: var(--bg-sunken); }
.table tbody tr.selected { background: var(--bg-selected); }
.table tbody tr:last-child td { border-bottom: none; }
.table .col-num { font-family: var(--font-mono); font-size: 11.5px; font-variant-numeric: tabular-nums; text-align: right; }
.table .col-id { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); }
.table .col-checkbox { width: 32px; padding-right: 0; }
.table .col-action { width: 40px; text-align: right; }

/* Checkbox */
.checkbox {
  width: 14px; height: 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: 3px;
  background: var(--bg-elev);
  display: inline-grid; place-items: center;
  cursor: pointer;
  transition: all 0.1s;
  flex-shrink: 0;
}
.checkbox:hover { border-color: var(--brand); }
.checkbox.checked { background: var(--brand); border-color: var(--brand); }
.checkbox.checked::after {
  content: ''; width: 8px; height: 5px;
  border-left: 1.5px solid white; border-bottom: 1.5px solid white;
  transform: rotate(-45deg) translate(0px, -1px);
}
.checkbox.indeterminate { background: var(--brand); border-color: var(--brand); }
.checkbox.indeterminate::after {
  content: ''; width: 8px; height: 1.5px; background: white;
}

/* Tabs */
.tabs {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  border: none;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  display: inline-flex; align-items: center; gap: 6px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--brand); }
.tab .count {
  background: var(--bg-sunken); padding: 1px 6px; border-radius: 10px;
  font-size: 10px; font-weight: 600; color: var(--text-muted);
}
.tab.active .count { background: var(--brand-soft); color: var(--brand-text); }

/* Filter chips */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 4px 10px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--bg-elev);
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px;
}
.chip:hover { border-color: var(--text-faint); color: var(--text); }
.chip.active { background: var(--text); color: var(--bg-elev); border-color: var(--text); }
.chip .count { font-variant-numeric: tabular-nums; opacity: 0.7; font-size: 10.5px; }

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

/* Bulk action bar */
.bulk-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px;
  background: var(--text);
  color: var(--bg-elev);
  border-radius: 8px;
  font-size: 12px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-md);
}
.bulk-bar .count { font-weight: 600; }
.bulk-bar .actions { margin-left: auto; display: flex; gap: 4px; }
.bulk-bar .btn { color: var(--bg-elev); }
.bulk-bar .btn:hover { background: rgba(255,255,255,0.12); }

/* Stage timeline */
.timeline {
  display: flex; align-items: flex-start;
  padding: 16px 0;
  position: relative;
  overflow-x: auto;
}
.timeline-step {
  flex: 1;
  min-width: 110px;
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  padding: 0 8px;
}
.timeline-step .node {
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--bg-elev);
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  z-index: 1;
  position: relative;
}
.timeline-step.done .node { background: var(--brand); border-color: var(--brand); color: white; }
.timeline-step.current .node { border-color: var(--brand); background: var(--brand-soft); }
.timeline-step.current .node::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: var(--brand);
}
.timeline-step:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 11px; left: 50%; right: -50%;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.timeline-step.done:not(:last-child)::after { background: var(--brand); }
.timeline-step .label {
  margin-top: 8px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  white-space: nowrap;
}
.timeline-step.current .label, .timeline-step.done .label { color: var(--text); }
.timeline-step .ts {
  font-size: 10px; color: var(--text-faint);
  font-family: var(--font-mono);
  margin-top: 2px;
  text-align: center;
  white-space: nowrap;
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(24,24,27,0.4);
  z-index: 100;
  display: grid; place-items: center;
  animation: fadeIn 0.12s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-elev);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  display: flex; flex-direction: column;
  animation: slideUp 0.16s;
}
@keyframes slideUp { from { transform: translateY(8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-lg { max-width: 720px; }
.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 12px;
}
.modal-title { font-size: 14px; font-weight: 600; }
.modal-body { padding: 20px; overflow: auto; flex: 1; }
.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex; gap: 8px; justify-content: flex-end;
  background: var(--bg-sunken);
  border-radius: 0 0 12px 12px;
}

/* Command palette */
.cmdk-backdrop {
  position: fixed; inset: 0;
  background: rgba(24,24,27,0.5);
  z-index: 200;
  display: flex; justify-content: center;
  padding-top: 12vh;
  animation: fadeIn 0.1s;
}
.cmdk {
  width: 600px; max-width: 90vw;
  background: var(--bg-elev);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  max-height: 60vh;
}
.cmdk-input {
  border: none;
  outline: none;
  padding: 14px 18px;
  font-size: 14px;
  background: transparent;
  border-bottom: 1px solid var(--border);
}
.cmdk-list { flex: 1; overflow: auto; padding: 6px; }
.cmdk-section { padding: 6px 10px 4px; font-size: 10px; font-weight: 600; text-transform: uppercase; color: var(--text-faint); letter-spacing: 0.06em; }
.cmdk-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text);
}
.cmdk-item.selected { background: var(--brand-soft); color: var(--brand-text); }
.cmdk-item .meta { margin-left: auto; font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }

/* Toast */
.toast-container {
  position: fixed; bottom: 20px; right: 20px;
  z-index: 300;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  background: var(--text);
  color: var(--bg-elev);
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 12.5px;
  box-shadow: var(--shadow-md);
  display: flex; align-items: center; gap: 10px;
  min-width: 280px;
  animation: slideInRight 0.18s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Skeletons */
.skel { background: var(--bg-sunken); border-radius: 4px; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.5; } }

/* Sync indicator */
.sync-status {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 8px;
  border-radius: 12px;
  background: var(--bg-sunken);
  font-size: 11px;
  color: var(--text-muted);
}
.sync-status .pulse {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 currentColor;
}
.sync-status.live .pulse { animation: livePulse 2s infinite; }
@keyframes livePulse {
  0% { box-shadow: 0 0 0 0 rgba(5,150,105,0.5); }
  70% { box-shadow: 0 0 0 6px rgba(5,150,105,0); }
  100% { box-shadow: 0 0 0 0 rgba(5,150,105,0); }
}
.sync-status.syncing .pulse { background: var(--info); animation: livePulse 1s infinite; }

/* Banner */
.banner {
  padding: 10px 16px;
  border-radius: 8px;
  display: flex; align-items: center; gap: 10px;
  font-size: 12.5px;
  border: 1px solid;
}
.banner-info { background: var(--info-soft); border-color: #bfdbfe; color: #1e40af; }
.banner-warn { background: var(--warning-soft); border-color: #fde68a; color: #92400e; }
.banner-error { background: var(--danger-soft); border-color: #fecaca; color: #991b1b; }
.banner-success { background: var(--success-soft); border-color: #a7f3d0; color: #065f46; }

/* Empty state */
.empty {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-muted);
}
.empty .emoji { font-size: 32px; margin-bottom: 12px; opacity: 0.3; }
.empty .title { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.empty .desc { font-size: 12px; color: var(--text-subtle); margin-bottom: 16px; }

/* Grid */
.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }

/* Layout helpers */
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 8px; }
.flex-1 { flex: 1; }
.gap-4 { gap: 4px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; } .gap-24 { gap: 24px; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; } .mb-24 { margin-bottom: 24px; }

.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-faint { color: var(--text-faint); }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12px; }
.text-md { font-size: 13px; }
.text-lg { font-size: 14px; }
.text-xl { font-size: 16px; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

.divider { height: 1px; background: var(--border); margin: 12px 0; }

/* Specifically for order detail split */
.split {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

/* Customer return portal — distinct vibe */
.portal {
  min-height: 100vh;
  background: linear-gradient(180deg, #fafafa 0%, #f4f4f5 100%);
  display: flex; flex-direction: column;
}
.portal-header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elev);
}
.portal-body {
  flex: 1;
  max-width: 560px;
  margin: 32px auto;
  width: 100%;
  padding: 0 24px;
}
.portal-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  box-shadow: var(--shadow-sm);
}

/* Login */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--bg-elev);
}
.login-pane {
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.login-form { width: 100%; max-width: 360px; }
.login-side {
  background: linear-gradient(135deg, #18181b 0%, #27272a 100%);
  color: white;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 48px;
  position: relative;
  overflow: hidden;
}
.login-side::before {
  content: ''; position: absolute; inset: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(99,102,241,0.15), transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(79,70,229,0.1), transparent 50%);
}

/* Charts */
.spark { width: 100%; height: 32px; }
.bar-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.bar-track { flex: 1; height: 6px; background: var(--bg-sunken); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* Progress ring */
.ring-wrap { position: relative; display: inline-block; }
.ring-wrap .ring-text {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
}

/* Drawer / detail rail */
.detail-rail {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 8px;
  position: sticky;
  top: 0;
}

/* Section header */
.section-header {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px;
}
.section-title { font-size: 14px; font-weight: 600; color: var(--text); }
.section-sub { font-size: 12px; color: var(--text-subtle); }

/* Tweaks panel overrides */
.tweaks-panel { z-index: 500; }

/* =========================================================================
   Responsive — embedded product demo on small screens (e.g. the marketing
   hero iframe on phones). The desktop layout above is unchanged; these blocks
   only ADD rules at narrow widths so the preview reads cleanly instead of a
   cramped desktop UI. Strategy: hide the desktop nav rail, give the content
   the full width, collapse stat/detail grids, and prevent any overflow.
   ========================================================================= */
@media (max-width: 720px) {
  .app, .app[data-collapsed="true"] { grid-template-columns: 1fr; }
  .sidebar { display: none; }                 /* desktop nav rail off on phones */
  .topbar { padding: 0 12px; gap: 8px; overflow: hidden; }
  .crumbs, .kbd-hint, .search-trigger { display: none; }  /* search opens via ⌘K on desktop; hide the wide box on phones */
  .topbar-actions { gap: 6px; }
  .page { padding: 16px; }
  /* let content rows/headers wrap instead of forcing the cards wider than the screen */
  .page .row { flex-wrap: wrap; }
  .card-header { flex-wrap: wrap; gap: 8px; }
  .card, .kpi, .table-wrap, .main { min-width: 0; }
  .grid-3, .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); }
  .split { grid-template-columns: 1fr; }
  .login-page { grid-template-columns: 1fr; }
  .login-side { display: none; }
  .tweaks-panel { display: none; }            /* the floating demo switcher is desktop-only */
}
@media (max-width: 430px) {
  .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
  .page { padding: 12px; }
  .topbar { padding: 0 12px; }
}

/* =========================================================================
   Mobile excellence pass (<=480px). The demo opens full-screen when a phone
   user taps "Open the live demo", so the DEFAULT dashboard view must read as
   an intentional, premium app at 360px — not a shrunk desktop. Everything
   below only ADDS rules at narrow widths; desktop appearance is untouched.
   Preserves: .sidebar hidden, grids collapsed to 1 column, .search-trigger /
   .crumbs / .kbd-hint hidden, .login-side / .tweaks-panel hidden.
   ========================================================================= */
@media (max-width: 480px) {
  /* --- Foundations: readable body type, never overflow the viewport --- */
  body { font-size: 14px; }
  img, svg, iframe, video, canvas { max-width: 100%; height: auto; }
  /* long ids / emails / urls / labels wrap instead of pushing width */
  .user-name, .card-title, .card-sub, .page-title,
  .kpi-label, .empty .desc, .banner, .cmdk-item, .toast,
  .table .col-id, .table .col-num { overflow-wrap: anywhere; word-break: break-word; }

  /* --- App shell / page rhythm: consistent 18px gutters, tighter vertical --- */
  .page { padding: 18px 18px 48px; }
  .page-narrow { max-width: 100%; }

  /* --- Topbar: fit 360px, keep icons tappable --- */
  .topbar { height: auto; min-height: var(--topbar-h); padding: 8px 16px; gap: 10px; flex-wrap: wrap; }
  .page-title { font-size: 15px; }
  .topbar-actions { gap: 4px; }
  .icon-btn { width: 40px; height: 40px; }   /* ~44px touch slop with surrounding gap */
  .icon-btn .dot { top: 9px; right: 9px; }

  /* --- Buttons: comfortable >=40px tap height; full-width primary actions --- */
  .btn { height: 40px; padding: 8px 14px; font-size: 13px; }
  .btn-sm { height: 36px; padding: 6px 12px; font-size: 12px; }
  .btn-lg { height: 44px; padding: 10px 18px; font-size: 14px; }
  /* footer actions stack to full width so they're easy to hit one-handed */
  .modal-footer .btn, .login-form .btn-lg, .portal-card .btn-lg { flex: 1; justify-content: center; }

  /* --- Form controls: bigger, no iOS zoom (>=16px font), full width --- */
  .input, .select { height: 44px; font-size: 16px; width: 100%; }
  textarea.input { font-size: 16px; }
  .input-group { display: flex; width: 100%; }
  .input-group .input { width: 100%; }
  .checkbox { width: 18px; height: 18px; }

  /* --- Cards: comfortable padding, full width --- */
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }
  .kpi { padding: 16px; }
  .kpi-value { font-size: 22px; }

  /* --- Tabs & chips: tappable rows, horizontal scroll instead of cramming --- */
  .tabs { gap: 2px; overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; }
  .tab { padding: 12px 12px; font-size: 13px; white-space: nowrap; flex-shrink: 0; min-height: 44px; }
  .chips { gap: 8px; }
  .chip { height: 36px; padding: 7px 14px; font-size: 12.5px; }

  /* --- Filter / bulk bars: stack and wrap, full-width controls --- */
  .filter-bar { gap: 8px; padding: 12px; }
  .filter-bar .input, .filter-bar .select, .filter-bar .input-group { width: 100%; }
  .bulk-bar { flex-wrap: wrap; gap: 8px; padding: 10px 14px; }
  .bulk-bar .actions { margin-left: 0; width: 100%; flex-wrap: wrap; }

  /* --- Tables: must scroll horizontally inside their card, never clip --- */
  .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 560px; font-size: 13px; }
  .table thead th { padding: 10px 12px; }
  .table tbody td { height: 44px; }

  /* --- Stage timeline: keep horizontal scroll but make it tap-scrollable --- */
  .timeline { -webkit-overflow-scrolling: touch; padding: 12px 0; }
  .timeline-step { min-width: 96px; }

  /* --- Section headers wrap rather than overflow --- */
  .section-header { flex-wrap: wrap; gap: 8px; }
  .section-title { font-size: 15px; }

  /* --- Detail rail: when grids collapse it shouldn't stick mid-scroll --- */
  .detail-rail { position: static; }

  /* --- Modal: fit small screens with side gutters; footer fits --- */
  .modal-backdrop { padding: 16px; place-items: end center; }
  .modal, .modal-lg { max-width: 100%; max-height: 88vh; border-radius: 14px; }
  .modal-header { padding: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; gap: 8px; }

  /* --- Command palette: fit width and not run off the top --- */
  .cmdk-backdrop { padding: 10vh 12px 0; }
  .cmdk { width: 100%; max-width: 100%; max-height: 72vh; }
  .cmdk-input { font-size: 16px; padding: 14px 16px; }
  .cmdk-item { padding: 12px 10px; min-height: 44px; }

  /* --- Toast: span the screen with gutters instead of a fixed 280px box --- */
  .toast-container { left: 12px; right: 12px; bottom: 12px; }
  .toast { min-width: 0; width: 100%; padding: 12px 14px; }

  /* --- Portal & login: real page padding, single column, comfy card --- */
  .portal-header { padding: 16px 18px; }
  .portal-body { margin: 24px auto; padding: 0 18px; max-width: 100%; }
  .portal-card { padding: 20px; border-radius: 14px; }
  .login-pane { padding: 24px 18px; }
  .login-form { max-width: 100%; }

  /* --- Empty state: trim the huge desktop padding --- */
  .empty { padding: 40px 18px; }

  /* --- Banner / row: wrap long content, comfortable spacing --- */
  .banner { align-items: flex-start; padding: 12px 14px; }
}

/* Very small phones (<=360px): a touch tighter so nothing clips */
@media (max-width: 360px) {
  .page { padding: 14px 14px 40px; }
  .topbar { padding: 8px 14px; }
  .kpi-value { font-size: 20px; }
  .table { min-width: 520px; }
}
