/* ═══════════════════════════════════════════════════════════
   AI Call — Modern Dashboard Design System
   ═══════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ───────────────────────────────── */
:root {
  /* Color Palette */
  /* Кабинет AI Call — светлый современный стиль (Stripe/Linear). */
  --primary: #0284c7;
  --primary-hover: #0369a1;
  --primary-light: rgba(2, 132, 199, 0.10);
  --primary-dark: #075985;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-light: rgba(13, 148, 136, 0.10);
  --success: #16a34a;
  --success-light: rgba(22, 163, 74, 0.10);
  --warning: #d97706;
  --warning-light: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-light: rgba(220, 38, 38, 0.10);
  --info: #2563eb;
  --info-light: rgba(37, 99, 235, 0.10);

  /* Backgrounds — светлая тема */
  --sidebar-bg: #ffffff;
  --sidebar-hover: #f1f5f9;
  --sidebar-active: rgba(2, 132, 199, 0.10);
  --sidebar-text: #475569;
  --sidebar-text-active: #0f172a;
  --sidebar-border: #e8ecf1;
  --page-bg: #f5f7fa;
  --card-bg: #ffffff;
  --card-border: #e7ebf0;
  --card-border-strong: #dde3ea;
  --surface-soft: #f8fafc;
  --topbar-bg: rgba(255, 255, 255, 0.85);

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #3d4a5c;
  --text-muted: #586577;

  /* Layout */
  --sidebar-width: 260px;
  --sidebar-collapsed-width: 72px;
  --topbar-height: 60px;
  --radius: 10px;
  --radius-lg: 14px;
  --radius-sm: 8px;

  /* Shadows — мягкие современные */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.10);

  /* Transitions */
  --transition: 0.2s ease;
  --transition-slow: 0.3s ease;

  /* Алиасы --color-* (используются в части шаблонов) -> фирменные токены,
     чтобы старые var(--color-X, светлый-fallback) не давали светлых блоков. */
  --color-bg: var(--card-bg);
  --color-bg-secondary: var(--surface-soft);
  --color-bg-muted: var(--surface-soft);
  --color-bg-subtle: var(--surface-soft);
  --color-border: var(--card-border);
  --color-primary: var(--primary);
  --color-primary-light: var(--primary-light);
  --color-danger: var(--danger);
  --color-error: var(--danger);
  --color-success: var(--success);
  --color-warning: var(--warning);
  --color-text-secondary: var(--text-secondary);
  --color-text-tertiary: var(--text-muted);
}

/* ── Тёмная тема (переключатель в топбаре) ───────────────────
   Переопределяем только токены — всё на var(--…) перекрашивается
   автоматически. Алиасы --color-* следуют за токенами. */
:root[data-theme="dark"] {
  --primary: #38bdf8;
  --primary-hover: #7dd3fc;
  --primary-light: rgba(56, 189, 248, 0.16);
  --primary-dark: #0ea5e9;
  --accent: #2dd4bf;
  --accent-hover: #5eead4;
  --accent-light: rgba(45, 212, 191, 0.16);
  --success: #4ade80;
  --success-light: rgba(74, 222, 128, 0.16);
  --warning: #fbbf24;
  --warning-light: rgba(251, 191, 36, 0.16);
  --danger: #f87171;
  --danger-hover: #fca5a5;
  --danger-light: rgba(248, 113, 113, 0.16);
  --info: #60a5fa;
  --info-light: rgba(96, 165, 250, 0.16);

  --sidebar-bg: #0e1726;
  --sidebar-hover: rgba(56, 189, 248, 0.12);
  --sidebar-active: rgba(56, 189, 248, 0.18);
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f1f5f9;
  --sidebar-border: #1e293b;
  --page-bg: #0a111e;
  --card-bg: #131c2b;
  --card-border: #243044;
  --card-border-strong: #2d3a52;
  --surface-soft: #1a2435;
  --topbar-bg: rgba(13, 20, 33, 0.82);

  --text-primary: #f8fafc;
  --text-secondary: #e2e8f0;
  --text-muted: #c3cdda;
}

/* Плавный переход цветов при переключении темы */
body, .sidebar, .topbar, .card, .stat-card {
  transition: background-color var(--transition), border-color var(--transition), color var(--transition);
}

