/* ================================================================
   PCUK Tracker — Design System
   Based on Claude Design handoff (oklch colour tokens)
   ================================================================ */

/* ── Tokens ──────────────────────────────────────────────────────── */
:root {
  --bg:            oklch(0.158 0.005 270);
  --bg-2:          oklch(0.182 0.006 270);
  --surface:       oklch(0.202 0.006 270);
  --surface-2:     oklch(0.235 0.007 270);
  --surface-3:     oklch(0.275 0.008 270);
  --border:        oklch(0.288 0.008 270);
  --border-soft:   oklch(0.245 0.008 270);
  --border-strong: oklch(0.36  0.010 270);

  --fg:   oklch(0.975 0.002 270);
  --fg-2: oklch(0.78  0.006 270);
  --fg-3: oklch(0.62  0.008 270);
  --fg-4: oklch(0.48  0.008 270);

  --accent:      oklch(0.72  0.18  264);
  --accent-2:    oklch(0.62  0.18  264);
  --accent-bg:   oklch(0.32  0.10  264 / 0.32);
  --accent-bg-2: oklch(0.30  0.10  264 / 0.18);
  --accent-fg:   oklch(0.88  0.10  264);

  --success:    oklch(0.78 0.16 158);
  --success-bg: oklch(0.34 0.08 158 / 0.30);
  --success-fg: oklch(0.88 0.10 158);

  --warn:    oklch(0.82 0.14 82);
  --warn-bg: oklch(0.36 0.09 82  / 0.32);
  --warn-fg: oklch(0.90 0.10 82);

  --danger:    oklch(0.72 0.19 25);
  --danger-bg: oklch(0.34 0.10 25  / 0.32);
  --danger-fg: oklch(0.86 0.13 25);

  --info:    oklch(0.76 0.13 222);
  --info-bg: oklch(0.32 0.08 222 / 0.32);
  --info-fg: oklch(0.88 0.09 222);

  --grape:    oklch(0.74 0.17 305);
  --grape-bg: oklch(0.32 0.10 305 / 0.32);
  --grape-fg: oklch(0.88 0.10 305);

  --shadow-1:   0 1px 0 0 oklch(1 0 0 / 0.03) inset, 0 0 0 1px oklch(1 0 0 / 0.02);
  --shadow-2:   0 12px 28px -8px oklch(0 0 0 / 0.55), 0 0 0 1px oklch(1 0 0 / 0.04);
  --shadow-pop: 0 24px 60px -12px oklch(0 0 0 / 0.7), 0 0 0 1px oklch(1 0 0 / 0.06);

  --radius:   8px;
  --radius-s: 6px;
  --radius-l: 12px;

  --row-h:     38px;
  --sidebar-w: 232px;
  --topbar-h:  52px;

  color-scheme: dark;
}

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'ss01','cv11','cv02';
  overflow: hidden;
}
::selection { background: var(--accent-bg); color: var(--fg); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

.mono { font-family: 'JetBrains Mono', 'Consolas', ui-monospace, monospace; font-variant-ligatures: none; }

/* ── Scrollbars ──────────────────────────────────────────────────── */
.scroller { overflow: auto; }
.scroller::-webkit-scrollbar { width: 10px; height: 10px; }
.scroller::-webkit-scrollbar-track { background: transparent; }
.scroller::-webkit-scrollbar-thumb { background: oklch(0.30 0.008 270); border-radius: 8px; border: 2px solid var(--bg); }
.scroller::-webkit-scrollbar-thumb:hover { background: oklch(0.40 0.008 270); }

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

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  border-right: 1px solid var(--border-soft);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.brand {
  display: flex; align-items: center; gap: 10px;
  height: var(--topbar-h);
  padding: 0 14px;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.brand-mark {
  width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), oklch(0.55 0.18 280));
  position: relative;
  box-shadow: 0 0 0 1px oklch(1 0 0 / 0.08), 0 6px 14px -6px oklch(0.55 0.20 264 / 0.6);
  flex-shrink: 0;
}
.brand-mark::after {
  content: ""; position: absolute; inset: 5px;
  background: oklch(0.18 0.005 270);
  border-radius: 3px;
  box-shadow: inset 0 0 0 1.5px oklch(0.92 0.06 264);
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; font-size: 13px; }
.brand-sub { font-size: 10px; color: var(--fg-4); letter-spacing: 0.06em; text-transform: uppercase; margin-top: 1px; }

.sidebar-search { padding: 4px 10px 8px; flex-shrink: 0; }
.nav-section { padding: 6px 10px; flex-shrink: 0; }
.nav-label {
  font-size: 10px; color: var(--fg-4); text-transform: uppercase; letter-spacing: 0.07em;
  padding: 12px 8px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 8px;
  border-radius: 6px;
  color: var(--fg-2);
  cursor: pointer;
  font-size: 12.5px;
  height: 28px;
  text-decoration: none;
  overflow: hidden;
  transition: background .12s ease, color .12s ease;
}
.nav-item:hover { background: var(--surface); color: var(--fg); }
.nav-item.active { background: var(--surface-2); color: var(--fg); box-shadow: inset 0 0 0 1px var(--border-soft); }
.nav-item.active .nav-icon { color: var(--accent); }
.nav-icon { width: 14px; height: 14px; color: var(--fg-3); display: inline-flex; flex-shrink: 0; }
.nav-badge {
  display: inline;
  margin-left: auto;
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 600;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--border-soft);
  margin-bottom: 0;
  vertical-align: middle;
}
.nav-badge.danger { background: var(--danger-bg); color: var(--danger-fg); border-color: transparent; }
.nav-badge.warn   { background: var(--warn-bg);   color: var(--warn-fg);   border-color: transparent; }

