/* ========================================================================
   Multibot Admin — neo-glassmorphism redesign (May 2026)
   ======================================================================== */

:root {
  /* Brand */
  --accent: #8B5CF6;
  --accent-2: #6E56CF;
  --accent-hi: #A78BFA;
  --accent-glow: rgba(139, 92, 246, 0.35);

  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.14);
  --danger: #F43F5E;
  --danger-soft: rgba(244, 63, 94, 0.14);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, 0.14);
  --info: #22D3EE;
  --info-soft: rgba(34, 211, 238, 0.14);

  /* Dark theme (default) */
  --bg: #0a0a14;
  --bg-2: #0f0f1e;
  --bg-3: #14142a;
  --surface: rgba(20, 20, 42, 0.6);
  --surface-2: rgba(30, 30, 60, 0.55);
  --surface-hover: rgba(139, 92, 246, 0.08);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #E8E8F5;
  --text-2: #9899B8;
  --text-3: #5A5C7A;
  --grid-line: rgba(255, 255, 255, 0.04);

  /* Radii */
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  /* Density (overridden by .density-* on root) */
  --pad: 16px;
  --row-pad: 13px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Shadows + glass */
  --shadow-soft: 0 4px 30px rgba(0, 0, 0, 0.25);
  --shadow-glow: 0 0 0 1px var(--border), 0 20px 50px -20px rgba(0, 0, 0, 0.5);
  --blur: 18px;
}

[data-theme='light'] {
  --bg: #F4F4FB;
  --bg-2: #ECECF8;
  --bg-3: #E2E2F2;
  --surface: rgba(255, 255, 255, 0.7);
  --surface-2: rgba(255, 255, 255, 0.85);
  --surface-hover: rgba(139, 92, 246, 0.06);
  --border: rgba(20, 20, 60, 0.08);
  --border-strong: rgba(20, 20, 60, 0.16);
  --text: #14142A;
  --text-2: #555770;
  --text-3: #8F92B0;
  --grid-line: rgba(20, 20, 60, 0.06);
  --accent-glow: rgba(139, 92, 246, 0.22);
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
}

#root {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Mesh-gradient backdrop ------------------------------------------------- */
.backdrop {
  position: fixed;
  inset: 0;
  z-index: -2;
  background: var(--bg);
  overflow: hidden;
}
.backdrop::before,
.backdrop::after {
  content: '';
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.45;
  pointer-events: none;
}
.backdrop::before {
  width: 600px; height: 600px;
  top: -200px; left: -100px;
  background: radial-gradient(circle, #8B5CF6, transparent 70%);
}
.backdrop::after {
  width: 700px; height: 700px;
  bottom: -300px; right: -200px;
  background: radial-gradient(circle, #22D3EE, transparent 70%);
  opacity: 0.25;
}
[data-theme='light'] .backdrop::before { opacity: 0.22; }
[data-theme='light'] .backdrop::after { opacity: 0.18; }

/* Subtle grid noise on top */
.backdrop-grid {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
}

/* ─── Layout ─────────────────────────────────────────────────────────── */
.app {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* ─── Sidebar ─────────────────────────────────────────────────────────── */
.sidebar {
  width: 248px;
  flex-shrink: 0;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface), transparent);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.brand-logo {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #EC4899);
  display: grid; place-items: center;
  font-weight: 800; color: white;
  font-size: 16px;
  box-shadow: 0 8px 24px -8px var(--accent-glow);
  position: relative;
  overflow: hidden;
}
.brand-logo::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255,255,255,0.3), transparent 50%);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-name { font-weight: 700; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { font-size: 10.5px; color: var(--text-3); margin-top: 2px; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.08em; }

.nav-group { display: flex; flex-direction: column; gap: 2px; }
.nav-label {
  font-size: 10px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.1em; font-weight: 600;
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  color: var(--text-2);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: 0.15s;
  position: relative;
  border: 1px solid transparent;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text); }
.nav-item.active {
  background: linear-gradient(135deg, rgba(139,92,246,0.18), rgba(139,92,246,0.06));
  color: var(--text);
  border-color: rgba(139,92,246,0.25);
  box-shadow: 0 0 0 1px rgba(139,92,246,0.1) inset, 0 8px 20px -10px var(--accent-glow);
}
.nav-item.active .nav-icon { color: var(--accent-hi); }
.nav-icon {
  width: 18px; height: 18px;
  flex-shrink: 0;
  color: var(--text-3);
  transition: 0.15s;
}
.nav-item:hover .nav-icon { color: var(--text-2); }
.nav-badge {
  margin-left: auto;
  font-size: 10px;
  background: var(--accent);
  color: white;
  padding: 1px 7px;
  border-radius: 8px;
  font-weight: 600;
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 4px;
}
.user-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: 0.15s;
}
.user-chip:hover { border-color: var(--border-strong); }
.user-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, #22D3EE, #8B5CF6);
  display: grid; place-items: center;
  color: white; font-weight: 700; font-size: 11px;
}
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 12.5px; font-weight: 600; line-height: 1.1; }
.user-role { font-size: 10.5px; color: var(--text-3); margin-top: 2px; }

