/* =============================================
   AVANCI AI - PREMIUM LIGHT THEME
   ============================================= */

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

:root {
  --primary: #6C5CE7;
  --primary-light: #A29BFE;
  --primary-dark: #5A4BD1;
  --primary-50: #F3F1FE;
  --primary-100: #E8E5FD;
  --primary-glow: rgba(108, 92, 231, 0.15);

  --accent: #00CEC9;
  --accent-light: #E0FAF9;
  --accent-dark: #00B5B0;

  --gradient-brand: linear-gradient(135deg, #6C5CE7, #00CEC9);
  --gradient-subtle: linear-gradient(135deg, #F3F1FE, #E0FAF9);

  --white: #FFFFFF;
  --gray-25: #FCFCFD;
  --gray-50: #F9FAFB;
  --gray-100: #F2F4F7;
  --gray-200: #EAECF0;
  --gray-300: #D0D5DD;
  --gray-400: #98A2B3;
  --gray-500: #667085;
  --gray-600: #475467;
  --gray-700: #344054;
  --gray-800: #1D2939;
  --gray-900: #101828;

  --success: #12B76A;
  --success-light: #ECFDF3;
  --warning: #F79009;
  --warning-light: #FFFAEB;
  --danger: #F04438;
  --danger-light: #FEF3F2;

  --sidebar-bg: #101828;
  --sidebar-hover: #1D2939;
  --sidebar-active: rgba(108, 92, 231, 0.2);
  --sidebar-text: #D0D5DD;
  --sidebar-text-active: #FFFFFF;

  --msg-in: #F2F4F7;
  --msg-out: #6C5CE7;
  --msg-ai: #E0FAF9;

  --radius-xs: 6px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-xs: 0 1px 2px rgba(16,24,40,0.05);
  --shadow-sm: 0 1px 3px rgba(16,24,40,0.1), 0 1px 2px rgba(16,24,40,0.06);
  --shadow: 0 4px 8px -2px rgba(16,24,40,0.1), 0 2px 4px -2px rgba(16,24,40,0.06);
  --shadow-md: 0 12px 16px -4px rgba(16,24,40,0.08), 0 4px 6px -2px rgba(16,24,40,0.03);
  --shadow-lg: 0 20px 24px -4px rgba(16,24,40,0.08), 0 8px 8px -4px rgba(16,24,40,0.03);
  --shadow-xl: 0 24px 48px -12px rgba(16,24,40,0.18);

  --sidebar-w: 250px;
}

html, body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* =============================================
   LOGIN
   ============================================= */
#login-screen {
  display: flex;
  min-height: 100vh;
}

.login-left {
  flex: 1;
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  position: relative;
  overflow: hidden;
}
.login-left::before {
  content: '';
  position: absolute;
  top: -20%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: rgba(255,255,255,0.08);
  border-radius: 50%;
}
.login-left::after {
  content: '';
  position: absolute;
  bottom: -15%;
  left: -5%;
  width: 350px;
  height: 350px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.login-left-content {
  position: relative;
  z-index: 1;
  max-width: 440px;
}
.login-logo-big {
  margin-bottom: 32px;
}
.login-hero-title {
  font-size: 42px;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
  margin-bottom: 12px;
}
.login-hero-title span {
  opacity: 0.7;
  font-weight: 300;
}
.login-hero-sub {
  font-size: 16px;
  color: rgba(255,255,255,0.8);
  line-height: 1.6;
  margin-bottom: 40px;
}
.login-features {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-feature {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,0.9);
  font-size: 14px;
  font-weight: 500;
}
.login-feature i {
  width: 24px;
  height: 24px;
  background: rgba(255,255,255,0.2);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  flex-shrink: 0;
}

.login-right {
  width: 520px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  background: var(--white);
}

.login-form-wrapper {
  width: 100%;
  max-width: 380px;
}
.login-form-wrapper h2 {
  font-size: 26px;
  font-weight: 700;
  color: var(--gray-900);
  margin-bottom: 8px;
}
.login-form-sub {
  font-size: 14px;
  color: var(--gray-500);
  margin-bottom: 32px;
}

#login-form .form-group { margin-bottom: 20px; }
#login-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
#login-form input {
  width: 100%;
  padding: 12px 14px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  color: var(--gray-900);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
#login-form input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}
#login-form input::placeholder { color: var(--gray-400); }

.error-text {
  color: var(--danger);
  font-size: 13px;
  text-align: center;
  margin-top: 12px;
}

/* =============================================
   APP LAYOUT
   ============================================= */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* =============================================
   SIDEBAR
   ============================================= */
#sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  z-index: 20;
}

.sidebar-brand {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-name {
  font-size: 17px;
  color: #fff;
  font-weight: 600;
  letter-spacing: -0.3px;
}
.brand-name strong {
  font-weight: 300;
  opacity: 0.6;
}

.sidebar-nav {
  list-style: none;
  padding: 16px 12px;
  flex: 1;
}
.sidebar-nav li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  margin-bottom: 4px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
  position: relative;
}
.sidebar-nav li:hover {
  background: var(--sidebar-hover);
  color: #fff;
}
.sidebar-nav li.active {
  background: var(--sidebar-active);
  color: var(--primary-light);
}
.sidebar-nav li.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--primary-light);
  border-radius: 0 3px 3px 0;
}
.sidebar-nav li i {
  width: 20px;
  text-align: center;
  font-size: 14px;
}
.nav-badge {
  position: absolute;
  right: 12px;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.nav-badge.show { display: flex; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}
.avatar {
  width: 34px;
  height: 34px;
  background: var(--gradient-brand);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; }
.user-role { font-size: 11px; color: var(--gray-400); text-transform: uppercase; letter-spacing: 0.5px; }

#btn-logout {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  transition: all 0.2s;
}
#btn-logout:hover { background: rgba(255,255,255,0.08); color: var(--danger); }

