/* ================================================================
   Sapphyre Analytics — Professional Light Theme
   Aesthetic: Metabase / Google Analytics / Mixpanel
   ================================================================ */

/* ── Design tokens ───────────────────────────────────────────────── */
:root {
  /* Dimensions */
  --sb-w:         240px;
  --sb-w-mini:    56px;        /* collapsed icon-only width */
  --topbar-h:     56px;
  --filterbar-h:  60px;

  /* Sidebar (deep indigo — KickCash guide §2.1) */
  --sb-bg:        #1a1040;
  --sb-hover:     rgba(255,255,255,0.08);
  --sb-active-bg: rgba(79,70,229,0.45);
  --sb-active-txt:#ffffff;
  --sb-txt:       rgba(255,255,255,0.65);
  --sb-txt-dim:   rgba(255,255,255,0.35);
  --sb-border:    rgba(255,255,255,0.08);

  /* App shell */
  --bg-app:       #f1f3f7;
  --bg-topbar:    #ffffff;
  --bg-filter:    #ffffff;
  --bg-card:      #ffffff;
  --bg-input:     #f8fafc;
  --bg-tbl-head:  #f9fafb;
  --bg-tbl-alt:   #f9fafb;
  --bg-tbl-hover: #fafafa;

  /* Borders */
  --border:       #e8eaf0;
  --border-md:    #d1d5db;
  --border-focus: #a5b4fc;

  /* Text */
  --txt-head:    #111827;
  --txt-body:    #334155;
  --txt-muted:   #6b7280;
  --txt-label:   #6b7280;

  /* Brand / semantic (KickCash guide §2.1) */
  --primary:     #4f46e5;   /* blue — interactive, charts, primary */
  --primary-dk:  #4338ca;
  --primary-lt:  #ede9fe;
  --primary-ring:rgba(79,70,229,0.15);
  --kc-purple:   #7c3aed;   /* brand purple */
  --blue:        #4f46e5;

  /* Semantic colours */
  --green:       #16a34a;
  --green-lt:    #dcfce7;
  --red:         #dc2626;
  --red-lt:      #fee2e2;
  --amber:       #d97706;
  --amber-lt:    #fef3c7;
  --purple:      #7c3aed;
  --purple-lt:   #ede9fe;
  --muted:       #6b7280;
  --sky:         #0ea5e9;
  --sky-lt:      #f0f9ff;
  --teal:        #0d9488;
  --teal-lt:     #f0fdfa;

  /* Shadows (guide §2.9) */
  --shadow-xs:   0 1px 2px rgba(30,16,64,0.04);
  --shadow-sm:   0 1px 4px rgba(30,16,64,0.04);
  --shadow:      0 1px 4px rgba(30,16,64,0.05);
  --shadow-md:   0 4px 12px rgba(30,16,64,0.08), 0 8px 32px rgba(30,16,64,0.10);

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r:    10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* System font stack — no external font (guide T1) */
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Reset ───────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--txt-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); cursor: pointer; }

/* Scrollbar */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Sidebar ─────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sb-w);
  background: var(--sb-bg);
  display: flex;
  flex-direction: column;
  z-index: 300;
  overflow: hidden;
  transition: width 0.2s ease;
}

/* Collapsed state — toggled by JS click */
.sidebar.collapsed { width: var(--sb-w-mini); }

/* Hide text labels when collapsed */
.sidebar.collapsed .sb-label,
.sidebar.collapsed .sb-names { opacity: 0; pointer-events: none; }
.sidebar .sb-label,
.sidebar .sb-names {
  opacity: 1; pointer-events: auto;
  transition: opacity 0.12s ease;
  white-space: nowrap; overflow: hidden;
}

/* Center icons + headers when collapsed */
.sidebar.collapsed .sb-item      { justify-content: center; padding-left: 0; padding-right: 0; }
.sidebar.collapsed .sb-group-hdr { justify-content: center; padding: 8px 0; }
/* Force group items visible in collapsed mode (icon-only) */
.sidebar.collapsed .sb-group-items { display: block !important; }
/* Logo centering — remove min-width so gem icon can actually center */
.sidebar.collapsed .sb-logo { padding: 14px 0; justify-content: center; min-width: 0; }
/* Collapse label/text widths to 0 so flex centering works on the icon alone */
.sidebar.collapsed .sb-label,
.sidebar.collapsed .sb-names,
.sidebar.collapsed .sb-g-label { width: 0; overflow: hidden; }
/* Hide chevron — no meaning when collapsed */
.sidebar.collapsed .sb-g-chev { display: none; }

/* Logo */
.sb-logo {
  display: flex; align-items: center; gap: 10px;
  padding: 16px;
  border-bottom: 1px solid var(--sb-border);
  flex-shrink: 0;
  min-width: var(--sb-w);
}
.sb-gem {
  width: 32px; height: 32px;
  background: transparent;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px;
  flex-shrink: 0;
}
.sb-names { display: flex; flex-direction: column; }
.sb-product {
  font-size: 14px; font-weight: 700; color: #fff;
}
.sb-tagline {
  font-size: 11px; color: rgba(255,255,255,0.4);
}

/* Nav area */
.kc-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 8px; }
.kc-nav::-webkit-scrollbar { width: 3px; }
.kc-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 99px; }

/* Groups */
.sb-group { margin-bottom: 2px; }
.sb-group-hdr {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px;
  border-radius: 8px; cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}
.sb-group-hdr:hover { background: var(--sb-hover); }
.sb-group-left { display: flex; align-items: center; gap: 8px; }
.sb-g-icon { font-size: 13px; color: rgba(255,255,255,0.45); width: 18px; text-align: center; flex-shrink: 0; }
.sb-g-label {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: rgba(255,255,255,0.35);
}
.sb-g-chev { font-size: 10px; color: rgba(255,255,255,0.3); }

.sb-group-items { overflow: hidden; }
.sb-group-items.sb-group-collapsed { display: none; }

/* Nav items */
.sb-item {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px 7px 20px;
  border-radius: 8px;
  color: var(--sb-txt);
  font-size: 13px; font-weight: 400;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
  user-select: none;
}
.sb-item:hover { background: var(--sb-hover); color: #fff; }
.sb-item.active { background: var(--sb-active-bg); color: #fff; font-weight: 600; }

.sb-icon { width: 18px; text-align: center; font-size: 14px; flex-shrink: 0; }
.sb-label { font-size: 13px; }

/* Sidebar footer — sync status */
.sb-footer {
  flex-shrink: 0;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--sb-border);
}
.sb-footer .sb-status-row { display: flex; align-items: center; gap: 8px; }
.sb-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #475569; flex-shrink: 0;
  transition: background 0.3s;
}
.sb-status-dot.online  { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,0.5); }
.sb-status-dot.offline { background: #ef4444; }
.sb-status-detail { display: flex; flex-direction: column; }
.sb-status-text { font-size: 12px; font-weight: 500; color: rgba(255,255,255,0.65); }
.sb-status-sub  { font-size: 11px; color: rgba(255,255,255,0.3); line-height: 1.4; }

/* Collapse toggle button — circular, overlaps sidebar edge */
.sb-toggle {
  position: fixed; top: 16px;
  left: calc(var(--sb-w) - 12px);
  z-index: 400;
  width: 24px; height: 24px;
  background: var(--sb-bg);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.7); font-size: 10px;
  cursor: pointer;
  transition: left 0.2s ease;
}
.sb-toggle:hover { color: #fff; background: #2d2a6e; }

/* Mobile overlay */
.sb-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 290;
  backdrop-filter: blur(2px);
}

/* ── Shell ───────────────────────────────────────────────────────── */
.shell {
  margin-left: var(--sb-w);   /* full sidebar default */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.25s cubic-bezier(0.4,0,0.2,1);
}

/* ── Topbar ──────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 100;
  height: var(--topbar-h);
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  box-shadow: var(--shadow-xs);
}

.tb-left { display: flex; align-items: center; gap: 12px; }

.tb-hamburger {
  display: none;
  background: none; border: none;
  color: var(--txt-label); font-size: 16px; padding: 4px;
}

.tb-breadcrumb { display: flex; align-items: center; gap: 8px; }
.tb-product-name {
  font-size: 13px; font-weight: 500; color: var(--txt-muted);
}
.tb-sep { font-size: 10px; color: var(--txt-muted); }
.tb-page-name {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
}

.tb-right { display: flex; align-items: center; gap: 10px; }

.tb-badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 12px; font-weight: 500; color: var(--txt-label);
  white-space: nowrap;
}
.tb-badge-status { color: var(--txt-muted); }
.tb-badge-status.online { background: var(--green-lt); border-color: rgba(16,185,129,0.3); color: var(--green); }

.tb-btn-refresh {
  height: 32px; padding: 0 14px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--txt-label);
  font-size: 12.5px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  transition: all 0.15s;
}
.tb-btn-refresh:hover {
  background: var(--primary-lt);
  border-color: var(--border-focus);
  color: var(--primary);
}
.tb-btn-refresh.loading i { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Filter bar ──────────────────────────────────────────────────── */
.filterbar {
  background: var(--bg-filter);
  border-bottom: 1px solid var(--border);
  padding: 10px 24px;
  box-shadow: var(--shadow-xs);
}

.fb-inner {
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
}

.fb-group { display: flex; flex-direction: column; gap: 3px; min-width: 130px; }
.fb-group.fb-grow { flex: 1; min-width: 160px; }

.fb-label {
  font-size: 12.25px; font-weight: 400;
  text-transform: none; letter-spacing: 0;
  color: var(--txt-muted);
  margin-bottom: 4px;
}

.fb-input {
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--txt-body);
  font-family: var(--font); font-size: 13px;
  padding: 0 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.fb-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-ring);
}
.fb-input::-webkit-calendar-picker-indicator { opacity: 0.5; }

.fb-actions {
  display: flex; gap: 8px; padding-bottom: 1px;
}

.fb-btn-apply {
  height: 34px; padding: 0 18px;
  background: var(--primary);
  border: none;
  border-radius: var(--r-sm);
  color: #fff;
  font-size: 13px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.fb-btn-apply:hover { background: var(--primary-dk); box-shadow: 0 2px 8px rgba(59,130,246,0.35); }
.fb-btn-apply:disabled { opacity: 0.6; cursor: not-allowed; }

.fb-btn-reset {
  height: 34px; padding: 0 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--txt-label);
  font-size: 13px; font-weight: 500;
  transition: all 0.15s;
  white-space: nowrap;
}
.fb-btn-reset:hover { background: var(--bg-app); border-color: var(--border-md); color: var(--txt-body); }

