:root {
  /* Design Tokens - B&W Theme */
  --bg-gradient: linear-gradient(160deg, #fafafa 0%, #f5f5f5 40%, #fafafa 100%);
  --sidebar-bg: rgba(255, 255, 255, 0.85);
  --panel-bg: rgba(255, 255, 255, 0.7);
  --panel-border: rgba(0, 0, 0, 0.08);
  --ink: #111111;
  --muted: #777777;
  --primary: #111111;
  --primary-dark: #000000;
  --primary-glow: rgba(0, 0, 0, 0.08);
  --accent: #555555;
  --accent-glow: rgba(0, 0, 0, 0.06);
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --glass-blur: 20px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06), 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.08), 0 4px 12px rgba(0, 0, 0, 0.04);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-main: "Inter", "Space Grotesk", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "IBM Plex Mono", monospace;
  --sidebar-width: 260px;

  /* Thematic component variables */
  --input-bg: #ffffff;
  --input-border: rgba(0, 0, 0, 0.12);
  --chip-bg: rgba(0, 0, 0, 0.03);
  --progress-track: rgba(0, 0, 0, 0.06);
  --import-bg: rgba(0, 0, 0, 0.02);
  --table-header-bg: rgba(0, 0, 0, 0.02);
  --table-row-hover: rgba(0, 0, 0, 0.02);
  --table-border: rgba(0, 0, 0, 0.06);
  --msg-sent-bg: #111111;
  --msg-sent-color: #ffffff;
  --msg-received-bg: #f0f0f0;
  --msg-received-color: #111111;
  --preview-bg: #f5f5f5;
  --preview-bg-img: none;
  --ink-contrast: #ffffff;
}

[data-theme="dark"] {
  --bg-gradient: linear-gradient(160deg, #0a0a0a 0%, #111111 40%, #0a0a0a 100%);
  --sidebar-bg: rgba(17, 17, 17, 0.9);
  --panel-bg: rgba(20, 20, 20, 0.7);
  --panel-border: rgba(255, 255, 255, 0.08);
  --ink: #eeeeee;
  --muted: #888888;
  --primary: #ffffff;
  --primary-dark: #cccccc;
  --primary-glow: rgba(255, 255, 255, 0.08);
  --accent: #aaaaaa;
  --accent-glow: rgba(255, 255, 255, 0.06);
  --danger: #ef4444;
  --warning: #f59e0b;
  --success: #22c55e;
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.3), 0 2px 8px rgba(0, 0, 0, 0.2);
  --shadow-lg: 0 20px 48px rgba(0, 0, 0, 0.5), 0 8px 24px rgba(0, 0, 0, 0.3);

  /* Dark theme component overrides */
  --input-bg: rgba(20, 20, 20, 0.8);
  --input-border: rgba(255, 255, 255, 0.1);
  --chip-bg: rgba(255, 255, 255, 0.05);
  --progress-track: rgba(255, 255, 255, 0.08);
  --import-bg: rgba(255, 255, 255, 0.03);
  --table-header-bg: rgba(20, 20, 20, 0.8);
  --table-row-hover: rgba(255, 255, 255, 0.03);
  --table-border: rgba(255, 255, 255, 0.06);
  --msg-sent-bg: #ffffff;
  --msg-sent-color: #111111;
  --msg-received-bg: rgba(30, 30, 30, 0.9);
  --msg-received-color: #eeeeee;
  --preview-bg: #151515;
  --preview-bg-img: none;
  --ink-contrast: #111111;
}

* {
  box-sizing: border-box;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--ink);
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.01em;
}

