/* NORTHLABS ADMIN — product-style partner console. Zero dependencies. */

/* Hide dashboard until JS confirms auth — prevents flash of content */
.layout { visibility: hidden; }
.layout.authed { visibility: visible; }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
img { display: block; max-width: 100%; }
a { text-decoration: none; color: inherit; }
button { cursor: pointer; background: none; border: none; font: inherit; }
input, select, textarea { font: inherit; }

:root {
  --bg: #eef2f5;
  --bg2: #f9fbfc;
  --bg3: #e3eaf0;
  --border: #ced9e2;
  --text: #101820;
  --text2: #445461;
  --text3: #71818d;
  --red: #176f86;
  --green: #187c72;
  --yellow: #ad7a00;
  --blue: #2054d1;
  --shadow: 0 1px 2px rgba(16,24,32,0.04), 0 16px 40px rgba(16,24,32,0.06);
  --shadow-md: 0 16px 36px rgba(16,24,32,0.10);
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Inter", system-ui, sans-serif;
  --font-display: ui-serif, Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* ── Spacing scale (4px base) ─────────────────────────────────── */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-7: 28px;
  --sp-8: 32px;
  --sp-9: 40px;
  --sp-10: 48px;
  --sp-11: 56px;
  --sp-12: 64px;

  /* ── Type scale ───────────────────────────────────────────────── */
  --text-xs: 11px;
  --text-sm: 12px;
  --text-md: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 24px;
  --text-3xl: 32px;

  /* ── Line heights ─────────────────────────────────────────────── */
  --lh-tight: 1.2;
  --lh-normal: 1.5;
  --lh-relaxed: 1.65;

  /* ── Radii ────────────────────────────────────────────────────── */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 10px;
  --radius-xl: 14px;

  /* ── Elevation (Shopify-style: tight + subtle) ────────────────── */
  --shadow-xs: 0 1px 1px rgba(15,23,42,0.04);
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06), 0 1px 3px rgba(15,23,42,0.04);
  --shadow-lg: 0 12px 32px rgba(15,23,42,0.12), 0 4px 12px rgba(15,23,42,0.06);

  /* ── Motion ───────────────────────────────────────────────────── */
  --ease-out: cubic-bezier(.22, 1, .36, 1);
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 260ms;

  /* ── Focus ring (soft button glow) ────────────────────────────── */
  --ring-blue: 0 0 0 3px rgba(96,165,250,0.18);
  --ring-blue-strong: 0 0 0 3px rgba(96,165,250,0.30);
}

[data-theme="dark"] {
  --bg: #0b1220;
  --bg2: #101826;
  --bg3: #162033;
  --border: #263245;
  --text: #e8edf7;
  --text2: #b3bfd3;
  --text3: #7e8aa2;
  --red: #e05050;
  --green: #51d28c;
  --yellow: #f5c24b;
  --blue: #7da3ff;
  --shadow: 0 1px 2px rgba(0,0,0,0.35), 0 10px 24px rgba(0,0,0,0.24);
  --shadow-md: 0 14px 36px rgba(0,0,0,0.36);
  --shadow-xs: 0 1px 1px rgba(0,0,0,0.30);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.32), 0 1px 3px rgba(0,0,0,0.24);
  --shadow-lg: 0 14px 40px rgba(0,0,0,0.50), 0 4px 14px rgba(0,0,0,0.32);
}

[data-theme="light"] {
  --bg: #f4f5f7;
  --bg2: #ffffff;
  --bg3: #eef1f5;
  --border: #dbe1ea;
  --text: #0f172a;
  --text2: #475569;
  --text3: #7a8699;
  --red: #c0392b;
  --green: #14804a;
  --yellow: #ad7a00;
  --blue: #2054d1;
  --shadow: 0 1px 2px rgba(15,23,42,0.05), 0 8px 24px rgba(15,23,42,0.04);
  --shadow-md: 0 10px 24px rgba(15,23,42,0.08);
}

body {
  font-family: var(--font-sans);
  background:
    radial-gradient(circle at 88% -8%, rgba(23,111,134,0.10), transparent 32rem),
    var(--bg);
  color: var(--text);
  font-size: var(--text-md);
  line-height: var(--lh-normal);
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}
/* Tabular numerals globally for clean column alignment */
.numeric,
td.numeric,
th.numeric,
.tabular,
.kpi-value,
.hero-card-value,
.stat-value,
.mini-stat-big,
.traffic-value,
.order-total,
.order-num {
  font-variant-numeric: tabular-nums;
}

/* Layout */
.layout { display: flex; min-height: 100vh; background: var(--bg); }

/* Sidebar */
.sidebar {
  width: 232px;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  padding: 24px 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
}

.logo {
  padding: 0 18px 20px;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.18em;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.logo span { color: var(--red); }

.nav a {
  display: block;
  padding: 10px 18px;
  color: var(--text2);
  font-size: 13px;
  border-radius: 0 999px 999px 0;
  margin-right: 14px;
  gap: 10px;
}

.nav a:hover { background: var(--bg3); color: var(--text); }
.nav a.active { background: rgba(192,57,43,0.12); color: var(--red); }
.nav-icon {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: currentColor;
}
.nav-icon svg {
  width: 16px;
  height: 16px;
  display: block;
}
.nav a.active .nav-icon { color: var(--red); }

.nav-section {
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.1em;
  padding: 16px 16px 8px;
}

.sidebar-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px 18px;
  border-top: 1px solid var(--border);
}

.user-info { font-size: 12px; color: var(--text2); }
.logout-btn { color: var(--text3); font-size: 12px; margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.logout-btn:hover { color: var(--red); }

/* Main */
.main {
  flex: 1;
  margin-left: 232px;
  padding: 18px 20px 28px;
  min-width: 0;
}

.page-header { display: none; }
.page-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.page-title {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.page-subtitle { font-size: 12px; color: var(--text3); margin-top: 4px; }
.admin-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 18px;
}
.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.topbar-titlewrap { min-width: 0; }
.topbar-kicker {
  font-size: 10px;
  font-weight: 700;
  color: var(--text3);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}
.topbar-title {
  font-family: var(--font-display);
  font-size: 24px;
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.topbar-subtitle {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text3);
}
.topbar-menu-btn,
.icon-button {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg2);
  color: var(--text2);
  box-shadow: var(--shadow);
}
.topbar-menu-btn svg,
.icon-button svg,
.icon-slot svg {
  width: 16px;
  height: 16px;
  display: block;
}
.global-search-trigger {
  width: 100%;
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg2);
  color: var(--text2);
  box-shadow: var(--shadow);
}
.global-search-trigger span { flex: 1; text-align: left; }
.global-search-trigger kbd {
  font: 600 11px/1 var(--font-mono);
  color: var(--text3);
  padding: 4px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
}
.topbar-center { min-width: 0; }
.avatar-menu { position: relative; }
.avatar-trigger {
  width: 38px;
  height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  box-shadow: var(--shadow);
  color: var(--text2);
}
.avatar-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  padding: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-md);
  z-index: 60;
}
.avatar-dropdown a,
.avatar-dropdown button {
  width: 100%;
  display: flex;
  align-items: center;
  padding: 9px 10px;
  border-radius: 10px;
  color: var(--text2);
  text-align: left;
}
.avatar-dropdown a:hover,
.avatar-dropdown button:hover { background: var(--bg3); color: var(--text); }
.avatar-dropdown button { gap: 8px; }
.whats-new-btn { position: relative; }
.whats-new-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  display: block;
}
.whats-new-btn.has-dot .whats-new-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(192,57,43,0.15); }

/* Cards */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.card-body { padding: 16px; }

/* Stats (legacy — kept for other pages) */
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; color: var(--text3); letter-spacing: 0.05em; margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 700; }

/* Page subtitle */
.page-subtitle { font-size: 12px; color: var(--text3); margin-top: 2px; }
.header-actions { display: flex; align-items: center; gap: 10px; }
.refresh-hint { font-size: 11px; color: var(--text3); }

/* Alert banner */
.alert-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-left: 4px solid var(--red);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  color: #7f1d1d;
}
[data-theme="dark"] .alert-banner {
  background: rgba(178,34,34,0.1);
  border-color: rgba(178,34,34,0.3);
  border-left-color: var(--red);
  color: #fca5a5;
}
.alert-link { font-weight: 600; color: var(--red); margin-left: auto; white-space: nowrap; }
.alert-link:hover { text-decoration: underline; }