/* ── Reset & Base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-primary);
  background: var(--page-bg);
  line-height: 1.6;
  overflow-x: hidden;
}

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

img { max-width: 100%; height: auto; }

.ui-icon {
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -0.18em;
}

button, input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

button { cursor: pointer; border: none; background: none; }

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width var(--transition-slow), transform var(--transition-slow);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--sidebar-border);
  min-height: 72px;
}

.sidebar-brand-icon {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  color: #fff;
}

.sidebar-brand-text {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  transition: opacity var(--transition);
}

.sidebar.collapsed .sidebar-brand-text {
  display: none;
}

/* В свёрнутом виде ужимаем брэнд и центрируем иконку + toggle, иначе при
   width=72px содержимое не помещалось и кнопка toggle уезжала за overflow,
   из-за чего sidebar нельзя было раскрыть обратно. */
.sidebar.collapsed .sidebar-brand {
  padding: 16px 8px;
  justify-content: space-between;
  gap: 4px;
}

.sidebar-toggle {
  margin-left: auto;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  color: var(--sidebar-text);
  transition: all var(--transition);
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(148, 163, 184, 0.2) transparent;
}

.sidebar-section {
  margin-bottom: 8px;
}

.sidebar-section-title {
  display: block;
  padding: 8px 20px 6px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
  transition: opacity var(--transition);
}

.sidebar.collapsed .sidebar-section-title {
  opacity: 0;
  height: 0;
  padding: 0;
  overflow: hidden;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  transition: all var(--transition);
  border-radius: 0;
  position: relative;
  white-space: nowrap;
}

.sidebar-link:hover {
  background: var(--sidebar-hover);
  color: var(--text-primary);
}

.sidebar-link.active {
  background: var(--sidebar-active);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.sidebar-link svg {
  flex-shrink: 0;
  opacity: 0.72;
  transition: opacity var(--transition), color var(--transition);
}

.sidebar-link:hover svg,
.sidebar-link.active svg {
  opacity: 1;
}

.sidebar-link span {
  transition: opacity var(--transition);
}

.sidebar.collapsed .sidebar-link span {
  opacity: 0;
  pointer-events: none;
}

.sidebar.collapsed .sidebar-link {
  padding: 10px calc((var(--sidebar-collapsed-width) - 18px) / 2);
  justify-content: center;
}

.sidebar-footer {
  padding: 16px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.sidebar-user-info {
  min-width: 0;
}

.sidebar-user-phone {
  display: block;
  font-size: 0.85rem;
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity var(--transition);
}

.sidebar.collapsed .sidebar-user-info {
  opacity: 0;
  width: 0;
  overflow: hidden;
}

.sidebar-logout {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--sidebar-text);
  transition: all var(--transition);
  flex-shrink: 0;
}

.sidebar-logout:hover {
  background: var(--danger-light);
  color: var(--danger);
}

.sidebar.collapsed .sidebar-logout {
  opacity: 0;
  width: 0;
  padding: 0;
}

/* ── Sidebar Overlay (Mobile) ────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 99;
  backdrop-filter: blur(4px);
  transition: opacity var(--transition-slow);
}

.sidebar-overlay.active {
  display: block;
  opacity: 1;
}

/* ── Main Content ────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  transition: margin-left var(--transition-slow);
}

.sidebar.collapsed ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* ── Topbar ──────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-height);
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--card-border);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 16px;
  z-index: 50;
}

.hamburger {
  display: none;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition);
}

.hamburger:hover { background: var(--primary-light); }

.topbar-breadcrumbs {
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.topbar-breadcrumbs a { color: var(--text-secondary); }
.topbar-breadcrumbs a:hover { color: var(--primary); }
.topbar-breadcrumbs .sep { color: var(--text-muted); margin: 0 2px; }
.topbar-breadcrumbs .current { color: var(--text-primary); font-weight: 600; }

/* Переключатель темы в топбаре */
.theme-toggle {
  margin-left: auto;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: background var(--transition), color var(--transition);
}
.theme-toggle:hover { background: var(--surface-soft); color: var(--text-primary); }
.theme-toggle .theme-icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .theme-icon-sun { display: block; }
:root[data-theme="dark"] .theme-toggle .theme-icon-moon { display: none; }

/* ── Page Content ────────────────────────────────────────── */
.page-content {
  padding: 24px 32px 48px;
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}

body.is-auth-layout {
  background: #0f172a;
}

body.is-auth-layout .main-content,
.auth-main-content {
  width: 100%;
  margin-left: 0 !important;
  background: transparent;
  transition: none;
}

body.is-auth-layout .page-content,
.auth-page-content {
  max-width: none;
  min-height: 100vh;
  padding: 0;
  margin: 0;
  animation: none;
}

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

.fade-in { animation: fadeIn 0.3s ease; }

/* ── Cards ───────────────────────────────────────────────── */
.card {
  background: linear-gradient(180deg, var(--card-bg) 0%, var(--surface-soft) 100%);
  border-radius: var(--radius-lg);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.035);
  border: 1px solid var(--card-border-strong);
  padding: 24px;
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.card:hover {
  border-color: #cbd8e6;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06), 0 14px 34px rgba(15, 23, 42, 0.05);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body {
  color: var(--text-secondary);
}

/* ── Stat Cards ──────────────────────────────────────────── */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: linear-gradient(180deg, var(--card-bg) 0%, var(--surface-soft) 100%);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--card-border-strong);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05), 0 10px 28px rgba(15, 23, 42, 0.035);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  border-color: #cbd8e6;
  box-shadow: 0 2px 4px rgba(15, 23, 42, 0.06), 0 14px 34px rgba(15, 23, 42, 0.05);
  transform: translateY(-2px);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
}