::selection {
  background: var(--primary);
  color: #fff;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
    filter: blur(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes slideInLeft {
  from {
    opacity: 0;
    transform: translateX(-12px);
    filter: blur(2px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
    filter: blur(0);
  }
}

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

.layout>section {
  animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.view-container.active > section:nth-child(1) { animation-delay: 0s; }
.view-container.active > section:nth-child(2) { animation-delay: 0.05s; }
.view-container.active > section:nth-child(3) { animation-delay: 0.1s; }
.view-container.active > section:nth-child(4) { animation-delay: 0.15s; }
.view-container.active > section:nth-child(5) { animation-delay: 0.2s; }

/* Glassmorphism Panel */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.6);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 24px;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.panel:hover {
  box-shadow: var(--shadow-lg);
}

/* ─── Sidebar Navigation ─────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px) saturate(1.8);
  -webkit-backdrop-filter: blur(24px) saturate(1.8);
  border-right: 1px solid var(--panel-border);
  padding: 24px 14px;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s ease;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding: 0 10px;
}

.sidebar-logo .brand-mark {
  width: 38px;
  height: 38px;
  font-size: 14px;
  border-radius: 12px;
}

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--panel-border) transparent;
}

.nav-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--primary);
  padding: 16px 14px 6px;
  opacity: 0.5;
  font-family: var(--font-mono);
  user-select: none;
  text-transform: uppercase;
}

.nav-section-label:first-child {
  padding-top: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  letter-spacing: -0.01em;
  position: relative;
}

.nav-item:hover {
  background: var(--primary-glow);
  color: var(--primary);
  transform: translateX(3px);
}

.nav-item.active {
  background: var(--ink);
  color: var(--ink-contrast);
  box-shadow: var(--shadow);
  font-weight: 600;
}

.nav-item i {
  font-size: 16px;
  width: 18px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--panel-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.sidebar-overlay.visible {
  display: block;
}

/* Hamburger button */
.hamburger-btn {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 1001;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  padding: 8px;
  cursor: pointer;
  color: var(--ink);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
}

.hamburger-btn:hover {
  box-shadow: var(--shadow);
}

/* ─── Main Content Layout ────────────────────────────── */
.layout {
  margin-left: var(--sidebar-width);
  padding: 28px 36px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: calc(100% - var(--sidebar-width));
}

.view-container {
  display: none;
  animation: fadeIn 0.4s ease forwards;
}

.view-container.active {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 16px;
}

/* ─── Header / Hero ──────────────────────────────────── */
.hero {
  grid-column: span 12;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.brand-section {
  flex: 1;
  min-width: 280px;
}

.brand-row {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 8px;
}

.brand-mark {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  background: var(--ink);
  color: var(--ink-contrast);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 24px;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
}

.brand-mark::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.1) 100%);
  border-radius: inherit;
}

.eyebrow {
  font-family: var(--font-mono);
  color: var(--primary);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 10px;
  margin: 0 0 6px;
  opacity: 0.85;
}

h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.03em;
  color: var(--ink);
  -webkit-text-fill-color: var(--ink);
}

h2 {
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.controls-section {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: flex-end;
}

/* ─── Theme Toggle ───────────────────────────────────── */
.theme-switch {
  position: relative;
  display: inline-block;
  width: 52px;
  height: 28px;
  flex-shrink: 0;
}

.theme-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 34px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

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

input:checked+.slider:before {
  transform: translateX(24px);
}

/* ─── Buttons ────────────────────────────────────────── */
.btn {
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  backdrop-filter: blur(8px);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  letter-spacing: -0.01em;
}

.btn:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
  box-shadow: var(--shadow-sm);
}

.btn.primary {
  background: var(--ink);
  color: var(--ink-contrast);
  border: none;
  box-shadow: var(--shadow);
}

.btn.primary:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.btn.accent {
  background: var(--muted);
  color: #fff;
  border: none;
  box-shadow: var(--shadow-sm);
}

.btn.accent:hover {
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.btn.danger {
  background: var(--danger);
  color: #fff;
  border: none;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  filter: grayscale(0.3);
}

/* ─── Inputs ─────────────────────────────────────────── */
label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-weight: 500;
  font-size: 13px;
  color: var(--ink);
  letter-spacing: -0.01em;
}

input,
textarea,
select {
  width: 100%;
  background: var(--input-bg);
  backdrop-filter: blur(8px);
  border: 1.5px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

select {
  cursor: pointer;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--input-bg);
}

input::placeholder,
textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* ─── Status Chips ────────────────────────────────────── */
.status-grid {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}

