@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=Inter:wght@400;500;600;700;800&family=Noto+Sans+SC:wght@400;500;600;700&display=swap');

/* ═══════════════════════════════════════════════════════════════
   forsab2b — Premium Design System
   ═══════════════════════════════════════════════════════════════ */

:root {
  --font: 'Inter', system-ui, sans-serif;
  --sidebar-w: 272px;
  --radius: 14px;
  --radius-xl: 20px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  /* Subscriber — light canvas + dark sidebar */
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --primary-glow: rgba(124, 58, 237, 0.45);
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.35);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --sidebar-bg: #09090f;
  --sidebar-border: rgba(255, 255, 255, 0.06);
  --sidebar-text: rgba(255, 255, 255, 0.55);
  --sidebar-text-active: #fff;
  --sidebar-hover: rgba(255, 255, 255, 0.05);
  --sidebar-active: rgba(124, 58, 237, 0.18);

  --canvas: #f8f9fc;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.12);
  --text: #0f0f14;
  --text-secondary: #52525b;
  --text-tertiary: #a1a1aa;

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 40px var(--primary-glow);

  /* Glass morphism */
  --glass-blur: 22px;
  --glass-saturate: 180%;
  --glass-bg: rgba(255, 255, 255, 0.65);
  --glass-bg-strong: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 255, 255, 0.45);
  --glass-shine: rgba(255, 255, 255, 0.55);
  --glass-inner: inset 0 1px 0 rgba(255, 255, 255, 0.65);
}

/* Native form controls follow app color mode */
html { color-scheme: light; }
html[data-color-mode="dark"] { color-scheme: dark; }

/* ── Dark mode (subscriber + auth) ── */
html[data-color-mode="dark"]:not([data-theme="admin"]) {
  --canvas: #07070e;
  --surface: rgba(16, 16, 26, 0.94);
  --surface-2: rgba(28, 28, 42, 0.72);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-tertiary: #71717a;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);

  --glass-bg: rgba(16, 16, 28, 0.55);
  --glass-bg-strong: rgba(20, 20, 34, 0.72);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-shine: rgba(255, 255, 255, 0.14);
  --glass-inner: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

html[data-color-mode="dark"]:not([data-theme="admin"]) .topbar {
  background: rgba(7, 7, 14, 0.88);
}

html[data-color-mode="dark"]:not([data-theme="admin"]) .grid-overlay {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
}

html[data-color-mode="dark"]:not([data-theme="admin"]) .mesh-bg::before {
  background: radial-gradient(circle, rgba(124, 58, 237, 0.22) 0%, transparent 70%);
}

html[data-color-mode="dark"]:not([data-theme="admin"]) .mesh-bg::after {
  background: radial-gradient(circle, rgba(6, 182, 212, 0.15) 0%, transparent 70%);
}

html[data-color-mode="dark"]:not([data-theme="admin"]) .auth-form-side {
  background: var(--canvas);
}

html[data-color-mode="dark"]:not([data-theme="admin"]) .auth-glass-card h2 {
  color: var(--text);
}

html[data-color-mode="dark"]:not([data-theme="admin"]) .auth-glass-card .subtitle,
html[data-color-mode="dark"]:not([data-theme="admin"]) .auth-form-header .subtitle {
  color: var(--text-secondary);
}

html[data-color-mode="dark"]:not([data-theme="admin"]) .auth-switch {
  color: var(--text-tertiary);
}

/* ── Arabic typography (Cairo + Western numerals) ── */
html[lang="ar"] {
  --font: 'Cairo', system-ui, sans-serif;
}

html[lang="zh"] {
  --font: 'Noto Sans SC', 'Inter', system-ui, sans-serif;
}

html[lang="ar"] .nums,
html[lang="ar"] .kpi-value,
html[lang="ar"] .plan-price,
html[lang="ar"] .campaign-stat-val,
html[lang="ar"] .auth-stat-val,
html[lang="ar"] input,
html[lang="ar"] .table td,
html[lang="ar"] [data-count] {
  font-variant-numeric: lining-nums tabular-nums;
  font-feature-settings: "lnum" 1, "tnum" 1;
}

/* Admin brand (amber) + light canvas by default */
[data-theme="admin"] {
  --primary: #d97706;
  --primary-light: #f59e0b;
  --primary-glow: rgba(217, 119, 6, 0.35);
  --accent: #ea580c;
  --sidebar-bg: #030712;
  --sidebar-active: rgba(251, 191, 36, 0.12);
  --canvas: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef1f7;
  --border: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.14);
  --text: #0f172a;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 8px 30px rgba(15, 23, 42, 0.08), 0 2px 8px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.12);
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.88);
  --glass-border: rgba(255, 255, 255, 0.55);
  --glass-shine: rgba(255, 255, 255, 0.6);
  --glass-inner: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

/* Admin dark mode */
html[data-color-mode="dark"][data-theme="admin"] {
  --primary: #fbbf24;
  --primary-light: #fde68a;
  --primary-glow: rgba(251, 191, 36, 0.35);
  --accent: #f97316;
  --canvas: #060a14;
  --surface: rgba(15, 23, 42, 0.72);
  --surface-2: rgba(30, 41, 59, 0.55);
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f8fafc;
  --text-secondary: #94a3b8;
  --text-tertiary: #64748b;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.25);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 32px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.55);
  --glass-bg: rgba(15, 23, 42, 0.55);
  --glass-bg-strong: rgba(15, 23, 42, 0.78);
  --glass-border: rgba(255, 255, 255, 0.1);
  --glass-shine: rgba(255, 255, 255, 0.12);
  --glass-inner: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

body {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
}

.app-body, .admin-body {
  background: var(--canvas);
  min-height: 100vh;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

a { color: var(--primary); text-decoration: none; transition: color 0.2s var(--ease); }
a:hover { color: var(--primary-light); }

/* ── Animated mesh background ── */
.mesh-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.mesh-bg::before,
.mesh-bg::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  animation: meshFloat 20s ease-in-out infinite;
}

.mesh-bg::before {
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.15) 0%, transparent 70%);
  top: -200px;
  right: -100px;
}

.mesh-bg::after {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, transparent 70%);
  bottom: -150px;
  left: 20%;
  animation-delay: -10s;
}

[data-theme="admin"] .mesh-bg::before {
  background: radial-gradient(circle, rgba(251, 191, 36, 0.12) 0%, transparent 70%);
}

[data-theme="admin"] .mesh-bg::after {
  background: radial-gradient(circle, rgba(249, 115, 22, 0.08) 0%, transparent 70%);
}

.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(15, 23, 42, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 23, 42, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 60% at 50% 30%, black 20%, transparent 100%);
}

html[data-color-mode="dark"][data-theme="admin"] .grid-overlay {
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px);
}

@keyframes meshFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -30px) scale(1.05); }
  66% { transform: translate(-20px, 20px) scale(0.95); }
}

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

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

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 20px var(--primary-glow); }
  50% { box-shadow: 0 0 40px var(--primary-glow), 0 0 60px rgba(124, 58, 237, 0.15); }
}

@keyframes spinSlow {
  to { transform: rotate(360deg); }
}

.animate-in {
  animation: fadeUp 0.6s var(--ease) both;
}

.animate-in-delay-1 { animation-delay: 0.08s; }
.animate-in-delay-2 { animation-delay: 0.16s; }
.animate-in-delay-3 { animation-delay: 0.24s; }
.animate-in-delay-4 { animation-delay: 0.32s; }