/* Nav text label: takes remaining space and truncates, keeping badge visible */
.nav-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-foot {
  margin-top: auto;
  padding: 10px;
  border-top: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  flex: 1; min-width: 0;
  padding: 6px 8px;
  border-radius: 7px;
  cursor: pointer;
}
.user-chip:hover { background: var(--surface); }
.avatar {
  width: 24px; height: 24px; border-radius: 50%;
  background: linear-gradient(135deg, oklch(0.55 0.18 200), oklch(0.45 0.18 280));
  display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 600;
  flex-shrink: 0;
  border: 1.5px solid var(--surface-2);
}
.user-meta { min-width: 0; }
.user-meta b { font-weight: 500; font-size: 12px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-meta span { color: var(--fg-4); font-size: 10.5px; }

/* ── Topbar ──────────────────────────────────────────────────────── */
.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  height: var(--topbar-h);
  border-bottom: 1px solid var(--border-soft);
  display: flex; align-items: center; gap: 12px;
  padding: 0 18px;
  background: var(--bg);
  flex-shrink: 0;
}
.crumb { display: flex; align-items: center; gap: 8px; color: var(--fg-3); font-size: 12.5px; }
.crumb b { color: var(--fg); font-weight: 600; }
.crumb-sep { color: var(--fg-4); }
.topbar-grow { flex: 1; }
.search-trigger {
  display: flex; align-items: center; gap: 8px;
  height: 30px;
  width: 280px;
  padding: 0 10px;
  border-radius: 7px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--fg-3);
  transition: border-color .12s ease, background .12s ease;
  text-align: left;
  cursor: pointer;
}
.search-trigger:hover { background: var(--surface-2); }
.search-trigger .kbd { margin-left: auto; }

.kbd {
  font-family: 'JetBrains Mono', 'Consolas', ui-monospace, monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-soft);
  color: var(--fg-3);
  line-height: 1.3;
}
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: 7px;
  color: var(--fg-2);
  transition: background .12s ease, color .12s ease;
}
.icon-btn:hover { background: var(--surface); color: var(--fg); }

/* ── Buttons ─────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  transition: background .12s ease, border-color .12s ease, transform .04s ease;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg-2); }
.btn.ghost:hover { background: var(--surface); color: var(--fg); }
.btn.primary { background: var(--accent); color: oklch(0.18 0.02 264); border-color: transparent; font-weight: 600; }
.btn.primary:hover { background: oklch(0.78 0.18 264); }
.btn.danger { color: var(--danger-fg); }
.btn.danger:hover { background: var(--danger-bg); border-color: transparent; }
.btn.success { color: var(--success-fg); }
.btn.success:hover { background: var(--success-bg); border-color: transparent; }
.btn.warn { color: var(--warn-fg); }
.btn.warn:hover { background: var(--warn-bg); border-color: transparent; }
.btn.small { height: 24px; padding: 0 8px; font-size: 11.5px; gap: 4px; }
.btn-group { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }

/* ── Pills / Status Badges ───────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--fg-2);
  border: 1px solid var(--border-soft);
  white-space: nowrap;
  line-height: 18px;
}
.pill .dot { width: 5px; height: 5px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.pill.success { background: var(--success-bg); color: var(--success-fg); border-color: transparent; }
.pill.warn    { background: var(--warn-bg);    color: var(--warn-fg);    border-color: transparent; }
.pill.danger  { background: var(--danger-bg);  color: var(--danger-fg);  border-color: transparent; }
.pill.info    { background: var(--info-bg);    color: var(--info-fg);    border-color: transparent; }
.pill.grape   { background: var(--grape-bg);   color: var(--grape-fg);   border-color: transparent; }
.pill.accent  { background: var(--accent-bg);  color: var(--accent-fg);  border-color: transparent; }
.pill.solid   { background: var(--surface-3);  color: var(--fg); }

/* ── Content area ────────────────────────────────────────────────── */
.content {
  flex: 1; min-height: 0; min-width: 0;
  overflow: auto;
}
.page-head {
  padding: 16px 18px 6px;
  display: flex; align-items: flex-end; gap: 16px;
  flex-shrink: 0;
}
.page-title { font-size: 18px; font-weight: 600; letter-spacing: -0.012em; margin: 0; display: flex; align-items: center; gap: 10px; }
.page-sub { color: var(--fg-3); font-size: 12.5px; margin-top: 2px; }

/* ── Tabs ────────────────────────────────────────────────────────── */
.tabs { display: flex; align-items: flex-end; gap: 2px; padding: 0 18px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.tab {
  position: relative;
  padding: 9px 11px;
  font-size: 12.5px;
  color: var(--fg-3);
  display: inline-flex; align-items: center; gap: 8px;
  border-radius: 6px 6px 0 0;
  cursor: pointer;
  transition: color .12s ease;
}
.tab:hover { color: var(--fg); }
.tab.active { color: var(--fg); }
.tab.active::after { content: ""; position: absolute; left: 8px; right: 8px; bottom: -1px; height: 2px; background: var(--accent); border-radius: 2px 2px 0 0; }
.tab-count { font-size: 10.5px; padding: 0 6px; line-height: 16px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--fg-2); font-variant-numeric: tabular-nums; }
.tab.active .tab-count { background: var(--accent-bg); color: var(--accent-fg); border-color: transparent; }

/* ── Dashboard Widgets ───────────────────────────────────────────── */
.widgets {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
  padding: 14px 18px 6px;
  flex-shrink: 0;
}
.widget {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px;
  min-width: 0;
}
.widget-clickable { cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.widget-clickable:hover { border-color: var(--accent); box-shadow: 0 4px 18px oklch(0 0 0 / 0.32); }
.widget-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; color: var(--fg-3); font-size: 11.5px; font-weight: 500; }
.widget-label { color: var(--fg-3); font-size: 11.5px; font-weight: 500; line-height: 1; }
.widget-icon { width: 24px; height: 24px; border-radius: 6px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--fg-3); flex-shrink: 0; }
.widget-value { font-size: 22px; font-weight: 600; letter-spacing: -0.018em; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 8px; }
.widget-delta { font-size: 10.5px; font-weight: 600; padding: 1px 5px; border-radius: 5px; }
.widget-delta.up   { color: var(--success-fg); background: var(--success-bg); }
.widget-delta.down { color: var(--danger-fg);  background: var(--danger-bg); }
.widget-sub { font-size: 11px; color: var(--fg-4); }
.widget-bottom { display: flex; align-items: flex-end; justify-content: space-between; margin-top: -2px; }
.widget-spark { display: block; flex-shrink: 0; opacity: 0.7; }

/* ── Dashboard header ────────────────────────────────────────────── */
.dash-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px 2px;
  flex-shrink: 0;
}
.dash-title { font-size: 14px; font-weight: 600; letter-spacing: -0.012em; color: var(--fg); }
.live-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--success-fg);
  background: var(--success-bg); padding: 2px 7px 2px 5px;
  border-radius: 999px; user-select: none;
}
.live-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--success); flex-shrink: 0;
  animation: live-pulse 2.2s ease infinite;
}
@keyframes live-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}
.date-pills { display: flex; gap: 2px; }
.date-pill {
  padding: 3px 9px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  color: var(--fg-3); cursor: pointer; background: none; border: 1px solid transparent;
  transition: background .12s, color .12s, border-color .12s;
}
.date-pill:hover { background: var(--surface-2); color: var(--fg); }
.date-pill.active { background: var(--surface-2); color: var(--fg); border-color: var(--border-soft); }