/* Tom Select — light theme */
.ts-wrapper .ts-control {
  background: var(--bg-input) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r-sm) !important;
  color: var(--txt-body) !important;
  min-height: 34px;
  font-size: 13px; font-family: var(--font);
  padding: 3px 8px;
  box-shadow: none !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ts-wrapper.focus .ts-control {
  border-color: var(--border-focus) !important;
  box-shadow: 0 0 0 3px var(--primary-ring) !important;
}
.ts-dropdown {
  background: #fff !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--r) !important;
  box-shadow: var(--shadow-md) !important;
  font-size: 13px; font-family: var(--font);
  margin-top: 4px !important;
}
.ts-dropdown .option { color: var(--txt-body) !important; padding: 8px 12px !important; }
.ts-dropdown .option:hover,
.ts-dropdown .option.active { background: var(--primary-lt) !important; color: var(--primary) !important; }
.ts-dropdown .option.selected { color: var(--primary) !important; font-weight: 600; }
.ts-wrapper .item {
  background: var(--primary-lt) !important;
  border: 1px solid rgba(59,130,246,0.25) !important;
  color: var(--primary) !important;
  border-radius: var(--r-xs) !important;
  font-size: 12px; font-weight: 500;
}
.ts-wrapper .item .remove { color: #93c5fd !important; border-left-color: rgba(59,130,246,0.2) !important; }
.ts-wrapper .placeholder { color: var(--txt-muted) !important; }

/* Collapsed shell */
.shell.sb-collapsed { margin-left: var(--sb-w-mini); }
.shell.sb-collapsed .loading-bar { left: var(--sb-w-mini); }

/* ── Loading bar ─────────────────────────────────────────────────── */
.loading-bar {
  position: fixed; top: 0; left: var(--sb-w); right: 0;
  height: 3px;
  transition: left 0.25s cubic-bezier(0.4,0,0.2,1);
  background: transparent;
  z-index: 999;
  transition: background 0.2s;
  overflow: hidden;
}
.loading-bar.active {
  background: linear-gradient(90deg, var(--primary), #8b5cf6, var(--primary));
  background-size: 200% 100%;
  animation: bar-slide 1.2s linear infinite;
}
@keyframes bar-slide {
  0%   { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}

/* ── Main content ────────────────────────────────────────────────── */
.content {
  flex: 1;
  padding: 22px 24px 40px;
  overflow-y: auto;
}

/* ── Notice banner ───────────────────────────────────────────────── */
.notice-banner {
  display: flex; align-items: flex-start; gap: 14px;
  background: #fffbeb;
  border: 1px solid rgba(245,158,11,0.3);
  border-radius: var(--r);
  padding: 16px 20px;
  margin-bottom: 24px;
}
.notice-banner.d-none { display: none; }
.notice-icon { color: var(--amber); font-size: 18px; padding-top: 1px; flex-shrink: 0; }
.notice-body { font-size: 13.5px; color: var(--txt-body); line-height: 1.6; }
.notice-body strong { color: var(--txt-head); }
.notice-body code {
  background: rgba(15,23,42,0.06);
  padding: 1px 6px; border-radius: 4px;
  font-size: 12px; color: var(--amber);
}

/* ── Page section ────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-title {
  font-size: 16px; font-weight: 700; color: #111827;
  letter-spacing: -0.01em; line-height: 1.2;
}
.page-subtitle {
  font-size: 12px; color: var(--txt-muted); margin-top: 4px;
}
.page-header-actions { display: flex; gap: 8px; align-items: center; }

/* ── KPI grid ────────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}
.kpi-grid-4 { grid-template-columns: repeat(4, 1fr); }
.kpi-grid-5 { grid-template-columns: repeat(5, 1fr); }
.kpi-grid-7 { grid-template-columns: repeat(7, 1fr); }

@media (max-width: 1400px) {
  .kpi-grid  { grid-template-columns: repeat(3, 1fr); }
  .kpi-grid-4{ grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-5{ grid-template-columns: repeat(3, 1fr); }
  .kpi-grid-7{ grid-template-columns: repeat(4, 1fr); }
}
@media (max-width: 900px) {
  .kpi-grid, .kpi-grid-4, .kpi-grid-7 { grid-template-columns: repeat(2, 1fr); }
  .kpi-grid-5 { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 600px) {
  .kpi-grid, .kpi-grid-4, .kpi-grid-5, .kpi-grid-7 { grid-template-columns: repeat(2, 1fr); }
}

/* ── Trend chart controls ────────────────────────────────────────── */
.trend-controls { display: flex; gap: 4px; flex-shrink: 0; }
.trend-btn {
  height: 28px; padding: 0 12px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--txt-label);
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.trend-btn:hover {
  background: var(--primary-lt);
  border-color: var(--border-focus);
  color: var(--primary);
}
.trend-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  cursor: default;
}
/* KPI cards are not interactive — no hover effect (guide §4.10) */

/* Coloured top strip */
.kpi-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--primary));
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}

/* kpi-top and kpi-icon hidden — guide §4.8: KPI cards do not use icons */
/* KPI icons remain visible — aid visual scanning */
.kpi-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--txt-muted);
  margin-bottom: 7px;
}
.kpi-value {
  font-size: 22px; font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.02em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-sub {
  font-size: 11px; color: var(--txt-muted); margin-top: 4px;
}

.kpi-skeleton {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  height: 110px;
  animation: shimmer 1.4s ease-in-out infinite;
  background: linear-gradient(90deg,
    #f1f5f9 0%, #e8edf3 50%, #f1f5f9 100%);
  background-size: 200% 100%;
}
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Card ────────────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card.mt-5 { margin-top: 20px; }
.card.mt-4 { margin-top: 16px; }

.card-header {
  display: flex; align-items: center;
  justify-content: space-between; gap: 12px;
  padding: 18px 20px 0;
}
.card-header.card-toolbar {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 12px;
}
.card-body { padding: 16px 20px 20px; }

.card-title-group { flex: 1; }
.card-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--txt-muted);
}
.card-subtitle {
  font-size: 12px; color: var(--txt-muted); margin-top: 2px;
}

.card-select {
  height: 30px; padding: 0 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--txt-label);
  font-family: var(--font); font-size: 12px;
  cursor: pointer; outline: none;
  transition: border-color 0.15s;
}
.card-select:focus { border-color: var(--border-focus); }

/* ── Chart areas ─────────────────────────────────────────────────── */
.chart-area  { width: 100%; min-height: 300px; overflow: hidden; position: relative; }
.chart-lg    { min-height: 320px; }
.chart-xl    { min-height: 420px; }
.chart-donut { min-height: 300px; }

.no-chart-msg {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  min-height: 200px; gap: 10px;
  color: var(--txt-muted);
  background: var(--bg-app);
  border-radius: var(--r);
}
.no-chart-msg i { font-size: 28px; opacity: 0.3; }
.no-chart-msg p { font-size: 13px; }

/* ── Grid layouts ────────────────────────────────────────────────── */
.grid-2col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
}
.grid-4-6 {
  display: grid; grid-template-columns: 2fr 3fr; gap: 24px;
}
@media (max-width: 1024px) {
  .grid-2col, .grid-4-6 { grid-template-columns: 1fr; }
}

/* ── Header action buttons ───────────────────────────────────────── */
.hdr-btn {
  height: 34px; padding: 0 16px;
  border-radius: var(--r-sm);
  font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 7px;
  transition: all 0.15s;
}
.hdr-btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--txt-label);
}
.hdr-btn-ghost:hover {
  background: var(--bg-app);
  border-color: var(--border-md);
  color: var(--txt-body);
}

/* ── Table ───────────────────────────────────────────────────────── */
.toolbar-left  { display: flex; align-items: center; gap: 12px; flex: 1; }
.toolbar-right { display: flex; align-items: center; gap: 8px; }
.toolbar-label { font-size: 12px; font-weight: 600; color: var(--txt-muted); white-space: nowrap; }

.search-box {
  position: relative; display: flex; align-items: center; max-width: 280px;
}
.search-ico {
  position: absolute; left: 10px;
  color: var(--txt-muted); font-size: 12px; pointer-events: none;
}
.search-field {
  height: 32px; width: 240px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--txt-body);
  font-family: var(--font); font-size: 13px;
  padding: 0 10px 0 32px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s, width 0.2s;
}
.search-field:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--primary-ring);
  width: 300px;
}
.search-field::placeholder { color: var(--txt-muted); }

.count-badge {
  display: inline-block;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 11.5px; font-weight: 600;
  color: var(--txt-muted);
  white-space: nowrap;
}

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%; border-collapse: collapse; font-size: 13px;
}
.data-table thead tr {
  background: var(--bg-tbl-head);
  border-bottom: 2px solid #e5e7eb;
}
.data-table th {
  padding: 9px 11px;
  text-align: left;
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--txt-muted); white-space: nowrap;
  cursor: pointer;
}
.data-table th:hover {
  background: #f1f5f9;
  color: #374151;
}
.th-sub { font-size: 9px; font-weight: 400; margin-left: 3px; opacity: 0.7; }
.th-num    { text-align: right; }
.th-center { text-align: center; }

.data-table td {
  padding: 8px 11px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--txt-body); vertical-align: middle;
}
.data-table tfoot td {
  font-weight: 700;
  border-top: 2px solid #e5e7eb;
  border-bottom: none;
  padding: 9px 11px;
  background: #f9fafb;
}
.data-table tbody tr:nth-child(even) td { background: var(--bg-tbl-alt); }
.data-table tbody tr td { transition: background 0.1s; }
.data-table tbody tr:hover td {
  background: var(--bg-tbl-hover);
}
.td-num    { text-align: right; }
.td-center { text-align: center; }
.td-mono   { font-variant-numeric: tabular-nums; }
.td-trunc  { max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-time   { white-space: nowrap; font-size: 12px; color: var(--txt-muted); }

.td-empty { text-align: center; padding: 32px 16px; }
.empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty-icon  { font-size: 28px; color: var(--txt-muted); opacity: 0.4; }
.empty-state p { font-size: 13.5px; color: var(--txt-muted); }

/* ── Badges ──────────────────────────────────────────────────────── */
.badge-yes {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--green-lt);
  color: var(--green); border-radius: var(--r-xs);
  padding: 2px 8px; font-size: 11.5px; font-weight: 600;
}
.badge-no {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--red-lt);
  color: var(--red); border-radius: var(--r-xs);
  padding: 2px 8px; font-size: 11.5px; font-weight: 600;
}
.badge-na {
  display: inline-flex; align-items: center;
  background: var(--bg-app); color: var(--txt-muted);
  border-radius: var(--r-xs); padding: 2px 8px; font-size: 11.5px;
}