.stat-card.stat-primary::after { background: linear-gradient(90deg, var(--primary), #38bdf8); }
.stat-card.stat-success::after { background: linear-gradient(90deg, var(--success), #4ade80); }
.stat-card.stat-warning::after { background: linear-gradient(90deg, var(--warning), #facc15); }
.stat-card.stat-accent::after { background: linear-gradient(90deg, var(--accent), #fb923c); }
.stat-card.stat-danger::after { background: linear-gradient(90deg, var(--danger), #f87171); }
.stat-card.stat-info::after { background: linear-gradient(90deg, var(--info), #818cf8); }

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  margin-bottom: 12px;
}

.stat-card-icon .ui-icon {
  width: 22px;
  height: 22px;
}

.stat-card-icon.icon-primary { background: var(--primary-light); color: var(--primary); }
.stat-card-icon.icon-success { background: var(--success-light); color: var(--success); }
.stat-card-icon.icon-warning { background: var(--warning-light); color: var(--warning); }
.stat-card-icon.icon-accent { background: var(--accent-light); color: var(--accent); }
.stat-card-icon.icon-danger { background: var(--danger-light); color: var(--danger); }
.stat-card-icon.icon-info { background: var(--info-light); color: var(--info); }

.stat-card-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

/* ── Badges ──────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-success { background: rgba(34,197,94,0.12); color: #22c55e; border: 1px solid rgba(34,197,94,0.2); }
.badge-warning { background: rgba(234,179,8,0.12); color: #eab308; border: 1px solid rgba(234,179,8,0.2); }
.badge-danger { background: rgba(239,68,68,0.12); color: #ef4444; border: 1px solid rgba(239,68,68,0.2); }
.badge-info { background: rgba(14,165,233,0.12); color: #0ea5e9; border: 1px solid rgba(14,165,233,0.2); }
.badge-muted { background: rgba(100,116,139,0.12); color: #64748b; border: 1px solid rgba(100,116,139,0.2); }
.badge-accent { background: rgba(249,115,22,0.12); color: #f97316; border: 1px solid rgba(249,115,22,0.2); }

/* Status text colors for dynamic Jinja2 classes */
.status-draft, .status-queued { color: #64748b; }
.status-running, .status-dialing, .status-ringing { color: #0ea5e9; }
.status-active, .status-connected { color: #22c55e; }
.status-paused, .status-password_required { color: #eab308; }
.status-completed { color: #22c55e; }
.status-failed, .status-no_answer, .status-privacy_restricted { color: #ef4444; }
.status-calling { color: #f97316; }

/* Call row hover */
.call-row {
  transition: background 150ms ease, transform 150ms ease;
  cursor: pointer;
}
.call-row:hover {
  background: rgba(14,165,233,0.06);
  transform: translateX(2px);
}

.dashboard-call-list {
  display: grid;
  gap: 10px;
}

.dashboard-call-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  align-items: center;
  padding: 12px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card-bg);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition), transform var(--transition);
}

.dashboard-call-item:hover {
  border-color: rgba(14, 165, 233, 0.45);
  box-shadow: var(--shadow-sm);
  color: var(--text-primary);
  transform: translateY(-1px);
}

.dashboard-call-main {
  min-width: 0;
}

.dashboard-call-phone {
  display: block;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dashboard-call-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
  margin-top: 4px;
  color: var(--text-secondary);
  font-size: 0.82rem;
}

.dashboard-call-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dashboard-call-time {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: right;
  white-space: nowrap;
}

.call-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.balance-two-grid,
.balance-metrics-grid {
  display: grid;
  gap: 16px;
  margin-bottom: 24px;
}

.balance-two-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.balance-metrics-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-top: 0;
}

.balance-metrics-grid .stat-card-value {
  overflow-wrap: anywhere;
}

/* Landing footer */
.landing-footer {
  text-align: center;
  padding: 32px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

/* Toggle switch */
.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #334155;
  border-radius: 12px;
  transition: background 200ms ease;
  cursor: pointer;
}
.toggle-switch.active { background: var(--primary); }
.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: white;
  border-radius: 50%;
  transition: transform 200ms ease;
}
.toggle-switch.active::after { transform: translateX(20px); }

/* Standalone icon indicator colors */
.icon-success { color: var(--success) !important; }
.icon-warning { color: var(--warning) !important; }
.icon-danger { color: var(--danger) !important; }
.icon-accent { color: var(--accent) !important; }
.icon-primary { color: var(--primary) !important; }
.icon-info { color: var(--info) !important; }

/* Toast slide animations */
@keyframes toast-slide-in {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toast-slide-out {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}


/* Pulse animation for active/live badges */
.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
  position: relative;
}

.pulse-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: pulse-ring 2s ease infinite;
}

.pulse-dot.pulse-success { background: var(--success); }
.pulse-dot.pulse-success::after { background: var(--success); }
.pulse-dot.pulse-danger { background: var(--danger); }
.pulse-dot.pulse-danger::after { background: var(--danger); }
.pulse-dot.pulse-warning { background: var(--warning); }
.pulse-dot.pulse-warning::after { background: var(--warning); }
.pulse-dot.pulse-primary { background: var(--primary); }
.pulse-dot.pulse-primary::after { background: var(--primary); }

@keyframes pulse-ring {
  0% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(2); opacity: 0; }
  100% { transform: scale(2); opacity: 0; }
}

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.4;
  transition: all var(--transition);
  white-space: nowrap;
  border: none;
  cursor: pointer;
}

.btn .ui-icon {
  width: 17px;
  height: 17px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-danger {
  background: linear-gradient(135deg, var(--danger), #f87171);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, var(--success), #4ade80);
  color: #fff;
  box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  padding: 8px 12px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--primary-light);
  color: var(--primary);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
  border-radius: 6px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* Legacy button classes compatibility */
.primary-button {
  composes: btn btn-primary;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}
.primary-button:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--primary-hover), var(--primary));
  box-shadow: 0 4px 12px rgba(14, 165, 233, 0.4);
  transform: translateY(-1px);
}
.primary-button:disabled { opacity: 0.5; cursor: not-allowed; }

.secondary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  background: var(--card-bg);
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
  cursor: pointer;
  transition: all var(--transition);
}
.secondary-button:hover:not(:disabled),
.ghost-button:hover:not(:disabled) {
  background: var(--surface-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.danger-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.875rem;
  background: linear-gradient(135deg, var(--danger), #f87171);
  color: #fff;
  border: none;
  cursor: pointer;
  transition: all var(--transition);
}
.danger-button:hover:not(:disabled) {
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.4);
  transform: translateY(-1px);
}

.small-button {
  padding: 5px 12px;
  font-size: 0.78rem;
  border-radius: 6px;
  font-weight: 600;
}

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--card-border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--card-bg);
  box-shadow: inset 0 1px 1px rgba(15, 23, 42, 0.025);
  transition: all var(--transition);
  outline: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.form-check {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}

.form-check input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  cursor: pointer;
}

/* Toggle Switch */
.toggle {
  position: relative;
  width: 44px;
  height: 24px;
  display: inline-block;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #cbd5e1;
  border-radius: 24px;
  transition: all var(--transition);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: var(--card-bg);
  border-radius: 50%;
  transition: all var(--transition);
}

.toggle input:checked + .toggle-slider {
  background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* ── Tables ──────────────────────────────────────────────── */
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--card-border-strong);
  background: var(--card-bg);
  scrollbar-width: thin;
  scrollbar-color: rgba(14, 165, 233, 0.45) transparent;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

thead th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--card-border);
  white-space: nowrap;
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-secondary);
}

tbody tr {
  transition: background var(--transition);
}

tbody tr:hover {
  background: var(--surface-soft);
}

/* ── Page Header ─────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header h1 {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.3;
}

.page-header .subtitle {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.page-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

/* ── Grid & Layout ───────────────────────────────────────── */
.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}

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

.stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.row {
  display: flex;
  gap: 16px;
  align-items: center;
}

.row-wrap {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }

/* ── Progress Bar ────────────────────────────────────────── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: #e2e8f0;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--primary), #38bdf8);
  transition: width 0.6s ease;
}

.progress-bar-fill.success {
  background: linear-gradient(90deg, var(--success), #4ade80);
}

.progress-bar-fill.warning {
  background: linear-gradient(90deg, var(--warning), #facc15);
}

/* ── Data Display ────────────────────────────────────────── */
.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #f1f5f9;
}

.data-row:last-child { border-bottom: none; }
.data-row span { color: var(--text-muted); font-size: 0.85rem; }
.data-row strong { color: var(--text-primary); font-weight: 600; }

/* ── Empty State ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  margin-bottom: 16px;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
}

.status-indicator.success {
  background: var(--success-light);
  color: var(--success);
}

.status-indicator.danger {
  background: var(--danger-light);
  color: var(--danger);
}

.status-indicator.warning {
  background: var(--warning-light);
  color: var(--warning);
}

.empty-state h3 {
  font-size: 1.1rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* ── Toast Notifications ─────────────────────────────────── */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  box-shadow: var(--shadow-lg);
  min-width: 300px;
  max-width: 480px;
  font-size: 0.875rem;
  transform: translateX(120%);
  transition: transform 0.3s ease;
  border-left: 4px solid var(--primary);
}

.toast.show { transform: translateX(0); }

.toast-success { border-left-color: var(--success); }
.toast-success .toast-icon { background: var(--success-light); color: var(--success); }
.toast-error { border-left-color: var(--danger); }
.toast-error .toast-icon { background: var(--danger-light); color: var(--danger); }
.toast-warning { border-left-color: var(--warning); }
.toast-warning .toast-icon { background: var(--warning-light); color: var(--warning); }
.toast-info { border-left-color: var(--primary); }
.toast-info .toast-icon { background: var(--primary-light); color: var(--primary); }

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

.toast-message { flex: 1; }

.toast-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
}

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