/* ── Dashboard main grid ─────────────────────────────────────────── */
.dash-main-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 12px;
  padding: 6px 18px 14px;
}
.dash-section-head { display: flex; align-items: center; gap: 7px; margin-bottom: 10px; }
.dash-section-title { font-size: 12.5px; font-weight: 600; color: var(--fg-2); }

/* ── Pipeline bars ───────────────────────────────────────────────── */
.pipeline-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.pipeline-label { width: 126px; font-size: 12px; color: var(--fg-2); flex-shrink: 0; }
.pipeline-track { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; min-width: 0; }
.pipeline-fill { height: 100%; border-radius: 99px; transition: width .4s ease; }
.pipeline-count { width: 28px; text-align: right; font-size: 11.5px; color: var(--fg-3); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ── Exception preview ───────────────────────────────────────────── */
.exc-preview-row { display: flex; align-items: flex-start; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--border-soft); cursor: pointer; transition: opacity .12s; }
.exc-preview-row:last-child { border-bottom: 0; }
.exc-preview-row:hover { opacity: 0.72; }
.exc-priority-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 5px; }
.exc-priority-dot.critical { background: var(--danger); }
.exc-priority-dot.warning  { background: var(--warn); }
.exc-priority-dot.low      { background: var(--fg-4); }
.exc-preview-num { font-family: 'JetBrains Mono', monospace; font-size: 11px; font-weight: 600; flex-shrink: 0; margin-top: 1px; }
.exc-preview-msg { font-size: 11.5px; color: var(--fg-3); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.exc-preview-time { font-size: 10.5px; color: var(--fg-4); flex-shrink: 0; margin-top: 1px; white-space: nowrap; }

/* ── Carrier mix ─────────────────────────────────────────────────── */
.carrier-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.carrier-name { width: 100px; font-size: 12px; color: var(--fg-2); flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.carrier-track { flex: 1; height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; min-width: 0; }
.carrier-fill { height: 100%; border-radius: 99px; background: var(--grape); transition: width .4s ease; }
.carrier-count { width: 28px; text-align: right; font-size: 11.5px; color: var(--fg-3); font-variant-numeric: tabular-nums; flex-shrink: 0; }

/* ── Secondary stats row ─────────────────────────────────────────── */
.dash-secondary { display: flex; align-items: center; flex-wrap: wrap; padding: 0 18px 18px; }
.dash-stat { display: flex; flex-direction: column; gap: 3px; padding: 10px 20px; border-left: 1px solid var(--border-soft); flex-shrink: 0; }
.dash-stat:first-child { border-left: 0; padding-left: 0; }
.dash-stat-label { font-size: 11px; color: var(--fg-4); white-space: nowrap; }
.dash-stat-value { font-size: 18px; font-weight: 600; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; line-height: 1.2; }

@media (max-width: 960px) {
  .dash-main-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .dash-stat { border-left: 0; padding: 6px 0; border-bottom: 1px solid var(--border-soft); width: 50%; }
}
.dash-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; padding: 6px 18px; }
.dash-grid.three { grid-template-columns: 1.4fr 1fr; }

/* Progress */
.progress-track { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .4s cubic-bezier(.2,.7,.2,1); }
.progress-fill.success { background: var(--success); }
.progress-fill.warn    { background: var(--warn); }
.progress-fill.danger  { background: var(--danger); }

/* ── Toolbar / Filters ───────────────────────────────────────────── */
.toolbar {
  position: sticky; top: 0; z-index: 3;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
  padding: 10px 18px;
  display: flex; align-items: center; gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.toolbar .grow { flex: 1; }

.filter-chip {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 8px;
  border-radius: 6px; font-size: 12px;
  color: var(--fg-2); background: var(--surface);
  border: 1px dashed var(--border);
  cursor: pointer;
  transition: border-color .12s ease, background .12s ease, color .12s ease;
}
.filter-chip:hover { background: var(--surface-2); color: var(--fg); }
.filter-chip.applied { border-style: solid; background: var(--surface-2); color: var(--fg); }
.filter-chip label { color: var(--fg-3); cursor: pointer; }

.search-input-wrap { position: relative; display: inline-flex; align-items: center; }
.search-input-wrap svg { position: absolute; left: 9px; color: var(--fg-3); pointer-events: none; }
.search-input {
  height: 28px; padding: 0 10px 0 28px;
  border-radius: 6px; background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--fg); width: 240px; font-size: 12px;
  transition: border-color .12s, background .12s;
}
.search-input::placeholder { color: var(--fg-4); }
.search-input:focus { outline: none; border-color: var(--accent); background: var(--surface-2); }

/* Toolbar-scoped inputs and selects (shared with .filter-row) */
.toolbar input[type="text"],
.toolbar input[type="search"],
.toolbar select,
.filter-row input[type="text"],
.filter-row input[type="search"],
.filter-row select {
  height: 28px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--fg);
  font-size: 12px;
  transition: border-color .12s, background .12s;
}
.toolbar input[type="text"]:focus,
.toolbar input[type="search"]:focus,
.toolbar select:focus,
.filter-row input[type="text"]:focus,
.filter-row input[type="search"]:focus,
.filter-row select:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface-2);
}
.toolbar input[type="text"]::placeholder,
.filter-row input[type="text"]::placeholder { color: var(--fg-4); }
.toolbar label,
.filter-row label {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--fg-2); cursor: pointer;
  white-space: nowrap; user-select: none;
}

/* Custom select arrow — removes OS default chevron, adds our own */
.toolbar select,
.filter-row select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 26px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2362687a' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 7px center;
}

/* Search input with icon */
.filter-row .search-input-wrap,
.toolbar .search-input-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  flex: 1;
  min-width: 160px;
  max-width: 280px;
}
.filter-row .search-input-wrap svg,
.toolbar .search-input-wrap svg {
  position: absolute;
  left: 9px;
  color: var(--fg-3);
  pointer-events: none;
  flex-shrink: 0;
}
.filter-row .search-input-wrap input,
.toolbar .search-input-wrap input {
  width: 100%;
  padding-left: 30px !important;
}

