:root {
  /* Design Tokens - Light Theme */
  --bg-gradient: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
  --sidebar-bg: #ffffff;
  --panel-bg: rgba(255, 255, 255, 0.85);
  --panel-border: rgba(226, 232, 240, 0.8);
  --ink: #0f172a;
  --muted: #64748b;
  --primary: #10b981;
  --primary-dark: #059669;
  --primary-glow: rgba(16, 185, 129, 0.15);
  --accent: #6366f1;
  --danger: #ef4444;
  --glass-blur: 16px;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.15), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --font-main: "Space Grotesk", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
  --sidebar-width: 280px;

  /* Thematic component variables */
  --input-bg: #ffffff;
  --input-border: rgba(226, 232, 240, 0.9);
  --chip-bg: rgba(241, 245, 249, 0.9);
  --progress-track: rgba(0, 0, 0, 0.08);
  --import-bg: rgba(241, 245, 249, 0.7);
  --table-header-bg: rgba(248, 250, 252, 0.9);
  --table-row-hover: rgba(16, 185, 129, 0.04);
  --table-border: rgba(226, 232, 240, 0.7);
  --msg-sent-bg: #dcf8c6;
  --msg-sent-color: #1a2e1a;
  --msg-received-bg: #ffffff;
  --msg-received-color: #1a1a1a;
  --preview-bg: #e5ddd5;
  --preview-bg-img: url("https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png");
}

[data-theme="dark"] {
  --bg-gradient: linear-gradient(135deg, #020617 0%, #0f172a 100%);
  --sidebar-bg: #1e293b;
  --panel-bg: rgba(30, 41, 59, 0.75);
  --panel-border: rgba(255, 255, 255, 0.08);
  --ink: #f1f5f9;
  --muted: #94a3b8;
  --primary: #34d399;
  --primary-dark: #10b981;
  --primary-glow: rgba(52, 211, 153, 0.2);
  --accent: #818cf8;
  --danger: #f87171;
  --shadow-sm: 0 1px 3px 0 rgba(0, 0, 0, 0.4), 0 1px 2px -1px rgba(0, 0, 0, 0.3);
  --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.35), 0 4px 6px -4px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 25px 30px -8px rgba(0, 0, 0, 0.5), 0 10px 15px -6px rgba(0, 0, 0, 0.4);

  /* Dark theme component overrides */
  --input-bg: rgba(15, 23, 42, 0.8);
  --input-border: rgba(255, 255, 255, 0.12);
  --chip-bg: rgba(255, 255, 255, 0.06);
  --progress-track: rgba(255, 255, 255, 0.1);
  --import-bg: rgba(255, 255, 255, 0.04);
  --table-header-bg: rgba(15, 23, 42, 0.6);
  --table-row-hover: rgba(52, 211, 153, 0.06);
  --table-border: rgba(255, 255, 255, 0.07);
  --msg-sent-bg: #1a3a2a;
  --msg-sent-color: #a8e6c1;
  --msg-received-bg: #1e293b;
  --msg-received-color: #e2e8f0;
  --preview-bg: #1a1f2e;
  --preview-bg-img: none;
}

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

body {
  margin: 0;
  font-family: var(--font-main);
  color: var(--ink);
  background: var(--bg-gradient);
  background-attachment: fixed;
  min-height: 100vh;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

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

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

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

.layout>section {
  animation: fadeIn 0.5s ease out forwards;
}

/* Glassmorphism Panel */
.panel {
  background: var(--panel-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 24px;
}

/* ─── Sidebar Navigation ─────────────────────────────── */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--panel-border);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

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

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

.nav-links {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  color: var(--muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 15px;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  font-family: inherit;
  letter-spacing: 0.01em;
}

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

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

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

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

/* 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: 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 32px;
  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: 24px;
}

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

.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: linear-gradient(135deg, var(--primary), var(--accent));
  color: #fff;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 24px;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 15px var(--primary-glow);
  flex-shrink: 0;
}

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

h1 {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  line-height: 1.2;
}

h2 {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 600;
}

.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: 14px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--ink);
  border-radius: var(--radius-md);
  padding: 10px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
}

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

.btn:active {
  transform: translateY(0);
}

.btn.primary {
  background: var(--primary);
  color: #fff;
  border: none;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.btn.primary:hover {
  background: var(--primary-dark);
  box-shadow: 0 6px 16px var(--primary-glow);
}

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

.btn.accent:hover {
  opacity: 0.9;
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── Inputs ─────────────────────────────────────────── */
label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 500;
  font-size: 14px;
  color: var(--ink);
}

input,
textarea,
select {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: var(--radius-md);
  padding: 11px 14px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

select {
  cursor: pointer;
}

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

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: 6px 14px;
  background: var(--chip-bg);
  border: 1px solid var(--panel-border);
  border-radius: 99px;
  font-size: 13px;
  font-family: var(--font-mono);
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--ink);
}

.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: 20px;
}

.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;
}

.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: linear-gradient(90deg, var(--primary), var(--accent));
  width: 0%;
  transition: width 0.3s ease;
  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 ease;
}

.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;
}

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

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

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

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

.data-table td {
  padding: 14px 20px;
  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(239, 68, 68, 0.12);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .status-hot {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.25);
}

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

[data-theme="dark"] .status-warm {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.25);
}

.status-cold {
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
  border: 1px solid rgba(99, 102, 241, 0.2);
}

[data-theme="dark"] .status-cold {
  background: rgba(129, 140, 248, 0.15);
  color: #818cf8;
  border-color: rgba(129, 140, 248, 0.25);
}

.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 {
    transform: translateX(-100%);
    box-shadow: none;
  }

  .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;
  }
}