/* ── Pagination ──────────────────────────────────────────────────── */
.pagination-bar {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 14px 22px; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--border);
}
.pg-info { font-size: 12.5px; color: var(--txt-muted); }
.pg-controls { display: flex; gap: 4px; }

.pg-btn {
  min-width: 32px; height: 32px; padding: 0 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--txt-label);
  font-family: var(--font); font-size: 12.5px; font-weight: 500;
  transition: all 0.12s;
}
.pg-btn:hover:not(:disabled) {
  background: var(--primary-lt);
  border-color: var(--border-focus);
  color: var(--primary);
}
.pg-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff; font-weight: 600;
}
.pg-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Revenue/payout colours in table ────────────────────────────── */
.rev { color: var(--primary); font-weight: 600; }
.pay { color: var(--red); font-weight: 600; }

/* ── Sidebar badge ("New") ───────────────────────────────────────── */
.sb-badge {
  margin-left: auto;
  background: rgba(59,130,246,0.2);
  color: #93c5fd;
  border-radius: 99px;
  padding: 1px 8px;
  font-size: 9.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Filter bar auto-hint ────────────────────────────────────────── */
.fb-auto-hint {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; color: var(--txt-muted);
  white-space: nowrap; padding-bottom: 2px;
  opacity: 0.7;
}
.fb-auto-hint i { color: var(--primary); font-size: 10px; }

/* ── Funnel step reorder cell ────────────────────────────────────── */
.funnel-step-cell {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.funnel-move-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--r-xs);
  color: var(--txt-muted);
  font-size: 11px;
  width: 22px; height: 18px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; padding: 0;
  line-height: 1;
  transition: all 0.12s;
}
.funnel-move-btn:hover:not(:disabled) {
  background: var(--primary-lt);
  border-color: var(--border-focus);
  color: var(--primary);
}
.funnel-move-btn:disabled {
  opacity: 0.2; cursor: not-allowed;
}

/* Funnel goal name badges */
.funnel-top-badge {
  display: inline-block;
  margin-left: 6px;
  background: var(--primary-lt);
  color: var(--primary);
  border-radius: var(--r-xs);
  padding: 1px 6px;
  font-size: 9.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: 0.07em;
}
.funnel-last-badge {
  display: inline-block;
  margin-left: 6px;
  background: var(--green-lt);
  color: var(--green);
  border-radius: var(--r-xs);
  padding: 1px 6px;
  font-size: 9.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em;
}

/* ── Offer Funnel — selector card ────────────────────────────────── */
.funnel-selector-card { overflow: visible; }

.funnel-selector-body {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  padding: 20px 24px;
}

.funnel-auto-hint {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 500; color: var(--txt-muted);
  white-space: nowrap; padding-bottom: 2px; opacity: 0.7;
}
.funnel-auto-hint i { color: var(--primary); font-size: 10px; }

.funnel-selector-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; font-weight: 700; color: var(--txt-head);
  white-space: nowrap;
  padding-bottom: 2px;
}
.funnel-selector-label i { color: var(--primary); }

.funnel-selector-input {
  flex: 1; min-width: 260px; max-width: 520px;
}

/* ── Offer Funnel — empty state ──────────────────────────────────── */
.funnel-empty-state {
  display: flex; justify-content: center;
  padding: 64px 24px;
}

.funnel-empty-inner {
  max-width: 480px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}

.funnel-empty-icon {
  width: 72px; height: 72px;
  background: var(--primary-lt);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: var(--primary);
  margin-bottom: 4px;
}

.funnel-empty-title {
  font-size: 18px; font-weight: 700; color: var(--txt-head);
  letter-spacing: -0.3px;
}
.funnel-empty-sub {
  font-size: 13.5px; color: var(--txt-muted); line-height: 1.6;
}

.funnel-hint-row {
  display: flex; gap: 12px; flex-wrap: wrap; justify-content: center;
  margin-top: 4px;
}
.funnel-hint {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--bg-app);
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 4px 12px;
  font-size: 11.5px; font-weight: 500; color: var(--txt-label);
}
.funnel-hint i { color: var(--primary); font-size: 10.5px; }

/* ── Offer Funnel — chart area ───────────────────────────────────── */
.chart-funnel-area { min-height: 380px; }

.funnel-chart-legend {
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; color: var(--txt-muted);
}
.funnel-legend-dot {
  width: 10px; height: 10px; border-radius: 2px; flex-shrink: 0;
}
.funnel-legend-txt { font-size: 12px; color: var(--txt-muted); }

/* ── Offer Funnel — KPI step badge ──────────────────────────────── */
.funnel-step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  background: var(--primary-lt);
  color: var(--primary);
  border-radius: 50%;
  font-size: 11.5px; font-weight: 700;
}