.seg {
  display: inline-flex; padding: 2px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 7px;
}
.seg button { padding: 0 9px; height: 22px; border-radius: 5px; font-size: 11.5px; color: var(--fg-3); display: inline-flex; align-items: center; gap: 5px; }
.seg button.active { background: var(--surface-3); color: var(--fg); box-shadow: 0 0 0 1px var(--border-soft); }
.seg button:hover:not(.active) { color: var(--fg); }

/* ── Table ───────────────────────────────────────────────────────── */
.table-wrap { flex: 1; min-height: 0; position: relative; display: flex; flex-direction: column; }
.table-scroll { flex: 1; min-height: 0; overflow: auto; }
.table-scroll::-webkit-scrollbar { width: 10px; height: 10px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: oklch(0.30 0.008 270); border-radius: 8px; border: 2px solid var(--bg); }

.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
.tbl thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-2);
  text-align: left; font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap; user-select: none;
}
.tbl tbody tr { background: var(--bg); transition: background .08s ease; }
.tbl tbody tr:hover { background: var(--surface); }
.tbl tbody tr.selected { background: var(--accent-bg-2); }
.tbl tbody tr.selected:hover { background: oklch(0.30 0.10 264 / 0.28); }
.tbl tbody tr.tr-ignored { opacity: 0.5; }
.tbl tbody tr.tr-clickable { cursor: pointer; }
.tbl tbody td {
  padding: 0 10px; height: var(--row-h);
  border-bottom: 1px solid var(--border-soft);
  vertical-align: middle; color: var(--fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tbl tbody td.mono-cell { font-family: 'JetBrains Mono', 'Consolas', ui-monospace, monospace; font-size: 11.5px; color: var(--fg-2); }
.tbl tbody td.muted { color: var(--fg-3); }
.tbl .col-select { width: 28px; padding-left: 14px; }
.tbl .col-actions { width: 90px; text-align: right; padding-right: 10px; }

.checkbox {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 3.5px;
  border: 1px solid var(--border-strong); background: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background .12s, border-color .12s;
  position: relative; flex-shrink: 0;
}
.checkbox:hover { border-color: var(--fg-3); }
.checkbox:checked { background: var(--accent); border-color: var(--accent); }
.checkbox:checked::after { content: ""; width: 7px; height: 4px; border-left: 1.6px solid oklch(0.18 0.02 264); border-bottom: 1.6px solid oklch(0.18 0.02 264); transform: rotate(-45deg) translate(0px, -1px); }
.checkbox:indeterminate { background: var(--accent); border-color: var(--accent); }
.checkbox:indeterminate::after { content: ""; width: 7px; height: 1.6px; background: oklch(0.18 0.02 264); }

.row-actions { display: none; align-items: center; gap: 2px; justify-content: flex-end; }
.tbl tbody tr:hover .row-actions { display: inline-flex; }
.row-action { width: 24px; height: 24px; border-radius: 5px; color: var(--fg-3); display: inline-flex; align-items: center; justify-content: center; }
.row-action:hover { background: var(--surface-2); color: var(--fg); }

.tbl-foot {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 18px;
  border-top: 1px solid var(--border-soft);
  background: var(--bg);
  font-size: 12px; color: var(--fg-3);
  flex-shrink: 0;
}
.tbl-foot .grow { flex: 1; }

/* ── Bulk Bar ─────────────────────────────────────────────────────── */
.bulkbar {
  position: absolute; left: 50%; bottom: 56px;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  display: flex; align-items: center; gap: 8px;
  box-shadow: var(--shadow-pop); z-index: 50;
  font-size: 12.5px; min-width: 480px;
  animation: bulk-in .18s cubic-bezier(.2,.8,.2,1) both;
}
@keyframes bulk-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
.bulkbar-count { display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px 3px 5px; background: var(--accent-bg); color: var(--accent-fg); border-radius: 999px; font-weight: 600; font-size: 12px; white-space: nowrap; }
.bulkbar-n { background: var(--accent); color: oklch(0.18 0.02 264); min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; font-size: 11px; font-variant-numeric: tabular-nums; padding: 0 3px; }
.bulkbar-sep { width: 1px; height: 18px; background: var(--border); flex-shrink: 0; }

/* ── Page & content animations ───────────────────────────────────── */
@keyframes page-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.page-anim { animation: page-in .2s cubic-bezier(.2,.8,.2,1) both; }

/* Widget stagger — first 5 children cascade in */
@keyframes widget-up {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}
.widget { animation: widget-up .26s cubic-bezier(.2,.8,.2,1) both; }
.widget:nth-child(2) { animation-delay: 50ms; }
.widget:nth-child(3) { animation-delay: 100ms; }
.widget:nth-child(4) { animation-delay: 150ms; }
.widget:nth-child(5) { animation-delay: 200ms; }

/* Table row stagger */
@keyframes row-fade { from { opacity: 0; } to { opacity: 1; } }
.tbl-animate tbody tr { animation: row-fade .18s ease both; }
.tbl-animate tbody tr:nth-child(2)  { animation-delay: 20ms; }
.tbl-animate tbody tr:nth-child(3)  { animation-delay: 40ms; }
.tbl-animate tbody tr:nth-child(4)  { animation-delay: 60ms; }
.tbl-animate tbody tr:nth-child(5)  { animation-delay: 80ms; }
.tbl-animate tbody tr:nth-child(6)  { animation-delay: 100ms; }
.tbl-animate tbody tr:nth-child(7)  { animation-delay: 120ms; }
.tbl-animate tbody tr:nth-child(8)  { animation-delay: 140ms; }
.tbl-animate tbody tr:nth-child(9)  { animation-delay: 160ms; }
.tbl-animate tbody tr:nth-child(10) { animation-delay: 180ms; }
.tbl-animate tbody tr:nth-child(n+11) { animation-delay: 200ms; }

/* Badge pop when count changes */
@keyframes badge-pop {
  0%   { transform: scale(1); }
  35%  { transform: scale(1.5); }
  65%  { transform: scale(.88); }
  100% { transform: scale(1); }
}
.badge-popping { animation: badge-pop .34s cubic-bezier(.4,0,.2,1) both; }

/* Drawer sections stagger in after slide */
.drawer-body .drawer-section { animation: page-in .22s cubic-bezier(.2,.8,.2,1) both; }
.drawer-body .drawer-section:nth-child(2) { animation-delay: 60ms; }
.drawer-body .drawer-section:nth-child(3) { animation-delay: 120ms; }
.drawer-body .drawer-section:nth-child(4) { animation-delay: 180ms; }
.drawer-body .drawer-section:nth-child(5) { animation-delay: 230ms; }
.drawer-body .drawer-section:nth-child(n+6) { animation-delay: 270ms; }

/* Progress bars — rendered at width:0 in HTML, JS sets data-w to animate */
.pipeline-fill, .carrier-fill { transition: width .55s cubic-bezier(.2,.8,.2,1); }

/* ── Drawer ──────────────────────────────────────────────────────── */
.scrim { position: fixed; inset: 0; background: oklch(0 0 0 / 0.4); backdrop-filter: blur(2px); z-index: 60; animation: fade .16s ease both; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.drawer {
  position: fixed; top: 8px; right: 8px; bottom: 8px;
  width: min(720px, 92vw);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px;
  box-shadow: var(--shadow-pop); z-index: 70;
  display: flex; flex-direction: column;
  animation: slide-in .22s cubic-bezier(.2,.8,.2,1) both;
  overflow: hidden;
}
@keyframes slide-in { from { transform: translateX(24px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border-soft); flex-shrink: 0; }
.drawer-head .grow { flex: 1; }
.drawer-body { flex: 1; min-height: 0; overflow: auto; }
.drawer-tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--border-soft); background: var(--bg-2); position: sticky; top: 0; z-index: 2; }
.drawer-section { padding: 16px 18px; border-bottom: 1px solid var(--border-soft); }
.drawer-section:last-child { border-bottom: 0; }
.drawer-section h5 { margin: 0 0 10px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-4); font-weight: 600; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 6px 14px; font-size: 12.5px; }
.kv dt { color: var(--fg-3); }
.kv dd { margin: 0; color: var(--fg); }
.drawer-foot { padding: 10px 14px; border-top: 1px solid var(--border-soft); display: flex; align-items: center; gap: 8px; background: var(--bg-2); flex-shrink: 0; }
.email-update-row { transition: border-color .12s, background .12s; }
.email-update-row:hover { border-color: var(--accent) !important; background: var(--surface-3, var(--surface-2)) !important; }

/* ── Command Palette ─────────────────────────────────────────────── */
.palette-scrim { position: fixed; inset: 0; background: oklch(0 0 0 / 0.5); backdrop-filter: blur(4px); z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding-top: 12vh; animation: fade .14s ease; }
.palette { width: min(620px, 92vw); background: var(--bg-2); border: 1px solid var(--border); border-radius: 14px; box-shadow: var(--shadow-pop); overflow: hidden; animation: pop .16s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { transform: translateY(-8px) scale(0.985); opacity: 0; } to { transform: translateY(0) scale(1); opacity: 1; } }
.palette-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); }
.palette-head input { flex: 1; background: transparent; border: 0; outline: none; font-size: 14px; color: var(--fg); }
.palette-head input::placeholder { color: var(--fg-4); }
.palette-body { max-height: min(56vh, 480px); overflow: auto; padding: 6px; }
.pal-section { padding: 6px 6px 4px; }
.pal-section h6 { margin: 0 0 4px; padding: 0 8px; font-size: 10px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-4); font-weight: 600; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 7px; cursor: pointer; font-size: 13px; color: var(--fg); }
.pal-item:hover, .pal-item.pal-active { background: var(--surface-2); }
.pal-ico { color: var(--fg-3); display: inline-flex; flex-shrink: 0; }
.pal-desc { color: var(--fg-3); font-size: 11.5px; margin-left: auto; }
.palette-foot { padding: 8px 14px; border-top: 1px solid var(--border-soft); display: flex; align-items: center; gap: 14px; color: var(--fg-4); font-size: 11px; }