/* ── App shell ── */
.app-shell {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

/* RTL: flex row flows inline-start → inline-end (right → left), so first child (sidebar) sits on the right naturally — do NOT use row-reverse */

/* ── Premium dark sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  align-self: flex-start;
  height: 100vh;
  z-index: 50;
  overflow: hidden;
}

.sidebar-brand {
  padding: 1.35rem 1.25rem 1.15rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.sidebar-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #7c3aed 0%, #06b6d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.5);
  position: relative;
}

[data-theme="admin"] .sidebar-logo {
  background: linear-gradient(135deg, #fbbf24 0%, #f97316 100%);
  box-shadow: 0 4px 20px rgba(251, 191, 36, 0.4);
  color: #0f0f14;
}

.sidebar-logo::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(124,58,237,0.6), rgba(6,182,212,0.6));
  z-index: -1;
  opacity: 0;
  transition: opacity 0.3s;
}

.sidebar-brand:hover .sidebar-logo::after { opacity: 1; }

.sidebar-brand-text {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  letter-spacing: -0.03em;
}

.sidebar-brand-sub {
  font-size: 10px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.35);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav { flex: 1; padding: 0.5rem 0.75rem; overflow-y: auto; }

.sidebar-section {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.25);
  padding: 1rem 0.75rem 0.4rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.65rem 0.85rem;
  border-radius: 11px;
  color: var(--sidebar-text);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.2s var(--ease);
  margin-bottom: 2px;
  position: relative;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: rgba(255, 255, 255, 0.85);
  transform: translateX(2px);
}

[dir="rtl"] .nav-item:hover { transform: translateX(-2px); }

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

.nav-item.active::before {
  content: '';
  position: absolute;
  inset-inline-start: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 18px;
  background: linear-gradient(180deg, var(--primary-light), var(--primary));
  border-start-end-radius: 3px;
  border-end-end-radius: 3px;
}

.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.65; }
.nav-item.active .nav-icon { opacity: 1; color: var(--primary-light); }

.sidebar-cta {
  margin: 0.5rem 0.75rem 0.75rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(6, 182, 212, 0.15));
  border: 1px solid rgba(124, 58, 237, 0.3);
}

[data-theme="admin"] .sidebar-cta {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(249, 115, 22, 0.1));
  border-color: rgba(251, 191, 36, 0.25);
}

.sidebar-cta-title { font-size: 12px; font-weight: 600; color: #fff; margin-bottom: 0.25rem; }
.sidebar-cta-sub { font-size: 11px; color: rgba(255, 255, 255, 0.45); margin-bottom: 0.65rem; }

.sidebar-footer {
  padding: 0.85rem;
  border-top: 1px solid var(--sidebar-border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.65rem;
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
}

[data-theme="admin"] .user-avatar {
  background: linear-gradient(135deg, #fbbf24, #f97316);
}

.user-email {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.85);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-role { font-size: 10px; color: rgba(255, 255, 255, 0.35); font-weight: 500; }

/* ── Main area ── */
.main-wrap {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--canvas);
  position: relative;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
  border-bottom: 1px solid var(--glass-border);
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  box-shadow: var(--glass-inner);
  position: sticky;
  top: 0;
  z-index: 40;
}

html[data-color-mode="dark"][data-theme="admin"] .topbar {
  background: rgba(6, 10, 20, 0.72);
  backdrop-filter: blur(24px) saturate(180%);
}

.topbar-breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 13px;
  color: var(--text-tertiary);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.topbar-breadcrumb strong {
  color: var(--text);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-shrink: 0;
}

.main-content {
  flex: 1;
  padding: 1.75rem 2rem 3rem;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

/* Full-width page content */
.page-full {
  width: 100%;
}

.page-form-panel {
  width: 100%;
  padding: 1.75rem;
}

/* ── Hero header ── */
.hero-header {
  margin-bottom: 2rem;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1.25rem;
}

.hero-title {
  font-size: clamp(1.75rem, 3vw, 2.25rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.1;
  background: linear-gradient(135deg, var(--text) 30%, var(--text-secondary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

html[data-color-mode="dark"][data-theme="admin"] .hero-title {
  background: linear-gradient(135deg, #fff 30%, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
}

.hero-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 0.4rem;
  max-width: 480px;
}

/* ── Bento KPI grid ── */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.kpi-card {
  padding: 1.35rem 1.5rem;
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
}

.kpi-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md), var(--glass-inner);
}

.kpi-card::after {
  content: '';
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(124, 58, 237, 0.45), transparent);
  z-index: 2;
  pointer-events: none;
}

[data-theme="admin"] .kpi-card::after {
  background: linear-gradient(90deg, transparent, rgba(251, 191, 36, 0.45), transparent);
}

.kpi-card.span-3 { grid-column: span 3; }
.kpi-card.span-4 { grid-column: span 4; }
.kpi-card.span-6 { grid-column: span 6; }
.kpi-card.span-8 { grid-column: span 8; }
.kpi-card.span-12 { grid-column: span 12; }

@media (max-width: 1100px) {
  .kpi-card.span-3, .kpi-card.span-4, .kpi-card.span-6, .kpi-card.span-8 { grid-column: span 6; }
}

@media (max-width: 640px) {
  .kpi-card.span-3, .kpi-card.span-4, .kpi-card.span-6, .kpi-card.span-8, .kpi-card.span-12 { grid-column: span 12; }
}

.kpi-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.12), rgba(6, 182, 212, 0.08));
  color: var(--primary);
}

[data-theme="admin"] .kpi-icon {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(249, 115, 22, 0.1));
  color: var(--primary);
}

.kpi-value {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.kpi-value-sm { font-size: 1.35rem; }

.kpi-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.85rem;
}

.kpi-progress-wrap { flex: 1; }

.kpi-progress-track {
  height: 6px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.kpi-progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 1s var(--ease);
}

.kpi-pct { font-size: 12px; font-weight: 700; color: var(--primary); min-width: 36px; text-align: end; }

.sparkline { width: 100%; height: 48px; margin-top: 0.5rem; }

.ring-chart {
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.ring-chart circle { transition: stroke-dashoffset 1.2s var(--ease); }

/* ── Glass panel ── */
.glass-panel,
.kpi-card,
.campaign-card,
.plan-card.glass-panel {
  position: relative;
  width: 100%;
  box-sizing: border-box;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(var(--glass-saturate));
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm), var(--glass-inner);
  overflow: hidden;
}

.glass-panel::before,
.kpi-card::before,
.glass-strong::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    145deg,
    var(--glass-shine) 0%,
    transparent 42%,
    transparent 58%,
    rgba(124, 58, 237, 0.04) 100%
  );
  pointer-events: none;
  z-index: 0;
}

[data-theme="admin"] .glass-panel::before,
[data-theme="admin"] .kpi-card::before,
[data-theme="admin"] .glass-strong::before {
  background: linear-gradient(
    145deg,
    rgba(251, 191, 36, 0.12) 0%,
    transparent 45%,
    transparent 100%
  );
}

.glass-strong {
  background: var(--glass-bg-strong);
  box-shadow: var(--shadow-md), var(--glass-inner), 0 0 0 1px rgba(124, 58, 237, 0.06);
}

[data-theme="admin"] .glass-strong {
  box-shadow: var(--shadow-md), var(--glass-inner), 0 0 0 1px rgba(251, 191, 36, 0.08);
}

.glass-panel > *,
.kpi-card > *,
.campaign-card > * {
  position: relative;
  z-index: 1;
}

.glass-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.15rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  backdrop-filter: blur(12px);
}

html[data-color-mode="dark"] .glass-panel-header {
  background: rgba(255, 255, 255, 0.03);
}

.glass-panel-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.glass-panel-body { padding: 0; }
.profile-form { padding: 1.5rem; }

/* ── Campaign cards ── */
.campaign-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.campaign-card {
  padding: 1.25rem 1.35rem;
  transition: all 0.25s var(--ease);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: block;
}

.campaign-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: rgba(124, 58, 237, 0.25);
  color: inherit;
}

.campaign-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.04), transparent);
  opacity: 0;
  transition: opacity 0.25s;
}

.campaign-card:hover::after { opacity: 1; }