/* ── Offer Funnel — progress bar in table ────────────────────────── */
.funnel-bar-wrap {
  display: flex; align-items: center; gap: 8px;
}
.funnel-bar-track {
  flex: 1; height: 8px;
  background: var(--bg-app);
  border-radius: 99px;
  overflow: hidden;
  min-width: 80px;
}
.funnel-bar-fill {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.4s cubic-bezier(0.4,0,0.2,1);
}
.funnel-bar-fill.step-1 { background: linear-gradient(90deg, #2563eb, #3b82f6); }
.funnel-bar-fill.low    { background: linear-gradient(90deg, #f59e0b, #fbbf24); }
.funnel-bar-fill.vlow   { background: linear-gradient(90deg, #ef4444, #f87171); }
.funnel-bar-pct {
  font-size: 11.5px; font-weight: 600; color: var(--txt-muted);
  min-width: 38px; text-align: right;
}

/* Funnel notice (Scenario B info message) */
.funnel-notice {
  display: flex; align-items: center; gap: 8px;
  background: rgba(99,102,241,.06); border: 1px solid rgba(99,102,241,.2);
  border-radius: var(--r); padding: 9px 14px;
  font-size: 12.5px; color: #475569; margin-bottom: 12px;
}
.funnel-notice i { color: var(--primary); flex-shrink: 0; }

/* Drop-off cell colouring */
.td-dropoff-hi  { color: var(--red);   font-weight: 600; }
.td-dropoff-mid { color: var(--amber); font-weight: 600; }
.td-dropoff-lo  { color: var(--txt-muted); }
.td-first-step  { color: var(--txt-muted); font-style: italic; }

/* ── Page sub-tabs (guide §15 .page-tabs) ───────────────────────── */
.page-tab-bar {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 18px;
}
.tab-btn {
  padding: 8px 16px;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  color: var(--txt-muted);
  background: none; border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
}
.tab-btn:hover { color: var(--txt-body); }
.tab-btn.active { color: #4f46e5; border-bottom-color: #4f46e5; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Recommendation badges ───────────────────────────────────────── */
.rec-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  white-space: nowrap;
}
.rec-scale    { background: var(--green-lt);  color: #059669; }
.rec-monitor  { background: var(--sky-lt);    color: var(--sky); }
.rec-optimize { background: var(--amber-lt);  color: #d97706; }
.rec-pause    { background: var(--red-lt);    color: var(--red); }

/* ── Alert bell (topbar) ─────────────────────────────────────────── */
.tb-alert-bell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  background: none; border: 1px solid var(--border);
  border-radius: var(--r); cursor: pointer;
  color: var(--txt-muted); font-size: 14px;
  transition: color 0.15s, background 0.15s;
}
.tb-alert-bell:hover { color: var(--txt-head); background: var(--bg-tbl-hover); }
.tb-alert-bell .tab-badge {
  position: absolute; top: -5px; right: -5px;
  min-width: 16px; height: 16px; padding: 0 4px;
  background: var(--red); color: #fff;
  border-radius: 99px; font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  border: 2px solid var(--bg-topbar, var(--bg-app));
}

/* ── Alert drawer ────────────────────────────────────────────────── */
.alert-drawer-overlay {
  display: none; position: fixed; inset: 0; z-index: 890;
}
.alert-drawer-overlay.open { display: block; }
.alert-drawer {
  position: fixed; top: 57px; right: 16px;
  width: 380px; max-height: calc(100vh - 80px);
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--r-lg); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  z-index: 900;
  transform: translateY(-8px) scale(0.97);
  opacity: 0; pointer-events: none;
  transition: transform 0.18s ease, opacity 0.18s ease;
}
.alert-drawer.open {
  transform: translateY(0) scale(1);
  opacity: 1; pointer-events: all;
}
.alert-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.alert-drawer-title { font-size: 14px; font-weight: 700; color: var(--txt-head); }
.alert-drawer-link {
  font-size: 11.5px; font-weight: 600; color: var(--primary);
  background: none; border: none; cursor: pointer; padding: 0;
}
.alert-drawer-link:hover { text-decoration: underline; }
.alert-drawer-close {
  width: 26px; height: 26px;
  display: flex; align-items: center; justify-content: center;
  background: none; border: none; cursor: pointer;
  color: var(--txt-muted); font-size: 13px; border-radius: var(--r);
}
.alert-drawer-close:hover { background: var(--bg-tbl-hover); color: var(--txt-head); }
.alert-drawer-body {
  overflow-y: auto; padding: 12px 14px;
  flex: 1;
}

/* ── Period comparison cards ─────────────────────────────────────── */
.comparison-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px;
}
@media (max-width: 1200px) { .comparison-grid { grid-template-columns: 1fr; } }

.comparison-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}
.comparison-card-title {
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--txt-muted); margin-bottom: 14px;
}
.cmp-row {
  display: flex; align-items: center;
  justify-content: space-between;
  padding: 6px 0; border-bottom: 1px solid var(--border);
}
.cmp-row:last-child { border-bottom: none; }
.cmp-label { font-size: 12.5px; color: var(--txt-body); font-weight: 500; }
.cmp-vals  { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.cmp-current { font-weight: 700; color: var(--txt-head); }
.cmp-arrow { font-size: 11px; }
.cmp-pct   { font-size: 11px; font-weight: 700; border-radius: 99px; padding: 2px 7px; }
.cmp-up    { color: var(--green); background: var(--green-lt); }
.cmp-down  { color: var(--red);   background: var(--red-lt); }
.cmp-flat  { color: var(--txt-muted); background: var(--bg-app); }

/* ── Leaderboard table (compact) ─────────────────────────────────── */
.lb-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.lb-table th {
  padding: 8px 12px; text-align: left;
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--txt-muted);
  background: var(--bg-tbl-head);
  border-bottom: 1px solid var(--border);
}
.lb-table th.th-r, .lb-table td.td-r { text-align: right; }
.lb-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--txt-body);
}
.lb-table tbody tr:last-child td { border-bottom: none; }
.lb-table tbody tr:hover td { background: var(--bg-tbl-hover); }
.lb-rank {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border-radius: 50%;
  background: var(--bg-app); border: 1px solid var(--border);
  font-size: 10.5px; font-weight: 700; color: var(--txt-muted);
}
.lb-rank-1 { background: #fef9c3; border-color: #fde047; color: #a16207; }
.lb-rank-2 { background: #f1f5f9; border-color: #94a3b8; color: #475569; }
.lb-rank-3 { background: #fff7ed; border-color: #fdba74; color: #c2410c; }

/* ── Trend pill chips (guide §4.7) ──────────────────────────────── */
.trend-up, .trend-down, .trend-flat {
  display: inline-block;
  border-radius: 20px;
  font-size: 0.65rem; font-weight: 700;
  padding: 2px 7px;
  white-space: nowrap;
}
.trend-up   { background: #d1fae5; color: #065f46; }
.trend-down { background: #fee2e2; color: #991b1b; }
.trend-flat { background: var(--bg-app); color: var(--txt-muted); }

/* ── Modals ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.52);
  z-index: 800;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  backdrop-filter: blur(3px);
  animation: modal-in 0.18s ease;
}
@keyframes modal-in { from { opacity:0; } to { opacity:1; } }

.modal-box {
  background: var(--bg-card);
  border-radius: var(--r-xl);
  box-shadow: 0 24px 80px rgba(15,23,42,0.22);
  width: 100%; max-width: 520px;
  max-height: 82vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modal-slide 0.2s cubic-bezier(0.34,1.56,0.64,1);
}
.modal-box-lg { max-width: 960px; }
@keyframes modal-slide { from { transform:translateY(20px); opacity:0; } to { transform:none; opacity:1; } }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 700; color: var(--txt-head); }
.modal-close {
  background: none; border: none; font-size: 22px;
  color: var(--txt-muted); cursor: pointer; line-height: 1;
  padding: 2px 6px; border-radius: var(--r-xs);
  transition: background 0.12s, color 0.12s;
}
.modal-close:hover { background: var(--bg-app); color: var(--txt-head); }
.modal-body { flex: 1; overflow-y: auto; padding: 20px 24px 24px; }

/* ── Slide-out panel ─────────────────────────────────────────────── */
.sp-overlay {
  position: fixed; inset: 0; z-index: 1050;
  background: rgba(0,0,0,0.28);
  opacity: 0; pointer-events: none;
  transition: opacity 0.22s;
}
.sp-overlay.open { opacity: 1; pointer-events: all; }

.slide-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 580px; max-width: 94vw;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  box-shadow: -6px 0 32px rgba(0,0,0,0.12);
  display: flex; flex-direction: column;
  z-index: 1051;
  transform: translateX(100%);
  transition: transform 0.24s cubic-bezier(0.4,0,0.2,1);
}
.slide-panel.open { transform: translateX(0); }

.sp-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.sp-header-left { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.sp-title {
  font-size: 16px; font-weight: 700; color: var(--txt-head);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 460px;
}
.sp-subtitle { font-size: 12px; color: var(--txt-muted); }
.sp-close {
  background: none; border: none; cursor: pointer;
  color: var(--txt-muted); font-size: 18px; line-height: 1;
  padding: 4px 6px; border-radius: var(--r-xs);
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0; margin-top: -2px;
}
.sp-close:hover { background: var(--bg-app); color: var(--txt-head); }

.sp-tab-bar {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  padding: 0 20px; flex-shrink: 0;
}
.sp-tab {
  padding: 10px 16px; font-size: 13px; font-weight: 500;
  color: var(--txt-muted); background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; transition: color 0.14s, border-color 0.14s;
}
.sp-tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.sp-tab:hover:not(.active) { color: var(--txt-head); }

.sp-body {
  flex: 1; overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

/* Clickable KPI card — pointer cursor only, no lift (guide §4.10) */
.kpi-card-click {
  cursor: pointer;
  user-select: none;
}
.kpi-card-click:hover {
  border-color: var(--border-md);
  background: #fafbfc;
}
.kpi-click-hint {
  font-size: 10px; color: var(--txt-muted);
  margin-top: 6px; display: flex; align-items: center; gap: 4px;
}
.kpi-click-hint i { font-size: 9px; }

/* Active / Paused status chips */
.status-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 99px;
  font-size: 11.5px; font-weight: 700;
}
.chip-active { background: var(--green-lt); color: #059669; }
.chip-paused { background: var(--red-lt);   color: var(--red); }

/* Modal publisher list */
.modal-pub-list { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.modal-pub-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r);
}
.modal-pub-id   { font-weight: 700; color: var(--txt-head); font-size: 13px; }
.modal-pub-name { font-size: 12px; color: var(--txt-muted); margin-top: 1px; }

/* ── Management / Data Manager forms ─────────────────────────────── */
.mgmt-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.mgmt-form-title {
  font-size: 13.5px; font-weight: 700; color: var(--txt-head);
  margin-bottom: 16px; display: flex; align-items: center; gap: 8px;
}
.mgmt-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}
.mgmt-field { display: flex; flex-direction: column; gap: 4px; }
.mgmt-field label {
  font-size: 10.5px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.07em; color: var(--txt-muted);
}
.mgmt-field input,
.mgmt-field textarea,
.mgmt-field select {
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--txt-body);
  font-family: var(--font); font-size: 13px;
  padding: 0 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.mgmt-field textarea { height: 60px; padding: 8px 10px; resize: vertical; }
.mgmt-field input:focus,
.mgmt-field textarea:focus { border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-ring); }

.mgmt-actions { display: flex; gap: 8px; align-items: flex-end; padding-top: 16px; }

/* ── Publisher admin form — sections ───────────────────────────── */
.pub-section {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px 16px;
  margin-bottom: 14px;
  background: var(--bg-app);
}
.pub-section-hdr {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.pub-section-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.pub-section-lbl {
  font-size: 12px; font-weight: 700; color: var(--txt-head);
  letter-spacing: .4px; text-transform: uppercase;
}

/* Game type field */
.pub-game-type-field { max-width: 180px; margin-bottom: 16px; }

/* Monetization: goals + bids side-by-side */
.pub-mono-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 680px) { .pub-mono-split { grid-template-columns: 1fr; } }
.pub-mono-col { display: flex; flex-direction: column; gap: 6px; }
.pub-col-label {
  font-size: 10.5px; font-weight: 700; color: var(--txt-muted);
  text-transform: uppercase; letter-spacing: .4px;
  display: flex; align-items: baseline; gap: 6px;
  margin-bottom: 4px;
}
.pub-col-hint {
  font-size: 10px; font-weight: 400; color: var(--txt-muted); text-transform: none; letter-spacing: 0;
}

/* Goal rows */
.pub-goal-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
}
.pub-goal-input {
  flex: 1;
  height: 30px; padding: 0 8px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px;
  color: var(--txt-head); font-size: 12px;
  transition: border-color .15s;
}
.pub-goal-input:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-ring); }
.pub-empty-hint { font-size: 11px; color: var(--txt-muted); padding: 4px 0; }

/* Bid table */
.pub-bid-table { width: 100%; border-collapse: collapse; }
.pub-bid-table thead th {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
  color: var(--txt-muted); padding: 4px 6px; border-bottom: 1px solid var(--border); text-align: left;
}
.pub-bid-table tbody td { padding: 3px 4px; vertical-align: middle; }
.pub-bid-goal { font-size: 12px; color: var(--txt-head); padding-left: 6px !important; }
.pub-bid-input {
  width: 90px; height: 28px; padding: 0 6px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px;
  color: var(--txt-head); font-size: 12px;
}
.pub-bid-input:focus { outline: none; border-color: var(--border-focus); }
.pub-bid-empty { font-size: 11px; color: var(--txt-muted); padding: 4px 2px; }

/* Add / remove buttons */
.pub-add-btn {
  display: inline-flex; align-items: center; gap: 5px;
  height: 28px; padding: 0 10px;
  background: transparent; border: 1px dashed var(--border);
  border-radius: 5px; color: var(--txt-muted); font-size: 11px; font-weight: 600;
  cursor: pointer; transition: border-color .15s, color .15s;
  margin-top: 4px; align-self: flex-start;
}
.pub-add-btn:hover { border-color: var(--primary); color: var(--primary); }
.pub-add-btn-sm { height: 24px; font-size: 10.5px; }
.pub-row-del {
  width: 22px; height: 22px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: transparent; border: none;
  color: var(--txt-muted); font-size: 11px; cursor: pointer; border-radius: 4px;
  transition: color .15s, background .15s;
}
.pub-row-del:hover { color: var(--red); background: rgba(239,68,68,.08); }

/* KPI groups */
.pub-kpi-groups {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 680px) { .pub-kpi-groups { grid-template-columns: 1fr; } }
.pub-kpi-group { display: flex; flex-direction: column; gap: 4px; }
.pub-kpi-group-title {
  font-size: 11px; font-weight: 700; color: var(--txt-muted);
  text-transform: uppercase; letter-spacing: .4px;
  margin-bottom: 6px;
}
.pub-kpi-row {
  display: flex; align-items: center; gap: 4px; margin-bottom: 4px;
}
.pub-kpi-dn {
  width: 48px; height: 28px; padding: 0 6px; text-align: center;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px;
  color: var(--txt-head); font-size: 12px;
}
.pub-kpi-dn:focus { outline: none; border-color: var(--border-focus); }
.pub-kpi-dlabel { font-size: 11px; color: var(--txt-muted); font-weight: 600; }
.pub-kpi-val {
  width: 60px; height: 28px; padding: 0 6px; text-align: right;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px;
  color: var(--txt-head); font-size: 12px;
}
.pub-kpi-val:focus { outline: none; border-color: var(--border-focus); }
.pub-kpi-unit { font-size: 11px; color: var(--txt-muted); }

/* Expected margin field */
.pub-margin-field { max-width: 180px; }

/* Table badges */
.pub-type-badge {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 10.5px; font-weight: 700; letter-spacing: .5px;
}
.chip-cpi { background: rgba(99,102,241,.12); color: #818cf8; }
.chip-cpe { background: rgba(16,185,129,.12); color: var(--green); }
.pub-goals-cell { display: flex; flex-wrap: wrap; gap: 3px; align-items: center; }
.pub-goal-tag {
  display: inline-block; padding: 1px 6px; border-radius: 4px;
  font-size: 10.5px; font-weight: 600;
  background: var(--bg-app); border: 1px solid var(--border); color: var(--txt-head);
}

/* ── Publisher form — Expected Funnel section ──────────────────── */
.pub-funnel-header {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 4px;
}
.pub-funnel-col-lbl {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--txt-muted);
}
.pub-funnel-col-lbl:first-child { flex: 1; }
.pub-funnel-col-num { width: 100px; text-align: right; }
.pub-funnel-row {
  display: flex; align-items: center; gap: 6px; margin-bottom: 4px;
}
.pub-funnel-goal {
  flex: 1;
  height: 30px; padding: 0 8px;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px;
  color: var(--txt-head); font-size: 12px;
}
.pub-funnel-goal:focus { outline: none; border-color: var(--border-focus); box-shadow: 0 0 0 3px var(--primary-ring); }
.pub-funnel-pct,
.pub-funnel-days {
  width: 90px; height: 30px; padding: 0 8px; text-align: right;
  background: var(--bg-card); border: 1px solid var(--border); border-radius: 5px;
  color: var(--txt-head); font-size: 12px;
}
.pub-funnel-pct:focus,
.pub-funnel-days:focus { outline: none; border-color: var(--border-focus); }

/* ── Publisher table — config summary column ───────────────────── */
.pub-list-table td { vertical-align: top; padding-top: 10px; padding-bottom: 10px; }
.pub-cfg-summary { display: flex; flex-direction: column; gap: 4px; }
.pub-cfg-line {
  display: flex; align-items: center; flex-wrap: wrap; gap: 4px;
}
.pub-cfg-label {
  font-size: 9.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .4px; color: var(--txt-muted);
  min-width: 60px;
}
.pub-kpi-chip {
  display: inline-block; padding: 1px 7px; border-radius: 4px;
  font-size: 10.5px; font-weight: 600;
  background: var(--bg-app); border: 1px solid var(--border); color: var(--txt-head);
}
.pub-kpi-chip-ret  { background: rgba(99,102,241,.08); border-color: rgba(99,102,241,.25); color: #818cf8; }
.pub-kpi-chip-roas { background: rgba(16,185,129,.08); border-color: rgba(16,185,129,.25); color: var(--green); }
.pub-kpi-chip-margin { background: rgba(245,158,11,.08); border-color: rgba(245,158,11,.25); color: var(--amber); }

/* Clone button */
.tbl-btn-clone {
  background: rgba(99,102,241,.1); color: #818cf8; border: 1px solid rgba(99,102,241,.25);
}
.tbl-btn-clone:hover { background: rgba(99,102,241,.18); }

/* Publishers tab — section note */
.pub-section-note {
  font-size: 12px; color: #64748b; margin: -4px 0 16px; padding: 8px 12px;
  background: rgba(99,102,241,.05); border-left: 3px solid var(--primary);
  border-radius: 0 var(--r-sm) var(--r-sm) 0;
}

/* Publisher enabled toggle row */
.pub-enabled-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 16px; padding: 10px 14px;
  background: var(--bg-alt); border: 1px solid var(--border);
  border-radius: var(--r-sm);
}
.pub-toggle-label {
  display: flex; align-items: center; gap: 8px;
  cursor: pointer; font-size: 13px; font-weight: 500; color: var(--txt);
  user-select: none;
}
.pub-toggle-label input[type="checkbox"] {
  width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary);
}
.pub-enabled-hint {
  font-size: 11px; color: var(--txt-muted); flex: 1;
}