/* ── Toasts ──────────────────────────────────────────────────────── */
.toast-stack { position: fixed; bottom: 16px; right: 16px; display: flex; flex-direction: column-reverse; gap: 8px; z-index: 100; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  background: var(--bg-2); border: 1px solid var(--border);
  box-shadow: var(--shadow-pop); font-size: 12.5px;
  min-width: 280px; max-width: 420px;
  animation: toast-in .2s cubic-bezier(.2,.8,.2,1);
  cursor: pointer;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.toast.removing { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
.toast-text { flex: 1; }
.toast-ico { flex-shrink: 0; }

/* ── Loading ─────────────────────────────────────────────────────── */
.skel { background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.4s infinite ease-in-out; border-radius: 4px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.loading-overlay { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 80px 40px; color: var(--fg-3); font-size: 13px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--surface-3); border-top-color: var(--accent); animation: spin .7s linear infinite; display: inline-block; flex-shrink: 0; }
.spinner-sm { width: 12px; height: 12px; border-width: 1.5px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Timeline ────────────────────────────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; position: relative; margin-left: 8px; }
.tl-item { display: grid; grid-template-columns: 18px 1fr auto; gap: 10px; padding: 8px 0; position: relative; }
.tl-item:not(:last-child)::before { content: ""; position: absolute; left: 8px; top: 24px; bottom: -4px; width: 1.5px; background: var(--border); }
.tl-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--surface-2); border: 1.5px solid var(--border-strong); margin-top: 3px; display: inline-flex; align-items: center; justify-content: center; color: var(--fg-3); font-size: 9px; flex-shrink: 0; }
.tl-dot.success { background: var(--success-bg); border-color: var(--success); color: var(--success-fg); }
.tl-dot.warn    { background: var(--warn-bg);    border-color: var(--warn);    color: var(--warn-fg); }
.tl-dot.danger  { background: var(--danger-bg);  border-color: var(--danger);  color: var(--danger-fg); }
.tl-dot.info    { background: var(--info-bg);    border-color: var(--info);    color: var(--info-fg); }
.tl-dot.accent  { background: var(--accent-bg);  border-color: var(--accent);  color: var(--accent-fg); }
.tl-title { font-size: 12.5px; }
.tl-sub   { color: var(--fg-3); font-size: 11.5px; }
.tl-time  { color: var(--fg-4); font-size: 11px; white-space: nowrap; }

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