/* Hero row */
.hero-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }

.hero-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px 28px;
  box-shadow: var(--shadow-md);
}
.hero-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text3);
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.hero-card-value {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text);
  margin-bottom: 10px;
  line-height: 1;
}
.hero-card-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.hero-card-sub { font-size: 12px; color: var(--text3); }
.hero-card-sub2 { font-size: 12px; color: var(--text3); }
.hero-card-sub2 strong { color: var(--text2); }

/* Delta pills */
.delta-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.delta-up { background: #dcfce7; color: #15803d; }
.delta-down { background: #fee2e2; color: #b91c1c; }
.delta-flat { background: var(--bg3); color: var(--text3); }
[data-theme="dark"] .delta-up { background: rgba(74,222,128,0.15); color: #4ade80; }
[data-theme="dark"] .delta-down { background: rgba(248,113,113,0.15); color: #f87171; }

/* KPI row */
.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 16px; }

.kpi-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 20px;
  box-shadow: var(--shadow);
}
.kpi-card-alert {
  border-color: #fca5a5;
  background: #fff5f5;
}
[data-theme="dark"] .kpi-card-alert {
  border-color: rgba(178,34,34,0.4);
  background: rgba(178,34,34,0.07);
}
.kpi-label { font-size: 10px; font-weight: 600; color: var(--text3); letter-spacing: 0.08em; margin-bottom: 8px; }
.kpi-value { font-size: 26px; font-weight: 700; color: var(--text); margin-bottom: 4px; line-height: 1; }
.kpi-card-alert .kpi-value { color: var(--red); }
.kpi-sub { font-size: 11px; color: var(--text3); }

/* Traffic row */
.traffic-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.traffic-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}
.traffic-icon { font-size: 20px; line-height: 1; margin-top: 2px; }
.traffic-label { font-size: 10px; font-weight: 600; color: var(--text3); letter-spacing: 0.08em; margin-bottom: 6px; }
.traffic-value { font-size: 26px; font-weight: 700; color: var(--text); line-height: 1; margin-bottom: 4px; }
.traffic-sub { font-size: 11px; color: var(--text3); }

/* Split layout */
.split-row { display: grid; grid-template-columns: 60% 1fr; gap: 16px; margin-bottom: 24px; }
.split-main {}
.split-side { display: flex; flex-direction: column; gap: 16px; }
.split-side .card { margin-bottom: 0; }

/* Card enhancements */
.card { box-shadow: var(--shadow); }
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.card-header-link { font-size: 12px; font-weight: 400; color: var(--blue); }
.card-header-link:hover { text-decoration: underline; }

/* Order table extras */
.order-num { font-family: monospace; font-size: 12px; color: var(--text2); }
.order-total { font-weight: 600; }
.order-date { display: flex; flex-direction: column; gap: 1px; }
.order-date span { font-size: 12px; }
.order-time { color: var(--text3); font-size: 11px; }

/* Top products list */
.top-products-list { list-style: none; }
.top-product-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.top-product-row:last-child { border-bottom: none; }
.top-product-img {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border);
}
.top-product-img-placeholder {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  background: var(--bg3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text3);
  flex-shrink: 0;
}
.top-product-info { flex: 1; min-width: 0; }
.top-product-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-product-stats { font-size: 11px; color: var(--text3); margin-top: 2px; }
.top-product-rank { font-size: 11px; font-weight: 700; color: var(--text3); flex-shrink: 0; }
.top-product-empty { padding: 32px; text-align: center; color: var(--text3); font-size: 13px; }

/* Mini stat */
.mini-stat-big { font-size: 32px; font-weight: 800; color: var(--text); }
.mini-stat-sub { font-size: 12px; color: var(--text3); margin-top: 4px; }

/* Sparkline */
.sparkline-wrap { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.sparkline-heading { font-size: 10px; font-weight: 600; color: var(--text3); letter-spacing: 0.08em; margin-bottom: 8px; }
.sparkline-svg { width: 100%; height: auto; display: block; }

.spark-bar { fill: var(--border); transition: fill 0.15s; }
.spark-bar:hover { fill: var(--text3); }
.spark-bar-today { fill: var(--red) !important; opacity: 0.85; }
.spark-bar-today:hover { opacity: 1; }
.spark-label { font-size: 7px; fill: var(--text3); font-family: system-ui, -apple-system, sans-serif; }

/* Status breakdown */
.status-breakdown-card { margin-bottom: 16px; }
.status-bar-track {
  display: flex;
  height: 10px;
  border-radius: 6px;
  overflow: hidden;
  gap: 2px;
  margin-bottom: 12px;
  background: var(--bg3);
}
.status-bar-seg { height: 100%; min-width: 4px; border-radius: 2px; cursor: default; transition: opacity 0.15s; }
.status-bar-seg:hover { opacity: 0.8; }
.status-bar-loading { font-size: 12px; color: var(--text3); padding: 2px 0; }
.status-bar-empty { font-size: 12px; color: var(--text3); }
.status-bar-legend { display: flex; flex-wrap: wrap; gap: 8px 20px; }
.status-legend-item { display: flex; align-items: center; gap: 6px; }
.status-legend-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-legend-label { font-size: 12px; color: var(--text2); }
.status-legend-count { font-size: 12px; font-weight: 600; color: var(--text); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
thead th {
  text-align: left;
  padding: 12px 16px;
  font-size: 10px;
  color: var(--text3);
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  position: sticky;
  top: 0;
  z-index: 1;
}
th.sortable {
  cursor: pointer;
  user-select: none;
}
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tr:hover td { background: rgba(32,84,209,0.04); }
.table-wrap {
  max-width: 100%;
  overflow: auto;
}
.numeric,
td.numeric,
th.numeric {
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
}
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; }

/* Badges */
.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.badge-pending { background: rgba(167,139,250,0.2); color: #a78bfa; }
.badge-confirmed { background: rgba(96,165,250,0.2); color: var(--blue); }
.badge-processing { background: rgba(250,204,21,0.2); color: var(--yellow); }
.badge-shipped { background: rgba(74,222,128,0.2); color: var(--green); }
.badge-delivered { background: rgba(74,222,128,0.3); color: var(--green); }
.badge-cancelled { background: rgba(248,113,113,0.2); color: var(--red); }
.badge-paid { background: rgba(74,222,128,0.22); color: var(--green); }
.badge-refunded { background: rgba(248,113,113,0.15); color: var(--red); }
.badge-approved { background: rgba(74,222,128,0.22); color: var(--green); }
.badge-denied { background: rgba(248,113,113,0.2); color: var(--red); }
.badge-none { background: var(--bg3); color: var(--text3); }
.badge-active { background: rgba(74,222,128,0.2); color: var(--green); }
.badge-draft { background: var(--bg3); color: var(--text3); }
.badge-tier-standard { background: rgba(232,232,232,0.08); color: var(--text2); }
.badge-tier-premium { background: rgba(218,165,32,0.15); color: #daa520; }
.badge-tier-wholesale { background: rgba(74,222,128,0.15); color: var(--green); }
.badge-low { background: rgba(250,204,21,0.2); color: var(--yellow); }
.badge-out { background: rgba(248,113,113,0.2); color: var(--red); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 500;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #cc2222; }
.btn-secondary { background: var(--bg3); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--text3); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #cc2222; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 11px; color: var(--text3); letter-spacing: 0.05em; margin-bottom: 6px; }
.form-input, .form-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
}
.form-input:focus, .form-select:focus { border-color: var(--red); outline: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

.search-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  margin-bottom: 12px;
}
.search-field {
  position: relative;
}
.search-field .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text3);
  pointer-events: none;
}
.search-field .form-input {
  height: 36px;
  padding-left: 38px;
  border-radius: 10px;
}
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg2);
  color: var(--text2);
  font-size: 12px;
}
.filter-chip button {
  color: var(--text3);
  font-size: 14px;
  line-height: 1;
}
.filter-chip button:hover { color: var(--red); }
.pagination-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px 0;
  flex-wrap: wrap;
}
.pagination-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.pagination-meta {
  font-size: 12px;
  color: var(--text3);
}
.page-size-select {
  width: auto;
  min-width: 88px;
  height: 32px;
  padding: 6px 10px;
}