.campaign-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.campaign-keyword {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.campaign-region { font-size: 12px; color: var(--text-tertiary); margin-top: 0.2rem; }

.campaign-stats {
  display: flex;
  gap: 1.25rem;
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.campaign-stat-val { font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.campaign-stat-lbl { font-size: 10px; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  padding: 0.6rem 1.2rem;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  border-radius: 11px;
  border: none;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 50%, #0891b2 100%);
  background-size: 200% auto;
  color: #fff;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.4);
}

.btn-primary:hover {
  background-position: right center;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.5);
}

[data-theme="admin"] .btn-primary {
  background: linear-gradient(135deg, #d97706, #ea580c);
  color: #fff;
  box-shadow: 0 4px 16px rgba(217, 119, 6, 0.32);
}

[data-theme="admin"] .btn-primary:hover { color: #fff; }

html[data-color-mode="dark"][data-theme="admin"] .btn-primary {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: #0f0f14;
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.35);
}

html[data-color-mode="dark"][data-theme="admin"] .btn-primary:hover { color: #0f0f14; }

.btn-glow { animation: pulseGlow 3s ease-in-out infinite; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover { background: var(--surface-2); color: var(--text); transform: translateY(-1px); }

.btn-ghost { background: transparent; color: var(--text-secondary); padding: 0.45rem 0.75rem; }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); }
.btn-danger:hover { background: var(--danger); color: #fff; }

.btn-sm { padding: 0.4rem 0.85rem; font-size: 12px; border-radius: 9px; }
.btn-lg { padding: 0.8rem 1.5rem; font-size: 14px; border-radius: 12px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }

/* ── Forms ── */
.form-group { margin-bottom: 1.15rem; }
.form-label { display: block; font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.45rem; letter-spacing: 0.01em; }
.form-hint { font-size: 11px; color: var(--text-tertiary); margin-top: 0.35rem; }

.campaign-create-form { display: flex; flex-direction: column; gap: 1.35rem; }
.campaign-create-step {
  padding: 1.15rem 1.2rem 1.25rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}
.campaign-create-step-head {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  margin-bottom: 0.95rem;
}
.campaign-create-step-num {
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  box-shadow: 0 6px 16px var(--primary-glow);
}
.campaign-create-step-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.campaign-create-step-sub {
  margin: 0.28rem 0 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}

.input, .select, .textarea {
  width: 100%;
  max-width: 100%;
  padding: 0.7rem 1rem;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-shadow: var(--shadow-xs);
  box-sizing: border-box;
}

.select {
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  padding-inline-end: 2.75rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23a1a1aa' stroke-width='2' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  background-size: 16px;
}

[dir="rtl"] .select {
  background-position: right 1rem center;
}

html[data-color-mode="dark"] .select option {
  background: #14141f;
  color: #f4f4f5;
}

.select-wrap {
  position: relative;
  width: 100%;
  max-width: 100%;
}

/* Region / option chips (replaces broken native select in RTL) */
.chip-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.chip-option {
  position: relative;
  cursor: pointer;
  user-select: none;
}

.chip-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.chip-option span {
  display: inline-flex;
  align-items: center;
  padding: 0.55rem 1rem;
  border-radius: 99px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.2s var(--ease);
  white-space: nowrap;
}

.chip-option:hover span {
  border-color: rgba(124, 58, 237, 0.35);
  color: var(--text);
}

.chip-option input:checked + span {
  background: rgba(124, 58, 237, 0.16);
  border-color: rgba(124, 58, 237, 0.45);
  color: var(--primary);
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.15);
}

.chip-option input:focus-visible + span {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

[data-theme="admin"] .chip-option input:checked + span {
  background: rgba(251, 191, 36, 0.14);
  border-color: rgba(251, 191, 36, 0.4);
  color: var(--primary);
  box-shadow: 0 0 20px rgba(251, 191, 36, 0.12);
}

/* Campaign tag fields + inventory tag cloud */
.tag-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.tag-field.is-invalid .tag-input-bar {
  border-color: rgba(220, 38, 38, 0.55);
  box-shadow: 0 0 0 4px rgba(220, 38, 38, 0.12);
}

.tag-input-bar.input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.85rem;
  height: auto;
  padding: 0.45rem 0.65rem;
  cursor: text;
}

.tag-input-bar.input:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.32rem 0.65rem;
  border-radius: 999px;
  border: 1px solid rgba(124, 58, 237, 0.28);
  background: rgba(124, 58, 237, 0.12);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  line-height: 1.25;
}

.tag-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-chip i {
  flex: 0 0 auto;
  font-style: normal;
  opacity: 0.65;
  font-size: 14px;
  line-height: 1;
}

.tag-chip:hover {
  background: rgba(124, 58, 237, 0.2);
}

.tag-typeahead {
  flex: 1 1 7rem;
  min-width: 5.5rem;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 0.35rem 0.25rem;
  margin: 0;
  width: auto;
}

.tag-typeahead::placeholder {
  color: var(--text-tertiary);
}

.tag-field .form-hint {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
  line-height: 1.45;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 0.45rem;
  max-height: 8.75rem;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0.65rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  scrollbar-width: thin;
  scrollbar-color: rgba(15, 23, 42, 0.25) transparent;
}

.tag-cloud::-webkit-scrollbar {
  width: 8px;
}

.tag-cloud::-webkit-scrollbar-thumb {
  background: rgba(15, 23, 42, 0.22);
  border-radius: 999px;
}

.tag-suggest {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: var(--shadow-xs);
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease), color 0.15s var(--ease), transform 0.15s var(--ease);
}

.tag-suggest:hover {
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
  color: var(--text);
  background: var(--surface);
  transform: translateY(-1px);
}

.tag-suggest.is-selected {
  background: rgba(124, 58, 237, 0.14);
  border-color: rgba(124, 58, 237, 0.42);
  color: var(--primary);
  font-weight: 600;
}

.tag-suggest-region {
  border-style: dashed;
  border-color: rgba(6, 182, 212, 0.45);
  color: var(--accent);
  background: rgba(6, 182, 212, 0.08);
}

.tag-suggest-region.is-selected {
  background: rgba(6, 182, 212, 0.18);
  border-color: rgba(6, 182, 212, 0.55);
  border-style: solid;
  color: var(--accent);
}

html[data-color-mode="dark"] .tag-suggest-region,
html[data-color-mode="dark"] .tag-suggest-region.is-selected {
  color: #67e8f9;
}

.tag-cloud-empty {
  font-size: 12.5px;
  color: var(--text-tertiary);
  padding: 0.25rem 0;
}

.input:focus, .select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.12);
}

[data-theme="admin"] .input:focus,
[data-theme="admin"] .select:focus {
  box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.14);
}

html[data-color-mode="dark"][data-theme="admin"] .input,
html[data-color-mode="dark"][data-theme="admin"] .select {
  background: rgba(15, 23, 42, 0.8);
  border-color: var(--border-strong);
}

html[data-color-mode="dark"][data-theme="admin"] .input:focus,
html[data-color-mode="dark"][data-theme="admin"] .select:focus {
  box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.12);
}

.form-card { max-width: 560px; }
.form-card-wide { max-width: 680px; }

/* ── Tables ── */
.table-wrap {
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  width: 100%;
  max-width: 100%;
}

.table { width: 100%; border-collapse: collapse; min-width: 600px; }

.table th {
  text-align: start;
  padding: 0.85rem 1.25rem;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  transition: background 0.15s;
}

.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover td { background: rgba(124, 58, 237, 0.03); }

[data-theme="admin"] .table tbody tr:hover td { background: rgba(251, 191, 36, 0.04); }

.table-link { font-weight: 700; color: var(--primary); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  font-size: 11px;
  font-weight: 700;
  border-radius: 99px;
  letter-spacing: 0.02em;
}

.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.badge-primary { background: rgba(124, 58, 237, 0.12); color: #7c3aed; }
.badge-success { background: rgba(16, 185, 129, 0.12); color: #059669; }
.badge-warning { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.badge-danger { background: rgba(239, 68, 68, 0.12); color: #dc2626; }
.badge-neutral { background: var(--surface-2); color: var(--text-secondary); }

[data-theme="admin"] .badge-primary { background: rgba(217, 119, 6, 0.14); color: #b45309; }
[data-theme="admin"] .badge-success { background: rgba(16, 185, 129, 0.12); color: #047857; }
html[data-color-mode="dark"][data-theme="admin"] .badge-primary { background: rgba(251, 191, 36, 0.15); color: #fbbf24; }
html[data-color-mode="dark"][data-theme="admin"] .badge-success { background: rgba(16, 185, 129, 0.15); color: #34d399; }

/* ── Progress ── */
.progress-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; }
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  box-shadow: 0 0 12px var(--primary-glow);
  transition: width 0.8s var(--ease);
}

/* ── Alerts ── */
.alert { padding: 0.9rem 1.15rem; border-radius: 12px; font-size: 13px; margin-bottom: 1rem; font-weight: 500; }
.alert-error { background: rgba(239, 68, 68, 0.08); color: #b91c1c; border: 1px solid rgba(239, 68, 68, 0.2); }
.alert-success { background: rgba(16, 185, 129, 0.08); color: #047857; border: 1px solid rgba(16, 185, 129, 0.2); }

/* ── Auth — cinematic ── */
.auth-page {
  min-height: 100vh;
  display: flex;
  position: relative;
  overflow: hidden;
}

.auth-canvas {
  flex: 1.2;
  position: relative;
  background: #050508;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.auth-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  animation: meshFloat 15s ease-in-out infinite;
}

.auth-orb-1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.6), transparent 70%);
  top: -10%; left: -10%;
}

.auth-orb-2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.5), transparent 70%);
  bottom: -5%; right: -5%;
  animation-delay: -7s;
}

.auth-orb-3 {
  width: 250px; height: 250px;
  background: radial-gradient(circle, rgba(167, 139, 250, 0.4), transparent 70%);
  top: 40%; left: 40%;
  animation-delay: -3s;
}

.auth-grid-lines {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 60px 60px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

.auth-showcase {
  position: relative;
  z-index: 2;
  max-width: 440px;
  padding: 3rem;
}

.auth-showcase-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 11px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.7);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 1.5rem;
}

.auth-showcase-badge span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: pulseGlow 2s infinite;
}

.auth-showcase h1 {
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  color: #fff;
  line-height: 1.1;
  margin-bottom: 1rem;
}