/* ── Helpers ─────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; }
.gap-2 { gap: 8px; } .gap-3 { gap: 12px; }
.ml-auto { margin-left: auto; } .mr-auto { margin-right: auto; }
.fg-2 { color: var(--fg-2); } .fg-3 { color: var(--fg-3); } .fg-4 { color: var(--fg-4); }
.tabular { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ================================================================
   App-specific additions
   ================================================================ */

/* ── Login ───────────────────────────────────────────────────────── */
#login-page {
  display: none; position: fixed; inset: 0; background: var(--bg);
  align-items: center; justify-content: center; z-index: 200;
}
.login-card {
  width: min(400px, 92vw); background: var(--surface);
  border: 1px solid var(--border-soft); border-radius: var(--radius-l);
  padding: 32px; box-shadow: var(--shadow-pop);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 28px; }
.login-brand .brand-mark { width: 32px; height: 32px; border-radius: 8px; }
.login-brand .brand-mark::after { inset: 7px; border-radius: 4px; }
.login-title { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -0.015em; }
.login-sub { color: var(--fg-4); font-size: 11.5px; margin-top: 2px; }

/* ── Alerts ──────────────────────────────────────────────────────── */
.alert { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; border-radius: var(--radius); font-size: 12.5px; margin-bottom: 12px; border: 1px solid transparent; }
.alert-error   { background: var(--danger-bg);  color: var(--danger-fg);  border-color: oklch(0.50 0.14 25  / 0.3); }
.alert-success { background: var(--success-bg); color: var(--success-fg); border-color: oklch(0.55 0.12 158 / 0.3); }
.alert-info    { background: var(--info-bg);    color: var(--info-fg);    border-color: oklch(0.55 0.10 222 / 0.3); }
.alert-warning { background: var(--warn-bg);    color: var(--warn-fg);    border-color: oklch(0.58 0.10 82  / 0.3); }

/* ── Forms ───────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--fg-2); }
.form-group input,
.form-group textarea,
.form-group select {
  padding: 7px 10px; border-radius: var(--radius-s);
  background: var(--bg-2); border: 1px solid var(--border-soft);
  color: var(--fg); font-size: 13px; transition: border-color .12s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-hint { font-size: 11px; color: var(--fg-4); }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; margin-bottom: 12px; }
.form-check input[type="checkbox"] { cursor: pointer; accent-color: var(--accent); width: 14px; height: 14px; }

/* ── Settings ────────────────────────────────────────────────────── */
.settings-kv { display: flex; flex-direction: column; }
.settings-row { display: grid; grid-template-columns: 200px 1fr auto; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--border-soft); }
.settings-row:last-child { border-bottom: 0; }
.settings-key { font-family: 'JetBrains Mono', 'Consolas', ui-monospace, monospace; font-size: 11.5px; color: var(--fg-3); }
.settings-input { padding: 6px 10px; border-radius: var(--radius-s); background: var(--bg-2); border: 1px solid var(--border-soft); color: var(--fg); font-size: 13px; width: 100%; transition: border-color .12s; }
.settings-input:focus { outline: none; border-color: var(--accent); }

/* ── Section header (old pattern) ───────────────────────────────── */
.section-header { display: flex; align-items: center; gap: 12px; padding: 14px 18px 6px; flex-shrink: 0; }
.section-header h2 { font-size: 18px; font-weight: 600; margin: 0; letter-spacing: -0.012em; }
.section-header-left { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-header .ml-auto { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* ── Card wrapper ────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; padding: 16px; }
.card-title { font-size: 13px; font-weight: 600; color: var(--fg-2); margin-bottom: 12px; }

/* ── Exception Queue ─────────────────────────────────────────────── */
.exc-summary { display: flex; gap: 8px; padding: 0 18px 10px; flex-wrap: wrap; }
.exc-summary-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: 999px; font-size: 12px; font-weight: 500; cursor: pointer; }
.exc-chip-critical { background: var(--danger-bg);  color: var(--danger-fg); }
.exc-chip-warning  { background: var(--warn-bg);    color: var(--warn-fg); }
.exc-chip-low      { background: var(--info-bg);    color: var(--info-fg); }
.exc-chip-ok       { background: var(--success-bg); color: var(--success-fg); }
.exc-group { padding: 0 18px 12px; }
.exc-group-header { display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 8px 8px 0 0; cursor: pointer; font-weight: 600; font-size: 13px; border: 1px solid var(--border-soft); border-bottom: 0; user-select: none; }
.exc-group-header.critical { background: var(--danger-bg);  color: var(--danger-fg); }
.exc-group-header.warning  { background: var(--warn-bg);    color: var(--warn-fg); }
.exc-group-header.low      { background: var(--info-bg);    color: var(--info-fg); }
.exc-group-count { padding: 1px 8px; border-radius: 999px; background: oklch(0 0 0 / 0.2); font-size: 11px; font-variant-numeric: tabular-nums; }
.exc-cards { border: 1px solid var(--border-soft); border-top: 0; border-radius: 0 0 8px 8px; overflow: hidden; }
.exc-card { display: grid; grid-template-columns: 36px 1fr auto; gap: 10px; align-items: start; padding: 10px 14px; border-bottom: 1px solid var(--border-soft); background: var(--bg); transition: background .08s; }
.exc-card:last-child { border-bottom: 0; }
.exc-card:hover { background: var(--surface); }
.exc-icon { font-size: 17px; padding-top: 2px; }
.exc-body { min-width: 0; }
.exc-type-badge { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--fg-4); margin-bottom: 2px; }
.exc-title { font-family: 'JetBrains Mono', 'Consolas', ui-monospace, monospace; font-size: 12px; font-weight: 600; color: var(--fg); }
.exc-message { font-size: 12px; color: var(--fg-3); margin-top: 2px; white-space: normal; }
.exc-meta { font-size: 11px; color: var(--fg-4); margin-top: 4px; }
.exc-actions { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; padding-top: 2px; }

