/* ============================================
   ADITION AI BOT — Dashboard Styles
   ============================================ */

:root {
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --primary-light: #e8f0fe;
  --success: #34a853;
  --success-light: #e6f4ea;
  --warning: #fbbc04;
  --warning-light: #fef7e0;
  --danger: #ea4335;
  --danger-light: #fce8e6;
  --info: #4285f4;
  --info-light: #e8f0fe;
  --purple: #9c27b0;
  --purple-light: #f3e5f5;
  --orange: #ff6d00;
  --orange-light: #fff3e0;
  --teal: #00897b;
  --teal-light: #e0f2f1;
  --sidebar-bg: #1e2a3b;
  --sidebar-text: #c8d6e5;
  --sidebar-hover: #2d3f55;
  --sidebar-active: #1a73e8;
  --sidebar-width: 260px;
  --header-height: 60px;
  --bg: #f0f4f8;
  --card-bg: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --transition: 0.2s ease;
  --whatsapp-green: #25d366;
  --whatsapp-bg: #efeae2;
  --whatsapp-sent: #d9fdd3;
  --whatsapp-received: #ffffff;
  --whatsapp-header: #128c7e;
}

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

html, body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  height: 100%;
  overflow: hidden;
}

/* ============ LAYOUT ============ */
#app { height: 100vh; display: flex; flex-direction: column; }

.app-container {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  height: 100vh;
  flex-shrink: 0;
  transition: transform var(--transition);
  z-index: 200;
  overflow-y: auto;
  scrollbar-width: none;
}
.sidebar::-webkit-scrollbar { display: none; }

.sidebar-logo {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-logo .logo-icon {
  width: 40px; height: 40px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: white;
  flex-shrink: 0;
}
.sidebar-logo .logo-text { flex: 1; }
.sidebar-logo .logo-title {
  font-size: 14px; font-weight: 700;
  color: #ffffff; line-height: 1.2;
}
.sidebar-logo .logo-sub {
  font-size: 10px; color: var(--sidebar-text);
  text-transform: uppercase; letter-spacing: 0.5px;
}

.sidebar-nav { flex: 1; padding: 12px 0; }

.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(200,214,229,0.5);
  padding: 12px 20px 4px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  font-size: 14px;
  font-weight: 500;
  position: relative;
  text-decoration: none;
}
.nav-item:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}
.nav-item.active {
  background: rgba(26,115,232,0.15);
  color: #ffffff;
  border-left-color: var(--sidebar-active);
}
.nav-item i {
  width: 20px;
  text-align: center;
  font-size: 15px;
  flex-shrink: 0;
}
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

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

.topbar {
  height: var(--header-height);
  background: white;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}