/* Publisher status badges (guide §10.2 — pill spec) */
.pub-status-badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 10px; border-radius: 20px; letter-spacing: .2px;
}
.pub-status-active {
  background: #dcfce7; color: #15803d;
  border: 1px solid rgba(22,163,74,.25);
}
.pub-status-paused {
  background: #fee2e2; color: #b91c1c;
  border: 1px solid rgba(220,38,38,.2);
}

/* Paused row — dim the whole row */
tr.pub-row-paused td { opacity: 0.55; }
tr.pub-row-paused td:last-child { opacity: 1; }

/* Toggle button (Pause / Activate) */
.tbl-btn-toggle {
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.25);
  color: #d97706;
}
.tbl-btn-toggle:hover { background: rgba(245,158,11,.18); }

/* ── Game Configurations admin styles ─────────────────────────── */

/* Status row */
.gc-status-row {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-bottom: 18px;
}
.gc-stat-card {
  flex: 1 1 110px; min-width: 100px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--r); padding: 12px 14px;
  cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
  text-align: center; user-select: none;
}
.gc-stat-card:hover { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(99,102,241,.12); }
.gc-stat-card--active { border-color: var(--primary); background: rgba(99,102,241,.06); }
.gc-stat-card--ok   { border-color: rgba(16,185,129,.3); }
.gc-stat-card--warn { border-color: rgba(245,158,11,.3); }
.gc-stat-val {
  font-size: 22px; font-weight: 700; color: var(--text); line-height: 1.1;
}
.gc-stat-lbl {
  font-size: 11px; color: #64748b; margin-top: 4px; font-weight: 500;
}

/* Alert banner */
.gc-alert {
  display: flex; align-items: center; gap: 10px;
  background: rgba(245,158,11,.08); border: 1px solid rgba(245,158,11,.3);
  border-radius: var(--r); padding: 10px 14px;
  font-size: 13px; color: var(--amber);
  margin-bottom: 14px;
}
.gc-alert i { flex-shrink: 0; }

/* Unconfigured Games section */
.uc-games-card { margin-top: 16px; border-color: rgba(245,158,11,.35); }
.uc-warn-icon { color: var(--amber); margin-right: 6px; }
.count-badge--warn { background: rgba(245,158,11,.12); color: var(--amber); }
.uc-games-subtitle {
  font-size: 12px; color: var(--text-muted);
  max-width: 480px; line-height: 1.4;
}
.uc-offer-name { font-weight: 500; }
.uc-offer-id code {
  font-size: 11px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px; color: #64748b;
}
.uc-pubs .count-badge { font-size: 11px; }
.uc-games-table tbody tr:hover { background: rgba(245,158,11,.04); }

/* Game info banner (shown when editing) */
.gc-game-info-banner {
  display: flex; align-items: center; gap: 10px;
  background: rgba(99,102,241,.06); border: 1px solid rgba(99,102,241,.2);
  border-radius: var(--r-sm); padding: 8px 14px;
  margin-bottom: 14px; font-size: 13px;
}
.gc-banner-id {
  font-size: 11px; color: #64748b;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; padding: 2px 6px;
}

/* Filter label in table toolbar */
.gc-filter-label {
  font-size: 12px; color: #64748b; font-style: italic;
}

/* Status chips */
.gc-chip { display: inline-block; padding: 2px 8px; border-radius: 10px; font-size: 11px; font-weight: 600; }
.gc-chip-configured { background: rgba(16,185,129,.1); color: var(--green); border: 1px solid rgba(16,185,129,.25); }
.gc-chip-pending    { background: rgba(245,158,11,.1); color: var(--amber); border: 1px solid rgba(245,158,11,.25); }

/* Game table */
.gc-table td { vertical-align: top; padding-top: 10px; padding-bottom: 10px; }

/* Funnel time input+unit pair */
.gc-funnel-time {
  display: flex; gap: 4px; align-items: center; width: 130px;
}
.gc-funnel-time-val {
  width: 56px; height: 30px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text);
  font-family: var(--font); font-size: 12px; padding: 0 6px;
}
.gc-funnel-time-val:focus { outline: none; border-color: var(--primary); }
.gc-funnel-time-unit {
  flex: 1; height: 30px;
  background: var(--input-bg); border: 1px solid var(--border);
  border-radius: var(--r-sm); color: var(--text);
  font-family: var(--font); font-size: 12px; padding: 0 4px;
  cursor: pointer;
}
.gc-funnel-time-unit:focus { outline: none; border-color: var(--primary); }

/* ── Funnel CSV import toolbar ───────────────────────────────────── */
.gc-funnel-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.gc-funnel-sample-link {
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  cursor: pointer;
}
.gc-funnel-sample-link:hover { text-decoration: underline; }

