/* ================================================================
   Lion Zap — Design System v3
   Clean · Minimal · Dark & Light Mode · Responsive
   ================================================================ */

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

/* ================================================================
   CSS VARIABLES — Dark Mode (default)
   ================================================================ */
:root {
  /* Backgrounds */
  --bg-base: #0d0d0d;
  --bg-surface: #141414;
  --bg-card: #1a1a1a;
  --bg-card-hover: #212121;
  --bg-input: #111111;
  --bg-overlay: rgba(0, 0, 0, 0.75);

  /* Primary — Emerald (WhatsApp vibe) */
  --primary: #10b981;
  --primary-hover: #0ea572;
  --primary-dim: rgba(16, 185, 129, 0.12);
  --primary-glow: rgba(16, 185, 129, 0.25);

  /* Semantic */
  --success: #22c55e;
  --success-dim: rgba(34, 197, 94, 0.12);
  --warning: #f59e0b;
  --warning-dim: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-dim: rgba(239, 68, 68, 0.12);
  --info: #3b82f6;
  --info-dim: rgba(59, 130, 246, 0.12);

  /* Accent for AI/bots */
  --accent: #8b5cf6;
  --accent-dim: rgba(139, 92, 246, 0.12);

  /* Teal */
  --teal: #06b6d4;
  --teal-dim: rgba(6, 182, 212, 0.12);

  /* Orange */
  --orange: #f97316;
  --orange-dim: rgba(249, 115, 22, 0.12);

  /* Text */
  --text-primary: #f5f5f5;
  --text-secondary: #a3a3a3;
  --text-muted: #525252;
  --text-inverse: #0d0d0d;

  /* Border */
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --border-focus: var(--primary);

  /* Sidebar */
  --sidebar-w: 248px;
  --sidebar-bg: #0d0d0d;
  --sidebar-border: rgba(255, 255, 255, 0.07);

  /* Radius */
  --r-xs: 4px;
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 28px;
  --r-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.6);
  --shadow-glow: 0 0 20px var(--primary-glow);

  /* Transition */
  --t-fast: 0.15s ease;
  --t-base: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --t-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-heading: 'Sora', 'Inter', sans-serif;
}

/* ================================================================
   LIGHT MODE
   ================================================================ */
[data-theme="light"] {
  --bg-base: #f8fafc;
  --bg-surface: #ffffff;
  --bg-card: #ffffff;
  --bg-card-hover: #f1f5f9;
  --bg-input: #f8fafc;
  --bg-overlay: rgba(0, 0, 0, 0.5);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --border: rgba(0, 0, 0, 0.08);
  --border-strong: rgba(0, 0, 0, 0.16);

  --sidebar-bg: #ffffff;
  --sidebar-border: rgba(0, 0, 0, 0.07);

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.5;
  transition: background var(--t-slow), color var(--t-slow);
}

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

a:hover {
  color: var(--primary-hover);
}

img {
  max-width: 100%;
  display: block;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

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

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--r-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ================================================================
   LAYOUT
   ================================================================ */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--t-slow), background var(--t-slow);
}

.main-content {
  margin-left: var(--sidebar-w);
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-slow);
}

.page-wrapper {
  padding: 1.6rem 2rem 3rem;
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
}

/* ================================================================
   SIDEBAR
   ================================================================ */
.sidebar-logo {
  padding: 1.4rem 1.2rem 1rem;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo a {
  display: flex;
  align-items: center;
  gap: .75rem;
  text-decoration: none;
  color: inherit;
}

.sidebar-logo-icon {
  width: 38px;
  height: 38px;
  background: var(--primary);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px var(--primary-glow);
}

.sidebar-logo-icon svg {
  width: 22px;
  height: 22px;
  color: white;
}

.sidebar-logo-text strong {
  font-family: var(--font-heading);
  font-size: .95rem;
  font-weight: 700;
  display: block;
  color: var(--text-primary);
}

.sidebar-logo-text span {
  font-size: .68rem;
  color: var(--text-muted);
  font-weight: 400;
}

/* Nav sections */
.sidebar-nav {
  flex: 1;
  padding: .8rem .8rem 0;
  overflow-y: auto;
}

.sidebar-section {
  margin-bottom: .2rem;
}

.sidebar-section-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: .8rem .7rem .3rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .8rem;
  border-radius: var(--r-md);
  color: var(--text-secondary);
  font-size: .845rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-base);
  margin-bottom: 1px;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

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

.nav-item.active .nav-icon {
  color: var(--primary);
}

.nav-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color var(--t-fast);
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  stroke-width: 2;
}

.nav-item:hover .nav-icon {
  color: var(--text-primary);
}