.auth-showcase h1 em {
  font-style: normal;
  background: linear-gradient(135deg, #a78bfa, #06b6d4);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.auth-showcase p {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.5);
  line-height: 1.65;
  margin-bottom: 2rem;
}

.auth-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.auth-stat {
  padding: 1rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
}

.auth-stat-val { font-size: 1.5rem; font-weight: 800; color: #fff; letter-spacing: -0.03em; }
.auth-stat-lbl { font-size: 10px; color: rgba(255,255,255,0.4); text-transform: uppercase; letter-spacing: 0.06em; margin-top: 0.2rem; }

.auth-form-side {
  flex: 0 0 480px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2.5rem;
  background: var(--surface);
  position: relative;
}

.auth-glass-card {
  width: 100%;
  max-width: 380px;
  padding: 0.25rem;
  border-radius: var(--radius-xl);
  background: var(--glass-bg-strong);
  backdrop-filter: blur(28px) saturate(200%);
  -webkit-backdrop-filter: blur(28px) saturate(200%);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-lg), var(--glass-inner);
}

.auth-glass-card h2 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin-bottom: 0.35rem;
}

.auth-glass-card .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.lang-pill {
  font-size: 11px;
  font-weight: 700;
  padding: 0.35rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  background: var(--surface);
  letter-spacing: 0.03em;
}

.lang-pill:hover { border-color: var(--primary); color: var(--primary); }
.lang-pill.is-active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(124, 58, 237, 0.12);
}

/* ── Misc ── */
.page-header { margin-bottom: 1.75rem; }
.page-header-row { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.page-title { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.03em; }
.page-subtitle { color: var(--text-secondary); font-size: 14px; margin-top: 0.35rem; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); box-shadow: var(--shadow-sm); }
.card-padded { padding: 1.5rem; }

.stat-grid,
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 1.35rem; box-shadow: var(--shadow-sm); }
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); }
.stat-value { font-size: 1.85rem; font-weight: 800; letter-spacing: -0.04em; margin-top: 0.35rem; word-break: break-word; }
.stat-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 0.35rem; }

.section-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 0.75rem;
  color: var(--text);
}

.glass-panel > .section-title:has(+ .table-wrap) {
  margin: 0;
  padding: 1.25rem 1.25rem 0.75rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.data-table th {
  text-align: start;
  padding: 0.85rem 1rem;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: top;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: rgba(124, 58, 237, 0.04); }
[data-theme="admin"] .data-table tbody tr:hover td { background: rgba(251, 191, 36, 0.06); }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; }

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-tertiary);
}

.empty-state-visual {
  width: 80px;
  height: 80px;
  margin: 0 auto 1.25rem;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.1), rgba(6, 182, 212, 0.08));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.empty-state-title { font-size: 15px; font-weight: 700; color: var(--text-secondary); margin-bottom: 0.35rem; }
.empty-state-sub { font-size: 13px; color: var(--text-tertiary); margin: 0; max-width: 36rem; line-height: 1.5; }

.plan-price { font-size: 2.25rem; font-weight: 800; letter-spacing: -0.04em; margin: 0.75rem 0; }
.plan-price span { font-size: 13px; font-weight: 500; color: var(--text-tertiary); }

.source-card-header { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.75rem; margin-bottom: 1rem; }

.pipeline-steps {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
}

.pipeline-step {
  flex: 1;
  min-width: 80px;
  padding: 0.65rem 0.5rem;
  border-radius: 10px;
  background: var(--surface-2);
  text-align: center;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  transition: all 0.2s;
}

.pipeline-step.done {
  background: rgba(124, 58, 237, 0.08);
  color: var(--primary);
  border-color: rgba(124, 58, 237, 0.2);
}

.pipeline-step.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.15), rgba(6, 182, 212, 0.1));
  color: var(--primary);
  border-color: rgba(124, 58, 237, 0.3);
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.15);
}

.pipeline-step-live {
  animation: pipelinePulse 2.4s ease-in-out infinite;
}

@keyframes pipelinePulse {
  0%, 100% { box-shadow: 0 0 16px rgba(124, 58, 237, 0.15); transform: scale(1); }
  50% { box-shadow: 0 0 28px rgba(124, 58, 237, 0.35), 0 0 40px rgba(6, 182, 212, 0.15); transform: scale(1.02); }
}

.progress-track-lg { height: 10px; }

.progress-fill-mining {
  background: linear-gradient(90deg, #7c3aed, #06b6d4, #a78bfa, #7c3aed);
  background-size: 300% 100%;
  animation: progressFlow 2.5s linear infinite;
  box-shadow: 0 0 20px rgba(124, 58, 237, 0.5);
}

@keyframes progressFlow {
  0% { background-position: 0% center; }
  100% { background-position: 300% center; }
}

.badge-live .badge-dot {
  animation: livePulse 1.4s ease-in-out infinite;
}

@keyframes livePulse {
  0%, 100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.6); }
  50% { opacity: 0.7; transform: scale(1.15); box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

.mining-active-panel {
  box-shadow: var(--shadow-md), 0 0 60px rgba(124, 58, 237, 0.08);
}

.mining-log-panel {
  border: 1px solid var(--border);
}

.mining-log-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.mining-log-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.activity-log-stream {
  max-height: 420px;
  overflow-y: auto;
  padding: 0.85rem 1rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  line-height: 1.55;
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.activity-log-line {
  display: flex;
  gap: 0.65rem;
  padding: 0.2rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.activity-log-line:last-child {
  border-bottom: none;
}

.activity-log-time {
  flex-shrink: 0;
  color: var(--text-tertiary);
  min-width: 4.5rem;
}

.activity-log-msg {
  color: var(--text-secondary);
  word-break: break-word;
}

.activity-log-line.activity-success .activity-log-msg { color: #6ee7b7; }
.activity-log-line.activity-warning .activity-log-msg { color: #fcd34d; }
.activity-log-line.activity-error .activity-log-msg { color: #fca5a5; }
.activity-log-line.activity-info .activity-log-msg { color: var(--text-secondary); }

.activity-log-empty {
  color: var(--text-tertiary);
  font-style: italic;
  padding: 1rem 0;
  text-align: center;
}

.campaign-control-bar {
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* ── Mining canvas — premium in-progress visualization ── */
.mining-canvas {
  position: relative;
  padding: 2.5rem 2rem 2rem;
  overflow: hidden;
  min-height: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.mining-canvas-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(124, 58, 237, 0.14) 0%, transparent 70%),
    radial-gradient(ellipse 50% 40% at 80% 70%, rgba(6, 182, 212, 0.1) 0%, transparent 60%);
  pointer-events: none;
}

.mining-canvas-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(124, 58, 237, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(124, 58, 237, 0.04) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: radial-gradient(ellipse 70% 60% at 50% 45%, black 20%, transparent 100%);
  pointer-events: none;
}

.mining-scene {
  position: relative;
  width: 320px;
  height: 320px;
  margin: 0 auto 1.5rem;
  flex-shrink: 0;
}

.mining-core {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 72px;
  height: 72px;
  z-index: 5;
}

.mining-core-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124, 58, 237, 0.45) 0%, transparent 70%);
  animation: coreGlow 3s ease-in-out infinite;
}

@keyframes coreGlow {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.15); opacity: 1; }
}

.mining-core-inner {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: 22px;
  background: linear-gradient(135deg, #7c3aed 0%, #0891b2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 40px rgba(124, 58, 237, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  animation: coreRotate 8s linear infinite;
}

@keyframes coreRotate {
  0%, 100% { box-shadow: 0 8px 40px rgba(124, 58, 237, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.25); }
  50% { box-shadow: 0 8px 50px rgba(6, 182, 212, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
}

.mining-core-icon {
  width: 32px;
  height: 32px;
  color: #fff;
}

.mining-pulse-ring {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 1px solid rgba(124, 58, 237, 0.25);
  pointer-events: none;
}

.mining-pulse-ring.ring-a {
  width: 100px;
  height: 100px;
  animation: ringExpand 3s ease-out infinite;
}

.mining-pulse-ring.ring-b {
  width: 100px;
  height: 100px;
  animation: ringExpand 3s ease-out infinite 1s;
}

.mining-pulse-ring.ring-c {
  width: 100px;
  height: 100px;
  animation: ringExpand 3s ease-out infinite 2s;
}

@keyframes ringExpand {
  0% { width: 90px; height: 90px; opacity: 0.7; border-color: rgba(124, 58, 237, 0.4); }
  100% { width: 280px; height: 280px; opacity: 0; border-color: rgba(6, 182, 212, 0); }
}

.mining-orbit {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  animation: orbitSpin linear infinite;
}

.mining-node-arm {
  transform: translate(0, 0);
}

.mining-orbit-1 { animation-duration: 18s; }
.mining-orbit-1 .mining-node-arm { transform: translate(130px, 0); }

.mining-orbit-2 { animation-duration: 22s; animation-direction: reverse; }
.mining-orbit-2 .mining-node-arm { transform: translate(0, -115px); }

.mining-orbit-3 { animation-duration: 26s; }
.mining-orbit-3 .mining-node-arm { transform: translate(-120px, 40px); }

.mining-orbit-4 { animation-duration: 20s; animation-direction: reverse; }
.mining-orbit-4 .mining-node-arm { transform: translate(90px, 90px); }

.mining-orbit-5 { animation-duration: 24s; }
.mining-orbit-5 .mining-node-arm { transform: translate(-90px, -80px); }

.mining-orbit-6 { animation-duration: 28s; animation-direction: reverse; }
.mining-orbit-6 .mining-node-arm { transform: translate(40px, -130px); }

@keyframes orbitSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.mining-node {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border-radius: 12px;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(124, 58, 237, 0.35);
  font-size: 11px;
  font-weight: 800;
  color: var(--primary-light);
  box-shadow: 0 4px 20px rgba(124, 58, 237, 0.25);
}

.mining-orbit-1 .mining-node { animation: nodeUpright 18s linear infinite; }
.mining-orbit-2 .mining-node { animation: nodeUpright 22s linear infinite reverse; }
.mining-orbit-3 .mining-node { animation: nodeUpright 26s linear infinite; }
.mining-orbit-4 .mining-node { animation: nodeUpright 20s linear infinite reverse; }
.mining-orbit-5 .mining-node { animation: nodeUpright 24s linear infinite; }
.mining-orbit-6 .mining-node { animation: nodeUpright 28s linear infinite reverse; }

@keyframes nodeUpright {
  from { transform: rotate(0deg); }
  to { transform: rotate(-360deg); }
}

.mining-streams {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
}

.mining-stream {
  fill: none;
  stroke: url(#streamGrad);
  stroke-width: 1.5;
  stroke-dasharray: 8 12;
  animation: streamFlow 2s linear infinite;
  opacity: 0.6;
}

.mining-stream:nth-child(2) { animation-delay: 0.5s; }
.mining-stream:nth-child(3) { animation-delay: 1s; }
.mining-stream:nth-child(4) { animation-delay: 1.5s; }

@keyframes streamFlow {
  to { stroke-dashoffset: -40; }
}

.mining-lead-card {
  position: absolute;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  z-index: 3;
  animation: leadConverge 4s ease-in-out infinite;
}

.mining-lead-line {
  display: block;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(90deg, rgba(124, 58, 237, 0.5), rgba(6, 182, 212, 0.3));
  width: 48px;
}

.mining-lead-line.short { width: 28px; opacity: 0.6; }

.mining-lead-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.mining-lead-card.lead-1 { top: 12%; left: 8%; animation-delay: 0s; }
.mining-lead-card.lead-2 { top: 18%; right: 6%; left: auto; animation-delay: 1.3s; }
.mining-lead-card.lead-3 { bottom: 14%; left: 12%; animation-delay: 2.6s; }

@keyframes leadConverge {
  0%, 100% { opacity: 0; transform: translate(0, 0) scale(0.85); }
  15% { opacity: 1; transform: translate(0, 0) scale(1); }
  70% { opacity: 0.8; transform: translate(calc(160px - 50%), calc(160px - 50%)) scale(0.6); }
  85% { opacity: 0; transform: translate(calc(160px - 50%), calc(160px - 50%)) scale(0.3); }
}

.mining-caption {
  position: relative;
  z-index: 2;
  text-align: center;
  max-width: 420px;
}

.mining-caption-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.85rem;
  border-radius: 99px;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #34d399;
  margin-bottom: 0.85rem;
}

.mining-live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
  animation: livePulse 1.4s ease-in-out infinite;
}

.mining-caption-title {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
  margin: 0 0 0.4rem;
}

.mining-caption-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 1.25rem;
  line-height: 1.55;
}

.mining-progress-mini {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: center;
}

.mining-progress-mini-track {
  width: 220px;
  height: 5px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}

.mining-progress-mini-fill {
  height: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.8s var(--ease);
  box-shadow: 0 0 12px var(--primary-glow);
}

.mining-progress-mini-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
}

.lead-row-in {
  animation: leadRowIn 0.45s var(--ease) both;
}

.poll-stable {
  animation: none !important;
}

.htmx-poll-region {
  position: relative;
}

.htmx-poll-region.htmx-swapping {
  opacity: 0.88;
  transition: opacity 0.12s var(--ease);
}

.htmx-poll-region.htmx-settling {
  opacity: 1;
  transition: opacity 0.2s var(--ease);
}

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

/* ── Campaign companies table + filters ── */
.campaign-companies-panel .glass-panel-header {
  flex-wrap: wrap;
  gap: 0.5rem;
}

.companies-panel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
  padding: 0.85rem 1.15rem;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  position: relative;
  z-index: 30;
}