.skeleton {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, var(--bg3) 25%, rgba(255,255,255,0.6) 37%, var(--bg3) 63%);
  background-size: 400% 100%;
  animation: skeletonShimmer 1.2s ease-in-out infinite;
  border-radius: 6px;
}
@keyframes skeletonShimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}
.skeleton-row td { padding-top: 12px; padding-bottom: 12px; }
.skeleton-line {
  height: 12px;
  width: 100%;
}
.skeleton-line.short { width: 60%; }
.skeleton-line.xs { width: 42%; }

.empty-state {
  padding: 52px 20px;
  text-align: center;
}
.empty-state-graphic {
  width: 120px;
  height: 120px;
  margin: 0 auto 16px;
  color: var(--text3);
}
.empty-state-title {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: -0.02em;
  margin-bottom: 8px;
}
.empty-state-copy {
  color: var(--text3);
  font-size: 13px;
  max-width: 340px;
  margin: 0 auto;
}
.empty-state-actions { margin-top: 16px; }

/* Login */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.login-box {
  width: 100%;
  max-width: 360px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 32px;
}
.login-title {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 24px;
}
.login-title span { color: var(--red); }
.login-error {
  background: rgba(248,113,113,0.1);
  border: 1px solid rgba(248,113,113,0.3);
  color: var(--red);
  padding: 10px;
  border-radius: 6px;
  font-size: 12px;
  margin-bottom: 16px;
  display: none;
}
.login-error.show { display: block; }

/* Modal — viewport-aware: header/footer sticky, body scrolls internally */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  overflow: hidden;
}
.modal-bg.open { display: flex; }
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
  width: 100%;
  max-width: 520px;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  background: var(--bg2);
}
.modal-title { font-weight: 600; font-size: 15px; letter-spacing: -0.01em; }
.modal-close {
  color: var(--text3);
  font-size: 22px;
  line-height: 1;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: all 0.12s;
}
.modal-close:hover { color: var(--text); background: var(--bg3); }
.modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
}

.product-thumb-button {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  cursor: zoom-in;
  transition: border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease;
}
.product-thumb-button:hover {
  border-color: var(--accent);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.12);
  transform: translateY(-1px);
}
.product-thumb-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.product-thumb-button img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}
.product-image-preview-modal {
  max-width: min(720px, calc(100vw - 48px));
}
.product-image-preview-stage {
  min-height: 360px;
  max-height: calc(100dvh - 150px);
  display: grid;
  place-items: center;
  padding: 28px;
  overflow: auto;
  background:
    linear-gradient(45deg, rgba(100, 116, 139, 0.05) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(100, 116, 139, 0.05) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(100, 116, 139, 0.05) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(100, 116, 139, 0.05) 75%);
  background-size: 24px 24px;
  background-position: 0 0, 0 12px, 12px -12px, -12px 0;
}
.product-image-preview-stage img {
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: calc(100dvh - 210px);
  object-fit: contain;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg2);
}
@media (max-width: 600px) {
  .modal-bg { padding: 0; align-items: flex-end; }
  .modal {
    max-width: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 12px 12px 0 0;
  }
  .product-image-preview-stage {
    min-height: 280px;
    padding: 18px;
  }
}

/* Drawer — right-side detail panel */
.drawer-bg {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  align-items: stretch;
  justify-content: flex-end;
  z-index: 1001;
  overflow: hidden;
}
.drawer-bg.open { display: flex; }
.drawer {
  width: min(100%, 480px);
  max-width: 480px;
  height: 100%;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-md);
  transform: translateX(100%);
  animation: drawerIn 220ms ease-out forwards;
}
@keyframes drawerIn {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.drawer-header,
.drawer-footer {
  flex-shrink: 0;
  background: var(--bg2);
  padding: 14px 18px;
  border-color: var(--border);
}
.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}
.drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 18px;
}
.drawer-footer {
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}
.drawer-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--text3);
}
.drawer-close:hover { background: var(--bg3); color: var(--text); }

/* Toast */
.toast-stack {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
  width: min(100vw - 24px, 360px);
}
.toast-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateX(16px);
  transition: transform 180ms ease, opacity 180ms ease;
}
.toast-item.show { opacity: 1; transform: translateX(0); }
.toast-item.hide { opacity: 0; transform: translateX(16px); }
.toast-item.success { border-left: 3px solid var(--green); }
.toast-item.error { border-left: 3px solid var(--red); }
.toast-item.info { border-left: 3px solid var(--blue); }
.toast-item.warning { border-left: 3px solid var(--yellow); }
.toast-content { flex: 1; color: var(--text); font-size: 13px; line-height: 1.4; }
.toast-action {
  color: var(--blue);
  font-weight: 600;
  font-size: 12px;
  white-space: nowrap;
}
.toast-close {
  color: var(--text3);
  font-size: 18px;
  line-height: 1;
}
.toast-close:hover { color: var(--text); }
.toast-box { display: none; }

/* Shell backdrop + palette */
.sidebar-backdrop,
.command-palette-bg {
  position: fixed;
  inset: 0;
  display: none;
  background: rgba(15,23,42,0.42);
  z-index: 990;
}
.sidebar-backdrop { z-index: 1085; }
.sidebar-open .sidebar-backdrop { display: block; }
.command-palette-bg { align-items: center; justify-content: center; padding: 24px; z-index: 1100; }
.command-palette-bg.open { display: flex; }
.command-palette {
  width: min(720px, 100%);
  max-height: min(70vh, 640px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.command-palette-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.command-palette-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 14px;
}
.command-palette-list {
  overflow: auto;
  padding: 10px;
}
.palette-group { margin-bottom: 8px; }
.palette-group-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text3);
  padding: 8px 10px;
}
.palette-item {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: 12px;
  color: var(--text);
}
.palette-item:hover { background: var(--bg3); }
.palette-item-label { font-weight: 500; }
.palette-item-meta { color: var(--text3); font-size: 12px; }
.palette-empty {
  padding: 32px 12px;
  color: var(--text3);
  text-align: center;
  font-size: 13px;
}

/* Empty */
.empty {
  text-align: center;
  padding: 48px;
  color: var(--text2);
}

/* Utils */
.mb-4 { margin-bottom: 16px; }
.mt-4 { margin-top: 16px; }
.text-right { text-align: right; }
.text-muted { color: var(--text2); }
.hidden { display: none; }