.modal-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 32px;
  max-width: 420px;
  width: 90%;
  box-shadow: var(--shadow-lg);
  animation: scaleIn 0.2s ease;
}

@keyframes scaleIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-text {
  color: var(--text-secondary);
  margin-bottom: 24px;
  font-size: 0.9rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Messages / Alerts ────────────────────────────────────── */
.message {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 16px;
}

.message.success {
  background: var(--success-light);
  color: #166534;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.message.error {
  background: var(--danger-light);
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.message.warning {
  background: var(--warning-light);
  color: #854d0e;
  border: 1px solid rgba(234, 179, 8, 0.2);
}

.inline-message {
  display: inline-block;
}

/* ── Stepper ─────────────────────────────────────────────── */
.stepper {
  display: flex;
  gap: 0;
  margin-bottom: 24px;
}

.step {
  flex: 1;
  text-align: center;
  padding: 12px 8px;
  position: relative;
}

.step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  margin-bottom: 4px;
  background: #e2e8f0;
  color: var(--text-muted);
}

.step.active .step-number {
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  color: #fff;
  box-shadow: 0 2px 8px rgba(14, 165, 233, 0.3);
}

.step.completed .step-number {
  background: linear-gradient(135deg, var(--success), #4ade80);
  color: #fff;
}

.step-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
}

.step.active .step-label { color: var(--primary); font-weight: 600; }
.step.completed .step-label { color: var(--success); }

/* ── Wizard Steps ────────────────────────────────────────── */
.step-card {
  display: flex;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--surface-soft);
  border: 1px solid var(--card-border);
  transition: all var(--transition);
}