.companies-panel-toolbar .companies-search {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 220px;
  min-width: 200px;
  padding: 0 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
}

.companies-panel-toolbar .companies-search svg {
  color: var(--text-tertiary);
  flex-shrink: 0;
}

.companies-panel-toolbar .companies-search-input {
  border: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding-inline: 0 !important;
  flex: 1;
  width: auto !important;
  max-width: none !important;
}

.companies-panel-toolbar .filter-dropdown {
  flex: 0 1 200px;
  min-width: 170px;
}

.companies-filter-meta {
  flex: 0 0 auto;
  margin-inline-start: auto;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.companies-table-scroll {
  max-height: min(420px, 52vh);
  overflow: auto;
  overscroll-behavior: contain;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}

.companies-table-scroll .companies-table {
  margin: 0;
}

.companies-table-scroll .companies-table-head th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--surface-2);
  box-shadow: 0 1px 0 var(--border);
}

.companies-table-scroll tbody tr[hidden] {
  display: none;
}

.filter-dropdown {
  position: relative;
  z-index: 1;
}

.filter-dropdown.is-open {
  z-index: 200;
}

.filter-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  min-height: 2.65rem;
  padding: 0.55rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
  box-shadow: var(--shadow-xs);
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease), background 0.18s var(--ease);
}

.filter-dropdown-trigger:hover {
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.04);
}

.filter-dropdown.is-open .filter-dropdown-trigger {
  border-color: rgba(124, 58, 237, 0.55);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.14);
}

.filter-dropdown-label {
  flex-shrink: 0;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-tertiary);
}

.filter-dropdown-value {
  flex: 1;
  min-width: 0;
  text-align: start;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-dropdown-chevron {
  flex-shrink: 0;
  color: var(--text-tertiary);
  transition: transform 0.2s var(--ease);
}

.filter-dropdown.is-open .filter-dropdown-chevron {
  transform: rotate(180deg);
  color: var(--primary);
}

.filter-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  inset-inline: 0;
  z-index: 210;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  box-shadow: var(--shadow-lg), 0 12px 40px rgba(0, 0, 0, 0.28);
  max-height: 280px;
  overflow-y: auto;
}

.filter-dropdown-menu[hidden] {
  display: none !important;
}

.filter-dropdown-menu--scroll {
  max-height: 240px;
}

.filter-dropdown-option {
  display: block;
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  text-align: start;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.filter-dropdown-option:hover {
  background: rgba(124, 58, 237, 0.1);
  color: var(--primary);
}

.filter-dropdown-option.is-selected {
  background: rgba(124, 58, 237, 0.16);
  color: var(--primary);
  font-weight: 800;
}

html[data-color-mode="dark"] .filter-dropdown-menu {
  background: rgba(18, 18, 30, 0.98);
  border-color: rgba(255, 255, 255, 0.12);
}

html[data-color-mode="dark"] .filter-dropdown-trigger,
html[data-color-mode="dark"] .companies-panel-toolbar .companies-search {
  background: rgba(16, 16, 28, 0.95);
  border-color: rgba(255, 255, 255, 0.12);
}

@media (max-width: 720px) {
  .companies-panel-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .companies-panel-toolbar .filter-dropdown,
  .companies-panel-toolbar .companies-search {
    flex: 1 1 100%;
    min-width: 0;
  }

  .companies-filter-meta {
    margin-inline-start: 0;
    text-align: center;
  }
}

.sidebar-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  flex-shrink: 0;
  position: relative;
  z-index: 5;
}

[data-theme="admin"] .sidebar-toggle {
  background: var(--surface);
  border-color: rgba(217, 119, 6, 0.35);
  color: var(--primary);
}

html[data-color-mode="dark"][data-theme="admin"] .sidebar-toggle {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(251, 191, 36, 0.35);
  color: #fbbf24;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 65;
  background: rgba(2, 6, 16, 0.62);
  /* No backdrop-filter: on iOS/WebKit it can blur the sidebar too when stacking is wrong. */
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.sidebar-backdrop.open { display: block; }

.search-bar { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; }

.plan-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.plan-card {
  padding: 1.75rem;
  position: relative;
  transition: all 0.25s var(--ease);
}

.plan-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.plan-card.featured { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary), var(--shadow-md); }

.plan-badge {
  position: absolute;
  top: 1rem;
  inset-inline-end: 1rem;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.6rem;
  border-radius: 99px;
  background: rgba(124, 58, 237, 0.12);
  color: var(--primary);
}

[data-theme="admin"] .plan-badge {
  background: rgba(251, 191, 36, 0.15);
  color: var(--primary);
}

.plan-name { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: -0.02em; }