/* ── Funnel CSV import preview modal ─────────────────────────────── */
.gc-import-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.gc-import-card {
  background: var(--bg-card);
  border: 1px solid var(--border-md);
  border-radius: var(--r-lg, 10px);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  width: 520px;
  max-width: 95vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.gc-import-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-sm);
}
.gc-import-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--txt-head);
  display: flex;
  align-items: center;
  gap: 7px;
}
.gc-import-close {
  background: none; border: none;
  color: var(--txt-muted); cursor: pointer;
  padding: 4px 6px; font-size: 13px; border-radius: var(--r-sm);
}
.gc-import-close:hover { color: var(--txt-body); background: var(--bg-app); }
.gc-import-status {
  padding: 10px 20px;
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
/* Each banner is a flex row so the icon sits beside the text */
.import-msg { display: flex; align-items: flex-start; gap: 6px; line-height: 1.45; }
.import-msg-ok   { color: var(--success, #16a34a); font-weight: 500; }
.import-msg-err  { color: var(--danger,  #dc2626); font-weight: 500; }
.import-msg-warn { color: #92400e; font-weight: 500; }  /* amber */
.gc-import-table-wrap {
  flex: 1;
  overflow-y: auto;
  padding: 0 20px 12px;
}
.gc-import-preview-table { width: 100%; font-size: 12px; }
.gc-import-preview-table .th-num,
.gc-import-preview-table .td-num { width: 48px; }
/* Invalid data row — red tint */
.import-row-err td {
  background: #fef2f2;
  color: var(--danger, #dc2626);
}
/* Raw unparsed value cell (shown instead of NaN when a row is invalid) */
.td-raw { font-style: italic; opacity: 0.85; }
/* Error detail sub-row (one per failing column, appears under the invalid data row) */
.import-err-sub td {
  background: #fff1f2;
  padding-top: 1px;
  padding-bottom: 3px;
  font-size: 11.5px;
}
.import-err-col {
  color: #9f1239;          /* rose-800 */
  font-family: var(--font-mono, monospace);
  font-weight: 600;
  white-space: nowrap;
  padding-left: 20px !important;
}
.import-err-msg {
  color: #be123c;          /* rose-700 */
}
.import-err-msg i { margin-right: 4px; }
.gc-import-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-sm);
}

.btn-primary {
  height: 34px; padding: 0 18px;
  background: var(--primary); border: none; border-radius: var(--r-sm);
  color: #fff; font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-dk); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-danger {
  height: 34px; padding: 0 18px;
  background: var(--red); border: none; border-radius: var(--r-sm);
  color: #fff; font-family: var(--font); font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-danger:hover { background: #dc2626; }
.btn-danger:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-ghost {
  height: 34px; padding: 0 14px;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--txt-label); font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap;
}
.btn-ghost:hover { background: var(--bg-app); border-color: var(--border-md); }

.btn-outline-sm {
  height: 28px; padding: 0 11px;
  background: transparent; border: 1px solid var(--border); border-radius: var(--r-sm);
  color: var(--txt-label); font-family: var(--font); font-size: 12px; font-weight: 500;
  cursor: pointer; transition: all 0.15s; white-space: nowrap; display: inline-flex; align-items: center;
}
.btn-outline-sm:hover { background: var(--bg-app); border-color: var(--primary); color: var(--primary); }

.tbl-btn {
  height: 26px; padding: 0 10px;
  border-radius: var(--r-xs);
  font-family: var(--font); font-size: 11.5px; font-weight: 600;
  cursor: pointer; border: 1px solid; transition: all 0.12s;
}
.tbl-btn-edit  { background: var(--primary-lt); border-color: rgba(59,130,246,0.3); color: var(--primary); }
.tbl-btn-edit:hover  { background: var(--primary); color: #fff; }
.tbl-btn-del   { background: var(--red-lt);     border-color: rgba(239,68,68,0.3);  color: var(--red); }
.tbl-btn-del:hover   { background: var(--red); color: #fff; }

/* ── Sync / Data Manager ─────────────────────────────────────────── */
.sync-log {
  font-family: 'SF Mono', 'Fira Mono', 'Consolas', monospace;
  font-size: 12px; line-height: 1.7;
  background: #0f172a; color: #e2e8f0;
  border-radius: var(--r);
  padding: 16px 18px;
  max-height: 340px;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}
.sync-log .log-ok     { color: #4ade80; }
.sync-log .log-err    { color: #f87171; }
.sync-log .log-info   { color: #94a3b8; }

.sync-progress-bar-wrap {
  height: 8px; background: var(--bg-app);
  border-radius: 99px; overflow: hidden; margin: 12px 0;
}
.sync-progress-bar {
  height: 100%; border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), #60a5fa);
  transition: width 0.4s ease;
  width: 0%;
}

.pub-preview-list {
  display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px;
}
.pub-chip {
  background: var(--primary-lt);
  color: var(--primary);
  border: 1px solid rgba(59,130,246,0.25);
  border-radius: 99px;
  padding: 2px 10px;
  font-size: 12px; font-weight: 600;
}

/* ── Metric multi-select pills ───────────────────────────────────── */
.metric-pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 12px; border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--bg-input);
  cursor: pointer;
  font-size: 12px; font-weight: 500; color: var(--txt-label);
  user-select: none;
  transition: all 0.12s;
}
.metric-pill input[type="checkbox"] { display: none; }
.metric-pill:has(input:checked) {
  background: var(--primary-lt);
  border-color: rgba(59,130,246,0.35);
  color: var(--primary);
}

/* ── Publisher Profile (360°) ────────────────────────────────────── */
.pp-header {
  display: flex; align-items: flex-start; gap: 20px;
  margin-bottom: 20px; flex-wrap: wrap;
}
.pp-back-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 1px solid var(--border);
  color: var(--txt-muted); font-size: 12.5px; font-weight: 600;
  padding: 6px 14px; border-radius: var(--r); cursor: pointer;
  transition: color 0.15s, background 0.15s; flex-shrink: 0;
  white-space: nowrap; align-self: center;
}
.pp-back-btn:hover { color: var(--txt-head); background: var(--bg-tbl-hover); }
.pp-identity { display: flex; align-items: center; gap: 14px; flex: 1; min-width: 0; }

/* ── Publisher Profile: Action Queue ─────────────────────────────── */
.pp-aq-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
}
.pp-aq-col {
  padding: 12px 16px;
  border-right: 1px solid var(--border);
}
.pp-aq-col:last-child { border-right: none; }
.pp-aq-hdr { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.pp-aq-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 5px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; gap: 8px;
}
.pp-aq-item:last-child { border-bottom: none; }
.pp-aq-item:hover { background: var(--bg-app); }
.pp-aq-name {
  font-size: 12.5px; color: var(--txt-head); font-weight: 500;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1; min-width: 0;
}
.pp-aq-pct  { font-size: 12px; font-weight: 700; flex-shrink: 0; }
.pp-aq-none { font-size: 12px; color: var(--txt-muted); padding: 5px 0; }

/* Trend column indicators */
.pp-trend-up     { color: var(--green); font-weight: 700; font-size: 15px; }
.pp-trend-stable { color: var(--txt-muted); font-size: 13px; }
.pp-trend-down   { color: var(--red); font-weight: 700; font-size: 15px; }

/* ── Publisher Profile: Offer Performance filters ─────────────────── */
.pp-filter-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 16px 12px;
  border-bottom: 1px solid var(--border);
}
.pp-filter-search {
  position: relative; flex: 1; min-width: 160px; max-width: 260px;
}
.pp-fi {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  font-size: 11px; color: var(--txt-muted); pointer-events: none;
}
.pp-filter-input {
  width: 100%; padding: 5px 8px 5px 28px;
  border: 1px solid var(--border); border-radius: var(--r);
  background: var(--bg-app); color: var(--txt-head);
  font-size: 12.5px; outline: none;
}
.pp-filter-input:focus { border-color: var(--primary); }
.pp-filter-select {
  padding: 5px 24px 5px 8px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--bg-app);
  color: var(--txt-head); font-size: 12.5px; cursor: pointer; outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2394a3b8' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center; background-size: 10px;
}
.pp-filter-select:focus { border-color: var(--primary); }
.pp-filter-range {
  display: flex; align-items: center; gap: 4px;
}
.pp-filter-range-label {
  font-size: 11.5px; color: var(--txt-muted); white-space: nowrap;
}
.pp-filter-range-input {
  width: 64px; padding: 5px 6px; border: 1px solid var(--border);
  border-radius: var(--r); background: var(--bg-app);
  color: var(--txt-head); font-size: 12px; outline: none;
  -moz-appearance: textfield;
}
.pp-filter-range-input::-webkit-outer-spin-button,
.pp-filter-range-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.pp-filter-range-input:focus { border-color: var(--primary); }
.pp-filter-range-sep { font-size: 12px; color: var(--txt-muted); }
.pp-filter-reset {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: none; border: 1px solid var(--border); border-radius: var(--r);
  color: var(--txt-muted); cursor: pointer; font-size: 12px; flex-shrink: 0;
}
.pp-filter-reset:hover { border-color: var(--primary); color: var(--primary); }

/* Sortable column headers */
.pp-sort-th { cursor: pointer; user-select: none; white-space: nowrap; }
.pp-sort-th:hover { color: var(--primary); }
.pp-sort-icon { font-size: 11px; color: var(--txt-muted); margin-left: 3px; }
.pp-sort-icon.pp-sort-active { color: var(--primary); font-weight: 700; }

/* Offer table wrapper — scrollable with sticky header */
.pp-offers-wrap { max-height: 520px; overflow-y: auto; }
.pp-offers-wrap thead th {
  position: sticky; top: 0; z-index: 2;
  background: var(--bg-card);
  box-shadow: 0 1px 0 var(--border);
}

/* Pagination bar */
.pp-pagination {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-top: 1px solid var(--border);
  font-size: 12.5px; color: var(--txt-muted); min-height: 44px;
}
.pp-pag-info { }
.pp-pag-btns { display: flex; align-items: center; gap: 8px; }
.pp-pag-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--r);
  background: none; color: var(--txt-head); font-size: 12px; cursor: pointer;
}
.pp-pag-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.pp-pag-btn:disabled { opacity: 0.35; cursor: default; }
.pp-pag-pages { font-weight: 600; color: var(--txt-head); }

/* Opportunity / Risk items */
.pp-action-item {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.1s;
}
.pp-action-item:last-child { border-bottom: none; }
.pp-action-item:hover { background: var(--bg-app); }
.pp-action-name {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
  max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pp-action-margin { font-size: 12px; color: var(--txt-muted); margin-top: 1px; }
.pp-action-empty  { font-size: 13px; color: var(--txt-muted); padding: 16px 0; text-align: center; }

/* Concentration bars */
.pp-conc-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.pp-conc-item:last-child { border-bottom: none; }
.pp-conc-name { font-size: 12.5px; font-weight: 600; color: var(--txt-head); min-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pp-conc-track { flex: 1; height: 6px; background: var(--bg-app); border-radius: 99px; overflow: hidden; }
.pp-conc-fill  { height: 100%; border-radius: 99px; background: var(--primary); }
.pp-conc-pct   { font-size: 12px; font-weight: 700; color: var(--txt-head); min-width: 38px; text-align: right; }
.pp-conc-warn  {
  display: flex; align-items: center; gap: 8px;
  background: var(--red-lt); border-radius: var(--r);
  padding: 8px 12px; margin-top: 12px;
  font-size: 12px; color: var(--red); font-weight: 600;
}

/* Ranking rows */
.pp-rank-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.pp-rank-row:last-child { border-bottom: none; }
.pp-rank-label { font-size: 12px; color: var(--txt-muted); }
.pp-rank-num   { font-size: 22px; font-weight: 800; color: var(--txt-head); line-height: 1; }
.pp-rank-of    { font-size: 11px; color: var(--txt-muted); margin-top: 2px; }

/* ── Publisher+Offer detail breadcrumb ──────────────────────────────── */
.po-header       { margin-bottom: 20px; }
.po-breadcrumb   { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.po-crumb-btn    {
  background: none; border: none; padding: 2px 4px;
  font-size: 12.5px; font-weight: 600; color: var(--primary);
  cursor: pointer; border-radius: 4px;
}
.po-crumb-btn:hover { text-decoration: underline; }
.po-crumb-sep    { font-size: 10px; color: var(--txt-muted); }
.po-crumb-current {
  font-size: 12.5px; font-weight: 600; color: var(--txt-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 280px;
}
.po-title-row    { display: flex; align-items: flex-start; gap: 14px; }

/* Activity rows */
.pp-act-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.pp-act-row:last-child { border-bottom: none; }
.pp-act-label { font-size: 12px; color: var(--txt-muted); }
.pp-act-val   { font-size: 13px; font-weight: 600; color: var(--txt-head); }

/* ── Offer Profile — status card ────────────────────────────────── */
.op-status-icon {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0; margin-bottom: 10px;
}
.op-status-line { font-size: 13px; color: var(--txt); line-height: 1.6; margin-bottom: 4px; }

/* ── Health Check page ───────────────────────────────────────────── */
.grid-3col {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px;
}
@media (max-width: 1100px) { .grid-3col { grid-template-columns: 1fr; } }

.health-period-card .card-body { padding-top: 4px; }

.hc-metrics { display: flex; flex-direction: column; gap: 0; }
.hc-metric-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 0; border-bottom: 1px solid var(--border);
}
.hc-metric-row:last-child { border-bottom: none; }
.hc-metric-label { font-size: 12px; color: var(--txt-muted); font-weight: 500; }
.hc-metric-value { font-size: 14px; font-weight: 700; color: var(--txt-head); }
.hc-metric-delta {
  font-size: 11.5px; font-weight: 600; display: flex; align-items: center; gap: 3px;
}
.hc-delta-up   { color: var(--green); }
.hc-delta-down { color: var(--red); }
.hc-delta-flat { color: var(--txt-muted); }
.hc-loading { text-align:center; padding: 20px; color: var(--txt-muted); font-size: 20px; }

/* Alert items */
.hc-alert-list { display: flex; flex-direction: column; gap: 8px; padding: 4px 0; }
.hc-alert-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 14px; border-radius: var(--r-sm);
  border-left: 3px solid transparent;
  background: var(--bg-app);
}
.hc-alert-item.sev-critical { border-left-color: var(--red); background: var(--red-lt); }
.hc-alert-item.sev-warning  { border-left-color: var(--amber); background: var(--amber-lt); }
.hc-alert-item.sev-info     { border-left-color: var(--blue); background: var(--primary-lt); }
.hc-alert-icon { font-size: 13px; margin-top: 1px; flex-shrink: 0; }
.hc-alert-item.sev-critical .hc-alert-icon { color: var(--red); }
.hc-alert-item.sev-warning  .hc-alert-icon { color: var(--amber); }
.hc-alert-item.sev-info     .hc-alert-icon { color: var(--blue); }
.hc-alert-msg { font-size: 13px; color: var(--txt-head); font-weight: 500; line-height: 1.4; }
.hc-alert-sub { font-size: 11.5px; color: var(--txt-muted); margin-top: 2px; }
.hc-no-alerts {
  text-align:center; padding: 28px 0;
  color: var(--green); font-size: 13px; font-weight: 600;
}

/* Campaign health filter tabs — kept for backward compat */
.hc-filter-btn {
  padding: 9px 16px; font-size: 12.5px; font-weight: 500;
  color: var(--txt-muted); background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  cursor: pointer; transition: color 0.14s, border-color 0.14s;
}
.hc-filter-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.hc-filter-btn:hover:not(.active) { color: var(--txt-head); }

/* ── Health Check: Operations Control Center ─────────────────────── */

/* Status dot indicators */
.hc-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin-right: 4px; flex-shrink: 0;
}
.hc-dot-healthy   { background: var(--green); }
.hc-dot-watchlist { background: var(--amber); }
.hc-dot-at-risk   { background: var(--red);   }

/* Status legend in card header */
.hc-status-legend {
  display: flex; align-items: center; gap: 10px;
  font-size: 11px; color: var(--txt-muted); margin-left: 12px;
}

/* Count badges coloured by sentiment */
.count-badge-red   { background: #fef2f2; color: var(--red);   }
.count-badge-green { background: #ecfdf5; color: var(--green); }

/* Action Queue — severity groups, 3 columns: Item · Reason · Revenue */
.hc-aq-col-header {
  display: grid; grid-template-columns: 1fr 1.8fr 76px;
  gap: 12px; padding: 7px 20px;
  background: var(--bg-tbl-head); border-bottom: 1px solid var(--border);
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--txt-muted);
}
/* Severity group divider */
.hc-aq-group-header {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 20px 5px; border-left: 3px solid;
  background: var(--sidebar-bg); border-bottom: 1px solid var(--border);
}
.hc-aq-group:not(:first-child) .hc-aq-group-header { border-top: 1px solid var(--border); }
.hc-aq-group-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.07em;
}
.hc-aq-group-count { font-size: 11px; color: var(--txt-muted); }
/* Row */
.hc-aq-row {
  display: grid; grid-template-columns: 1fr 1.8fr 76px;
  gap: 12px; padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  align-items: start; transition: background 0.12s; cursor: pointer;
}
.hc-aq-row:last-child { border-bottom: none; }
.hc-aq-row:hover { background: var(--hover); }
/* Name: 2-line wrap so long offer names don't vanish */
.hc-aq-name {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word; line-height: 1.35;
}
.hc-aq-reason { min-width: 0; }
.hc-aq-reason-text { font-size: 13px; color: var(--txt-body); line-height: 1.45; font-weight: 500; }
.hc-aq-impact { text-align: right; }
.hc-aq-impact-rev {
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
/* Inline plain-text reason under name in Risk / Scale / Funnel rows */
.hc-entity-reason {
  font-size: 12px; color: var(--txt-muted); margin-top: 3px; line-height: 1.35;
}
@media (max-width: 700px) {
  .hc-aq-col-header { grid-template-columns: 1fr 76px; }
  .hc-aq-row        { grid-template-columns: 1fr 76px; }
  .hc-aq-reason     { display: none; }
}

/* Card-level context subtitle (injected by JS) */
.hc-card-subtitle {
  font-size: 11.5px; color: var(--txt-muted);
  padding: 2px 20px 10px; line-height: 1.4;
}

/* Legacy priority items — kept for drawer compatibility */
.hc-priority-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.hc-priority-item:last-child { border-bottom: none; }
.hc-priority-item:hover { background: var(--hover); margin: 0 -20px; padding: 10px 20px; }
.hc-priority-body { flex: 1; min-width: 0; }
.hc-priority-name {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
  word-break: break-word; line-height: 1.35;
}
.hc-priority-detail { font-size: 12px; color: var(--txt-muted); margin-top: 2px; }
.hc-priority-meta {
  font-size: 12px; color: var(--txt-muted); text-align: right;
  white-space: nowrap; flex-shrink: 0;
}

/* Entity rows (risk / scale / funnel) */
.hc-entity-row {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.hc-entity-row:last-child { border-bottom: none; }
.hc-entity-row:hover { background: var(--hover); }
.hc-entity-left  { flex: 1; min-width: 0; }
.hc-entity-right { text-align: right; flex-shrink: 0; min-width: 72px; }
.hc-entity-name  {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
  /* 2-line wrap instead of hard truncation — full name visible in title tooltip */
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word; white-space: normal; max-width: none;
}

/* Reason chips */
.hc-reason-chip {
  display: inline-block; padding: 2px 7px; border-radius: 4px;
  font-size: 11px; font-weight: 500;
}
.hc-reason-chip.sev-critical { background: #fef2f2; color: var(--red);   }
.hc-reason-chip.sev-warning  { background: #fffbeb; color: #92400e;      }
.hc-reason-chip.sev-success  { background: #ecfdf5; color: var(--green); }

/* Publisher / Offer Health list */
.hc-health-summary {
  display: flex; gap: 16px; padding: 10px 20px;
  border-bottom: 1px solid var(--border); font-size: 12px;
}
.hc-health-count         { font-weight: 600; }
.hc-health-count.healthy   { color: var(--green); }
.hc-health-count.watchlist { color: var(--amber); }
.hc-health-count.at_risk   { color: var(--red);   }

.hc-health-list { display: flex; flex-direction: column; }
.hc-health-row {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 16px; border-bottom: 1px solid var(--border);
  transition: background 0.12s;
}
.hc-health-row:last-child { border-bottom: none; }
.hc-health-row:hover { background: var(--hover); }

/* Anomaly detection grid */
.hc-anomaly-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px;
}
.hc-anomaly-tile {
  border: 1px solid var(--border); border-radius: 8px;
  padding: 14px; display: flex; flex-direction: column; gap: 10px;
}
.hc-anomaly-tile-empty { opacity: 0.45; }
.hc-anomaly-header {
  display: flex; align-items: flex-start; gap: 10px;
}
.hc-anomaly-header > div { flex: 1; min-width: 0; }
.hc-anomaly-label { font-size: 13px; font-weight: 600; color: var(--txt-head); }
.hc-anomaly-count {
  background: #f1f5f9; color: var(--txt-head); font-size: 18px; font-weight: 700;
  border-radius: 6px; padding: 4px 10px; flex-shrink: 0; line-height: 1.2;
}
.hc-anomaly-count.empty { color: var(--txt-muted); }
.hc-anomaly-examples { display: flex; flex-direction: column; gap: 6px; }
.hc-anomaly-example {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  font-size: 12px; padding: 4px 6px; border-radius: 4px;
  transition: background 0.1s;
}
.hc-anomaly-example:hover { background: var(--hover); }

/* ── HC Info popup ───────────────────────────────────────────────── */
.hc-info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 20px; height: 20px; border: none; cursor: pointer;
  color: #64748b; background: rgba(100,116,139,0.12);
  font-size: 13px; padding: 0; margin-left: 6px;
  border-radius: 50%; transition: color 0.15s, background 0.15s;
  vertical-align: middle; flex-shrink: 0;
}
.hc-info-btn:hover { color: var(--accent); background: rgba(99,102,241,0.12); }

.hc-info-popup {
  background: #1e293b;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 14px 16px; min-width: 260px; max-width: 340px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35); font-size: 13px;
}
.hc-info-title {
  font-weight: 700; color: #f1f5f9; font-size: 13px;
  margin-bottom: 10px; padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.hc-info-row {
  display: flex; gap: 8px; align-items: flex-start; margin-bottom: 7px;
}
.hc-info-row:last-child { margin-bottom: 0; }
.hc-info-label {
  font-weight: 600; color: #ffffff; font-size: 12px;
  min-width: 68px; flex-shrink: 0;
}
.hc-info-desc {
  color: #94a3b8; font-size: 12px; line-height: 1.4;
}

/* ── HC Stat bar (breakdown chips + impact) ──────────────────────── */
.hc-stat-bar {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px;
  padding: 10px 16px 10px; border-bottom: 1px solid var(--border);
  background: var(--sidebar-bg); border-radius: 8px 8px 0 0;
}
.hc-stat-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 3px 10px; font-size: 12px;
  white-space: nowrap;
}
.hc-stat-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.hc-stat-label { color: var(--txt-muted); }
.hc-stat-count { font-weight: 700; font-size: 13px; }
.hc-stat-impact {
  margin-left: auto; font-size: 12px; color: var(--txt-label);
  font-weight: 500; white-space: nowrap;
}

/* ── HC Segment bar (entity health) ─────────────────────────────── */
.hc-health-header { padding: 10px 16px 0; }
.hc-health-counts {
  display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 0 10px;
}
.hc-segment-bar {
  display: flex; height: 6px; border-radius: 4px; overflow: hidden;
  background: var(--border); gap: 1px;
}
.hc-seg { height: 100%; min-width: 2px; }
.hc-seg-healthy   { background: var(--green); }
.hc-seg-watchlist { background: var(--amber); }
.hc-seg-at-risk   { background: var(--red);   }

/* ── HC Show-more expand ─────────────────────────────────────────── */
.hc-detail-list { }
.hc-show-more-btn {
  display: flex; align-items: center; gap: 6px; justify-content: center;
  width: 100%; padding: 8px 16px; background: none; border: none;
  border-top: 1px dashed var(--border); cursor: pointer;
  font-size: 12px; color: var(--accent); font-weight: 500;
  transition: background 0.15s;
}
.hc-show-more-btn:hover { background: var(--hover); }

/* ── Analytics: Growth Drivers ──────────────────────────────────── */
.an-drivers-section { margin-bottom: 8px; }
.an-drivers-section-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--txt-muted);
  padding: 12px 20px 6px;
}
.an-drivers-cols {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  border-top: 1px solid var(--border);
}
.an-drivers-col {
  padding: 0;
  border-right: 1px solid var(--border);
}
.an-drivers-col:last-child { border-right: none; }
.an-drivers-col-header {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 16px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.06em;
  border-bottom: 1px solid var(--border);
}
.an-drivers-gain   .an-drivers-col-header { color: var(--green); background: rgba(22,163,74,0.05); }
.an-drivers-decline .an-drivers-col-header { color: var(--red);   background: rgba(220,38,38,0.05); }
.an-driver-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s;
}
.an-driver-row:last-child { border-bottom: none; }
.an-driver-row:hover { background: var(--hover); }
.an-driver-name-wrap { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.an-driver-name {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.an-driver-new-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.05em;
  padding: 1px 5px; border-radius: 3px;
  background: rgba(99,102,241,0.15); color: var(--accent);
  flex-shrink: 0;
}
.an-driver-nums { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; margin-left: 8px; }
.an-driver-delta { font-size: 13px; font-weight: 700; }
.an-driver-curr  { font-size: 11px; color: var(--txt-muted); margin-top: 2px; }

/* ── Analytics: Concentration Risk ──────────────────────────────── */
.an-conc-row { padding: 10px 20px; border-bottom: 1px solid var(--border); }
.an-conc-row:last-child { border-bottom: none; }
.an-conc-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.an-conc-name {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.an-conc-pct { font-size: 13px; font-weight: 700; flex-shrink: 0; margin-left: 8px; }
.an-conc-track {
  height: 5px; border-radius: 3px; background: var(--border);
  overflow: hidden;
}
.an-conc-fill { height: 100%; border-radius: 3px; transition: width 0.3s; }

/* ── Analytics: Contribution bars ───────────────────────────────── */
.an-contrib-row {
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s;
}
.an-contrib-row:last-child { border-bottom: none; }
.an-contrib-row:hover { background: var(--hover); }
.an-contrib-meta { display: flex; align-items: center; justify-content: space-between; margin-bottom: 5px; }
.an-contrib-name {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.an-contrib-stats { font-size: 12px; color: var(--txt-muted); flex-shrink: 0; margin-left: 8px; }
.an-contrib-bar-wrap { display: flex; align-items: center; gap: 8px; }
.an-contrib-bar {
  height: 4px; border-radius: 3px;
  background: var(--accent); opacity: 0.7; min-width: 2px;
  transition: width 0.3s;
}
.an-contrib-pct { font-size: 11px; color: var(--txt-muted); white-space: nowrap; }

/* ── Analytics: Winners & Losers ─────────────────────────────────── */
.an-wl-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  cursor: pointer; transition: background 0.12s;
}
.an-wl-row:last-child { border-bottom: none; }
.an-wl-row:hover { background: var(--hover); }
.an-wl-left  { display: flex; align-items: center; gap: 6px; min-width: 0; flex: 1; }
.an-wl-right { display: flex; flex-direction: column; align-items: flex-end; flex-shrink: 0; margin-left: 8px; }
.an-wl-name {
  font-size: 13px; font-weight: 600; color: var(--txt-head);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.an-wl-delta { font-size: 13px; font-weight: 700; }
.an-wl-curr  { font-size: 11px; color: var(--txt-muted); margin-top: 2px; }
.an-wl-badge {
  font-size: 9px; font-weight: 700; letter-spacing: 0.04em;
  padding: 1px 5px; border-radius: 3px; flex-shrink: 0;
  text-transform: uppercase;
}
.an-wl-badge-pub   { background: rgba(59,130,246,0.12); color: #3b82f6; }
.an-wl-badge-offer { background: rgba(168,85,247,0.12); color: #a855f7; }

/* ── Analytics: Winners & Losers — multi-metric rows ────────────── */
.an-wl-top  { display: flex; align-items: center; gap: 6px; margin-bottom: 5px; }
.an-wl-metrics {
  display: flex; gap: 16px; flex-wrap: wrap;
  padding-left: 0;
}
.an-wl-metric {
  display: flex; align-items: center; gap: 4px;
  font-size: 12px;
}
.an-wl-metric-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--txt-muted); flex-shrink: 0;
}
.an-wl-metric small { font-size: 10px; opacity: 0.85; }

/* ── Analytics: New vs Existing Revenue ─────────────────────────── */
.an-nve-body {
  display: grid; grid-template-columns: 1fr auto 1fr; gap: 0;
  padding: 0;
}
.an-nve-col { padding: 16px 20px; }
.an-nve-divider {
  width: 1px; background: var(--border);
  margin: 16px 0;
}
.an-nve-col-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.07em; color: var(--txt-muted);
  margin-bottom: 12px;
}
.an-nve-bar-row {
  display: flex; height: 10px; border-radius: 5px;
  overflow: hidden; background: var(--border);
  margin-bottom: 14px;
}
.an-nve-bar-seg { height: 100%; transition: width 0.3s; }
.an-nve-exist { background: var(--accent); }
.an-nve-new   { background: var(--green); }
.an-nve-legend { display: flex; gap: 20px; flex-wrap: wrap; }
.an-nve-legend-item { display: flex; align-items: flex-start; gap: 7px; }
.an-nve-dot {
  width: 9px; height: 9px; border-radius: 50%;
  flex-shrink: 0; margin-top: 3px;
}
.an-nve-dot-exist { background: var(--accent); }
.an-nve-dot-new   { background: var(--green); }
.an-nve-legend-label { font-size: 11px; color: var(--txt-muted); margin-bottom: 2px; }
.an-nve-legend-val   { font-size: 14px; font-weight: 700; color: var(--txt-head); }
.an-nve-legend-pct   { font-size: 12px; font-weight: 500; color: var(--txt-muted); }

@media (max-width: 700px) {
  .an-nve-body { grid-template-columns: 1fr; }
  .an-nve-divider { width: 100%; height: 1px; margin: 0 16px; }
  .an-wl-metrics { gap: 10px; }
}

/* ── Analytics: empty state ─────────────────────────────────────── */
.an-empty {
  padding: 20px 16px; font-size: 13px; color: var(--txt-muted);
  font-style: italic;
}

/* ── Utilities ───────────────────────────────────────────────────── */
.d-none { display: none !important; }

/* Bootstrap Icons spin — replaces fa-spin (guide I1) */
.bi-spin { display: inline-block; animation: spin 0.7s linear infinite; }

/* Monospace currency (guide T3) */
.text-money {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════════════════════════════════════
   UX POLISH — Toast · Skeleton · Form Error · Armed Delete · Inline Confirm
   ══════════════════════════════════════════════════════════════════ */

/* ── Toast notifications ─────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  max-width: 340px;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  box-shadow: 0 4px 20px rgba(15,23,42,.22);
  pointer-events: auto;
  animation: toast-in .2s cubic-bezier(.22,.68,0,1.2);
  transition: opacity .28s ease, transform .28s ease;
  line-height: 1.35;
  word-break: break-word;
}
.toast.toast-out { opacity: 0; transform: translateX(12px); }
.toast-success { background: #16a34a; }
.toast-error   { background: #dc2626; }
.toast-info    { background: #4f46e5; }
.toast-icon    { flex-shrink: 0; font-size: 14px; }
@keyframes toast-in {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Skeleton loaders ────────────────────────────────────────────── */
.skel-line {
  height: 13px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: skel-shimmer 1.4s infinite linear;
}
.skel-line-sm { height: 10px; width: 60%; }
@keyframes skel-shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
tr.skel-row td { padding: 8px 11px; vertical-align: middle; }

/* ── Inline form error message ───────────────────────────────────── */
.form-error-msg {
  display: none;
  font-size: 12px;
  color: var(--red, #ef4444);
  font-weight: 500;
  margin-top: 6px;
  padding: 7px 10px;
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: 6px;
}
.form-error-msg::before {
  content: '\f057  ';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
}

/* ── Armed delete button (2-click confirm) ───────────────────────── */
.tbl-btn-del-armed {
  background: var(--red, #ef4444) !important;
  color: #fff !important;
  border-color: var(--red, #ef4444) !important;
  font-weight: 600 !important;
  animation: armed-pulse .5s ease;
}
@keyframes armed-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ── Inline clear-database confirm ──────────────────────────────── */
.inline-db-confirm {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 14px;
  background: rgba(239,68,68,.07);
  border: 1px solid rgba(239,68,68,.25);
  border-radius: 8px;
  flex-wrap: wrap;
}
.inline-db-confirm.open { display: flex; }
.inline-db-confirm-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--red, #ef4444);
  white-space: nowrap;
}
.inline-db-confirm-input {
  font-family: 'JetBrains Mono', 'Courier New', monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .5px;
  padding: 5px 10px;
  border: 1px solid rgba(239,68,68,.35);
  border-radius: 5px;
  background: var(--bg-card, #fff);
  color: var(--txt-head, #0f172a);
  width: 110px;
  outline: none;
  transition: border-color .15s;
}
.inline-db-confirm-input:focus { border-color: var(--red, #ef4444); }

/* ── Inline sync form error ─────────────────────────────────────── */
.sync-form-error {
  display: none;
  font-size: 12px;
  font-weight: 500;
  color: var(--red, #ef4444);
  margin-top: 6px;
}

/* ── Responsive ──────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(calc(-1 * var(--sb-w)));
    width: var(--sb-w);
  }
  .sidebar .sb-label,
  .sidebar .sb-names { opacity: 1; pointer-events: auto; }
  .sidebar .sb-item { justify-content: flex-start; padding: 7px 10px 7px 20px; }
  .sidebar.collapsed { width: var(--sb-w); transform: translateX(calc(-1 * var(--sb-w))); }
  .sidebar.open { transform: translateX(0); }
  .sb-toggle { display: none; }
  .sb-overlay.open { display: block; }
  .shell, .shell.sb-collapsed { margin-left: 0; transition: none; }
  .loading-bar, .shell.sb-collapsed .loading-bar { left: 0; transition: none; }
  .tb-hamburger { display: flex; }
  .tb-product-name, .tb-sep { display: none; }
  .content { padding: 20px 16px 40px; }
  .filterbar { padding: 10px 16px; }
  .kpi-grid, .kpi-grid-4 { grid-template-columns: 1fr 1fr; }
  .tb-badge { display: none; }
}