.step-card.step-completed {
  background: var(--success-light);
  border-color: rgba(34, 197, 94, 0.2);
}

.step-card.step-active {
  background: var(--primary-light);
  border-color: rgba(14, 165, 233, 0.3);
}

.step-index {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  flex-shrink: 0;
  background: #e2e8f0;
  color: var(--text-muted);
}

.step-completed .step-index { background: var(--success); color: #fff; }
.step-active .step-index { background: var(--primary); color: #fff; }

.step-card strong {
  display: block;
  font-size: 0.9rem;
  margin-bottom: 2px;
}

.step-card p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
}

/* ── Live State Cards ────────────────────────────────────── */
.live-state-card {
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.live-state-card span {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.live-state-success {
  background: var(--success-light);
  border: 1px solid rgba(34, 197, 94, 0.2);
}
.live-state-success span { color: var(--success); }

.live-state-warning {
  background: var(--warning-light);
  border: 1px solid rgba(234, 179, 8, 0.2);
}
.live-state-warning span { color: #854d0e; }

.live-state-danger {
  background: var(--danger-light);
  border: 1px solid rgba(239, 68, 68, 0.2);
}
.live-state-danger span { color: var(--danger); }

/* ── Active Call Card ─────────────────────────────────────── */
.active-call-card {
  border: 2px solid var(--primary);
  animation: callPulse 2s ease infinite;
}

@keyframes callPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(14, 165, 233, 0.3); }
  50% { box-shadow: 0 0 0 8px rgba(14, 165, 233, 0); }
}

/* Waveform animation */
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 24px;
}

.waveform-bar {
  width: 3px;
  background: var(--primary);
  border-radius: 2px;
  animation: waveform 1.2s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { animation-delay: 0s; height: 8px; }
.waveform-bar:nth-child(2) { animation-delay: 0.1s; height: 16px; }
.waveform-bar:nth-child(3) { animation-delay: 0.2s; height: 12px; }
.waveform-bar:nth-child(4) { animation-delay: 0.3s; height: 20px; }
.waveform-bar:nth-child(5) { animation-delay: 0.4s; height: 14px; }

@keyframes waveform {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

/* ── Form Grid (Legacy compat) ───────────────────────────── */
.form-grid {
  display: grid;
  gap: 16px;
}

.form-grid label {
  display: block;
}

.form-grid label span {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-grid input[type="text"],
.form-grid input[type="tel"],
.form-grid input[type="number"],
.form-grid input[type="password"],
.form-grid input[type="email"],
.form-grid textarea,
.form-grid select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  color: var(--text-primary);
  background: var(--card-bg);
  transition: all var(--transition);
  outline: none;
}

.form-grid input:focus,
.form-grid textarea:focus,
.form-grid select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

.form-grid textarea {
  resize: vertical;
  min-height: 80px;
}

.form-grid .full-row {
  grid-column: 1 / -1;
}

.form-grid .two-up {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.form-grid small,
.form-grid .note-copy {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Content Grid (Legacy compat) ───────────────────────── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.content-grid > *,
.stat-grid > *,
.grid-2 > *,
.grid-3 > *,
.grid-4 > * {
  min-width: 0;
}

.settings-grid {
  grid-template-columns: 2fr 1fr;
}

/* ── Panel Block (Legacy compat) ─────────────────────────── */
.panel-block {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--card-border);
  padding: 24px;
  margin-bottom: 20px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  gap: 12px;
}

.section-head h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.section-head a {
  font-size: 0.85rem;
}

.wide-head {
  margin-bottom: 20px;
}

.wide-head h1 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--primary);
  margin-bottom: 4px;
  display: block;
}

.lede {
  font-size: 0.95rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.compact { margin-bottom: 0 !important; }

/* ── Status Grid (Legacy) ────────────────────────────────── */
.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.four-up {
  grid-template-columns: repeat(4, 1fr);
}

.status-tile {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
}

.status-tile:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.status-tile span {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.status-tile strong {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.status-tile p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
}

.status-tile.ready {
  border-color: rgba(34, 197, 94, 0.3);
}
.status-tile.ready strong { color: var(--success); }

.status-tile.warning-tile {
  border-color: rgba(234, 179, 8, 0.3);
}
.status-tile.warning-tile strong { color: var(--warning); }

/* ── Status Badge (Legacy) ───────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.status-badge-success {
  background: var(--success-light);
  color: #166534;
}

.status-badge-warning {
  background: var(--warning-light);
  color: #854d0e;
}

/* ── Table Pill (Legacy) ─────────────────────────────────── */
.table-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  background: var(--surface-soft);
  color: var(--text-secondary);
}

.table-pill.is-ready {
  background: var(--success-light);
  color: #166534;
}

/* ── Auth Pages ──────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  min-height: 100svh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 48px);
  overflow-x: hidden;
  background:
    radial-gradient(circle at 20% 20%, rgba(0, 196, 255, 0.18), transparent 38%),
    radial-gradient(circle at 80% 78%, rgba(157, 255, 207, 0.12), transparent 36%),
    linear-gradient(135deg, #031423 0%, #06243a 45%, #071a2c 100%);
}

.auth-panel {
  background: var(--card-bg);
  border: 1px solid rgba(226, 232, 240, 0.92);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 4vw, 42px);
  max-width: 500px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.auth-panel .eyebrow {
  color: var(--primary);
  margin-bottom: 8px;
}

.auth-panel h1 {
  font-size: clamp(1.45rem, 2vw, 1.75rem);
  font-weight: 800;
  line-height: 1.22;
  margin-bottom: 16px;
}

.auth-panel .lede {
  margin-bottom: 24px;
}

.auth-wide { max-width: 520px; }

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 24px;
}

.auth-brand:hover {
  color: var(--text-primary);
}

.auth-brand .sidebar-brand-icon {
  width: 34px;
  height: 34px;
}

.auth-help-card {
  background: var(--surface-soft);
  border: 1px solid var(--card-border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}

.auth-help-title {
  margin: 0 0 8px;
  font-weight: 700;
}

.auth-help-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.75;
  color: var(--text-secondary);
}

.auth-panel .btn {
  min-height: 44px;
  width: 100%;
}

/* ── Landing Page ────────────────────────────────────────── */
.hero-shell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  gap: 60px;
  padding: 48px;
  flex-wrap: wrap;
}

.hero-copy {
  max-width: 520px;
  min-width: 0;
}

.hero-copy h1 {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.hero-visual {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-width: 440px;
  min-width: 0;
}

.visual-panel {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow);
}

.visual-panel-large {
  padding: 28px;
}

.visual-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.accent-panel {
  border-color: var(--primary);
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.05), rgba(249, 115, 22, 0.05));
}