.status-chip {
  padding: 8px 16px;
  background: var(--chip-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: 99px;
  font-size: 12px;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
  letter-spacing: -0.02em;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.status-chip:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

/* ─── Config Forms ────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.span-2 {
  grid-column: span 2;
}

/* ─── Message Preview ─────────────────────────────────── */
.preview-container {
  background: var(--preview-bg);
  background-image: var(--preview-bg-img);
  background-size: cover;
  border-radius: var(--radius-md);
  padding: 20px;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--panel-border);
}

.msg-bubble {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  line-height: 1.5;
}

.msg-bubble.sent {
  background: var(--msg-sent-bg);
  color: var(--msg-sent-color);
  align-self: flex-end;
  border-top-right-radius: 2px;
}

.msg-bubble.received {
  background: var(--msg-received-bg);
  color: var(--msg-received-color);
  align-self: flex-start;
  border-top-left-radius: 2px;
}

/* ─── Dashboard Grid ──────────────────────────────────── */
.qr-panel {
  grid-column: span 4;
}

.config-panel {
  grid-column: span 8;
}

/* ─── Collapsible Settings Sections ───────────────────── */
.settings-section {
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
  background: var(--input-bg);
  backdrop-filter: blur(8px);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-section[open] {
  border-color: var(--ink);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), var(--shadow);
}

.settings-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  list-style: none;
  background: transparent;
  transition: all 0.2s ease;
  letter-spacing: -0.01em;
}

.settings-summary::-webkit-details-marker { display: none; }
.settings-summary::marker { content: ""; }

.settings-summary::after {
  content: "";
  margin-left: auto;
  width: 20px;
  height: 20px;
  background: var(--chip-bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), background 0.2s;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23777777' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
}

.settings-section[open] > .settings-summary::after {
  transform: rotate(90deg);
  background-color: var(--primary-glow);
}

.settings-summary:hover {
  background: var(--primary-glow);
}

.settings-summary svg,
.settings-summary i {
  width: 18px;
  height: 18px;
  color: var(--primary);
}

.settings-body {
  padding: 16px 18px 20px;
  border-top: 1px solid var(--panel-border);
}

.reports-panel,
.logs-panel,
.custom-panel {
  grid-column: span 12;
}

.qr-box {
  background: var(--input-bg);
  border: 1px solid var(--panel-border);
  padding: 20px;
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  min-height: 300px;
  justify-content: center;
}

.qr-box img {
  max-width: 100%;
  border-radius: 8px;
}

/* ─── Progress Bar ────────────────────────────────────── */
.progress-wrapper {
  margin: 10px 0;
  background: var(--progress-track);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--ink);
  width: 0%;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 99px;
}

/* ─── Import Box ──────────────────────────────────────── */
.import-box {
  background: var(--import-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 20px;
}

/* ─── Auth ────────────────────────────────────────────── */
.auth-shell {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  animation: fadeIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(24px) saturate(1.8);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-message {
  color: var(--danger);
  font-size: 13px;
  min-height: 20px;
  text-align: center;
  font-weight: 500;
}

.auth-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ─── Leads Dashboard ─────────────────────────────────── */
.lead-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: var(--ink);
  border-radius: 0 2px 2px 0;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--ink);
}

.kpi-value {
  font-size: 28px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--ink);
  letter-spacing: -0.03em;
  line-height: 1;
}

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

.lead-charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

.lead-chart-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 24px;
  max-height: 320px;
  display: flex;
  flex-direction: column;
}

.lead-chart-panel canvas {
  max-height: 240px;
  width: 100% !important;
  height: auto !important;
}