/* ── Order detail layout ─────────────────────────────────────────── */
.info-layout { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; padding: 0 18px 12px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 16px; }
.detail-field { display: flex; flex-direction: column; gap: 3px; }
.detail-label { font-size: 10.5px; color: var(--fg-4); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.detail-value { font-size: 13px; color: var(--fg); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.action-bar { display: flex; gap: 8px; padding: 0 18px 12px; flex-wrap: wrap; align-items: center; flex-shrink: 0; }
.quick-links { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border-soft); }

/* ── Job progress ────────────────────────────────────────────────── */
.job-progress-wrap { padding: 8px 18px; background: var(--surface); border-bottom: 1px solid var(--border-soft); }
.job-progress-header { display: flex; justify-content: space-between; align-items: center; font-size: 12.5px; margin-bottom: 6px; color: var(--fg-3); }
.job-progress-track { height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.job-progress-fill { height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s ease; }

/* ── Status colors ───────────────────────────────────────────────── */
.proxy-good { color: var(--success-fg); }
.proxy-warn { color: var(--warn-fg); }
.proxy-bad  { color: var(--danger-fg); }
.conf-high   { color: var(--success-fg); font-weight: 600; }
.conf-medium { color: var(--warn-fg);    font-weight: 600; }
.conf-low    { color: var(--danger-fg);  font-weight: 600; }
.log-error   { color: var(--danger-fg); }
.log-warning { color: var(--warn-fg); }
.log-info    { color: var(--info-fg); }
.log-debug   { color: var(--fg-4); }

/* ── Icon buttons (copy, refresh, etc.) ──────────────────────────── */
.copy-btn, .icon-btn-sm {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 20px; border-radius: 4px;
  color: var(--fg-4); background: none;
  transition: background .12s, color .12s; cursor: pointer; border: 0;
  flex-shrink: 0;
}
.copy-btn:hover, .icon-btn-sm:hover { background: var(--surface-2); color: var(--fg-2); }


/* ── Empty state ─────────────────────────────────────────────────── */
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 60px 40px; color: var(--fg-3); text-align: center; }
.empty-state-icon { width: 48px; height: 48px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: center; }
.empty-state h3 { font-size: 15px; font-weight: 600; color: var(--fg); margin: 0; }
.empty-state p { font-size: 12.5px; max-width: 320px; margin: 0; }

/* ── Narvar progress (inline) ────────────────────────────────────── */
#narvar-progress { padding: 6px 18px; }
.email-debug-row td { background: var(--bg-2) !important; border-top: 1px solid var(--border-soft); padding: 12px 16px !important; white-space: normal !important; height: auto !important; }

/* ── Mobile ──────────────────────────────────────────────────────── */
#sidebar-overlay { display: none; position: fixed; inset: 0; background: oklch(0 0 0 / 0.6); z-index: 40; }
#sidebar-overlay.open { display: block; }
.menu-toggle { display: none; width: 30px; height: 30px; border-radius: 7px; align-items: center; justify-content: center; color: var(--fg-2); transition: background .12s; }
.menu-toggle:hover { background: var(--surface); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; top: 0; left: 0; bottom: 0; width: var(--sidebar-w); transform: translateX(-100%); transition: transform .2s ease; z-index: 50; }
  .sidebar.open { transform: translateX(0); }
  .menu-toggle { display: flex !important; }
  .search-trigger { width: 160px; }
  .widgets { grid-template-columns: repeat(3, 1fr); }
  .dash-grid { grid-template-columns: 1fr; }
  .info-layout { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .settings-row { grid-template-columns: 1fr; gap: 8px; }
}
@media (max-width: 560px) {
  .widgets { grid-template-columns: 1fr 1fr; }
  .bulkbar { min-width: unset; left: 12px; right: 12px; transform: none; bottom: 12px; }
}

/* ── Table-wrap scrolling ─────────────────────────────────────────── */
.table-wrap { overflow: auto; }

/* ── Backward compat: old btn-* modifier classes ─────────────────── */
.btn.btn-primary { background: var(--accent); color: oklch(0.18 0.02 264); border-color: transparent; font-weight: 600; }
.btn.btn-primary:hover { background: oklch(0.78 0.18 264); }
.btn.btn-success { color: var(--success-fg); }
.btn.btn-success:hover { background: var(--success-bg); border-color: transparent; }
.btn.btn-warning { color: var(--warn-fg); }
.btn.btn-warning:hover { background: var(--warn-bg); border-color: transparent; }
.btn.btn-danger { color: var(--danger-fg); }
.btn.btn-danger:hover { background: var(--danger-bg); border-color: transparent; }
.btn.btn-sm, .btn.btn-xs { height: 24px; padding: 0 8px; font-size: 11.5px; gap: 4px; }

/* ── Backward compat: old .badge-* status classes ────────────────── */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; background: var(--surface-2); color: var(--fg-2); border: 1px solid var(--border-soft); white-space: nowrap; }
.badge-delivered { background: var(--success-bg); color: var(--success-fg); border-color: transparent; }
.badge-shipped, .badge-out_for_delivery { background: var(--grape-bg); color: var(--grape-fg); border-color: transparent; }
.badge-in_transit { background: var(--info-bg); color: var(--info-fg); border-color: transparent; }
.badge-delivery_attempted, .badge-delayed { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.badge-cancelled, .badge-refunded, .badge-returned, .badge-failed_check, .badge-unknown { background: var(--danger-bg); color: var(--danger-fg); border-color: transparent; }
.badge-confirmed, .badge-processing { background: var(--accent-bg); color: var(--accent-fg); border-color: transparent; }
.badge-active { background: var(--success-bg); color: var(--success-fg); border-color: transparent; }
.badge-inactive { background: var(--danger-bg); color: var(--danger-fg); border-color: transparent; }
.badge-paused { background: var(--warn-bg); color: var(--warn-fg); border-color: transparent; }
.badge-disabled { background: var(--surface-2); color: var(--fg-3); border: 1px solid var(--border); }
.badge-stage-email_monitoring { background: var(--accent-bg); color: var(--accent-fg); border-color: transparent; }
.badge-stage-narvar_tracking { background: var(--info-bg); color: var(--info-fg); border-color: transparent; }
.badge-stage-completed { background: var(--success-bg); color: var(--success-fg); border-color: transparent; }
.badge-stage-cancelled { background: var(--danger-bg); color: var(--danger-fg); border-color: transparent; }

/* ── Backward compat: table without .tbl class ───────────────────── */
table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 12.5px; }
thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-2); text-align: left; font-weight: 500; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.05em; color: var(--fg-3);
  padding: 8px 10px; border-bottom: 1px solid var(--border-soft);
  white-space: nowrap; user-select: none;
}
tbody tr { background: var(--bg); transition: background .08s ease; }
tbody tr:hover { background: var(--surface); }
tbody td { padding: 0 10px; height: var(--row-h); border-bottom: 1px solid var(--border-soft); vertical-align: middle; overflow: hidden; text-overflow: ellipsis; }
.td-mono { font-family: 'JetBrains Mono', 'Consolas', ui-monospace, monospace; font-size: 11.5px; color: var(--fg-2); }
.td-check, .th-check { width: 28px; padding-left: 14px; }
.td-nowrap { white-space: nowrap; }
.tr-clickable { cursor: pointer; }
.tr-ignored { opacity: 0.5; }