.strip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  padding: 48px 32px;
  max-width: 1400px;
  margin: 0 auto;
}

.strip-grid article {
  padding: 28px;
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--card-border);
}

.strip-grid article span {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 8px;
}

.strip-grid h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.strip-grid p {
  font-size: 0.9rem;
  color: var(--text-muted);
}

/* ── Error Pages ─────────────────────────────────────────── */
.error-shell {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--surface-soft) 0%, var(--card-border) 100%);
}

.error-panel {
  text-align: center;
  padding: 48px 36px;
  max-width: 520px;
}

.error-code {
  font-size: 6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  margin-bottom: 16px;
}

.error-title {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.error-desc {
  color: var(--text-muted);
  line-height: 1.7;
  margin-bottom: 28px;
}

/* ── Admin ───────────────────────────────────────────────── */
.admin-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

/* ── Misc legacy ─────────────────────────────────────────── */
.section-stack {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.plain-list {
  list-style: none;
  padding: 0;
}

.plain-list li {
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
  font-size: 0.9rem;
}

.plain-list li:last-child { border-bottom: none; }

.compact-list li { padding: 6px 0; font-size: 0.85rem; }

.note-copy {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.5;
}

.empty-copy {
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: 16px 0;
}

.inline-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.account-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.account-card {
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid var(--card-border);
}

.account-card span {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.account-card strong {
  font-size: 0.9rem;
  color: var(--text-primary);
}

.hero-account-card {
  grid-column: 1 / -1;
  background: var(--primary-light);
  border-color: rgba(14, 165, 233, 0.2);
}

.progress-track {
  width: 100%;
  height: 6px;
  background: #e2e8f0;
  border-radius: 9999px;
  margin: 8px 0;
  overflow: hidden;
}

.progress-track span {
  display: block;
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, var(--primary), #38bdf8);
  transition: width 0.5s ease;
}

.meter-card {
  background: var(--surface-soft);
  border-radius: var(--radius);
  padding: 16px;
  border: 1px solid var(--card-border);
}

.meter-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.next-stage-card {
  background: var(--primary-light);
  border: 1px solid rgba(14, 165, 233, 0.2);
  border-radius: var(--radius-sm);
  padding: 14px;
}

.next-stage-card span {
  display: block;
  font-size: 0.75rem;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 4px;
}

.hero-actions a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.dashboard-grid {
  grid-template-columns: 3fr 2fr;
}

.admin-status-grid {
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)) !important;
}

.upload-shell small {
  display: block;
  margin-top: 4px;
}

.advanced-import-shell {
  margin-top: 24px;
}

.advanced-import-shell summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.advanced-import-body {
  margin-top: 16px;
}

.advanced-grid {
  grid-template-columns: 1fr 1fr;
}

.telegram-live-grid {
  grid-template-columns: 3fr 2fr;
}

.telegram-overview-grid {
  grid-template-columns: repeat(4, 1fr);
}

.telegram-stepper {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 24px;
}

.workspace-shell {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.workspace-hero {
  display: flex;
  align-items: flex-start;
  gap: 24px;
}

.workspace-intro {
  flex: 1;
}

code {
  background: var(--surface-soft);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 1024px) {
  .four-up { grid-template-columns: repeat(2, 1fr); }
  .telegram-overview-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .telegram-live-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .balance-metrics-grid { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  .sidebar.mobile-open {
    transform: translateX(0);
  }
  .sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  .mobile-open.sidebar.collapsed {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
  }
  .hamburger {
    display: flex;
  }
  .topbar {
    padding: 0 16px;
  }
  .page-content {
    padding: 16px;
  }
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .four-up { grid-template-columns: 1fr; }
  .telegram-overview-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .hero-shell { flex-direction: column; align-items: stretch; padding: 24px; }
  .hero-copy,
  .hero-visual { width: 100%; max-width: none; }
  .hero-copy h1 { font-size: 1.8rem; }
  .hero-note-grid { grid-template-columns: 1fr !important; }
  .auth-panel { padding: 28px; }
  .account-grid { grid-template-columns: 1fr 1fr; }
  .balance-two-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .form-grid .two-up { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .table-wrap {
    position: relative;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
  }
  .table-wrap::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 28px;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0), var(--card-bg));
  }
  .table-wrap table {
    min-width: 640px;
  }
  .table-wrap th,
  .table-wrap td {
    padding-left: 12px;
    padding-right: 12px;
  }
  .call-form-grid {
    grid-template-columns: 1fr;
  }
  .call-form-grid .btn {
    width: 100%;
  }
  .calls-table-wrapper {
    display: none;
  }
  .calls-mobile-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }
  .panel-block { padding: 16px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .balance-two-grid,
  .balance-metrics-grid {
    grid-template-columns: 1fr;
  }
  .dashboard-call-item {
    grid-template-columns: 1fr;
  }
  .dashboard-call-time {
    text-align: left;
  }
  .account-grid { grid-template-columns: 1fr; }
  .strip-grid { grid-template-columns: 1fr; padding: 16px; }
  .visual-grid { grid-template-columns: 1fr; }
  .hero-copy h1 {
    font-size: 1.65rem;
  }
  .hero-actions {
    flex-direction: column;
  }
  .hero-actions .btn {
    width: 100%;
  }
  .auth-shell {
    padding: 18px;
  }
}

/* ── Call form grid ─────────────────────────────────────── */
.call-form-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr auto;
  gap: 12px;
  align-items: end;
}