.lead-chart-panel h4 {
  margin: 0 0 16px 0;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

@media (max-width: 768px) {
  .lead-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .lead-charts-row {
    grid-template-columns: 1fr;
  }
}

/* ─── Data Table (Leads) ──────────────────────────────── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead {
  background: var(--table-header-bg);
  position: sticky;
  top: 0;
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid var(--table-border);
  white-space: nowrap;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--table-border);
  color: var(--ink);
  vertical-align: top;
}

.data-table tbody tr {
  transition: background-color 0.15s ease;
}

.data-table tbody tr:hover {
  background: var(--table-row-hover);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* Lead status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-family: var(--font-mono);
  white-space: nowrap;
}

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

.status-hot {
  background: rgba(0, 0, 0, 0.08);
  color: #111;
  border: 1.5px solid #111;
  font-weight: 800;
}

[data-theme="dark"] .status-hot {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: #fff;
}

.status-warm {
  background: rgba(0, 0, 0, 0.05);
  color: #555;
  border: 1.5px solid #888;
}

[data-theme="dark"] .status-warm {
  background: rgba(255, 255, 255, 0.06);
  color: #ccc;
  border-color: #888;
}

.status-cold {
  background: transparent;
  color: #999;
  border: 1.5px solid #ccc;
}

[data-theme="dark"] .status-cold {
  background: transparent;
  color: #777;
  border-color: #555;
}

.reason-cell {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  color: var(--muted);
  max-width: 280px;
  line-height: 1.5;
}

/* ─── Muted helper ────────────────────────────────────── */
.muted {
  color: var(--muted);
}

/* ─── User info ───────────────────────────────────────── */
.user-info {
  padding: 0 12px;
}

/* ─── Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {

  .qr-panel,
  .config-panel {
    grid-column: span 12;
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 280px;
  }

  .hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    transform: translateX(-100%);
    box-shadow: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    will-change: transform;
    z-index: 1000;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  .layout {
    margin-left: 0;
    width: 100%;
    padding: 24px 16px;
    padding-top: 64px;
  }

  .hero {
    flex-direction: column;
    gap: 16px;
  }

  .controls-section {
    align-items: flex-start;
    width: 100%;
  }
}

@media (max-width: 640px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .span-2 {
    grid-column: span 1;
  }

  h1 {
    font-size: 24px;
  }

  .layout {
    padding: 16px 12px;
    padding-top: 64px;
    gap: 20px;
  }

  .panel {
    padding: 16px;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   Automation Hub Styles
   ═══════════════════════════════════════════════════════════════════════════ */

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

.automation-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.automation-card.enabled {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary-glow);
}
.automation-card .toggle-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.toggle-switch input[type="checkbox"] {
  display: none;
}
.toggle-slider {
  position: relative;
  width: 44px;
  height: 24px;
  background: var(--panel-border);
  border-radius: 12px;
  transition: background 0.25s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.25s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
input[type="checkbox"]:checked + .toggle-slider {
  background: var(--primary);
}
input[type="checkbox"]:checked + .toggle-slider::after {
  transform: translateX(20px);
}
.toggle-status-label {
  font-weight: 600;
  min-width: 24px;
}
.toggle-status-label.on  { color: var(--primary); }
.toggle-status-label.off { color: var(--muted); }

/* Master toggle buttons */
.agent-master-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.agent-master-controls .btn {
  font-size: 13px;
  padding: 6px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#automationView .panel {
  margin-bottom: 20px;
}

#automationView h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

#automationView .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

#abTestForm textarea,
#objectionTestForm textarea {
  width: 100%;
  min-height: 80px;
  resize: vertical;
  font-family: var(--font-main);
  font-size: 13px;
  padding: 10px;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  background: var(--input-bg);
  color: var(--ink);
}

#digestPreview {
  display: none;
  margin-top: 12px;
  padding: 12px;
  background: var(--import-bg);
  border-radius: var(--radius-sm);
  white-space: pre-wrap;
  font-size: 13px;
  max-height: 320px;
  overflow-y: auto;
}

@media (max-width: 768px) {
  .automation-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ANALYTICS DASHBOARD
   ═══════════════════════════════════════════════════════════════════════════ */

.analytics-section {
  padding: 24px;
}

.analytics-section-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
}

/* ── Card grid layouts ──────────────────────────────────── */
.analytics-grid {
  display: grid;
  gap: 16px;
}

.analytics-grid-3 { grid-template-columns: repeat(3, 1fr); }
.analytics-grid-4 { grid-template-columns: repeat(4, 1fr); }
.analytics-grid-5 { grid-template-columns: repeat(5, 1fr); }
.analytics-grid-6 { grid-template-columns: repeat(6, 1fr); }

.analytics-card {
  background: var(--chip-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.analytics-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--ink);
  opacity: 0;
  transition: opacity 0.2s;
}

.analytics-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--ink);
}

.analytics-card:hover::before {
  opacity: 1;
}

.analytics-card-sm {
  padding: 14px 12px;
}

.analytics-card-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.analytics-card-value {
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1.1;
}

/* ── Daily volume chart ─────────────────────────────────── */
.daily-volume-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 120px;
  padding: 0 4px;
  overflow-x: auto;
}