/* Theme Toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text3);
  font-size: 12px;
  margin-bottom: 8px;
  padding: 0;
}
.theme-toggle:hover { color: var(--text); }
.theme-toggle svg { width: 14px; height: 14px; }

.login-theme-toggle {
  position: fixed;
  top: 16px;
  right: 16px;
  color: var(--text3);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg2);
  border: 1px solid var(--border);
}
.login-theme-toggle:hover { color: var(--text); border-color: var(--text3); }
.login-theme-toggle svg { width: 14px; height: 14px; }

/* Responsive */
@media (max-width: 1200px) {
  .traffic-row { grid-template-columns: repeat(2, 1fr); }
  .admin-topbar { grid-template-columns: minmax(0, 1fr) minmax(280px, 380px); }
  .topbar-right { grid-column: 1 / -1; justify-content: flex-end; }
}
@media (max-width: 1024px) {
  .kpi-row { grid-template-columns: repeat(2, 1fr); }
  .split-row { grid-template-columns: 1fr; }
  .main { margin-left: 220px; }
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .hero-row { grid-template-columns: 1fr; }
  .admin-topbar { grid-template-columns: 1fr; }
  .topbar-right { justify-content: space-between; }
}
@media (max-width: 600px) {
  .sidebar {
    display: block;
    transform: translateX(-102%);
    transition: transform 220ms ease;
    z-index: 1090;
    width: min(86vw, 280px);
  }
  .sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .stats { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
  .traffic-row { grid-template-columns: 1fr; }
  .hero-row { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
  .header-actions { display: none; }
  .admin-topbar { grid-template-columns: 1fr auto; }
  .topbar-center { display: none; }
  .topbar-menu-btn { display: inline-flex; }
  .drawer { width: 100%; max-width: 100%; }
  .toast-stack {
    left: 12px;
    right: 12px;
    width: auto;
  }
}

/* ─── Accessibility polish ───────────────────────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: 3px;
}
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--red);
  color: #fff;
  padding: 10px 16px;
  z-index: 10000;
  text-decoration: none;
  font-weight: 600;
  font-size: 13px;
}
.skip-link:focus { left: 12px; top: 12px; }

/* Tables: horizontal scroll on narrow viewports instead of clipping */
.card-body > table { width: 100%; }
@media (max-width: 900px) {
  .card-body { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .card-body > table { min-width: 720px; }
}

/* Modal: dialog gets a subtle keyboard focus indicator */
.modal-bg.open .modal { animation: modalIn 140ms ease-out; }
@keyframes modalIn {
  from { transform: translateY(8px) scale(0.985); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}
.modal-close:focus-visible { outline-offset: 0; }
.drawer-bg.open .drawer { animation: drawerIn 220ms ease-out forwards; }

/* ─── Analytics page components ──────────────────────────────────────────── */
.analytics-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}
@media (max-width: 1024px) { .analytics-grid { grid-template-columns: 1fr; } }

.period-btns { display: flex; gap: 6px; }
.period-btn {
  padding: 6px 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--text2);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  transition: all 0.12s;
}
.period-btn:hover { color: var(--text); border-color: var(--text3); }
.period-btn.active {
  background: var(--text);
  color: var(--bg2);
  border-color: var(--text);
}

.exclude-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text2);
  cursor: pointer;
  padding: 6px 10px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.exclude-toggle:hover { color: var(--text); }
.exclude-toggle input { accent-color: var(--red); }

.alert-card { border-color: rgba(248,113,113,0.35); }
.alert-card .card-header { color: var(--red); }
.alert-item {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  color: var(--text);
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.alert-item:last-child { border-bottom: 0; }
.alert-type {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--red);
  flex-shrink: 0;
}

/* Generic bar chart used on analytics */
.chart-bar-row {
  display: grid;
  grid-template-columns: 120px 1fr 80px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.chart-bar-row:last-child { border-bottom: 0; }
.chart-bar-label { color: var(--text2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chart-bar-track {
  height: 8px;
  background: var(--bg3);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}
.chart-bar-fill {
  height: 100%;
  background: var(--text2);
  transition: width 0.3s;
}
.chart-bar-fill-default { background: var(--text3); }
.chart-bar-fill-blue { background: var(--blue); }
.chart-bar-fill-green { background: var(--green); }
.chart-bar-fill-red { background: var(--red); }
.chart-bar-value {
  font-family: ui-monospace, SFMono-Regular, monospace;
  text-align: right;
  color: var(--text);
  font-weight: 600;
}

/* Device breakdown */
.device-bars { padding: 4px 0; }
.device-item {
  display: grid;
  grid-template-columns: 90px 50px 1fr;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  font-size: 12px;
}
.device-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text3);
}
.device-pct {
  font-family: ui-monospace, SFMono-Regular, monospace;
  color: var(--text);
  font-weight: 600;
}
.device-bar {
  height: 6px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}
.device-bar-fill {
  height: 100%;
  background: var(--blue);
  transition: width 0.3s;
}

/* ─── Sidebar nav badge (pending counts) ─────────────────────────────────── */
.nav a {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--red);
  border-radius: 9px;
  letter-spacing: 0;
  margin-left: 8px;
  flex-shrink: 0;
}
.nav a.active .nav-badge {
  background: #fff;
  color: var(--red);
}

/* ═══════════════════════════════════════════════════════════════════════════
   REFRESH LAYER — Shopify/Linear/Stripe-grade polish
   These rules sit AFTER the legacy layer so they override where appropriate
   while leaving the existing class names intact for the rest of the codebase.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Typography pass ─────────────────────────────────────────────────────── */
.page-title,
.topbar-title {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: var(--lh-tight);
}
.card-header {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.005em;
}

/* ── Card refresh ────────────────────────────────────────────────────────── */
.card {
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  transition: box-shadow var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
}
.card-clickable { cursor: pointer; }
.card-clickable:hover {
  box-shadow: var(--shadow-sm);
  transform: translateY(-1px);
}

/* ── Button system upgrade ───────────────────────────────────────────────── */
.btn {
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out),
              transform var(--dur-fast) var(--ease-out);
  white-space: nowrap;
  line-height: 1;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled,
.btn[disabled],
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 44px; padding: 0 18px; font-size: 14px; }

.btn-primary { background: var(--red); color: #fff; border-color: var(--red); }
.btn-primary:hover:not(:disabled) { background: #a82e21; border-color: #a82e21; }
.btn-primary:focus-visible { box-shadow: 0 0 0 3px rgba(192,57,43,0.25); }

.btn-secondary { background: var(--bg2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--bg3); border-color: var(--text3); }
.btn-secondary:focus-visible { box-shadow: var(--ring-blue); }

.btn-danger { background: var(--red); color: #fff; border-color: var(--red); }
.btn-danger:hover:not(:disabled) { background: #a82e21; border-color: #a82e21; }

.btn-ghost {
  background: transparent;
  color: var(--text2);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg3); color: var(--text); }

.btn-icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text2);
  border: 1px solid transparent;
  transition: background var(--dur-fast) var(--ease-out),
              border-color var(--dur-fast) var(--ease-out),
              color var(--dur-fast) var(--ease-out);
}
.btn-icon:hover:not(:disabled) { background: var(--bg3); color: var(--text); }
.btn-icon svg { width: 16px; height: 16px; display: block; }

/* ── Form inputs refresh ─────────────────────────────────────────────────── */
.form-input,
.form-select,
.form-textarea {
  width: 100%;
  height: 36px;
  padding: 0 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 13px;
  line-height: 1;
  transition: border-color var(--dur-fast) var(--ease-out),
              box-shadow var(--dur-fast) var(--ease-out);
}
.form-textarea {
  height: auto;
  min-height: 80px;
  padding: 10px 12px;
  resize: vertical;
  line-height: var(--lh-normal);
}
.form-input::placeholder,
.form-textarea::placeholder { color: var(--text3); }
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(96,165,250,0.15);
}
.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--bg3);
  color: var(--text3);
  cursor: not-allowed;
}
.form-label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 6px;
}
.form-group { margin-bottom: var(--sp-4); }
.form-help {
  margin-top: 6px;
  font-size: var(--text-sm);
  color: var(--text3);
}
.form-error {
  margin-top: 6px;
  font-size: var(--text-sm);
  color: var(--red);
}
.form-input.is-invalid,
.form-select.is-invalid,
.form-textarea.is-invalid { border-color: var(--red); }
.form-input.is-invalid:focus,
.form-select.is-invalid:focus,
.form-textarea.is-invalid:focus {
  box-shadow: 0 0 0 3px rgba(192,57,43,0.18);
}

/* ── Table refresh ───────────────────────────────────────────────────────── */
table {
  border-collapse: separate;
  border-spacing: 0;
}
thead th {
  padding: 12px 16px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text3);
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}
tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
  transition: background var(--dur-fast) var(--ease-out);
}
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: var(--bg3); }
.card .card-body > table tbody tr:first-child td:first-child { border-top-left-radius: var(--radius-lg); }
.card .card-body > table tbody tr:first-child td:last-child { border-top-right-radius: var(--radius-lg); }
.card .card-body > table tbody tr:last-child td:first-child { border-bottom-left-radius: var(--radius-lg); }
.card .card-body > table tbody tr:last-child td:last-child { border-bottom-right-radius: var(--radius-lg); }

td.numeric,
th.numeric,
.numeric {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 28px;
  transition: color var(--dur-fast) var(--ease-out);
}
th.sortable:hover { color: var(--text2); }
th.sortable::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  margin-top: -4px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8' fill='none' stroke='%237a8699' stroke-width='1.4'><path d='M2 3l2-2 2 2M2 5l2 2 2-2'/></svg>");
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-out);
}
th.sortable:hover::after { opacity: 1; }
th.sortable.sort-asc,
th.sortable.sort-desc {
  color: var(--blue);
  font-weight: 700;
}
th.sortable.sort-asc::after,
th.sortable.sort-desc::after { opacity: 1; }
th.sortable.sort-asc::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8' fill='none' stroke='%232054d1' stroke-width='1.6'><path d='M2 5l2-2 2 2'/></svg>");
}
th.sortable.sort-desc::after {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='8' viewBox='0 0 8 8' fill='none' stroke='%232054d1' stroke-width='1.6'><path d='M2 3l2 2 2-2'/></svg>");
}