/* =============================================
   MAIN CONTENT
   ============================================= */
#main-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--white);
}
#page-content {
  flex: 1;
  overflow-y: auto;
}

/* =============================================
   CONVERSATIONS PAGE
   ============================================= */
.conv-page {
  display: flex;
  height: 100vh;
}

.conv-topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}
.conv-topbar select {
  padding: 8px 12px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  color: var(--gray-900);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  min-width: 200px;
  cursor: pointer;
}
.conv-topbar select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glow); }
.conv-topbar label {
  font-size: 13px;
  color: var(--gray-500);
  font-weight: 500;
  white-space: nowrap;
}

.queue-panel {
  width: 380px;
  background: var(--white);
  border-right: 1px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.queue-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 8px;
}
.queue-tab {
  flex: 1;
  padding: 14px 8px;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-400);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  margin-bottom: -1px;
}
.queue-tab:hover { color: var(--gray-600); }
.queue-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.queue-tab .tab-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  margin-left: 6px;
  padding: 0 6px;
}
.queue-tab.active .tab-count {
  background: var(--primary-50);
  color: var(--primary);
}
.queue-tab:not(.active) .tab-count {
  background: var(--gray-100);
  color: var(--gray-400);
}

.conv-search {
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-100);
  position: relative;
}
.conv-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  color: var(--gray-900);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
.conv-search input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
  background: var(--white);
}
.conv-search input::placeholder { color: var(--gray-400); }
.conv-search i {
  position: absolute;
  left: 28px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  font-size: 13px;
}

.contact-list {
  flex: 1;
  overflow-y: auto;
}
.contact-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100);
  transition: background 0.15s;
}
.contact-item:hover { background: var(--gray-50); }
.contact-item.active { background: var(--primary-50); }
.contact-item .contact-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--gray-500);
  flex-shrink: 0;
}
.contact-item .contact-info { flex: 1; min-width: 0; }
.contact-item .contact-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-item .contact-preview {
  font-size: 13px;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.contact-item .contact-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
}
.contact-item .contact-time {
  font-size: 11px;
  color: var(--gray-400);
}
.contact-item .contact-badge {
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 6px;
}
.contact-badge.unread {
  background: var(--primary);
  color: #fff;
}
.contact-badge.bot {
  background: var(--accent-light);
  color: var(--accent-dark);
}