/* ─── Main content ────────────────────────────────────────────────────── */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, var(--surface), transparent);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  flex-shrink: 0;
  z-index: 10;
}
.page-title-block { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-title { font-size: 19px; font-weight: 700; letter-spacing: -0.02em; }
.page-sub { font-size: 12.5px; color: var(--text-2); }

.topbar-search {
  flex: 1;
  max-width: 420px;
  margin-left: 18px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: 0.15s;
  font-family: inherit;
}
.topbar-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.topbar-search input::placeholder { color: var(--text-3); }
.topbar-search-icon {
  position: absolute; left: 13px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-3); pointer-events: none;
}
.topbar-search-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 10.5px; color: var(--text-3);
  padding: 2px 6px; border-radius: 4px;
  border: 1px solid var(--border-strong);
}
.topbar-right {
  display: flex; align-items: center; gap: 8px; margin-left: auto;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 80px;
}

/* ─── Common surfaces ─────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255,255,255,0.05), transparent 30%);
}
[data-theme='light'] .card::before {
  background: linear-gradient(180deg, rgba(255,255,255,0.6), transparent 40%);
}

.section-title { font-size: 13px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: 0.08em; margin: 24px 0 12px; }

/* ─── Stat cards (KPI) ────────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.kpi {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.kpi-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px;
}
.kpi-label {
  font-size: 12px; color: var(--text-2); font-weight: 500;
  display: flex; align-items: center; gap: 6px;
}
.kpi-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--surface-2);
  color: var(--accent-hi);
}
.kpi-icon.green { color: var(--success); }
.kpi-icon.red { color: var(--danger); }
.kpi-icon.amber { color: var(--warning); }
.kpi-icon.cyan { color: var(--info); }
.kpi-value {
  font-size: 26px; font-weight: 700; line-height: 1.1; letter-spacing: -0.02em;
  font-feature-settings: 'tnum';
  font-family: var(--font-sans);
}
.kpi-meta {
  display: flex; align-items: center; gap: 8px; font-size: 11.5px;
  color: var(--text-3); margin-top: 2px;
}
.kpi-delta {
  display: inline-flex; align-items: center; gap: 3px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 6px;
}
.kpi-delta.up { color: var(--success); background: var(--success-soft); }
.kpi-delta.down { color: var(--danger); background: var(--danger-soft); }

.kpi-spark {
  height: 32px;
  margin-top: 4px;
  width: 100%;
}

/* ─── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  transition: 0.15s;
  text-decoration: none;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { border-color: var(--border-strong); background: var(--surface-hover); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #EC4899);
  color: white;
  border-color: transparent;
  box-shadow: 0 6px 18px -6px var(--accent-glow);
}
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-hover); }
.btn-icon { width: 34px; height: 34px; padding: 0; flex-shrink: 0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ─── Inputs ──────────────────────────────────────────────────────────── */
.input, .select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  outline: none;
  transition: 0.15s;
  font-family: inherit;
}
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.input::placeholder { color: var(--text-3); }
.select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%239899B8' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
  cursor: pointer;
}
.select option { background: #14142A; color: var(--text); }
[data-theme='light'] .select option { background: white; color: var(--text); }

/* ─── Table ───────────────────────────────────────────────────────────── */
.table-card { overflow: hidden; }
.table-header {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.table-title { font-size: 14.5px; font-weight: 600; }
.table-meta { color: var(--text-3); font-size: 12px; margin-left: 4px; }

table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  font-size: 10.5px; font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(20, 20, 42, 0.3);
  position: sticky; top: 0;
}
[data-theme='light'] thead th { background: rgba(255,255,255,0.5); }
tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
tbody tr { transition: 0.12s; }
tbody tr:hover { background: var(--surface-hover); }
tbody tr:last-child td { border-bottom: none; }

.mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.amount.positive { color: var(--success); }

/* ─── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  border: 1px solid transparent;
}
.badge-success { background: var(--success-soft); color: var(--success); border-color: rgba(16,185,129,0.25); }
.badge-danger { background: var(--danger-soft); color: var(--danger); border-color: rgba(244,63,94,0.25); }
.badge-warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(245,158,11,0.25); }
.badge-info { background: var(--info-soft); color: var(--info); border-color: rgba(34,211,238,0.25); }
.badge-purple { background: rgba(139,92,246,0.14); color: var(--accent-hi); border-color: rgba(139,92,246,0.28); }
.badge-gray { background: rgba(152,153,184,0.12); color: var(--text-2); border-color: var(--border-strong); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 8px currentColor; }

/* ─── Avatar ──────────────────────────────────────────────────────────── */
.avatar {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid; place-items: center;
  color: white;
  font-weight: 700;
  font-size: 12px;
  flex-shrink: 0;
}
.avatar-sm { width: 24px; height: 24px; font-size: 10px; border-radius: 6px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; border-radius: 14px; }
.av-1 { background: linear-gradient(135deg, #8B5CF6, #EC4899); }
.av-2 { background: linear-gradient(135deg, #22D3EE, #3B82F6); }
.av-3 { background: linear-gradient(135deg, #10B981, #22D3EE); }
.av-4 { background: linear-gradient(135deg, #F59E0B, #F43F5E); }
.av-5 { background: linear-gradient(135deg, #EC4899, #F43F5E); }
.av-6 { background: linear-gradient(135deg, #6366F1, #8B5CF6); }
.av-7 { background: linear-gradient(135deg, #14B8A6, #0EA5E9); }
.av-8 { background: linear-gradient(135deg, #A78BFA, #F472B6); }

/* ─── Chart card ──────────────────────────────────────────────────────── */
.chart-card {
  padding: 20px 22px;
  margin-bottom: 16px;
}
.chart-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 18px; flex-wrap: wrap; gap: 12px;
}
.chart-title { font-size: 14px; font-weight: 600; }
.chart-sub { font-size: 12px; color: var(--text-3); margin-top: 2px; }
.chart-tabs { display: flex; gap: 4px; padding: 3px; background: var(--surface-2);
  border-radius: 9px; border: 1px solid var(--border); }
.chart-tab { padding: 4px 11px; font-size: 12px; border-radius: 6px; cursor: pointer;
  color: var(--text-2); font-weight: 500; transition: 0.15s; }
.chart-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.chart-tab:hover:not(.active) { color: var(--text); }

/* ─── Scroll ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ─── Misc ────────────────────────────────────────────────────────────── */
.row { display: flex; align-items: center; gap: 10px; }
.flex-col { display: flex; flex-direction: column; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.text-2 { color: var(--text-2); }
.text-3 { color: var(--text-3); }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fs-12 { font-size: 12px; }
.fs-11 { font-size: 11px; }
.fs-13 { font-size: 13px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-2);
}

.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* Sparkline cells */
.sparkbar {
  height: 6px;
  border-radius: 3px;
  background: var(--surface-2);
  overflow: hidden;
  position: relative;
}
.sparkbar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #EC4899);
  border-radius: 3px;
}

/* ─── Two-column layouts ──────────────────────────────────────────────── */
.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.three-col {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 16px;
}
.detail-grid {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}

/* Tabs */
.tabs-line {
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.tab-line {
  padding: 10px 14px;
  font-size: 13px; font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: 0.15s;
  display: flex; align-items: center; gap: 6px;
}
.tab-line:hover { color: var(--text); }
.tab-line.active { color: var(--text); border-bottom-color: var(--accent); }
.tab-line-count {
  font-size: 11px; padding: 1px 7px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-3); font-weight: 600;
}

/* ── Chat-like dialog (Telegram-style bubbles) ─────────────────────── */
.chat-thread {
  display: flex; flex-direction: column; gap: 6px;
  padding: 16px 0;
}
.chat-date-sep { text-align: center; margin: 16px 0 8px; }
.chat-date-sep span {
  display: inline-block; padding: 4px 12px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 12px; font-size: 11px; color: var(--text-3);
  font-weight: 500; letter-spacing: 0.02em;
}
.chat-sys { text-align: center; margin: 8px 0; }
.chat-sys-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-2);
}
.chat-sys-pill svg { stroke: var(--accent-hi); flex-shrink: 0; }
.chat-sys-time {
  color: var(--text-3); font-size: 10.5px; margin-left: 4px;
  font-family: var(--font-mono);
}
.chat-row {
  display: flex; gap: 8px; margin: 4px 0;
  max-width: 78%; align-items: flex-end;
}
.chat-row.left { align-self: flex-start; }
.chat-row.right { align-self: flex-end; flex-direction: row-reverse; }
.chat-ava {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; flex-shrink: 0;
  font-size: 12px; font-weight: 700; color: white;
}
.chat-ava.bot {
  background: var(--surface-3); border: 1px solid var(--border); color: var(--text-2);
}
.chat-ava.user { background: linear-gradient(135deg, #8B5CF6, #EC4899); }
.chat-bubbles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.chat-bubble {
  padding: 8px 12px; border-radius: 16px;
  font-size: 13.5px; line-height: 1.45;
  word-wrap: break-word; max-width: 100%; position: relative;
}
.chat-bubble.bot {
  background: var(--surface-2); border: 1px solid var(--border);
  color: var(--text); border-bottom-left-radius: 6px;
}
.chat-bubble.user {
  background: linear-gradient(135deg, #7C3AED, #6366F1);
  color: white; border-bottom-right-radius: 6px;
}
.chat-row.left  .chat-bubble + .chat-bubble.bot  { border-top-left-radius: 6px; }
.chat-row.right .chat-bubble + .chat-bubble.user { border-top-right-radius: 6px; }
.chat-text { white-space: pre-wrap; word-break: break-word; }
.chat-text b, .chat-text strong { font-weight: 700; }
.chat-text i, .chat-text em { font-style: italic; }
.chat-text u { text-decoration: underline; }
.chat-text s, .chat-text strike, .chat-text del { text-decoration: line-through; opacity: 0.7; }
.chat-text code {
  font-family: var(--font-mono); font-size: 0.9em;
  padding: 1px 5px; border-radius: 4px;
  background: rgba(0, 0, 0, 0.25);
}
.chat-bubble.bot .chat-text code { background: var(--surface-3); }
.chat-text pre {
  font-family: var(--font-mono); font-size: 0.85em;
  padding: 8px 10px; border-radius: 8px; margin: 4px 0;
  background: rgba(0, 0, 0, 0.3); overflow-x: auto;
}
.chat-text blockquote {
  margin: 6px 0; padding: 4px 10px;
  border-left: 3px solid currentColor; opacity: 0.85;
}
.chat-text a {
  color: inherit; text-decoration: underline; text-underline-offset: 2px;
}
.chat-bubble.user .chat-text a { color: #fff; }

/* Inline-keyboard под bot-bubble (как видит юзер в Telegram) */
.chat-kbd {
  display: flex; flex-direction: column; gap: 4px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
}
.chat-kbd-row {
  display: flex; gap: 4px; flex-wrap: wrap;
}
.chat-kbd-btn {
  display: inline-flex; align-items: center; gap: 4px;
  flex: 1; min-width: 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid rgba(108, 99, 255, 0.35);
  font-size: 12.5px; font-weight: 500;
  color: var(--accent-hi);
  text-align: center;
  justify-content: center;
  cursor: default;
  word-break: break-word;
  line-height: 1.3;
}
.chat-kbd-btn.has-url {
  background: rgba(108, 99, 255, 0.18);
}
.chat-kbd-extlink { opacity: 0.6; font-size: 11px; flex-shrink: 0; }

/* Broadcast detail modal */
.bc-detail-modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(720px, 92vw); max-height: 88vh;
  /* Solid background (не полупрозрачный — содержимое за модалкой не должно просвечивать) */
  background: #161628;
  border: 1px solid var(--border); border-radius: 16px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7);
  display: flex; flex-direction: column; z-index: 1000;
}
[data-theme="light"] .bc-detail-modal { background: #ffffff; }
.bc-detail-head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: flex-start; gap: 12px;
}
.bc-detail-body {
  flex: 1; overflow-y: auto;
  padding: 16px 20px;
  display: flex; flex-direction: column; gap: 16px;
}
.bc-detail-section { display: flex; flex-direction: column; gap: 6px; }
.bc-detail-label {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  color: var(--text-3); letter-spacing: 0.06em;
}
.bc-recip-list {
  max-height: 280px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface-2);
}
.bc-recip-row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12.5px;
}
.bc-recip-row:last-child { border-bottom: none; }
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }

.chip-tabs { display: flex; gap: 4px; }
.chip-tab {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11.5px; font-weight: 600;
  color: var(--text-3);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer; user-select: none; transition: 0.12s;
}
.chip-tab:hover { color: var(--text); }
.chip-tab.active {
  background: rgba(108, 99, 255, 0.18);
  border-color: rgba(108, 99, 255, 0.4);
  color: var(--accent-hi);
}

.chat-time {
  font-size: 10.5px; margin-top: 4px; text-align: right;
  opacity: 0.7; font-family: var(--font-mono);
}
.chat-bubble.user .chat-time { color: rgba(255, 255, 255, 0.75); }
.chat-bubble.bot .chat-time { color: var(--text-3); }
@media (max-width: 600px) {
  .chat-row { max-width: 92%; }
  .chat-ava { width: 28px; height: 28px; font-size: 11px; }
  .chat-bubble { padding: 7px 10px; font-size: 13px; }
}

/* Dialog/timeline (legacy, оставлен для других страниц) */
.timeline { display: flex; flex-direction: column; gap: 8px; }
.tl-item {
  display: flex; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--r-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  position: relative;
}
.tl-item.user::before,
.tl-item.bot::before,
.tl-item.click::before,
.tl-item.err::before,
.tl-item.pay::before {
  content: '';
  position: absolute;
  left: 0; top: 12px; bottom: 12px;
  width: 3px;
  border-radius: 0 3px 3px 0;
}
.tl-item.user::before { background: var(--accent); }
.tl-item.bot::before { background: var(--info); }
.tl-item.click::before { background: var(--warning); }
.tl-item.err::before { background: var(--danger); }
.tl-item.pay::before { background: var(--success); }
.tl-icon {
  width: 28px; height: 28px;
  border-radius: 8px;
  display: grid; place-items: center;
  flex-shrink: 0;
  background: var(--surface-2);
  color: var(--text-2);
}
.tl-body { flex: 1; min-width: 0; }
.tl-meta {
  font-size: 11px; color: var(--text-3);
  display: flex; gap: 10px; flex-wrap: wrap;
  margin-bottom: 4px;
}
.tl-text { font-size: 13px; word-break: break-word; }

/* Funnel step row */
.funnel-row {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.funnel-row:last-child { border-bottom: none; }
.step-num {
  width: 32px; height: 32px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-weight: 700; font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border);
}
.step-num.done { background: var(--accent); color: white; border-color: transparent; }
.step-info { flex: 1; min-width: 0; }
.step-name { font-size: 13.5px; font-weight: 500; }
.step-cond { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.step-bar-wrap { width: 200px; flex-shrink: 0; }
.step-bar {
  height: 6px;
  background: var(--surface-2);
  border-radius: 3px;
  overflow: hidden;
}
.step-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--info));
  border-radius: 3px;
}
.step-count {
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--text-3);
  margin-top: 4px;
}

/* Funnel list item */
.funnel-list-item {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: 0.15s;
}
.funnel-list-item:hover { background: var(--surface-hover); }
.funnel-list-item.selected {
  background: linear-gradient(90deg, rgba(139,92,246,0.16), transparent);
  border-left: 2px solid var(--accent);
  padding-left: 14px;
}

/* Profile card */
.profile-card { padding: 22px; }
.profile-name { font-size: 18px; font-weight: 700; margin-top: 12px; }
.profile-username { color: var(--text-2); font-size: 13px; margin-top: 2px; }
.profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12.5px;
}
.profile-row:last-child { border-bottom: none; }
.profile-key { color: var(--text-3); }
.profile-val { font-weight: 500; text-align: right; }

/* Spinner */
.spinner {
  width: 16px; height: 16px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bot card */
.bot-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  transition: 0.18s;
  cursor: pointer;
}
.bot-card:hover {
  border-color: rgba(139,92,246,0.4);
  transform: translateY(-2px);
  box-shadow: 0 14px 40px -20px var(--accent-glow);
}
.bot-head { display: flex; align-items: center; gap: 12px; }
.bot-name { font-weight: 700; font-size: 14.5px; line-height: 1.15; }
.bot-username { font-size: 11.5px; color: var(--text-3); margin-top: 2px;
  font-family: var(--font-mono); }
.bot-stats-row {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  padding: 10px;
  background: var(--surface-2);
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
}
.bot-stat { text-align: center; }
.bot-stat-v { font-size: 16px; font-weight: 700; font-variant-numeric: tabular-nums; }
.bot-stat-l { font-size: 10px; color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.06em; margin-top: 2px; }

/* Broadcasts */
.bc-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.bc-card:last-child { border-bottom: none; }
.bc-title { font-weight: 600; font-size: 14px; }
.bc-meta { display: flex; gap: 8px; align-items: center; color: var(--text-3); font-size: 11.5px; margin-top: 4px; }
.bc-stats { display: flex; gap: 20px; align-items: center; }
.bc-stat { display: flex; flex-direction: column; align-items: flex-end; }
.bc-stat-v { font-size: 14px; font-weight: 700; }
.bc-stat-l { font-size: 10.5px; color: var(--text-3); text-transform: uppercase; letter-spacing: 0.06em; }

.progress-ring {
  width: 44px; height: 44px;
  flex-shrink: 0;
}

/* Empty state */
.empty {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-3);
}
.empty-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  background: var(--surface-2);
  display: grid; place-items: center;
  margin: 0 auto 12px;
  color: var(--text-3);
}

/* Theme toggle */
.theme-toggle {
  display: inline-flex;
  background: var(--surface-2);
  padding: 3px;
  border-radius: 9px;
  border: 1px solid var(--border);
  gap: 1px;
}
.theme-toggle button {
  border: none;
  background: transparent;
  padding: 5px 9px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-2);
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.theme-toggle button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* ════════════════════════════════════════════════════════════════════
   v2: density, radius, accent, overlays, login, responsive
   ════════════════════════════════════════════════════════════════════ */

/* Density variants */
[data-density='compact'] {
  --pad: 12px;
  --row-pad: 9px;
}
[data-density='compact'] tbody td { padding: 9px 14px; font-size: 12.5px; }
[data-density='compact'] thead th { padding: 8px 14px; }
[data-density='compact'] .table-header { padding: 12px 14px; }
[data-density='compact'] .kpi { padding: 14px 16px; }
[data-density='compact'] .card.chart-card { padding: 16px 18px; }

[data-density='comfy'] tbody td { padding: 18px 18px; }
[data-density='comfy'] thead th { padding: 14px 18px; }
[data-density='comfy'] .table-header { padding: 20px 22px; }
[data-density='comfy'] .kpi { padding: 22px 24px; }

/* Radius variants */
[data-radius='sharp']  { --r-sm: 4px;  --r-md: 6px;  --r-lg: 8px;   --r-xl: 10px; }
[data-radius='soft']   { --r-sm: 10px; --r-md: 14px; --r-lg: 18px;  --r-xl: 24px; }
[data-radius='round']  { --r-sm: 14px; --r-md: 20px; --r-lg: 26px;  --r-xl: 32px; }
.card, .table-card { border-radius: var(--r-md); }
.btn { border-radius: var(--r-sm); }

/* Accent variants */
[data-accent='purple'] {
  --accent: #8B5CF6; --accent-2: #6E56CF; --accent-hi: #A78BFA;
  --accent-glow: rgba(139, 92, 246, 0.35);
}
[data-accent='cyan'] {
  --accent: #06B6D4; --accent-2: #0891B2; --accent-hi: #22D3EE;
  --accent-glow: rgba(6, 182, 212, 0.35);
}
[data-accent='emerald'] {
  --accent: #10B981; --accent-2: #059669; --accent-hi: #34D399;
  --accent-glow: rgba(16, 185, 129, 0.35);
}
[data-accent='amber'] {
  --accent: #F59E0B; --accent-2: #D97706; --accent-hi: #FBBF24;
  --accent-glow: rgba(245, 158, 11, 0.35);
}
[data-accent='rose'] {
  --accent: #F43F5E; --accent-2: #E11D48; --accent-hi: #FB7185;
  --accent-glow: rgba(244, 63, 94, 0.35);
}

/* ─── Overlays (Command palette, Notifications, Composer) ───────────── */

.overlay-root {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  animation: overlayFade 0.18s ease;
}
[data-theme='light'] .overlay-root { background: rgba(20, 20, 60, 0.3); }
@keyframes overlayFade { from { opacity: 0; } to { opacity: 1; } }

.overlay-dim {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 999;
  animation: overlayFade 0.15s ease;
}

/* Command palette */
.cmd-palette {
  width: 100%;
  max-width: 620px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  animation: cmdRise 0.18s ease;
}
@keyframes cmdRise {
  from { opacity: 0; transform: translateY(-12px); }
  to { opacity: 1; transform: translateY(0); }
}

.cmd-search {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}
.cmd-search input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  font-size: 15px;
  color: var(--text);
  font-family: inherit;
}
.cmd-search input::placeholder { color: var(--text-3); }
.kbd {
  display: inline-flex; align-items: center;
  padding: 2px 8px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-2);
  font-weight: 600;
}

.cmd-list { flex: 1; overflow-y: auto; padding: 8px 0; }
.cmd-group-label {
  font-size: 10px; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.1em;
  padding: 10px 18px 6px;
  font-weight: 600;
}
.cmd-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 18px;
  cursor: pointer;
  color: var(--text-2);
  transition: 0.1s;
}
.cmd-item.active {
  background: var(--surface-hover);
  color: var(--text);
}
.cmd-item.active svg:first-child { color: var(--accent-hi); }

.cmd-foot {
  display: flex; gap: 18px;
  padding: 10px 18px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--text-3);
}

/* Notifications panel */
.notif-panel {
  position: fixed;
  top: 70px;
  right: 24px;
  width: 380px;
  max-height: 540px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  box-shadow: 0 20px 60px -10px rgba(0,0,0,0.4);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: notifSlide 0.18s ease;
}
@keyframes notifSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}
.notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
}
.notif-list { flex: 1; overflow-y: auto; }
.notif-item {
  display: flex; gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: 0.12s;
  position: relative;
}
.notif-item:hover { background: var(--surface-hover); }
.notif-item.unread::before {
  content: '';
  position: absolute;
  left: 0; top: 8px; bottom: 8px;
  width: 2px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.notif-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.notif-icon.success { background: var(--success-soft); color: var(--success); }
.notif-icon.warning { background: var(--warning-soft); color: var(--warning); }
.notif-icon.info    { background: var(--info-soft); color: var(--info); }
.notif-icon.danger  { background: var(--danger-soft); color: var(--danger); }

/* Broadcast composer */
.composer {
  width: 100%;
  max-width: 920px;
  max-height: 88vh;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-lg);
  box-shadow: 0 30px 80px -20px rgba(0,0,0,0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cmdRise 0.2s ease;
}
.composer-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 22px 28px;
  border-bottom: 1px solid var(--border);
}
.composer-body { flex: 1; overflow-y: auto; padding: 22px 28px; }
.composer-foot {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}
.composer-label {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 600; color: var(--text-3);
  text-transform: uppercase; letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.composer-steps { display: flex; gap: 6px; }
.composer-step-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  transition: 0.18s;
}
.composer-step-dot.active {
  background: var(--accent);
  border-color: var(--accent);
  width: 22px; border-radius: 4px;
}
.composer-step-dot.done {
  background: var(--accent-hi);
  border-color: var(--accent-hi);
}