.daily-volume-bar-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
  min-width: 28px;
}

.daily-volume-bar-stack {
  display: flex;
  flex-direction: column-reverse;
  width: 100%;
  border-radius: 4px 4px 0 0;
  overflow: hidden;
}

.daily-volume-bar-stack .bar-segment {
  width: 100%;
  min-height: 0;
  transition: height 0.3s ease;
}

.daily-volume-bar-group .bar-label {
  font-size: 9px;
  color: var(--muted);
  white-space: nowrap;
  margin-top: 4px;
}

.daily-volume-legend {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
}

.legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}

/* ── Lead funnel ────────────────────────────────────────── */
.funnel-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.funnel-label {
  font-size: 12px;
  color: var(--muted);
  min-width: 80px;
  text-align: right;
  font-weight: 500;
}

.funnel-bar-bg {
  flex: 1;
  height: 28px;
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
}

.funnel-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  padding: 0 8px;
  min-width: fit-content;
}

.funnel-bar-fill span {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ── Temperature bars ───────────────────────────────────── */
.temp-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

.temp-icon {
  font-size: 18px;
  min-width: 24px;
  text-align: center;
}

.temp-bar-bg {
  flex: 1;
  height: 22px;
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.temp-bar-fill {
  height: 100%;
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.temp-bar-fill span {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

.temp-count {
  font-size: 14px;
  font-weight: 700;
  font-family: var(--font-mono);
  min-width: 30px;
  text-align: right;
}

/* ── Activity by source ─────────────────────────────────── */
.source-breakdown {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.source-label {
  font-size: 12px;
  min-width: 100px;
  text-align: right;
  color: var(--ink);
  font-weight: 500;
  font-family: var(--font-mono);
}

.source-bar-bg {
  flex: 1;
  height: 22px;
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.source-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: var(--radius-sm);
  transition: width 0.5s ease;
  display: flex;
  align-items: center;
  padding: 0 8px;
}

.source-bar-fill span {
  font-size: 11px;
  font-weight: 600;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* ── Top tags list ──────────────────────────────────────── */
.top-tags-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

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

.tag-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  background: var(--primary);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  min-width: 60px;
  text-align: center;
}

.tag-pct {
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--ink);
}

.tag-bar-bg {
  flex: 1;
  height: 8px;
  background: var(--chip-bg);
  border-radius: 4px;
  overflow: hidden;
}

.tag-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ── Scoring insight box ────────────────────────────────── */
.analytics-insight {
  padding: 10px 14px;
  background: var(--import-bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--ink);
  border-left: 3px solid var(--primary);
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 1024px) {
  .analytics-grid-5 { grid-template-columns: repeat(3, 1fr); }
  .analytics-grid-6 { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
  .analytics-grid-3,
  .analytics-grid-4,
  .analytics-grid-5,
  .analytics-grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }
  .analytics-card-value { font-size: 22px; }
  .daily-volume-chart { height: 80px; }
  #analyticsView .analytics-section[style*="span 7"],
  #analyticsView .analytics-section[style*="span 5"],
  #analyticsView .analytics-section[style*="span 6"] {
    grid-column: span 12 !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   LIVE CHAT / HUMAN TAKEOVER
   ═══════════════════════════════════════════════════════════════════════════ */

/* Takeover cards */
.takeover-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--chip-bg);
  backdrop-filter: blur(8px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  margin-bottom: 10px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.takeover-card:hover {
  box-shadow: var(--shadow);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.takeover-info {
  flex: 1;
  min-width: 0;
}

.takeover-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-left: 12px;
}

/* Chat bubbles */
.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
  word-wrap: break-word;
  position: relative;
}

.chat-in {
  align-self: flex-start;
  background: var(--chip-bg);
  border: 1px solid var(--panel-border);
  border-bottom-left-radius: 4px;
  color: var(--ink);
}

.chat-out {
  align-self: flex-end;
  background: var(--ink);
  color: var(--ink-contrast);
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-sm);
}

.chat-bubble-text {
  white-space: pre-wrap;
}

.chat-bubble-time {
  display: block;
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.6;
  text-align: right;
}

.chat-in .chat-bubble-time {
  color: var(--muted);
}

/* Smart Reply Suggestion Buttons */
.smart-reply-btn {
  padding: 8px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--bg-secondary, var(--input-bg));
  backdrop-filter: blur(8px);
  color: var(--ink);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  max-width: 300px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}
.smart-reply-btn:hover {
  background: var(--ink);
  color: var(--ink-contrast);
  border-color: transparent;
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}
.smart-reply-btn .sr-type {
  display: inline-block;
  font-size: 9px;
  text-transform: uppercase;
  opacity: 0.6;
  margin-right: 4px;
  vertical-align: middle;
}

/* Knowledge Base Document Card */
.kb-doc-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  background: var(--input-bg);
  transition: border-color 0.2s;
}
.kb-doc-card:hover {
  border-color: var(--primary);
}
.kb-doc-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}
.kb-doc-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}
.kb-doc-details {
  min-width: 0;
}
.kb-doc-details .kb-doc-name {
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kb-doc-details .kb-doc-meta {
  font-size: 11px;
  color: var(--muted-ink, var(--muted));
  margin-top: 2px;
}

/* Heatmap cell */
.heatmap-cell {
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: var(--ink);
  min-height: 24px;
  transition: transform 0.15s;
}
.heatmap-cell:hover {
  transform: scale(1.2);
  z-index: 1;
}

/* Live chat section responsive */
@media (max-width: 768px) {
  #livechatView .panel[style*="span 4"],
  #livechatView .panel[style*="span 8"] {
    grid-column: span 12 !important;
  }
  .chat-bubble { max-width: 90%; }
}