/* Chat panel */
.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--gray-50);
  min-width: 0;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
}
.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.chat-header .contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--gray-500);
}
.chat-header .chat-name { font-size: 14px; font-weight: 600; color: var(--gray-900); }
.chat-header .chat-phone { font-size: 12px; color: var(--gray-400); }
.chat-header-actions {
  display: flex;
  gap: 8px;
}
.chat-header-actions button {
  background: var(--white);
  border: 1px solid var(--gray-200);
  color: var(--gray-600);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-header-actions button:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.msg-bubble {
  max-width: 60%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 13px;
  line-height: 1.6;
  position: relative;
  word-wrap: break-word;
}
.msg-in {
  background: var(--white);
  color: var(--gray-800);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-xs);
}
.msg-out {
  background: var(--msg-out);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.msg-ai {
  background: var(--msg-ai);
  color: var(--gray-800);
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  border-left: 3px solid var(--accent);
}
.msg-time {
  font-size: 10px;
  color: var(--gray-400);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.msg-out .msg-time { color: rgba(255,255,255,0.6); justify-content: flex-end; }
.msg-ai .msg-time { justify-content: flex-end; }
.msg-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.msg-label.agent { color: var(--primary); }
.msg-label.bot { color: var(--accent-dark); }

.msg-date-sep {
  text-align: center;
  padding: 16px 0;
}
.msg-date-sep span {
  background: var(--white);
  color: var(--gray-400);
  font-size: 11px;
  font-weight: 500;
  padding: 6px 16px;
  border-radius: 20px;
  box-shadow: var(--shadow-xs);
}

.chat-input {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  background: var(--white);
  border-top: 1px solid var(--gray-200);
}
.chat-input input {
  flex: 1;
  padding: 12px 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  color: var(--gray-900);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
.chat-input input:focus { border-color: var(--primary); box-shadow: 0 0 0 4px var(--primary-glow); }
.chat-input input::placeholder { color: var(--gray-400); }
.chat-input .btn-send {
  width: 46px;
  height: 46px;
  background: var(--primary);
  border: none;
  border-radius: var(--radius);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.chat-input .btn-send:hover {
  background: var(--primary-dark);
  box-shadow: 0 4px 12px var(--primary-glow);
}

.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--gray-400);
}
.chat-empty i { font-size: 56px; opacity: 0.3; color: var(--gray-300); }
.chat-empty h3 { font-size: 16px; color: var(--gray-600); font-weight: 600; }
.chat-empty p { font-size: 13px; }

/* =============================================
   PAGE HEADERS & BODY
   ============================================= */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 24px 32px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--white);
}
.page-header h2 {
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-900);
}
.page-body {
  padding: 28px 32px;
  overflow-y: auto;
  max-height: calc(100vh - 80px);
}

/* =============================================
   GENERIC COMPONENTS
   ============================================= */

/* Cards */
.card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-100);
}
.card-header h3 { font-size: 15px; font-weight: 600; color: var(--gray-800); }

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-xs);
}
.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-icon.purple { background: var(--primary-50); color: var(--primary); }
.stat-icon.teal { background: var(--accent-light); color: var(--accent-dark); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.warning { background: var(--warning-light); color: var(--warning); }
.stat-icon.danger { background: var(--danger-light); color: var(--danger); }
.stat-info h3 { font-size: 24px; font-weight: 700; color: var(--gray-900); }
.stat-info p { font-size: 12px; color: var(--gray-500); margin-top: 2px; }

/* Table */
table { width: 100%; border-collapse: collapse; }
th {
  padding: 12px 20px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  border-bottom: 1px solid var(--gray-200);
  background: var(--gray-50);
}
td {
  padding: 14px 20px;
  font-size: 13px;
  color: var(--gray-700);
  border-bottom: 1px solid var(--gray-100);
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-25); }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-green { background: var(--success-light); color: var(--success); }
.badge-red { background: var(--danger-light); color: var(--danger); }
.badge-orange { background: var(--warning-light); color: var(--warning); }
.badge-blue { background: var(--accent-light); color: var(--accent-dark); }
.badge-purple { background: var(--primary-50); color: var(--primary); }
.badge i { font-size: 7px; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px var(--primary-glow); }
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-accent:hover { background: var(--accent-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.9; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline {
  background: var(--white);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}
.btn-outline:hover { background: var(--gray-50); border-color: var(--gray-400); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 14px; }
.btn-full { width: 100%; justify-content: center; }
.btn-icon-only {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-xs);
  font-size: 14px;
  transition: all 0.15s;
}
.btn-icon-only:hover { color: var(--gray-700); background: var(--gray-100); }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 6px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--white);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-sm);
  color: var(--gray-900);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-glow);
}
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--gray-400); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