.nav-badge {
  margin-left: auto;
  background: var(--primary);
  color: white;
  font-size: .58rem;
  font-weight: 700;
  padding: .1rem .4rem;
  border-radius: var(--r-full);
  line-height: 1.6;
}

/* Admin section separator */
.nav-separator {
  height: 1px;
  background: var(--border);
  margin: .8rem .7rem;
}

.sidebar-admin-label {
  font-size: .6rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--warning);
  padding: .4rem .7rem .3rem;
}

/* Sidebar footer */
.sidebar-footer {
  padding: .8rem;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: .65rem;
  padding: .55rem .6rem;
  border-radius: var(--r-md);
  transition: background var(--t-fast);
}

.sidebar-user:hover {
  background: var(--bg-card-hover);
}

.sidebar-avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  color: white;
  flex-shrink: 0;
}

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

.sidebar-user-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: .65rem;
  color: var(--text-muted);
  margin-top: 1px;
}

.sidebar-logout {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--t-fast);
  flex-shrink: 0;
}

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

.sidebar-logout svg {
  width: 15px;
  height: 15px;
}

/* ================================================================
   TOPBAR
   ================================================================ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0;
  margin-bottom: 1.6rem;
  gap: 1rem;
}

/* Topbar left side content */

.page-title {
  font-family: var(--font-heading);
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: .8rem;
  color: var(--text-secondary);
  margin-top: 3px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: .6rem;
}

/* Theme Toggle Button */
.btn-theme-toggle {
  width: 38px;
  height: 38px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  font-size: .9rem;
}

.btn-theme-toggle:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

/* Mobile toggle: sun = show in dark, moon = show in light */
.icon-sun {
  display: block;
}

.icon-moon {
  display: none;
}

[data-theme="light"] .icon-sun {
  display: none;
}

[data-theme="light"] .icon-moon {
  display: block;
}

/* ================================================================
   CARDS
   ================================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.4rem;
  transition: border-color var(--t-base), box-shadow var(--t-base), background var(--t-slow);
}

.card:hover {
  border-color: var(--border-strong);
}

/* ================================================================
   STAT CARDS
   ================================================================ */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.3rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: all var(--t-base);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.stat-icon.green {
  background: var(--success-dim);
  color: var(--success);
}

.stat-icon.blue {
  background: var(--info-dim);
  color: var(--info);
}

.stat-icon.orange {
  background: var(--orange-dim);
  color: var(--orange);
}

.stat-icon.red {
  background: var(--danger-dim);
  color: var(--danger);
}

.stat-icon.violet {
  background: var(--accent-dim);
  color: var(--accent);
}

.stat-icon.teal {
  background: var(--teal-dim);
  color: var(--teal);
}

.stat-icon.primary {
  background: var(--primary-dim);
  color: var(--primary);
}

.stat-body {
  flex: 1;
  min-width: 0;
}

.stat-label {
  font-size: .72rem;
  color: var(--text-secondary);
  margin-bottom: 3px;
  font-weight: 500;
}

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

/* stat color helpers */
.stat-value.c-green {
  color: var(--success);
}

.stat-value.c-orange {
  color: var(--warning);
}

.stat-value.c-red {
  color: var(--danger);
}

/* ================================================================
   GRIDS
   ================================================================ */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

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

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

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

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

@media (max-width: 900px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* ================================================================
   BUTTONS
   ================================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: var(--r-sm);
  font-family: var(--font-body);
  font-size: .835rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--t-fast);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1;
  position: relative;
  overflow: hidden;
}

.btn svg {
  width: 15px;
  height: 15px;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  color: white;
  box-shadow: 0 4px 16px var(--primary-glow);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, .2);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, .2);
  color: var(--danger);
}

.btn-success {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, .2);
}

.btn-success:hover {
  background: rgba(34, 197, 94, .2);
  color: var(--success);
}

.btn-warning {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, .2);
}

.btn-warning:hover {
  background: rgba(245, 158, 11, .2);
  color: var(--warning);
}

.btn-sm {
  padding: .35rem .75rem;
  font-size: .75rem;
}

.btn-lg {
  padding: .75rem 1.6rem;
  font-size: .925rem;
}

.btn-xl {
  padding: .9rem 2rem;
  font-size: 1rem;
}

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

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

.w-100 {
  width: 100%;
}

/* ================================================================
   FORMS
   ================================================================ */
.form-group {
  margin-bottom: 1.1rem;
}

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

.form-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: .875rem;
  padding: .6rem .9rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-slow);
  outline: none;
  appearance: none;
  -webkit-appearance: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: var(--bg-input);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-control:disabled {
  opacity: .5;
  cursor: not-allowed;
}

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

select.form-control {
  cursor: pointer;
}

.form-hint {
  font-size: .7rem;
  color: var(--text-muted);
  margin-top: .3rem;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .8rem;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .8rem;
}