/* ── Backward compat: old bulk-bar ───────────────────────────────── */
.bulk-bar { display: flex; align-items: center; gap: 8px; padding: 10px 18px; background: var(--surface-2); border-bottom: 1px solid var(--border-soft); flex-wrap: wrap; }
.bulk-bar-count { font-weight: 600; color: var(--accent-fg); background: var(--accent-bg); padding: 2px 8px; border-radius: 999px; font-size: 12px; }

/* ── Backward compat: old dashboard stat cards ───────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 14px 18px; }
.stat-card { background: var(--surface); border: 1px solid var(--border-soft); border-radius: 10px; padding: 12px 14px; }
.stat-card.clickable { cursor: pointer; transition: border-color .12s; }
.stat-card.clickable:hover { border-color: var(--accent); }
.stat-label { font-size: 11.5px; color: var(--fg-3); font-weight: 500; margin-bottom: 6px; }
.stat-value { font-size: 24px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-value.blue { color: var(--info-fg); }
.stat-value.green { color: var(--success-fg); }
.stat-value.red { color: var(--danger-fg); }
.stat-value.orange { color: var(--warn-fg); }
.stat-value.dim { color: var(--fg-3); }
.stat-sub { font-size: 11px; color: var(--fg-4); margin-top: 4px; }

/* ── Backward compat: old timeline ───────────────────────────────── */
.timeline-item { display: grid; grid-template-columns: 24px 1fr; gap: 10px; padding: 8px 0; position: relative; }
.timeline-item:not(:last-child)::before { content: ""; position: absolute; left: 11px; top: 28px; bottom: -4px; width: 1.5px; background: var(--border); }
.timeline-dot { width: 22px; height: 22px; border-radius: 50%; background: var(--surface-2); border: 1.5px solid var(--border-strong); display: flex; align-items: center; justify-content: center; font-size: 11px; flex-shrink: 0; }
.timeline-body { min-width: 0; }
.timeline-title { font-size: 12.5px; font-weight: 500; color: var(--fg); }
.timeline-time { font-size: 11px; color: var(--fg-4); margin-top: 2px; }

/* ── Misc compat ─────────────────────────────────────────────────── */
.empty-icon { font-size: 32px; margin-bottom: 4px; }

/* ── Premium table system ─────────────────────────────────────────── */

/* Page header (replaces .section-header on list pages) */
.page-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px 10px; flex-shrink: 0;
}
.page-title { font-size: 15px; font-weight: 600; letter-spacing: -0.012em; }
.page-count { font-size: 12.5px; color: var(--fg-4); font-variant-numeric: tabular-nums; }

/* Copy button that fades in on row hover */
.tbl .row-copy { opacity: 0; transition: opacity .1s; pointer-events: none; }
.tbl tr:hover .row-copy { opacity: 1; pointer-events: auto; }

/* Bulk bar (shows above table when rows are selected) */
.bulk-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 18px; flex-wrap: wrap;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-soft);
  animation: bulkbar-in .14s ease;
}
@keyframes bulkbar-in { from { opacity:0; transform:translateY(-4px); } to { opacity:1; transform:none; } }
.bulk-bar-count { font-size: 12px; font-weight: 600; background: var(--accent-bg); color: var(--accent-fg); padding: 2px 9px; border-radius: 999px; flex-shrink: 0; }

/* Table container (replaces .card style="padding:0;" pattern) */
.tbl-container {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  overflow: hidden;
  margin: 0 18px 18px;
}
.tbl-container .table-wrap { overflow: auto; }

/* Proxy inline rate bar */
.proxy-rate-row { display: flex; align-items: center; gap: 8px; }
.proxy-rate-track { width: 48px; height: 4px; border-radius: 99px; background: var(--surface-3); overflow: hidden; flex-shrink: 0; }
.proxy-rate-fill { height: 100%; border-radius: 99px; }

/* Log level badge */
.log-badge { display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; padding: 2px 6px; border-radius: 4px; white-space: nowrap; }
.log-badge.error   { background: var(--danger-bg); color: var(--danger-fg); }
.log-badge.warning { background: var(--warn-bg);   color: var(--warn-fg); }
.log-badge.info    { background: var(--info-bg);    color: var(--info-fg); }
.log-badge.debug   { background: var(--surface-2);  color: var(--fg-4); }

/* Exception card - make clickable */
.exc-card { cursor: pointer; }
.exc-card.critical:hover { background: oklch(0.22 0.007 270); }
.exc-card.warning:hover  { background: oklch(0.22 0.007 270); }
.exc-card.low:hover      { background: var(--surface); }

/* Filter row (filter chips / toolbar row) */
.filter-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px 0; flex-wrap: wrap; flex-shrink: 0;
}
.filter-chips { display: flex; gap: 2px; background: var(--surface-2); border-radius: 8px; padding: 2px; }
.filter-chip {
  padding: 3px 10px; border-radius: 6px; font-size: 11.5px; font-weight: 500;
  color: var(--fg-3); cursor: pointer; background: none; border: 0;
  transition: background .1s, color .1s;
}
.filter-chip.active { background: var(--surface-3); color: var(--fg); }
.filter-chip:hover:not(.active) { color: var(--fg-2); }

/* Empty table state */
.tbl-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 48px 24px; color: var(--fg-3); text-align: center; }
.tbl-empty-icon { width: 36px; height: 36px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border-soft); display: flex; align-items: center; justify-content: center; color: var(--fg-3); margin-bottom: 4px; }
.tbl-empty h4 { font-size: 13.5px; font-weight: 600; color: var(--fg); margin: 0; }
.tbl-empty p { font-size: 12px; max-width: 280px; margin: 0; color: var(--fg-4); }

/* Error row state */
.tbl-error { padding: 16px 18px; }

/* Inline check td */
.td-check, .th-check { width: 38px; padding: 0 0 0 14px !important; }

/* Actions td */
.td-actions { white-space: nowrap; }
.td-actions .btn-group { opacity: 0; transition: opacity .1s; }
.tbl tr:hover .td-actions .btn-group { opacity: 1; }