.topbar-title {
  flex: 1;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.topbar-bot-status {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.topbar-bot-status.online {
  background: var(--success-light); color: var(--success);
}
.topbar-bot-status.offline {
  background: var(--danger-light); color: var(--danger);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

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

/* ============ CARDS ============ */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-header h2, .card-header h3 {
  font-size: 15px; font-weight: 700; color: var(--text);
}
.card-header .card-header-actions { margin-left: auto; display: flex; gap: 8px; }
.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: #fafafa;
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ============ STAT CARDS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stat-card .stat-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
.stat-card .stat-value {
  font-size: 26px; font-weight: 800; line-height: 1;
}
.stat-card .stat-label {
  font-size: 12px; color: var(--text-muted); font-weight: 500;
}
.stat-card .stat-change {
  font-size: 11px; font-weight: 600;
  display: flex; align-items: center; gap: 4px;
}
.stat-card .stat-change.up { color: var(--success); }
.stat-card .stat-change.down { color: var(--danger); }

/* Status colors */
.icon-blue { background: var(--primary-light); color: var(--primary); }
.icon-green { background: var(--success-light); color: var(--success); }
.icon-orange { background: var(--orange-light); color: var(--orange); }
.icon-red { background: var(--danger-light); color: var(--danger); }
.icon-purple { background: var(--purple-light); color: var(--purple); }
.icon-teal { background: var(--teal-light); color: var(--teal); }
.icon-yellow { background: var(--warning-light); color: #c4930a; }

/* ============ STATUS INDICATORS ============ */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.status-badge.online, .status-badge.active, .status-badge.success, .status-badge.connected {
  background: var(--success-light); color: var(--success);
}
.status-badge.offline, .status-badge.error, .status-badge.failed, .status-badge.disconnected {
  background: var(--danger-light); color: var(--danger);
}
.status-badge.warning, .status-badge.cooldown, .status-badge.pending {
  background: var(--warning-light); color: #c4930a;
}
.status-badge.info, .status-badge.ai {
  background: var(--info-light); color: var(--info);
}
.status-badge.human {
  background: var(--purple-light); color: var(--purple);
}
.status-badge.disabled, .status-badge.inactive {
  background: #f3f4f6; color: var(--text-muted);
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #2d9249; }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #c62828; }
.btn-warning { background: var(--warning); color: #333; }
.btn-warning:hover { background: #e0a800; }
.btn-outline {
  background: white; color: var(--text);
  border: 1px solid var(--border);
}
.btn-outline:hover { background: #f9fafb; }
.btn-ghost {
  background: transparent; color: var(--text-muted);
}
.btn-ghost:hover { background: #f3f4f6; color: var(--text); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-icon { padding: 8px; }
.btn-whatsapp { background: var(--whatsapp-green); color: white; }
.btn-whatsapp:hover { background: #1ea952; }
.btn-purple { background: var(--purple); color: white; }
.btn-purple:hover { background: #7b1fa2; }

/* ============ FORMS ============ */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.form-label .required { color: var(--danger); }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: white;
  transition: border-color var(--transition);
  outline: none;
  font-family: inherit;
}
.form-control:focus { border-color: var(--primary); }
.form-control::placeholder { color: #b0b8c4; }
textarea.form-control { resize: vertical; min-height: 80px; }
.form-text { font-size: 11px; color: var(--text-muted); margin-top: 4px; }
.form-select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text);
  background: white;
  cursor: pointer;
  outline: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath fill='%236b7280' d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  padding-right: 36px;
}
.form-select:focus { border-color: var(--primary); }

/* ============ TOGGLE SWITCH ============ */
.toggle-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}
.toggle {
  position: relative;
  display: inline-block;
  width: 46px; height: 26px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #d1d5db;
  border-radius: 26px;
  transition: var(--transition);
}
.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px; width: 20px;
  left: 3px; bottom: 3px;
  background: white;
  border-radius: 50%;
  transition: var(--transition);
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle input:checked + .toggle-slider { background: var(--success); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }
.toggle-label { font-size: 14px; font-weight: 500; cursor: pointer; }

/* ============ TABLES ============ */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  background: #f8f9fb;
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: #fafbfc; }
.td-actions { display: flex; gap: 6px; align-items: center; }

/* ============ SEARCH & FILTERS ============ */
.search-bar {
  position: relative;
  flex: 1;
}
.search-bar i {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 14px;
}
.search-bar input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  outline: none;
  background: white;
  font-family: inherit;
}
.search-bar input:focus { border-color: var(--primary); }

.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* ============ TABS ============ */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.tab:hover { color: var(--primary); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal {
  background: white;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-md);
  animation: modalIn 0.2s ease;
}
@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header h3 { font-size: 16px; font-weight: 700; flex: 1; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 18px;
  padding: 4px;
}
.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: #fafafa;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ============ CONVERSATIONS ============ */
.conversations-layout {
  display: flex;
  height: calc(100vh - var(--header-height));
  overflow: hidden;
  gap: 0;
}
.conv-list {
  width: 320px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: white;
  overflow: hidden;
}
.conv-list-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: #fafafa;
}
.conv-list-header h3 { font-size: 15px; font-weight: 700; margin-bottom: 10px; }
.conv-search { position: relative; }
.conv-search input {
  width: 100%; padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--border); border-radius: 20px;
  font-size: 13px; outline: none; background: white;
  font-family: inherit;
}
.conv-search i {
  position: absolute; left: 11px; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted); font-size: 13px;
}
.conv-items { flex: 1; overflow-y: auto; }
.conv-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  border-bottom: 1px solid #f3f4f6;
  transition: background var(--transition);
}
.conv-item:hover { background: #f9fafb; }
.conv-item.active { background: var(--primary-light); }
.conv-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700;
  flex-shrink: 0;
}
.conv-item-info { flex: 1; min-width: 0; }
.conv-item-name {
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 3px;
}
.conv-item-msg {
  font-size: 12px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.conv-item-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}
.conv-item-time { font-size: 11px; color: var(--text-muted); }
.conv-unread {
  background: var(--whatsapp-green);
  color: white;
  font-size: 10px; font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px; text-align: center;
}

/* Conversation window */
.conv-window {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--whatsapp-bg);
}
.conv-window-header {
  background: var(--whatsapp-header);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.conv-window-header .conv-avatar { width: 38px; height: 38px; font-size: 14px; }
.conv-window-info { flex: 1; }
.conv-window-info .name { font-size: 15px; font-weight: 700; }
.conv-window-info .status { font-size: 12px; opacity: 0.85; }
.conv-window-actions { display: flex; gap: 6px; }
.conv-window-actions button {
  background: rgba(255,255,255,0.15);
  border: none; color: white;
  padding: 6px 12px; border-radius: 16px;
  font-size: 12px; font-weight: 600; cursor: pointer;
  transition: background var(--transition);
}
.conv-window-actions button:hover { background: rgba(255,255,255,0.25); }
.conv-window-actions button.active-btn { background: var(--warning); color: #333; }

.conv-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg-bubble {
  max-width: 70%;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
  line-height: 1.5;
  position: relative;
  word-break: break-word;
}
.msg-bubble.received {
  background: var(--whatsapp-received);
  align-self: flex-start;
  border-radius: 0 10px 10px 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.msg-bubble.sent {
  background: var(--whatsapp-sent);
  align-self: flex-end;
  border-radius: 10px 0 10px 10px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.msg-bubble.human-sent {
  background: #e3f2fd;
  align-self: flex-end;
  border-radius: 10px 0 10px 10px;
}
.msg-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg-sender-label {
  font-size: 11px; font-weight: 700;
  margin-bottom: 3px;
}
.msg-sender-label.customer { color: var(--teal); }
.msg-sender-label.ai { color: var(--primary); }
.msg-sender-label.human { color: var(--purple); }
.msg-actions {
  display: flex; gap: 4px; margin-top: 6px;
}
.msg-action-btn {
  font-size: 11px; padding: 3px 8px;
  border-radius: 10px; border: 1px solid var(--border);
  background: white; cursor: pointer; color: var(--text-muted);
  transition: all var(--transition);
}
.msg-action-btn:hover { border-color: var(--primary); color: var(--primary); }
.msg-action-btn.good { border-color: var(--success); color: var(--success); }
.msg-action-btn.bad { border-color: var(--danger); color: var(--danger); }

.conv-toolbar {
  background: #f0f0f0;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.conv-toolbar .btn { font-size: 12px; padding: 6px 12px; }

.conv-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  gap: 12px;
  background: var(--whatsapp-bg);
}
.conv-empty i { font-size: 48px; opacity: 0.3; }
.conv-empty p { font-size: 14px; }

/* ============ KNOWLEDGE BASE ============ */
.kb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.kb-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.kb-card-header {
  display: flex; align-items: flex-start; gap: 10px; margin-bottom: 10px;
}
.kb-card-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.kb-card-title { font-size: 14px; font-weight: 700; }
.kb-card-cat { font-size: 11px; color: var(--text-muted); }
.kb-card-content { font-size: 13px; color: var(--text-muted); line-height: 1.5; margin-bottom: 12px; }
.kb-card-footer {
  display: flex; align-items: center;
  border-top: 1px solid var(--border);
  padding-top: 10px;
  gap: 8px;
}

/* ============ PROGRESS BAR ============ */
.progress-bar {
  height: 8px;
  background: #e5e7eb;
  border-radius: 4px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--primary);
  transition: width 0.5s ease;
}

/* ============ ALERTS ============ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
  margin-bottom: 16px;
}
.alert-success { background: var(--success-light); color: #2d7a2d; border-color: #b7e0b7; }
.alert-danger { background: var(--danger-light); color: #c62828; border-color: #f5bfbf; }
.alert-warning { background: var(--warning-light); color: #92740a; border-color: #fde68a; }
.alert-info { background: var(--info-light); color: #1557b0; border-color: #bbd0f8; }

/* ============ TOAST NOTIFICATIONS ============ */
#toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: #1a1a2e;
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow-md);
  animation: toastIn 0.3s ease;
  min-width: 260px;
  max-width: 360px;
}
.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }
.toast.info { border-left: 4px solid var(--info); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ============ OVERLAY FOR MOBILE SIDEBAR ============ */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
}

/* ============ ANALYTICS CHARTS ============ */
.chart-container { position: relative; height: 240px; }
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ============ LOG ENTRIES ============ */
.log-entry {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.log-time { color: var(--text-muted); white-space: nowrap; flex-shrink: 0; min-width: 80px; }
.log-icon { width: 24px; flex-shrink: 0; display: flex; justify-content: center; }
.log-msg { flex: 1; }
.log-type { font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 4px; }
.log-type.info { background: var(--info-light); color: var(--info); }
.log-type.success { background: var(--success-light); color: var(--success); }
.log-type.error { background: var(--danger-light); color: var(--danger); }
.log-type.warning { background: var(--warning-light); color: #c4930a; }

/* ============ API KEY PRIORITY ============ */
.api-priority-flow {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 16px;
  background: #f8f9fb;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}
.api-flow-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px dashed var(--border);
}
.api-flow-step:last-child { border-bottom: none; }
.api-flow-arrow {
  text-align: center;
  padding: 4px;
  color: var(--text-muted);
  font-size: 16px;
}

/* ============ ATTENTION ITEMS ============ */
.attention-item {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  gap: 14px;
  align-items: flex-start;
  box-shadow: var(--shadow);
}
.attention-icon {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; flex-shrink: 0;
}
.attention-content { flex: 1; }
.attention-title { font-size: 14px; font-weight: 700; margin-bottom: 4px; }
.attention-msg { font-size: 13px; color: var(--text-muted); }
.attention-actions { display: flex; gap: 6px; margin-top: 10px; }

/* ============ TEST AI ============ */
.test-ai-result {
  background: #f8f9fb;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.test-result-row {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.test-result-row:last-child { border-bottom: none; }
.test-result-label {
  font-weight: 700;
  min-width: 160px;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding-top: 2px;
}
.test-result-value { flex: 1; line-height: 1.6; }
.test-response-box {
  background: var(--whatsapp-sent);
  border: 1px solid #c8e6c9;
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 14px;
  line-height: 1.6;
  margin-top: 8px;
}

/* ============ EMPTY STATES ============ */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }
.empty-state .btn { margin-top: 16px; }

/* ============ LOGIN SCREEN ============ */
.login-screen {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e2a3b 0%, #2d3f55 50%, #1a73e8 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.login-logo {
  text-align: center;
  margin-bottom: 30px;
}
.login-logo-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: white;
  margin: 0 auto 14px;
}
.login-logo h1 { font-size: 22px; font-weight: 800; color: var(--text); }
.login-logo p { font-size: 13px; color: var(--text-muted); }
.login-error {
  background: var(--danger-light);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}

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

  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay { display: block; }
  .sidebar-overlay.visible { display: block; }

  .topbar-menu-btn { display: flex; align-items: center; }

  .page-content { padding: 16px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-card .stat-value { font-size: 22px; }

  .chart-grid { grid-template-columns: 1fr; }
  .kb-grid { grid-template-columns: 1fr; }

  .conversations-layout {
    height: calc(100vh - var(--header-height));
  }
  .conv-list {
    width: 100%;
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 10;
    transition: transform var(--transition);
  }
  .conv-list.hidden { transform: translateX(-100%); }
  .conv-window { width: 100%; }

  .modal { max-width: 100%; margin: 0; border-radius: var(--radius) var(--radius) 0 0; }
  .modal-backdrop { align-items: flex-end; padding: 0; }

  .filter-bar { flex-direction: column; align-items: stretch; }
  .filter-bar .btn { justify-content: center; }

  .btn-lg { padding: 11px 18px; font-size: 14px; }

  table { font-size: 12px; }
  th, td { padding: 9px 10px; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .topbar-title { font-size: 15px; }
  .topbar-bot-status span { display: none; }
}

/* ============ SCROLLBARS ============ */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ============ UTILITIES ============ */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }
.mb-24 { margin-bottom: 24px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-bold { font-weight: 700; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-center { text-align: center; }
.w-100 { width: 100%; }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
@media (max-width: 600px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ============ SECTION HEADER ============ */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}
.section-header h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}
.section-header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}
.page-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 20px; }

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

/* ============ NEVER SAY RULES LIST ============ */
.rule-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 10px;
}
.rule-item.disabled { opacity: 0.5; }
.rule-text { flex: 1; font-size: 14px; }
.rule-actions { display: flex; gap: 6px; }

/* ============ PRIORITY BADGE ============ */
.priority-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: 12px; font-weight: 800;
  background: var(--primary);
  color: white;
}