/* Input group (icon prefix/suffix) */
.input-group {
  position: relative;
}

.input-group .form-control {
  padding-left: 2.4rem;
}

.input-group-icon {
  position: absolute;
  left: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.input-group-icon svg {
  width: 16px;
  height: 16px;
}

.input-group-suffix {
  position: absolute;
  right: .75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  display: flex;
  transition: color var(--t-fast);
}

.input-group-suffix:hover {
  color: var(--text-primary);
}

.input-group-suffix svg {
  width: 16px;
  height: 16px;
}

.input-group .form-control.has-suffix {
  padding-right: 2.5rem;
}

/* Range sliders */
input[type="range"] {
  width: 100%;
  accent-color: var(--primary);
  cursor: pointer;
  height: 4px;
}

/* Toggles */
.toggle-group {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: .8rem;
}

.toggle-label {
  font-size: .85rem;
  color: var(--text-secondary);
  flex: 1;
}

.toggle {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
}

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

.toggle-slider {
  position: absolute;
  inset: 0;
  background: var(--bg-card-hover);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  cursor: pointer;
  transition: all var(--t-base);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  left: 3px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  background: var(--text-muted);
  border-radius: 50%;
  transition: all var(--t-base);
}

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

.toggle input:checked+.toggle-slider::before {
  transform: translate(18px, -50%);
  background: white;
}

/* ================================================================
   BADGES
   ================================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: var(--r-full);
  font-size: .68rem;
  font-weight: 700;
  line-height: 1;
}

.badge-connected {
  background: var(--success-dim);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, .2);
}

.badge-connecting {
  background: var(--warning-dim);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, .2);
}

.badge-disconnected {
  background: var(--danger-dim);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, .2);
}

.badge-blue {
  background: var(--info-dim);
  color: var(--info);
  border: 1px solid rgba(59, 130, 246, .2);
}

.badge-violet {
  background: var(--accent-dim);
  color: var(--accent);
  border: 1px solid rgba(139, 92, 246, .2);
}

.badge-primary {
  background: var(--primary-dim);
  color: var(--primary);
  border: 1px solid rgba(16, 185, 129, .2);
}

.badge-orange {
  background: var(--orange-dim);
  color: var(--orange);
  border: 1px solid rgba(249, 115, 22, .2);
}

.badge-dot::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ================================================================
   TABLES
   ================================================================ */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  width: 100%;
  min-width: 0;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  background: var(--bg-surface);
  font-size: .68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-muted);
  padding: .75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border);
  transition: background var(--t-fast);
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody td {
  padding: .85rem 1rem;
  font-size: .845rem;
  color: var(--text-secondary);
  vertical-align: middle;
}

tbody td:first-child {
  color: var(--text-primary);
  font-weight: 500;
}

/* ================================================================
   MODALS
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-base);
  padding: 1rem;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-xl);
  padding: 1.8rem;
  width: min(560px, 95vw);
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(.96) translateY(8px);
  transition: transform var(--t-base);
  box-shadow: var(--shadow-lg);
}

.modal-overlay.open .modal {
  transform: scale(1) translateY(0);
}

.modal-lg {
  width: min(800px, 95vw);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.4rem;
}

.modal-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  font-size: 1.1rem;
}

.modal-close:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .6rem;
  margin-top: 1.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
}

/* ================================================================
   SECTION HEADERS
   ================================================================ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
}

.section-title {
  font-family: var(--font-heading);
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* ================================================================
   PROGRESS BAR
   ================================================================ */
.progress-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: var(--r-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--primary);
  border-radius: var(--r-full);
  transition: width .5s ease;
}

/* ================================================================
   QR CODE
   ================================================================ */
.qr-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
}

.qr-wrapper img {
  width: 220px;
  height: 220px;
  border-radius: var(--r-md);
  border: 3px solid var(--primary);
  box-shadow: 0 0 24px var(--primary-glow);
}

.qr-instruction {
  font-size: .85rem;
  color: var(--text-secondary);
  text-align: center;
}

.paircode-display {
  font-size: 2rem;
  font-weight: 800;
  letter-spacing: .2em;
  color: var(--primary);
  text-align: center;
  padding: 1rem 1.5rem;
  background: var(--primary-dim);
  border-radius: var(--r-md);
  border: 1px solid rgba(16, 185, 129, .2);
}

/* ================================================================
   INSTANCE CARDS
   ================================================================ */
.instance-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 1.3rem;
  transition: all var(--t-base);
  display: flex;
  flex-direction: column;
  gap: .9rem;
  border-left: 3px solid transparent;
}

.instance-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.instance-card.connected {
  border-left-color: var(--success);
}

.instance-card.connecting {
  border-left-color: var(--warning);
}

.instance-card.disconnected {
  border-left-color: var(--danger);
}