/* ── Sidebar nav polish ──────────────────────────────────────────────────── */
.nav a {
  height: 36px;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0 var(--sp-4) 0 var(--sp-4);
  margin-right: 12px;
  font-size: 13px;
  color: var(--text2);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  border-left: 3px solid transparent;
  transition: background var(--dur-fast) ease,
              color var(--dur-fast) ease,
              border-left-color var(--dur-fast) ease;
}
.nav a:hover {
  background: var(--bg3);
  color: var(--text);
  border-left-color: transparent;
}
.nav a.active {
  background: rgba(178,34,34,0.08);
  color: var(--red);
  border-left: 3px solid var(--red);
  padding-left: calc(var(--sp-4) - 3px);
}
[data-theme="dark"] .nav a.active { background: rgba(224,80,80,0.12); }
.nav a svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.8;
  transition: opacity var(--dur-fast) ease;
}
.nav a.active svg { opacity: 1; }

/* ── Drawer refinement (parallel to modal) ───────────────────────────────── */
.drawer-bg {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.5);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  display: none;
  justify-content: flex-end;
  align-items: stretch;
  z-index: 1001;
  overflow: hidden;
}
.drawer-bg.open { display: flex; }
.drawer {
  position: relative;
  width: 520px;
  max-width: 100vw;
  height: 100%;
  background: var(--bg2);
  border-left: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--dur-base) var(--ease-out);
  animation: none;
}
.drawer-bg.open .drawer { transform: translateX(0); }
.drawer-header {
  flex-shrink: 0;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg2);
}
.drawer-title {
  font-size: var(--text-md);
  font-weight: 600;
  letter-spacing: -0.005em;
}
.drawer-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--sp-6);
}
.drawer-footer {
  flex-shrink: 0;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  background: var(--bg2);
}
.drawer-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
  color: var(--text3);
  font-size: 20px;
  line-height: 1;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.drawer-close:hover { background: var(--bg3); color: var(--text); }

@media (max-width: 600px) {
  .drawer-bg {
    align-items: flex-end;
    justify-content: stretch;
  }
  .drawer {
    width: 100vw;
    max-width: 100vw;
    height: auto;
    max-height: 90vh;
    max-height: 90dvh;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    transform: translateY(100%);
  }
  .drawer-bg.open .drawer { transform: translateY(0); }
}

/* ── Skeleton loaders ────────────────────────────────────────────────────── */
.skeleton {
  display: block;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
  border-radius: var(--radius-sm);
  position: relative;
  overflow: hidden;
}
@keyframes skeleton-pulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skeleton-text { height: 12px; border-radius: 4px; }
.skeleton-text-lg { height: 18px; border-radius: 4px; }
.skeleton-circle { border-radius: 50%; }
.skeleton-cell {
  display: block;
  width: 100%;
}
.skeleton-cell::before {
  content: "";
  display: block;
  height: 12px;
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg3) 25%, var(--bg) 50%, var(--bg3) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--sp-12) var(--sp-5);
}
.empty-state-icon {
  width: 48px;
  height: 48px;
  color: var(--text3);
  opacity: 0.7;
  margin-bottom: var(--sp-1);
}
.empty-state-icon svg {
  width: 100%;
  height: 100%;
  display: block;
  stroke-width: 1.5;
  fill: none;
  stroke: currentColor;
}
.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--text);
  margin-top: var(--sp-4);
  font-family: var(--font-sans);
  letter-spacing: -0.01em;
}
.empty-state-desc {
  font-size: var(--text-sm);
  color: var(--text3);
  margin-top: var(--sp-2);
  max-width: 320px;
  line-height: var(--lh-normal);
}
.empty-state-action { margin-top: var(--sp-4); }

/* ── Toast stack polish ──────────────────────────────────────────────────── */
.toast-stack {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 9999;
  width: auto;
  max-width: 380px;
}
.toast-item {
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  padding: 12px 14px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  max-width: 380px;
  width: auto;
  opacity: 0;
  transform: translateX(16px);
  transition: transform var(--dur-base) var(--ease-out),
              opacity var(--dur-base) var(--ease-out);
}
.toast-item.show { opacity: 1; transform: translateX(0); }
.toast-item.hide { opacity: 0; transform: translateX(16px); }
.toast-item.success { border-left: 3px solid var(--green); }
.toast-item.error   { border-left: 3px solid var(--red); }
.toast-item.info    { border-left: 3px solid var(--blue); }
.toast-item.warning { border-left: 3px solid var(--yellow); }

/* ── Focus rings refinement ──────────────────────────────────────────────── */
*:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}
.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.18);
}
.btn-primary:focus-visible,
.btn-danger:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(192,57,43,0.25);
}

/* ── Filter chip system ──────────────────────────────────────────────────── */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.4;
  transition: border-color var(--dur-fast) ease, color var(--dur-fast) ease;
}
.chip:hover { border-color: var(--text3); color: var(--text); }
.chip-label { white-space: nowrap; }
.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  color: var(--text3);
  font-size: 14px;
  line-height: 1;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--dur-fast) ease, color var(--dur-fast) ease;
}
.chip-remove:hover { background: var(--red); color: #fff; }

/* ── Search field (with leading magnifier) ───────────────────────────────── */
.search-field {
  position: relative;
}
.search-field .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text3);
  pointer-events: none;
  transition: color var(--dur-fast) ease;
}
.search-field .form-input {
  height: 36px;
  padding-left: 36px;
  padding-right: 12px;
  border-radius: var(--radius-md);
}
.search-field .form-input:focus + .search-icon,
.search-field:focus-within .search-icon { color: var(--text2); }