.plan-features {
  list-style: none;
  padding: 0;
  margin: 0 0 1.25rem;
  font-size: 13px;
  color: var(--text-secondary);
}

.plan-features li { padding: 0.4rem 0; display: flex; align-items: center; gap: 0.5rem; }
.plan-features li::before { content: '✓'; color: var(--success); font-weight: 700; }

.source-grid { display: flex; flex-direction: column; gap: 1rem; }
.source-card { padding: 1.35rem 1.5rem; }
.source-name { margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -0.02em; }
.source-desc { margin: 0.35rem 0 0; font-size: 13px; color: var(--text-secondary); }
.source-meta { margin: 0.35rem 0 0; font-size: 11px; color: var(--text-tertiary); }
.source-config-form { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.source-config-form .span-2 { grid-column: span 2; }
.source-endpoints { margin: 0.75rem 0; display: flex; flex-direction: column; gap: 0.35rem; }
.source-endpoints-label { margin: 0; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-tertiary); }
.source-endpoint { display: block; font-size: 11px; padding: 0.35rem 0.55rem; border-radius: 8px; background: var(--surface-2); color: var(--text-secondary); word-break: break-all; }
.source-hint { font-size: 12px; color: var(--text-tertiary); line-height: 1.45; }
.source-status-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.source-env-keys { margin: 0.65rem 0; display: flex; flex-direction: column; gap: 0.35rem; }
.source-field { display: flex; flex-direction: column; gap: 0.35rem; }
.source-field-head { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.field-hint { margin: 0; font-size: 11px; color: var(--text-tertiary); line-height: 1.4; }
.field-origin { font-size: 10px; }
.source-form-actions { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; margin-top: 0.25rem; }
.source-csv-info { display: flex; align-items: center; gap: 0.65rem; flex-wrap: wrap; margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }

.input-lg { padding: 0.85rem 1.1rem; font-size: 15px; border-radius: 12px; }

.auth-form-header h2 {
  font-size: 1.65rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  margin-bottom: 0.35rem;
}

.auth-form-header .subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.auth-form { display: flex; flex-direction: column; gap: 0.15rem; }

.auth-switch {
  margin-top: 1.5rem;
  font-size: 13px;
  color: var(--text-tertiary);
  text-align: center;
}

.auth-switch a { font-weight: 700; }

.billing-subnav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 1.35rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
}

.billing-subnav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.95rem;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.billing-subnav-link span.nums {
  font-size: 11px;
  opacity: 0.75;
}

.billing-subnav-link:hover {
  color: var(--text);
  background: var(--surface);
}

.billing-subnav-link.is-active {
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow-xs);
  border: 1px solid var(--border-strong);
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
}

.theme-toggle:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.theme-toggle svg { width: 18px; height: 18px; }

.billing-mode-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 0.45rem 0.85rem;
  border-radius: 99px;
  letter-spacing: 0.02em;
}

.billing-mode-demo {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.25);
}

.billing-mode-stripe {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.25);
}

.billing-result-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 1rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  background: var(--surface-2);
  color: var(--text-tertiary);
}

.billing-result-success {
  background: rgba(16, 185, 129, 0.12);
  color: var(--success);
  box-shadow: 0 0 30px rgba(16, 185, 129, 0.2);
}

/* ── Profile page ── */
.profile-hero { padding: 1.75rem 2rem; margin-bottom: 1.5rem; }
.profile-hero-inner { display: flex; align-items: center; gap: 1.35rem; flex-wrap: wrap; }
.profile-avatar-xl {
  width: 80px;
  height: 80px;
  border-radius: 22px;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  font-weight: 800;
  box-shadow: 0 8px 32px rgba(124, 58, 237, 0.45);
  flex-shrink: 0;
}
[data-theme="admin"] .profile-avatar-xl {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: #0f0f14;
  box-shadow: 0 8px 32px rgba(251, 191, 36, 0.35);
}
.profile-hero-meta { display: flex; flex-direction: column; gap: 0.45rem; }
.profile-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 1.25rem;
  align-items: start;
}
@media (max-width: 960px) {
  .profile-grid { grid-template-columns: 1fr; }
}
.profile-meta-list { padding: 0.5rem 1.5rem 1.25rem; display: flex; flex-direction: column; gap: 1rem; }
.profile-meta-item { display: flex; flex-direction: column; gap: 0.35rem; }
.profile-meta-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-tertiary);
}
.profile-meta-value { font-size: 14px; font-weight: 600; }

.user-chip-link {
  text-decoration: none;
  color: inherit;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}
.user-chip-link:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(124, 58, 237, 0.35);
  color: inherit;
}

@media (max-width: 900px) {
  /* Sidebar must leave the flex flow — otherwise it steals ~272px on phones (esp. RTL). */
  .app-shell {
    display: block;
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  .sidebar-toggle { display: inline-flex; }

  .topbar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.55rem;
    padding: 0 0.85rem;
    height: 56px;
    width: 100%;
    box-sizing: border-box;
  }

  .sidebar {
    position: fixed !important;
    top: 0;
    bottom: 0;
    left: 0;
    right: auto;
    width: min(var(--sidebar-w), 86vw) !important;
    max-width: 320px;
    height: 100dvh;
    margin: 0 !important;
    transform: translate3d(-105%, 0, 0);
    -webkit-transform: translate3d(-105%, 0, 0);
    transition: transform 0.28s var(--ease), visibility 0.28s;
    z-index: 70;
    box-shadow: var(--shadow-lg);
    visibility: hidden;
    pointer-events: none;
    align-self: auto;
    background: var(--sidebar-bg);
    filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  [dir="rtl"] .sidebar {
    left: auto;
    right: 0;
    transform: translate3d(105%, 0, 0);
    -webkit-transform: translate3d(105%, 0, 0);
  }

  .sidebar.open {
    transform: translate3d(0, 0, 0) !important;
    -webkit-transform: translate3d(0, 0, 0) !important;
    visibility: visible;
    pointer-events: auto;
  }

  body.sidebar-open {
    overflow: hidden;
    touch-action: none;
  }

  .main-wrap {
    display: flex;
    flex-direction: column;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    margin: 0;
  }

  .auth-canvas { display: none; }
  .auth-form-side { flex: 1; }

  .main-content {
    padding: 1rem 0.85rem 2rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .page-full,
  .hero-header,
  .bento-grid,
  .glass-panel,
  .kpi-card,
  .stats-grid,
  .stat-grid {
    max-width: 100%;
    box-sizing: border-box;
  }

  .hero-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
  }

  .hero-header > .btn,
  .hero-header > a.btn {
    width: 100%;
    max-width: 100%;
    justify-content: center;
    box-sizing: border-box;
  }

  .hero-title {
    font-size: 1.45rem;
    overflow-wrap: anywhere;
  }

  .hero-subtitle { max-width: none; }

  .glass-panel-header {
    flex-wrap: wrap;
    gap: 0.65rem;
    padding: 0.95rem 1rem;
  }

  .section-title { font-size: 1rem; }
  .glass-panel > .section-title:has(+ .table-wrap) {
    padding: 1rem 1rem 0.65rem;
  }

  .stat-card { padding: 1rem; }
  .stat-value { font-size: 1.45rem; }

  .stats-grid,
  .stat-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.15rem;
  }

  .bento-grid {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .kpi-card.span-3,
  .kpi-card.span-4,
  .kpi-card.span-6,
  .kpi-card.span-8,
  .kpi-card.span-12 {
    grid-column: 1 / -1;
  }

  .table { min-width: 560px; }
  .data-table { min-width: 560px; }

  .table th,
  .table td,
  .data-table th,
  .data-table td {
    padding: 0.7rem 0.75rem;
    font-size: 12px;
  }

  .search-bar .input { max-width: none !important; flex: 1 1 100%; width: 100%; }
  .search-bar .btn { width: 100%; }
  .btn-group { width: 100%; }
  .page-form-panel { padding: 1.15rem; }
  .campaign-create-step { padding: 1rem; }
  .campaign-create-form { gap: 1rem; }
  .form-card,
  .form-card-wide { max-width: none; }
  .source-config-form .span-2 { grid-column: span 1; }
}

@media (max-width: 640px) {
  .topbar-breadcrumb span:first-child,
  .topbar-breadcrumb span:nth-child(2) { display: none; }
  .topbar-actions { gap: 0.35rem; }
  .topbar-actions .btn-ghost { padding-inline: 0.5rem; }
  .lang-pill { padding: 0.35rem 0.55rem; font-size: 11px; }
  .stats-grid,
  .stat-grid {
    grid-template-columns: 1fr;
  }
  .kpi-card { padding: 1.1rem 1.15rem; }
  .plan-grid { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
  .empty-state { padding: 2.5rem 1.25rem; }
}

.pagination-bar {
  display: none;
}

/* ── Professional pagination ── */
.pagination-pro {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.15rem 1.35rem 1.25rem;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04) 0%, transparent 100%);
}