.seg-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: 0.15s;
}
.seg-card:hover { border-color: var(--border-strong); }
.seg-card.active {
  background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(139,92,246,0.04));
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.seg-radio {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: grid; place-items: center;
  flex-shrink: 0;
  transition: 0.15s;
}
.seg-radio span {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  transition: 0.15s;
}
.seg-card.active .seg-radio { border-color: var(--accent); }
.seg-card.active .seg-radio span { opacity: 1; }

/* Telegram preview */
.tg-preview {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px;
  position: relative;
  overflow: hidden;
}
.tg-chrome {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-3);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 12px;
}
.tg-bubble {
  background: linear-gradient(135deg, rgba(34,211,238,0.08), rgba(139,92,246,0.05));
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px 16px;
  position: relative;
  max-width: 90%;
}
[data-theme='light'] .tg-bubble {
  background: white;
}
.tg-btn {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  padding: 9px 14px;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-hi);
  cursor: pointer;
  transition: 0.15s;
}
.tg-btn:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

/* Login screen */
.login-wrap {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 32px;
}
.login-card {
  width: 100%;
  max-width: 980px;
  background: var(--surface);
  backdrop-filter: blur(var(--blur));
  -webkit-backdrop-filter: blur(var(--blur));
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: 0 40px 100px -20px rgba(0,0,0,0.5);
  overflow: hidden;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  min-height: 580px;
}
.login-visual {
  background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(34,211,238,0.08));
  padding: 44px 48px;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--border);
}
.login-visual-content { position: relative; z-index: 2; }
.login-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  pointer-events: none;
}
.login-orb-1 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, #8B5CF6, transparent 70%);
  top: -80px; right: -80px;
  opacity: 0.5;
}
.login-orb-2 {
  width: 240px; height: 240px;
  background: radial-gradient(circle, #22D3EE, transparent 70%);
  bottom: -60px; left: -40px;
  opacity: 0.4;
}
.login-chips {
  display: flex; gap: 10px; margin-top: 36px; flex-wrap: wrap;
}
.login-chip {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.login-chip-icon {
  width: 32px; height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #EC4899);
  color: white;
  display: grid; place-items: center;
}

.login-form {
  padding: 44px 48px;
  display: flex;
  flex-direction: column;
}
.login-fields { display: flex; flex-direction: column; gap: 14px; }
.login-field { display: flex; flex-direction: column; gap: 6px; }
.login-field label {
  display: flex; justify-content: space-between;
  font-size: 12px; font-weight: 600; color: var(--text-2);
}
.login-input-wrap {
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: 0.15s;
}
.login-input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.login-input-wrap input {
  flex: 1;
  padding: 12px 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-size: 14px;
  font-family: inherit;
}
.login-divider {
  display: flex; align-items: center; gap: 10px;
  margin: 6px 0 2px;
  color: var(--text-3);
  font-size: 11px;
}
.login-divider::before, .login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ─── Responsive ─────────────────────────────────────────────────────── */

/* Mobile nav button — hidden on desktop */
.mobile-nav-btn { display: none !important; }

@media (max-width: 1440px) {
  /* Bot detail hero KPIs: 5 cols → 3 cols when squeezed */
  div[style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 1280px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 280px 1fr; }

  /* Overview: 2fr 1fr stacks last-col below main on medium screens */
  div[style*="grid-template-columns: 2fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 1024px) {
  /* Sidebar collapses to icon strip on tablet */
  .sidebar {
    width: 64px;
    padding: 12px 8px;
  }
  .brand-text, .nav-item span:not(.nav-badge), .nav-label,
  .sidebar-bottom .user-info { display: none; }
  .sidebar-bottom .user-chip { justify-content: center; padding: 8px; }
  .sidebar-bottom .user-chip > svg { display: none; }
  .nav-item { justify-content: center; padding: 10px; }
  .nav-badge { display: none; }
  .brand { justify-content: center; padding: 6px 0 18px; }

  .topbar { padding: 12px 18px; }
  .content { padding: 18px 18px 80px; }

  .detail-grid { grid-template-columns: 1fr; }
  .three-col, .two-col { grid-template-columns: 1fr; }

  /* All 1fr 1fr layouts stack */
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns:1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* 5-col KPI down to 2 */
  div[style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }
  /* Funnels list (360px 1fr) stacks */
  div[style*="grid-template-columns: 360px 1fr"] {
    grid-template-columns: 1fr !important;
  }
  /* Composer 2-col layouts stack */
  .composer-body > div[style*="grid-template-columns"] {
    grid-template-columns: 1fr !important;
  }
  .composer { max-width: 95vw; }
}

@media (max-width: 900px) {
  /* Sidebar becomes off-canvas drawer */
  .sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    z-index: 998;
    padding: 16px;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  /* Restore full labels in drawer */
  .sidebar.mobile-open .brand-text,
  .sidebar .brand-text { display: flex !important; }
  .sidebar .nav-item span:not(.nav-badge) { display: inline !important; }
  .sidebar .nav-label { display: block !important; }
  .sidebar-bottom .user-info { display: flex !important; flex-direction: column; }
  .sidebar-bottom .user-chip { justify-content: flex-start; padding: 8px 10px; }
  .sidebar-bottom .user-chip > svg { display: block; }
  .nav-item { justify-content: flex-start; padding: 9px 12px; }
  .nav-badge { display: inline-flex; }
  .brand { justify-content: flex-start; padding: 6px 10px 18px; }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(4px);
    z-index: 997;
    animation: overlayFade 0.18s ease;
  }

  .mobile-nav-btn { display: inline-flex !important; }
  .main { width: 100%; }

  /* Topbar: hide search, show smaller controls */
  .topbar-search { display: none; }
  .topbar { padding: 12px 14px; gap: 8px; }
  .page-title { font-size: 17px; }
  .page-sub { display: none; }

  /* KPI grid */
  .kpi-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .content { padding: 14px 12px 80px; }
}

@media (max-width: 768px) {
  .kpi-value { font-size: 22px; }
  .kpi { padding: 14px 16px; }
  .table-header { padding: 12px 14px; flex-wrap: wrap; gap: 8px; }
  .table-header > div[style*="margin-left: auto"] { width: 100%; }
  .table-header .input, .table-header .select { flex: 1; min-width: 120px; }

  /* Login: stack panels */
  .login-card { grid-template-columns: 1fr; min-height: auto; }
  .login-visual { padding: 28px 24px; min-height: 200px; }
  .login-form { padding: 28px 24px; }
  .login-chips { display: none; }

  /* Notifications: full-width on mobile */
  .notif-panel {
    width: calc(100vw - 24px);
    right: 12px;
    left: 12px;
    max-height: calc(100vh - 100px);
  }

  /* Composer: fill screen */
  .composer {
    max-width: 100vw;
    width: 100vw;
    max-height: 100vh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .composer-head { padding: 16px 18px; }
  .composer-body { padding: 16px 18px; }
  .composer-foot { padding: 12px 18px; }

  /* Tables: horizontal scroll */
  .table-card table { min-width: 720px; }
  .table-card { overflow-x: auto; }

  /* Tabs scroll horizontally */
  .tabs-line { overflow-x: auto; flex-wrap: nowrap; }
  .tab-line { flex-shrink: 0; }

  /* Command palette: fill screen */
  .overlay-root { padding-top: 6vh; padding-left: 12px; padding-right: 12px; }
  .cmd-palette { max-width: 100%; max-height: 80vh; }
}

@media (max-width: 540px) {
  .kpi-grid { grid-template-columns: 1fr; gap: 8px; }
  div[style*="grid-template-columns: repeat(5, 1fr)"] {
    grid-template-columns: 1fr !important;
  }
  /* Compact top-5 cards on overview */
  div[style*="grid-template-columns: repeat(5, 1fr)"] .card { padding: 12px; }

  .topbar { padding: 10px 12px; }
  .page-title { font-size: 15px; }

  /* Heatmap labels shrink */
  .chart-card { padding: 16px 14px; }

  /* Login OTP */
  .login-form input[maxlength="1"] {
    width: 38px !important;
    height: 46px !important;
    font-size: 18px !important;
  }

  /* Sidebar drawer slightly narrower */
  .sidebar { width: 240px; }

  /* Avatar sizes shrink */
  .avatar-lg { width: 48px; height: 48px; font-size: 16px; }

  /* Profile card avatar */
  .profile-card { padding: 18px; }
}

/* 4K / ultra-wide: cap content width for readability */
@media (min-width: 1920px) {
  .content { max-width: 1720px; margin: 0 auto; padding: 28px 32px 80px; }
}