/* ─── Password visibility toggle ─────────────────────────────── */
.pw-toggle-wrap { position: relative; display: block; }
.pw-toggle-wrap > .form-input { padding-right: 42px; width: 100%; box-sizing: border-box; }
.pw-toggle-btn {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.pw-toggle-btn:hover { color: var(--text); background: var(--bg3); }
.pw-toggle-btn:focus-visible { outline: 2px solid #a51c1c; outline-offset: 2px; }

/* ─── Settings page polish (scoped via body.settings-page) ────── */
body.settings-page .main { padding-bottom: 64px; }
body.settings-page .page-header { margin-bottom: 20px; }
.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 760px;
}
.settings-grid .card { margin: 0; }
.settings-grid .card .card-header { display: flex; flex-direction: column; gap: 4px; }
.settings-grid .card-sub {
  font-size: 12px;
  color: var(--text3);
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}
@media (min-width: 1100px) {
  .settings-grid { grid-template-columns: repeat(2, 1fr); }
  .settings-grid .card-wide { grid-column: 1 / -1; }
}
body.settings-page .session-grid {
  display: grid;
  grid-template-columns: 88px 1fr;
  row-gap: 10px;
  column-gap: 12px;
  align-items: center;
  font-size: 13px;
}
body.settings-page .session-grid .session-k {
  font-size: 11px;
  color: var(--text3);
  letter-spacing: .08em;
  text-transform: uppercase;
}
body.settings-page .session-grid .session-v {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text);
}
body.settings-page .pref-radios { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; }
body.settings-page .pref-radios label { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* ─── 2FA card badges ────────────────────────────────────────── */
.tfa-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
}
.tfa-badge-on  { background: rgba(74, 222, 128, 0.13); color: #15803d; border: 1px solid rgba(74, 222, 128, 0.35); }
.tfa-badge-off { background: rgba(248, 113, 113, 0.10); color: #b91c1c; border: 1px solid rgba(248, 113, 113, 0.30); }
[data-theme="dark"] .tfa-badge-on  { color: #4ade80; }
[data-theme="dark"] .tfa-badge-off { color: #f87171; }

/* ═══════════════════════════════════════════════════════════════════════════
   SETTINGS PAGE — editorial work surface (v=10 redesign)
   Scoped via body.settings-page. Production-grade, no .card containers.
   Pairs a system serif (Hoefler / Iowan / Georgia) on display elements with
   the existing sans body. Crimson reserved for active state + primary action.
   ═══════════════════════════════════════════════════════════════════════════ */

body.settings-page .main.settings-main {
  padding: 36px 48px 96px;
  max-width: 1320px;
}

/* ── PAGE HEAD ─────────────────────────────────────────────────────────── */
body.settings-page .settings-pagehead {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 48px;
  align-items: end;
  padding-bottom: 28px;
  margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}

body.settings-page .settings-eyebrow {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 12px;
}

body.settings-page .settings-h1 {
  font-family: 'Hoefler Text', 'Iowan Old Style', 'Big Caslon', Georgia, serif;
  font-size: 52px;
  line-height: 1;
  font-weight: 400;
  letter-spacing: -0.022em;
  margin: 0;
  color: var(--text);
}

body.settings-page .settings-deck {
  margin: 12px 0 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text2);
  max-width: 56ch;
}

/* metadata bar — right-aligned, hairline-separated */
body.settings-page .settings-meta {
  display: flex;
  gap: 0;
  align-items: baseline;
  margin: 0;
  padding: 0;
  font-size: 12px;
}
body.settings-page .meta-pair {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 18px;
  border-left: 1px solid var(--border);
}
body.settings-page .meta-pair:first-child { border-left: 0; padding-left: 0; }
body.settings-page .meta-pair:last-child { padding-right: 0; }
body.settings-page .meta-pair dt {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text3);
  margin: 0;
}
body.settings-page .meta-pair dd {
  font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  letter-spacing: 0;
}
body.settings-page .meta-state.meta-on {
  color: #14532d;
}
body.settings-page .meta-state.meta-off {
  color: var(--text3);
}
[data-theme="dark"] body.settings-page .meta-state.meta-on { color: #4ade80; }

/* ── TWO-COLUMN SHELL ──────────────────────────────────────────────────── */
body.settings-page .settings-shell {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 80px;
  margin-top: 40px;
  align-items: start;
}

/* ── LEFT: STICKY NUMBERED TOC ─────────────────────────────────────────── */
body.settings-page .settings-toc {
  position: sticky;
  top: 28px;
  align-self: start;
  display: flex;
  flex-direction: column;
  padding-top: 6px;
}

body.settings-page .toc-eyebrow {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text3);
  margin: 0 0 16px;
}

body.settings-page .toc-link {
  display: grid;
  grid-template-columns: 28px 16px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  text-decoration: none;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  transition: color 0.18s ease;
}
body.settings-page .toc-link:hover { color: var(--text); }

body.settings-page .toc-num {
  font-family: 'Hoefler Text', 'Iowan Old Style', Georgia, serif;
  font-size: 18px;
  font-weight: 400;
  font-feature-settings: "lnum" 1;
  letter-spacing: -0.02em;
  color: var(--text3);
  font-style: italic;
  transition: color 0.18s ease;
}

body.settings-page .toc-rule {
  height: 1px;
  width: 12px;
  background: var(--text3);
  transition: width 0.25s ease, background-color 0.18s ease;
  transform-origin: left center;
}

body.settings-page .toc-label {
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.003em;
}

body.settings-page .toc-state {
  font-family: 'SF Mono', Menlo, Consolas, monospace;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.14em;
  padding: 2px 6px;
  background: var(--bg3);
  color: var(--text3);
  border-radius: 2px;
}
body.settings-page .toc-state[data-on="1"] {
  background: rgba(34, 139, 34, 0.12);
  color: #15803d;
}
[data-theme="dark"] body.settings-page .toc-state[data-on="1"] { color: #4ade80; background: rgba(74, 222, 128, 0.12); }

body.settings-page .toc-link.active { color: var(--text); }
body.settings-page .toc-link.active .toc-num { color: #a51c1c; font-style: normal; }
body.settings-page .toc-link.active .toc-rule { background: #a51c1c; }

body.settings-page .toc-foot {
  margin: 28px 0 0;
  font-size: 11px;
  color: var(--text3);
  line-height: 1.55;
  font-style: italic;
  max-width: 22ch;
}

/* ── RIGHT: SECTION FLOW ───────────────────────────────────────────────── */
body.settings-page .settings-flow {
  display: flex;
  flex-direction: column;
  gap: 80px;
  min-width: 0;
}

body.settings-page .sec {
  scroll-margin-top: 28px;
}

body.settings-page .sec-head {
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: start;
  gap: 24px;
  padding-bottom: 20px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border);
}

body.settings-page .sec-num {
  font-family: 'Hoefler Text', 'Iowan Old Style', 'Big Caslon', Georgia, serif;
  font-size: 44px;
  line-height: 0.85;
  font-weight: 400;
  letter-spacing: -0.025em;
  font-feature-settings: "lnum" 1;
  color: var(--text3);
  padding-top: 6px;
}

body.settings-page .sec-titles { min-width: 0; max-width: 60ch; }

body.settings-page .sec-title {
  font-family: 'Hoefler Text', 'Iowan Old Style', 'Big Caslon', Georgia, serif;
  font-size: 28px;
  font-weight: 400;
  line-height: 1.1;
  letter-spacing: -0.012em;
  color: var(--text);
  margin: 0;
}

body.settings-page .sec-sub {
  margin: 10px 0 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text2);
}

body.settings-page .sec-lead {
  margin: 0 0 24px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text2);
}

/* ── FORMS ─────────────────────────────────────────────────────────────── */
body.settings-page .sec-form { max-width: 560px; }
body.settings-page .sec-form-narrow { max-width: 360px; }

body.settings-page .form-group {
  margin: 0 0 16px;
}
body.settings-page .form-group:last-child { margin-bottom: 0; }

body.settings-page .form-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: 7px;
}

body.settings-page .form-input {
  width: 100%;
  padding: 11px 13px;
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 3px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
  box-sizing: border-box;
}
body.settings-page .form-input:hover:not(:disabled) {
  border-color: var(--text3);
}
body.settings-page .form-input:focus {
  outline: none;
  border-color: #a51c1c;
  box-shadow: 0 0 0 3px rgba(165, 28, 28, 0.10);
}
body.settings-page .form-input:disabled {
  background: var(--bg3);
  color: var(--text2);
  cursor: not-allowed;
}

body.settings-page .form-input-mono {
  font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  letter-spacing: -0.005em;
}
body.settings-page .form-input-secret {
  font-size: 13px;
  letter-spacing: 0.12em;
  font-weight: 500;
}
body.settings-page .form-input-otp {
  font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 20px;
  letter-spacing: 0.35em;
  text-align: center;
  font-weight: 600;
  padding: 14px 13px;
}

body.settings-page .form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

body.settings-page .form-actions {
  margin-top: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
}

body.settings-page .form-hint {
  font-size: 12px;
  color: var(--text3);
  line-height: 1.5;
}
body.settings-page .form-hint-block {
  display: block;
  margin: 0 0 14px;
  max-width: 50ch;
}

/* ── BUTTONS ───────────────────────────────────────────────────────────── */
body.settings-page .btn {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 10px 18px;
  border-radius: 3px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.05s;
  white-space: nowrap;
}
body.settings-page .btn:active { transform: translateY(1px); }
body.settings-page .btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }

body.settings-page .btn-primary {
  background: #a51c1c;
  border-color: #a51c1c;
  color: #fff;
}
body.settings-page .btn-primary:hover:not(:disabled) {
  background: #8a1818;
  border-color: #8a1818;
}

body.settings-page .btn-danger {
  background: transparent;
  border-color: #a51c1c;
  color: #a51c1c;
}
body.settings-page .btn-danger:hover:not(:disabled) {
  background: #a51c1c;
  color: #fff;
}