/* ── Call mobile cards ──────────────────────────────────── */
.calls-mobile-list {
  display: none;
}

.call-card-mobile {
  display: block;
  padding: 12px;
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  background: var(--card-bg);
  text-decoration: none;
  color: inherit;
  transition: box-shadow var(--transition);
}

.call-card-mobile:hover {
  box-shadow: var(--shadow-md);
}

.call-card-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.call-card-meta {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.call-card-result {
  margin-top: 4px;
  font-size: 0.8rem;
  font-weight: 600;
}

/* ── Calls table wrapper ────────────────────────────────── */
.calls-table-wrapper {
  overflow-x: auto;
}

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

/* ── Print ────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .toast-container { display: none; }
  .main-content { margin-left: 0; }
  .page-content { padding: 0; }
}

/* ── Call detail mobile ─────────────────────────────────── */
.call-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.call-outcome-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr;
  gap: 16px;
}

@media (max-width: 768px) {
  .call-info-grid,
  .call-outcome-grid {
    grid-template-columns: 1fr;
  }

  .call-transcript-message {
    padding: 12px;
    gap: 8px;
  }

  .call-transcript-message .role-icon {
    min-width: 28px;
  }

  .call-form-grid {
    grid-template-columns: 1fr;
  }

  .call-form-grid .form-group,
  .call-form-grid .form-input,
  .call-form-grid .note-copy {
    min-width: 0 !important;
    width: 100%;
  }

  .call-form-grid .btn {
    width: 100%;
  }

  .tab-btn {
    flex: 1 1 0;
    min-width: 0;
    padding-left: 10px;
    padding-right: 10px;
    white-space: normal;
  }
}