/* ============ MASKED KEY ============ */
.masked-key {
  font-family: 'Courier New', monospace;
  font-size: 13px;
  background: #f3f4f6;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
}

/* ============ CURRENT KEY HERO ============ */
.current-key-hero {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 28px;
  margin-bottom: 20px;
}
.current-key-hero .key-label { font-size: 12px; opacity: 0.8; text-transform: uppercase; letter-spacing: 1px; }
.current-key-hero .key-name { font-size: 28px; font-weight: 800; margin: 6px 0; }
.current-key-hero .key-details { font-size: 13px; opacity: 0.85; }

/* ============ PAGE TRANSITION ============ */
.page-section {
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ REPAIR LOOKUP HISTORY ============ */
.lookup-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid #f3f4f6;
  font-size: 13px;
}
.lookup-job {
  font-weight: 700; color: var(--primary);
  min-width: 100px;
}

/* ============ CONNECTION TEST ============ */
.connection-test-result {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-top: 12px;
  display: none;
}
.connection-test-result.success { background: var(--success-light); color: var(--success); display: flex; gap: 8px; align-items: center; }
.connection-test-result.error { background: var(--danger-light); color: var(--danger); display: flex; gap: 8px; align-items: center; }

/* ============ LANGUAGE TAGS ============ */
.lang-tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  background: var(--info-light);
  color: var(--info);
  margin: 3px;
}