/* ── 2FA BADGE ─────────────────────────────────────────────────────────── */
body.settings-page .tfa-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 5px 10px;
  border-radius: 2px;
  border: 1px solid;
  align-self: start;
  margin-top: 6px;
  white-space: nowrap;
}
body.settings-page .tfa-badge-off {
  background: rgba(165, 28, 28, 0.06);
  color: #a51c1c;
  border-color: rgba(165, 28, 28, 0.30);
}
body.settings-page .tfa-badge-on {
  background: rgba(34, 139, 34, 0.07);
  color: #15803d;
  border-color: rgba(34, 139, 34, 0.32);
}
[data-theme="dark"] body.settings-page .tfa-badge-on { color: #4ade80; }

/* ── 2FA SETUP STAGE — annotated lettered steps ────────────────────────── */
body.settings-page .tfa-stage {
  margin-top: 28px;
  padding: 28px 28px 24px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  position: relative;
}
body.settings-page .tfa-stage::before {
  content: 'Setup';
  position: absolute;
  top: -8px;
  left: 22px;
  background: var(--bg);
  padding: 0 8px;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text3);
}

body.settings-page .tfa-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

body.settings-page .tfa-step {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 18px;
  align-items: start;
}

body.settings-page .tfa-step-marker {
  font-family: 'Hoefler Text', 'Iowan Old Style', Georgia, serif;
  font-size: 26px;
  font-style: italic;
  font-weight: 400;
  color: #a51c1c;
  line-height: 0.9;
  text-align: center;
  padding-top: 2px;
}

body.settings-page .tfa-step-body { min-width: 0; }

body.settings-page .tfa-step-title {
  margin: 0 0 4px;
  font-size: 14.5px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--text);
}

body.settings-page .tfa-step-desc {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text2);
}

body.settings-page .tfa-step-desc em {
  font-family: 'Hoefler Text', 'Iowan Old Style', Georgia, serif;
  font-style: italic;
  font-size: 1.05em;
}

/* ── THEME PILLS (replaces radios visually; radios still drive state) ──── */
body.settings-page .theme-pills {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg2);
}
body.settings-page .theme-pill {
  position: relative;
  cursor: pointer;
  margin: 0;
}
body.settings-page .theme-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
body.settings-page .theme-pill span {
  display: block;
  padding: 9px 20px;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text2);
  border-right: 1px solid var(--border);
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
body.settings-page .theme-pill:last-child span { border-right: 0; }
body.settings-page .theme-pill:hover span { color: var(--text); background: var(--bg3); }
body.settings-page .theme-pill.is-active span {
  background: #a51c1c;
  color: #fff;
}
body.settings-page .theme-pill input:focus-visible + span {
  outline: 2px solid #a51c1c;
  outline-offset: 2px;
}