.pagination-pro-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem 1.5rem;
}

.pagination-pro-stats {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 2.25rem;
  padding: 0.35rem 0.85rem 0.35rem 0.65rem;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.pagination-pro-stats-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: rgba(124, 58, 237, 0.1);
  color: var(--primary);
}

.pagination-pro-stats-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.pagination-pro-size {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}

.pagination-pro-size-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-tertiary);
}

.pagination-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.pagination-select {
  appearance: none;
  min-width: 4.5rem;
  height: 2.35rem;
  padding: 0 2rem 0 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow-xs), var(--glass-inner);
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.pagination-select:hover,
.pagination-select:focus {
  outline: none;
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}

.pagination-select-chevron {
  position: absolute;
  inset-inline-end: 0.65rem;
  pointer-events: none;
  color: var(--text-tertiary);
}

.pagination-pro-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.pagination-pro-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 2.5rem;
  height: 2.5rem;
  padding: 0 0.75rem;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow: var(--shadow-xs);
  transition: transform 0.18s var(--ease), background 0.2s var(--ease), border-color 0.2s var(--ease), color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.pagination-pro-btn:hover:not(.is-disabled) {
  transform: translateY(-1px);
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.35);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.pagination-pro-btn--edge {
  min-width: 2.5rem;
  padding: 0 0.55rem;
}

.pagination-pro-btn.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  box-shadow: none;
}

.pagination-pro-pages {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.3rem;
  border-radius: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
}

.pagination-pro-page {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.35rem;
  height: 2.35rem;
  padding: 0 0.5rem;
  border-radius: 9px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  transition: background 0.18s var(--ease), color 0.18s var(--ease), border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}

.pagination-pro-page:hover:not(.is-active) {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.pagination-pro-page.is-active {
  background: linear-gradient(135deg, var(--primary) 0%, #6366f1 100%);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 14px rgba(124, 58, 237, 0.35);
}

.pagination-pro-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.75rem;
  height: 2.35rem;
  color: var(--text-tertiary);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  user-select: none;
}

html[data-color-mode="dark"] .pagination-pro {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
}

html[data-color-mode="dark"] .pagination-pro-pages {
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.2);
}

[data-theme="admin"] .pagination-pro-stats-icon {
  background: rgba(217, 119, 6, 0.12);
  color: var(--primary);
}

[data-theme="admin"] .pagination-pro-page.is-active {
  background: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.28);
  color: #fff;
}

html[data-color-mode="dark"][data-theme="admin"] .pagination-pro-page.is-active {
  background: linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%);
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
  color: #0f0f14;
}

[data-theme="admin"] .pagination-pro-btn:hover:not(.is-disabled) {
  background: rgba(217, 119, 6, 0.1);
  border-color: rgba(217, 119, 6, 0.35);
  color: var(--primary);
}

[data-theme="admin"] .pagination-select:hover,
[data-theme="admin"] .pagination-select:focus {
  border-color: rgba(251, 191, 36, 0.45);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.12);
}

@media (max-width: 720px) {
  .pagination-pro-btn-text { display: none; }
  .pagination-pro-nav { gap: 0.3rem; }
  .pagination-pro-top { justify-content: center; }
  .pagination-pro-stats { width: 100%; justify-content: center; }
  .pagination-pro-size { width: 100%; justify-content: center; }
}

/* ── Smart Miner chat UX ── */
.sm-hero-actions {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex-wrap: wrap;
}
.sm-history-toggle {
  display: none;
}
.smart-miner-layout {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
  max-width: min(1280px, 100%);
}
.sm-history {
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 820px);
  max-height: min(78vh, 900px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface);
  overflow: hidden;
}
.sm-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
}
.sm-history-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}
.sm-history-new {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
}
.sm-history-new:hover { text-decoration: underline; }
.sm-history-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.45rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.sm-history-empty {
  padding: 1.25rem 0.85rem;
  font-size: 12.5px;
  color: var(--text-secondary);
  text-align: center;
}
.sm-history-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.45rem;
  padding: 0.65rem 0.7rem;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.sm-history-item:hover {
  background: var(--surface-2);
}
.sm-history-item.is-active {
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.22);
}
.sm-history-item-main {
  min-width: 0;
  flex: 1 1 auto;
}
.sm-history-item-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sm-history-item-preview {
  margin-top: 0.18rem;
  font-size: 11.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sm-history-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.25rem;
  flex: 0 0 auto;
}
.sm-history-item-time {
  font-size: 10.5px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.sm-history-item-delete {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 8px;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.sm-history-item:hover .sm-history-item-delete,
.sm-history-item.is-active .sm-history-item-delete,
.sm-history-item-delete:focus {
  opacity: 1;
}
.sm-history-item-delete:hover {
  background: rgba(239, 68, 68, 0.12);
  color: var(--danger);
}
.sm-history-backdrop {
  display: none;
}
.smart-miner {
  display: flex;
  flex-direction: column;
  min-height: min(72vh, 820px);
  max-height: min(78vh, 900px);
  max-width: none;
  width: 100%;
  padding: 0;
  overflow: hidden;
}
@media (max-width: 900px) {
  .sm-history-toggle { display: inline-flex; }
  .smart-miner-layout {
    grid-template-columns: 1fr;
    position: relative;
  }
  .sm-history {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    width: min(86vw, 320px);
    max-height: none;
    min-height: 100vh;
    z-index: 60;
    border-radius: 0;
    transform: translateX(-105%);
    transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
  }
  :dir(rtl) .sm-history {
    transform: translateX(105%);
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.18);
  }
  .smart-miner-layout.is-history-open .sm-history {
    transform: translateX(0);
  }
  .sm-history-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 55;
    background: rgba(8, 8, 16, 0.45);
  }
  .sm-history-backdrop[hidden] { display: none !important; }
  .sm-history-item-delete { opacity: 0.75; }
}
.smart-miner-feed {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1.25rem 1.35rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.sm-msg {
  max-width: 92%;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.sm-msg-user {
  align-self: flex-end;
  background: rgba(124, 58, 237, 0.1);
  border-color: rgba(124, 58, 237, 0.22);
}
.sm-msg-assistant { align-self: flex-start; }
.sm-msg-enter {
  animation: smMsgEnter 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.sm-msg-user.sm-msg-enter {
  animation-name: smMsgEnterUser;
}
.sm-msg-assistant.sm-msg-enter,
.sm-msg-loading.sm-msg-enter {
  animation-name: smMsgEnterAssistant;
}
@keyframes smMsgEnter {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes smMsgEnterUser {
  from {
    opacity: 0;
    transform: translateY(10px) translateX(8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
  }
}
@keyframes smMsgEnterAssistant {
  from {
    opacity: 0;
    transform: translateY(10px) translateX(-8px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) translateX(0) scale(1);
  }
}
:dir(rtl) .sm-msg-user.sm-msg-enter {
  animation-name: smMsgEnterAssistant;
}
:dir(rtl) .sm-msg-assistant.sm-msg-enter,
:dir(rtl) .sm-msg-loading.sm-msg-enter {
  animation-name: smMsgEnterUser;
}
@media (prefers-reduced-motion: reduce) {
  .sm-msg-enter,
  .sm-msg-user.sm-msg-enter,
  .sm-msg-assistant.sm-msg-enter,
  .sm-msg-loading.sm-msg-enter {
    animation: none !important;
    opacity: 1;
    transform: none;
  }
}
.sm-msg-results-slot,
.sm-msg-status-slot {
  max-width: 100%;
  width: 100%;
  align-self: stretch;
}
.sm-msg-text {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text);
  white-space: pre-wrap;
}
.sm-error { color: var(--danger); }
.sm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.75rem;
}
.sm-chip {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font-size: 12.5px;
  font-family: var(--font);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
}
.sm-chip:hover {
  border-color: rgba(124, 58, 237, 0.4);
  color: var(--text);
  transform: translateY(-1px);
}
.smart-miner.is-busy .sm-chip,
.smart-miner.is-busy .sm-start-btn,
.smart-miner.is-busy .sm-action-btn,
.smart-miner.is-busy .sm-custom-field,
.smart-miner.is-busy .sm-custom-send {
  opacity: 0.55;
  pointer-events: none;
  cursor: wait;
}
.sm-chips-block.is-locked .sm-chip,
.sm-confirm.is-locked .sm-start-btn {
  opacity: 0.45;
  pointer-events: none;
  cursor: default;
  transform: none;
}
.sm-chips-block.is-locked .sm-chip:hover {
  border-color: var(--border-strong);
  color: var(--text-secondary);
  transform: none;
}
.sm-chips-block {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.sm-chips-block .sm-chips {
  margin-top: 0;
}
.sm-custom-input {
  display: flex;
  align-items: stretch;
  gap: 0.45rem;
  width: 100%;
  max-width: 28rem;
}
.sm-custom-field {
  flex: 1 1 auto;
  min-width: 0;
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 0.55rem 0.85rem;
  font-size: 13.5px;
  font-family: var(--font);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.sm-custom-field::placeholder {
  color: var(--text-secondary);
  opacity: 0.85;
}
.sm-custom-field:focus {
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.12);
}
.sm-custom-send {
  appearance: none;
  flex: 0 0 auto;
  border: 1px solid rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.12);
  color: var(--text);
  border-radius: 12px;
  padding: 0.55rem 0.95rem;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}
.sm-custom-send:hover {
  background: rgba(124, 58, 237, 0.18);
  border-color: rgba(124, 58, 237, 0.5);
  transform: translateY(-1px);
}
.sm-msg-loading {
  align-self: flex-start;
  padding: 0.7rem 0.95rem;
}
.sm-loading {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
}
.sm-loading-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
}
.sm-loading-dots i {
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--primary);
  opacity: 0.35;
  animation: smLoadingPulse 1s ease-in-out infinite;
}
.sm-loading-dots i:nth-child(2) { animation-delay: 0.15s; }
.sm-loading-dots i:nth-child(3) { animation-delay: 0.3s; }
.sm-loading-label {
  font-size: 12.5px;
  color: var(--text-secondary);
}
@keyframes smLoadingPulse {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-2px); }
}
.sm-chip-region {
  border-style: dashed;
  border-color: rgba(6, 182, 212, 0.45);
  color: #0e7490;
  background: rgba(6, 182, 212, 0.08);
}
.sm-confirm-text {
  margin: 0 0 0.85rem;
  font-family: var(--font);
  font-size: 13.5px;
  white-space: pre-wrap;
  color: var(--text);
}
.sm-status-list { display: flex; flex-direction: column; gap: 0.45rem; }
.sm-status-card {
  display: flex;
  align-items: flex-start;
  gap: 0.7rem;
  padding: 0.65rem 0.8rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.sm-status-icon {
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  background: var(--surface-2);
  color: var(--text-tertiary);
  flex: 0 0 auto;
}
.sm-status-card.is-done .sm-status-icon {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
}
.sm-status-card.is-active .sm-status-icon {
  background: rgba(124, 58, 237, 0.15);
  color: var(--primary);
}
.sm-status-title { font-size: 13px; font-weight: 600; color: var(--text); }
.sm-status-detail { font-size: 12px; color: var(--text-secondary); margin-top: 0.15rem; }
.sm-progress-line {
  margin-top: 0.35rem;
  font-size: 12px;
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
}
.sm-results-block { margin-top: 0.85rem; }
.sm-table-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-bottom: 0.7rem;
}
.sm-results-overview {
  margin-bottom: 0.7rem;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}