.instance-header {
  display: flex;
  align-items: center;
  gap: .8rem;
}

.instance-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  flex-shrink: 0;
  overflow: hidden;
  color: white;
}

.instance-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.instance-name {
  font-weight: 600;
  font-size: .9rem;
}

.instance-phone {
  font-size: .75rem;
  color: var(--text-muted);
}

.instance-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}

/* ================================================================
   TOASTS
   ================================================================ */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.toast {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .8rem 1.2rem;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  font-size: .835rem;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  min-width: 240px;
  max-width: 360px;
  animation: toast-in .25s ease;
  color: var(--text-primary);
}

.toast.success {
  border-left: 3px solid var(--success);
}

.toast.error {
  border-left: 3px solid var(--danger);
}

.toast.info {
  border-left: 3px solid var(--info);
}

.toast.warning {
  border-left: 3px solid var(--warning);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(1.5rem);
  }
}

/* ================================================================
   LOADERS
   ================================================================ */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}

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

.skeleton {
  background: linear-gradient(90deg,
      var(--bg-card-hover) 25%,
      var(--border-strong) 50%,
      var(--bg-card-hover) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--r-sm);
}

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

  100% {
    background-position: -200% 0;
  }
}

/* ================================================================
   UTILITIES
   ================================================================ */
.divider {
  height: 1px;
  background: var(--border);
  margin: 1.2rem 0;
}

.text-primary {
  color: var(--text-primary) !important;
}

.text-secondary {
  color: var(--text-secondary) !important;
}

.text-muted {
  color: var(--text-muted) !important;
}

.text-success {
  color: var(--success) !important;
}

.text-danger {
  color: var(--danger) !important;
}

.text-warning {
  color: var(--warning) !important;
}

.text-info {
  color: var(--info) !important;
}

.text-primary-c {
  color: var(--primary) !important;
}

/* legacy compat */
.text-green {
  color: var(--success) !important;
}

.text-red {
  color: var(--danger) !important;
}

.text-yellow {
  color: var(--warning) !important;
}

.text-accent {
  color: var(--primary) !important;
}

.text-sm {
  font-size: .8rem;
}

.text-xs {
  font-size: .7rem;
}

.fw-500 {
  font-weight: 500;
}

.fw-600 {
  font-weight: 600;
}

.fw-700 {
  font-weight: 700;
}

.fw-800 {
  font-weight: 800;
}

.d-flex {
  display: flex;
}

.align-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.flex-1 {
  flex: 1;
}

.gap-1 {
  gap: .4rem;
}

.gap-2 {
  gap: .8rem;
}

.gap-3 {
  gap: 1.2rem;
}

.mb-1 {
  margin-bottom: .4rem;
}

.mb-2 {
  margin-bottom: .8rem;
}

.mb-3 {
  margin-bottom: 1.2rem;
}

.mb-4 {
  margin-bottom: 1.8rem;
}

.mt-1 {
  margin-top: .4rem;
}

.mt-2 {
  margin-top: .8rem;
}

.mt-3 {
  margin-top: 1.2rem;
}

.ms-auto {
  margin-left: auto;
}

.truncate {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* ================================================================
   API WARNING BANNER
   ================================================================ */
.api-warning {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .5rem .8rem;
  background: var(--danger-dim);
  border: 1px solid rgba(239, 68, 68, .2);
  border-radius: var(--r-sm);
  font-size: .75rem;
  color: var(--danger);
  margin-bottom: .6rem;
  text-decoration: none;
}

/* ================================================================
   MOBILE SIDEBAR TOGGLE
   ================================================================ */
.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: .9rem;
  left: .9rem;
  z-index: 150;
  width: 40px;
  height: 40px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: all var(--t-fast);
  box-shadow: var(--shadow-sm);
}

.sidebar-mobile-toggle:hover {
  color: var(--text-primary);
  border-color: var(--border-strong);
}

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

/* Mobile overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 90;
}

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  :root {
    --sidebar-w: 248px;
  }

  .sidebar {
    transform: translateX(-100%);
  }

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

  .main-content {
    margin-left: 0;
  }

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

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

  .topbar {
    padding: 0;
    padding-left: 2.5rem;
    align-items: flex-start;
  }

  .page-wrapper {
    padding: 1.2rem 1rem 2rem;
  }

  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  .topbar-actions .btn-lg {
    padding: .55rem 1rem;
    font-size: .8rem;
  }

  .page-title {
    font-size: 1.15rem;
  }

  #toast-container {
    left: 1rem;
    right: 1rem;
    bottom: 1rem;
  }

  .toast {
    min-width: auto;
    max-width: 100%;
  }
}

@media (max-width: 480px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .page-wrapper {
    padding: 1rem .75rem 2rem;
  }
}