/* ── DARK THEME ADJUSTMENTS ────────────────────────────────────────────── */
[data-theme="dark"] body.settings-page .settings-h1 { color: var(--text); }
[data-theme="dark"] body.settings-page .sec-num,
[data-theme="dark"] body.settings-page .toc-num { color: var(--text3); }
[data-theme="dark"] body.settings-page .toc-link.active .toc-num,
[data-theme="dark"] body.settings-page .tfa-step-marker { color: #ef4444; }
[data-theme="dark"] body.settings-page .toc-link.active .toc-rule { background: #ef4444; }
[data-theme="dark"] body.settings-page .btn-primary,
[data-theme="dark"] body.settings-page .btn-primary:hover { background: #b91c1c; border-color: #b91c1c; }
[data-theme="dark"] body.settings-page .theme-pill.is-active span { background: #b91c1c; }
[data-theme="dark"] body.settings-page .tfa-badge-off { color: #f87171; border-color: rgba(248,113,113,0.30); background: rgba(248,113,113,0.06); }

/* ── RESPONSIVE — collapses TOC to top scroller below 980px ────────────── */
@media (max-width: 980px) {
  body.settings-page .main.settings-main { padding: 28px 24px 64px; }
  body.settings-page .settings-pagehead {
    grid-template-columns: 1fr;
    align-items: start;
    gap: 24px;
  }
  body.settings-page .settings-meta { flex-wrap: wrap; }
  body.settings-page .settings-shell {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  body.settings-page .settings-toc {
    position: relative;
    top: 0;
    flex-direction: row;
    overflow-x: auto;
    gap: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
  }
  body.settings-page .toc-eyebrow,
  body.settings-page .toc-foot { display: none; }
  body.settings-page .toc-link {
    grid-template-columns: auto auto auto;
    border-bottom: 0;
    padding: 6px 0;
    flex-shrink: 0;
  }
  body.settings-page .toc-rule { display: none; }
  body.settings-page .settings-h1 { font-size: 40px; }
  body.settings-page .sec-head { grid-template-columns: 44px 1fr; gap: 14px; }
  body.settings-page .sec-head > .tfa-badge { grid-column: 1 / -1; justify-self: start; margin-top: 8px; }
  body.settings-page .sec-num { font-size: 32px; }
  body.settings-page .sec-title { font-size: 24px; }
  body.settings-page .form-row { grid-template-columns: 1fr; }
  body.settings-page .settings-flow { gap: 56px; }
}

/* ─── Override: utilitarian pass over the editorial block above.
   All-sans, mono numerals, tighter rhythm. No serif/italic flourishes. */
body.settings-page .settings-h1 {
  font-family: inherit;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.15;
}
body.settings-page .settings-deck {
  font-size: 13px;
  margin-top: 6px;
}
body.settings-page .settings-pagehead { padding-bottom: 20px; }

body.settings-page .toc-num,
body.settings-page .sec-num,
body.settings-page .tfa-step-marker {
  font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  font-style: normal !important;
  font-feature-settings: "tnum" 1;
  letter-spacing: 0;
}
body.settings-page .toc-num { font-size: 12px; font-weight: 600; }
body.settings-page .toc-link.active .toc-num { color: #a51c1c; }
body.settings-page .toc-link { grid-template-columns: 24px 1fr auto; gap: 12px; padding: 9px 0; }
body.settings-page .toc-rule { display: none; }
body.settings-page .toc-label { font-size: 13px; font-weight: 500; }

body.settings-page .sec-num {
  font-size: 13px;
  font-weight: 700;
  color: var(--text3);
  padding-top: 4px;
  letter-spacing: 0.05em;
}
body.settings-page .sec-title {
  font-family: inherit;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.005em;
}
body.settings-page .sec-sub { font-size: 13px; margin-top: 4px; }
body.settings-page .sec-head { grid-template-columns: 36px 1fr auto; gap: 14px; padding-bottom: 14px; margin-bottom: 20px; }

body.settings-page .settings-flow { gap: 48px; }
body.settings-page .settings-shell { gap: 64px; margin-top: 28px; }

body.settings-page .tfa-step-marker {
  font-size: 13px;
  font-weight: 700;
  color: #a51c1c;
  padding-top: 4px;
  letter-spacing: 0.05em;
}
body.settings-page .tfa-step-desc em {
  font-family: inherit;
  font-style: italic;
  font-size: 1em;
}
body.settings-page .tfa-stage { padding: 20px; margin-top: 20px; }
body.settings-page .tfa-stage::before { display: none; }
body.settings-page .tfa-step-title { font-size: 13px; }
body.settings-page .tfa-steps { gap: 22px; }

body.settings-page .main.settings-main { padding: 28px 32px 64px; }

body.settings-page .meta-pair dd {
  font-family: 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}

/* ── NORTH LABS HOUSE REFRESH ────────────────────────────────────────────
   Quiet, cold, and operational. Keeps the existing admin behavior intact
   while bringing the console into the current storefront visual system. */
:root {
  --bg: #eef2f5;
  --bg2: #fbfcfd;
  --bg3: #e5ebf0;
  --border: #d3dce4;
  --text: #0b1117;
  --text2: #455461;
  --text3: #71808b;
  --red: #176f86;
  --blue: #176f86;
  --green: #187c72;
  --shadow: 0 1px 2px rgba(11,17,23,.05), 0 16px 36px rgba(11,17,23,.06);
  --shadow-md: 0 18px 42px rgba(11,17,23,.10);
  --font-display: var(--font-sans);
}

[data-theme="dark"] {
  --bg: #080d12;
  --bg2: #0e151c;
  --bg3: #151f28;
  --border: #26343f;
  --text: #f1f5f7;
  --text2: #b6c2ca;
  --text3: #82929d;
  --red: #8dcfff;
  --blue: #8dcfff;
  --green: #67c9bd;
  --shadow: 0 1px 2px rgba(0,0,0,.35), 0 16px 36px rgba(0,0,0,.28);
  --shadow-md: 0 18px 42px rgba(0,0,0,.40);
}

body {
  background: radial-gradient(circle at 88% -8%, rgba(141,203,255,.12), transparent 32rem), var(--bg);
}

.sidebar {
  width: 248px;
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  border-right-color: var(--border);
  padding-top: 28px;
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.logo {
  padding: 0 24px 24px;
  font-size: 13px;
  letter-spacing: .24em;
  border-bottom-color: var(--border);
}
.logo span { color: var(--text3); }
.nav-section { padding: 14px 24px 5px; color: var(--text3); letter-spacing: .14em; font-size: 9px; font-weight: 700; }
.nav a {
  margin-right: 18px;
  padding: 8px 24px;
  border-radius: 0 6px 6px 0;
  transition: background var(--dur-base) var(--ease-out), color var(--dur-base) var(--ease-out);
  display: flex;
  align-items: center;
}
.nav a.active { background: rgba(23,111,134,.12); color: var(--red); }
.nav a:hover { background: var(--bg3); }
.sidebar .nav {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  padding-bottom: 12px;
}
.sidebar-footer {
  position: static;
  flex: 0 0 auto;
  background: var(--bg2);
}
.main { margin-left: 248px; padding: 28px 32px 48px; }
.page-title { font-family: var(--font-sans); font-size: 28px; letter-spacing: -.025em; }
.card, .today-card, .callout { border-radius: 6px; box-shadow: var(--shadow-xs); }
.card-header { letter-spacing: .01em; }
.btn-primary, .btn-danger { background: var(--red); border-color: var(--red); }
.btn-primary:hover:not(:disabled), .btn-danger:hover:not(:disabled) { filter: brightness(.92); }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
}
[hidden] { display: none !important; }

/* Operations dashboard */
.dash-section { margin-bottom: 26px; }
.dash-section-label,
.eyebrow {
  color: var(--text3);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.dash-section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
}
.dash-section-head .dash-section-label { margin: 0; }
.dash-section-head a,
.card-header a { color: var(--blue); font-size: 12px; font-weight: 600; }
.ops-metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.metric-link { display: block; min-width: 0; }
.ops-metric {
  min-height: 108px;
  padding: 16px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-xs);
}
.metric-link .ops-metric { height: 100%; transition: border-color var(--dur-fast), transform var(--dur-fast); }
.metric-link:hover .ops-metric { border-color: var(--blue); transform: translateY(-1px); }
.ops-metric > span { display: block; color: var(--text3); font-size: 10px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.ops-metric > strong { display: block; margin-top: 9px; color: var(--text); font-size: 28px; line-height: 1; font-variant-numeric: tabular-nums; }
.ops-metric > small { display: block; margin-top: 7px; color: var(--text3); font-size: 11px; }
.ops-metric.is-attention { border-color: color-mix(in srgb, var(--yellow) 46%, var(--border)); }
.dash-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
  padding: 13px 15px;
  background: color-mix(in srgb, var(--yellow) 8%, var(--bg2));
  border: 1px solid color-mix(in srgb, var(--yellow) 38%, var(--border));
  border-radius: 6px;
}
.dash-alert strong, .dash-alert span { display: block; }
.dash-alert span { margin-top: 2px; color: var(--text3); font-size: 12px; }
.dashboard-queues { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 14px; }
.dashboard-lower { display: grid; grid-template-columns: minmax(0,1.35fr) minmax(320px,.65fr); gap: 14px; }
.dashboard-queues .card, .dashboard-lower .card { margin: 0; min-width: 0; }
.dashboard-queues .card-header,
.dashboard-lower .card-header { padding: 13px 15px; }
.queue-list { padding: 0; }
.dashboard-queue-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 15px;
  border-bottom: 1px solid var(--border);
}
.dashboard-queue-row:last-child { border-bottom: 0; }
.dashboard-queue-row:hover { background: color-mix(in srgb, var(--blue) 5%, transparent); }
.dashboard-queue-row strong,
.dashboard-queue-row span { display: block; }
.dashboard-queue-row strong { font-size: 12px; color: var(--text); }
.dashboard-queue-row span { margin-top: 2px; font-size: 11px; color: var(--text3); overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.dashboard-queue-row small { flex: none; color: var(--text2); font-size: 11px; font-variant-numeric: tabular-nums; }
.queue-empty { padding: 24px 16px; color: var(--text3); font-size: 12px; text-align: center; }
.danger-text { color: var(--red) !important; font-weight: 700; }
.activity-list { list-style: none; }
.activity-list li { display: flex; align-items: flex-start; gap: 11px; padding: 12px 15px; border-bottom: 1px solid var(--border); }
.activity-list li:last-child { border-bottom: 0; }
.activity-dot { width: 7px; height: 7px; margin-top: 6px; border-radius: 99px; background: var(--green); flex: none; }
.activity-text { color: var(--text); font-size: 12px; }
.activity-when { margin-top: 2px; color: var(--text3); font-size: 10px; }

/* Fulfilment workspace */
.fulfilment-board { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 14px; margin-top: 18px; }
.queue-column { min-width: 0; padding: 14px; background: color-mix(in srgb,var(--bg2) 70%,transparent); border: 1px solid var(--border); border-radius: 7px; }
.queue-column > header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 2px 2px 13px; }
.queue-column h2 { margin-top: 3px; font-size: 15px; }
.queue-count { display: grid; place-items: center; min-width: 27px; height: 27px; padding: 0 7px; border-radius: 99px; background: var(--bg3); color: var(--text2); font-size: 11px; font-weight: 700; }
.queue-card { margin-bottom: 9px; padding: 13px; background: var(--bg2); border: 1px solid var(--border); border-radius: 6px; box-shadow: var(--shadow-xs); }
.queue-card:last-child { margin-bottom: 0; }
.queue-card-top, .queue-card-meta, .queue-card-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.queue-card-top strong { font-size: 12px; }
.queue-card-customer { margin-top: 8px; font-size: 12px; color: var(--text2); }
.queue-card-meta { margin-top: 5px; color: var(--text3); font-size: 10px; }
.queue-card-actions { margin-top: 12px; }
.tracking-input { margin-top: 10px; padding: 8px 9px; font-size: 12px; }

/* User and audit controls */
.role-note { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; margin-bottom: 14px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg2); color: var(--text3); font-size: 11px; }
.role-note strong { color: var(--text); }
.compact-select { min-width: 130px; padding: 7px 9px; font-size: 12px; }
.muted, .field-help { color: var(--text3); font-size: 11px; }
.field-help { display: block; margin-top: 5px; line-height: 1.45; }
.audit-filters { display: grid; grid-template-columns: minmax(240px,1fr) 160px 160px auto; gap: 10px; margin-bottom: 14px; }

@media (max-width: 760px) {
  .layout { display: block; }
  .sidebar {
    width: min(86vw, 280px);
    height: 100vh;
    position: fixed;
    padding: 20px 0;
    border-right: 1px solid var(--border);
    border-bottom: 0;
  }
  .logo { padding: 0 20px 18px; margin-bottom: 8px; }
  .nav { display: block; padding-bottom: 12px; }
  .nav-section { display: block; padding-left: 20px; }
  .nav a { margin-right: 14px; padding: 9px 20px; border-radius: 0 5px 5px 0; white-space: normal; }
  .sidebar-footer { position: static; display: block; padding: 14px 20px; }
  .logout-btn { margin-top: 8px; }
  .main { width: 100%; margin-left: 0; padding: 18px 14px 36px; }
  .admin-topbar { grid-template-columns: minmax(0,1fr) auto; gap: 10px; }
  .topbar-left { gap: 9px; }
  .topbar-title { font-size: 22px; }
  .topbar-subtitle { font-size: 11px; }
  .topbar-right { gap: 7px; }
  .icon-button, .avatar-trigger { width: 34px; height: 34px; }
  .ops-metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-queues, .dashboard-lower, .fulfilment-board { grid-template-columns: 1fr; }
  .audit-filters { grid-template-columns: 1fr; }
  .dash-section-head { align-items: flex-end; }
}

@media (min-width: 761px) and (max-width: 1120px) {
  .ops-metric-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .dashboard-queues, .fulfilment-board { grid-template-columns: 1fr; }
  .dashboard-lower { grid-template-columns: 1fr; }
}