.sm-company-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}
.sm-company-group {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  overflow: hidden;
}
.sm-company-group.is-orphan {
  border-style: dashed;
  background: color-mix(in srgb, var(--surface) 92%, var(--surface-2));
}
.sm-company-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.95rem;
  border: 0;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.06), transparent);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: start;
}
.sm-company-group.is-orphan .sm-company-header {
  background: transparent;
}
.sm-company-header-main {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
.sm-company-mark {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  color: #0f766e;
  background: linear-gradient(135deg, rgba(13, 148, 136, 0.18), rgba(6, 182, 212, 0.1));
}
.sm-company-group.is-orphan .sm-company-mark {
  color: var(--text-tertiary);
  background: var(--surface-2);
}
.sm-company-info { min-width: 0; }
.sm-company-name {
  font-size: 14.5px;
  font-weight: 800;
  color: var(--text);
  overflow-wrap: anywhere;
}
.sm-company-sub {
  margin-top: 0.15rem;
  font-size: 12px;
  color: var(--text-secondary);
}
.sm-company-chevron {
  color: var(--text-tertiary);
  transition: transform 0.18s ease;
  flex: 0 0 auto;
}
.sm-company-group.is-collapsed .sm-company-chevron {
  transform: rotate(-90deg);
}
[dir="rtl"] .sm-company-group.is-collapsed .sm-company-chevron {
  transform: rotate(90deg);
}
.sm-company-leads {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0 0.7rem 0.75rem;
}
.sm-company-group.is-collapsed .sm-company-leads {
  display: none;
}
.sm-lead-card {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.85rem;
  width: 100%;
  padding: 0.75rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.15s;
}
.sm-lead-card:hover,
.sm-lead-card:focus-visible {
  border-color: rgba(124, 58, 237, 0.35);
  background: rgba(124, 58, 237, 0.04);
  outline: none;
}
.sm-lead-card-main {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  min-width: 0;
  flex: 1 1 auto;
}
.sm-lead-avatar {
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--primary);
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.18), rgba(99, 102, 241, 0.1));
}
.sm-lead-card-body {
  min-width: 0;
  flex: 1 1 auto;
}
.sm-lead-card-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
}
.sm-lead-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}
.sm-lead-index {
  flex: 0 0 auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-tertiary);
}
.sm-lead-meta {
  margin-top: 0.2rem;
  font-size: 12.5px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}
.sm-lead-contacts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.85rem;
  margin-top: 0.45rem;
}
.sm-lead-contact {
  font-size: 12px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.sm-lead-linkedin {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}
.sm-lead-linkedin:hover {
  text-decoration: underline;
}
.sm-lead-card-actions {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}
.sm-missing { color: var(--danger); font-weight: 600; }
.sm-summary { margin-top: 0.85rem; }
.sm-summary-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 0.35rem;
}
.sm-summary-list {
  margin: 0;
  padding-inline-start: 1.1rem;
  color: var(--text-secondary);
  font-size: 12.5px;
}
.sm-actions { margin-top: 0.9rem; }
.sm-actions-prompt {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 0.4rem;
}
.sm-actions-list {
  margin: 0;
  padding-inline-start: 1.2rem;
  display: grid;
  gap: 0.35rem;
}
.sm-action-link,
.sm-action-btn {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  color: var(--primary);
  font: inherit;
  cursor: pointer;
  text-align: start;
}
.sm-row-btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 11.5px;
  font-family: var(--font);
  cursor: pointer;
  white-space: nowrap;
}
.sm-row-btn:hover { border-color: rgba(124, 58, 237, 0.4); color: var(--text); }
.sm-row-btn-primary {
  border-color: rgba(124, 58, 237, 0.35);
  color: var(--primary);
  background: rgba(124, 58, 237, 0.08);
}

.sm-colleagues {
  border-top: 1px solid var(--border);
}
.sm-colleagues-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}
.sm-colleague-chip {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 12px;
  padding: 0.55rem 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  cursor: pointer;
  font: inherit;
  color: inherit;
  max-width: 100%;
  transition: border-color 0.15s, background 0.15s;
}
.sm-colleague-chip:hover {
  border-color: rgba(13, 148, 136, 0.45);
  background: rgba(13, 148, 136, 0.06);
}
.sm-colleague-chip strong {
  font-size: 13px;
  overflow-wrap: anywhere;
}
.sm-colleague-chip span {
  font-size: 11.5px;
  color: var(--text-secondary);
  overflow-wrap: anywhere;
}

/* Smart Miner detail dialog polish */
.lead-modal--smart .lead-modal-dialog {
  width: min(820px, 100%);
  max-height: min(90vh, 940px);
  box-shadow:
    0 24px 64px rgba(8, 8, 18, 0.28),
    0 0 0 1px rgba(255, 255, 255, 0.06);
}
.lead-modal--smart.is-open .lead-modal-dialog {
  animation: leadModalIn 0.32s var(--ease, cubic-bezier(0.22, 1, 0.36, 1));
}
.sm-modal-skeleton {
  padding: 1.5rem;
  display: grid;
  gap: 0.85rem;
}
.sm-modal-skeleton-line,
.sm-modal-skeleton-card {
  border-radius: 10px;
  background: linear-gradient(
    90deg,
    var(--surface-2) 0%,
    rgba(124, 58, 237, 0.08) 45%,
    var(--surface-2) 100%
  );
  background-size: 200% 100%;
  animation: smSkeleton 1.2s ease-in-out infinite;
}
.sm-modal-skeleton-line { height: 14px; width: 70%; }
.sm-modal-skeleton-line--lg { height: 28px; width: 48%; }
.sm-modal-skeleton-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 0.5rem;
}
.sm-modal-skeleton-card { height: 110px; }
@keyframes smSkeleton {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
body.modal-open { overflow: hidden; }

@media (max-width: 720px) {
  .smart-miner { min-height: 70vh; }
  .smart-miner-feed { padding: 1rem; }
  .sm-msg { max-width: 100%; }
  .sm-lead-card {
    flex-direction: column;
    align-items: stretch;
  }
  .sm-lead-card-actions {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .sm-modal-skeleton-grid { grid-template-columns: 1fr; }
}