/* Toggle */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; cursor: pointer; inset: 0;
  background: var(--gray-200); border-radius: 24px; transition: 0.3s;
}
.toggle-slider:before {
  content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.3s;
  box-shadow: var(--shadow-xs);
}
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

/* Modal */
#modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(16, 24, 40, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}
#modal {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.modal-close {
  background: none;
  border: none;
  color: var(--gray-400);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: var(--radius-xs);
  transition: all 0.15s;
}
.modal-close:hover { color: var(--gray-700); background: var(--gray-100); }
#modal-body { padding: 24px; }
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* QR */
.qr-container { text-align: center; padding: 20px; }
.qr-container img {
  max-width: 280px;
  border-radius: var(--radius);
  margin: 16px 0;
  box-shadow: var(--shadow-sm);
}
.qr-container p { color: var(--gray-500); font-size: 13px; }

/* Toast */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  animation: toastIn 0.3s ease;
  min-width: 280px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 10px;
}
.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--danger); color: #fff; }
@keyframes toastIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* Empty */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--gray-400);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; color: var(--gray-300); }
.empty-state h3 { font-size: 16px; margin-bottom: 8px; color: var(--gray-600); font-weight: 600; }
.empty-state p { font-size: 13px; color: var(--gray-400); }

/* Loading */
.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; justify-content: center; align-items: center; padding: 60px; }

/* Section divider */
.section-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--gray-800);
  margin: 24px 0 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--gray-200);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* Instance card grid */
.instance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 20px;
}
.instance-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-xs);
  transition: all 0.2s;
}
.instance-card:hover {
  box-shadow: var(--shadow-sm);
  border-color: var(--gray-300);
}
.instance-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.instance-card-header h4 { font-size: 15px; font-weight: 600; color: var(--gray-900); }
.instance-card-meta {
  display: flex;
  gap: 16px;
  font-size: 13px;
  color: var(--gray-500);
  margin-bottom: 16px;
}
.instance-card-meta span { display: flex; align-items: center; gap: 6px; }
.instance-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.instance-card-name {
  font-size: 12px;
  color: var(--gray-400);
  font-family: 'SF Mono', 'Menlo', monospace;
  margin-top: 2px;
}

/* Flow tabs for flows page */
.flow-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200);
  padding: 0 32px;
  background: var(--white);
}
.flow-tab {
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-400);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  margin-bottom: -1px;
}
.flow-tab:hover { color: var(--gray-600); }
.flow-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* =============================================
   RESPONSIVE
   ============================================= */
@media (max-width: 1100px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
}

@media (max-width: 900px) {
  #sidebar { width: 64px; }
  .brand-text, .sidebar-nav li span, .user-meta { display: none; }
  .sidebar-brand { justify-content: center; padding: 16px; }
  .sidebar-nav li { justify-content: center; padding: 12px; }
  .sidebar-nav li.active::before { display: none; }
  .sidebar-footer { justify-content: center; }
  .sidebar-user { justify-content: center; }
  #btn-logout { display: none; }
  .queue-panel { width: 300px; }
}

@media (max-width: 640px) {
  .queue-panel { width: 100%; }
  .chat-panel { display: none; }
  .instance-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 16px; }
}