/* ═══════════════════════════════════════════════════════════════════════════
   BILLING & PLANS
   ═══════════════════════════════════════════════════════════════════════════ */

.status-badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
}
.badge-green {
  background: rgba(0, 0, 0, 0.05);
  color: #16a34a;
}
.badge-yellow {
  background: rgba(0, 0, 0, 0.05);
  color: #d97706;
}
.badge-red {
  background: rgba(0, 0, 0, 0.05);
  color: #dc2626;
}
[data-theme="dark"] .badge-green {
  background: rgba(255, 255, 255, 0.06);
  color: #22c55e;
}
[data-theme="dark"] .badge-yellow {
  background: rgba(255, 255, 255, 0.06);
  color: #f59e0b;
}
[data-theme="dark"] .badge-red {
  background: rgba(255, 255, 255, 0.06);
  color: #ef4444;
}

/* Usage meter cards */
.usage-meter-card {
  background: var(--chip-bg);
  border-radius: var(--radius-sm);
  padding: 16px;
  border: 1px solid var(--panel-border);
}

.usage-bar-track {
  width: 100%;
  height: 8px;
  background: var(--progress-track);
  border-radius: 4px;
  overflow: hidden;
}

.usage-bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.6s ease;
}

/* Plan cards */
.plan-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.plan-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.plan-card-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Feature comparison table */
.billing-feature-table th {
  background: var(--chip-bg);
  font-weight: 600;
}

.billing-feature-table td,
.billing-feature-table th {
  padding: 8px 12px;
  border-bottom: 1px solid var(--panel-border);
}

.billing-feature-table tr:hover td {
  background: var(--chip-bg);
}

/* Billing view responsive */
@media (max-width: 768px) {
  #billingPlanCards {
    grid-template-columns: 1fr !important;
  }
  #billingUsageMeters {
    grid-template-columns: 1fr !important;
  }
}

/* ═══════════════════════════════════════════════════════════════════════════
   ADMIN PANEL
   ═══════════════════════════════════════════════════════════════════════════ */

.admin-kpi-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  padding: 20px;
  transition: transform 0.15s;
}

.admin-kpi-card:hover {
  transform: translateY(-2px);
}

.admin-table th {
  background: var(--chip-bg);
  font-weight: 600;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--panel-border);
  white-space: nowrap;
}

.admin-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  vertical-align: middle;
}

.admin-table tr:hover td {
  background: var(--chip-bg);
}

/* Admin nav item special styling */
#adminNavItem {
  border-top: 1px solid var(--panel-border);
  margin-top: 4px;
  padding-top: 12px;
}

@media (max-width: 768px) {
  #adminKpis {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}