/* ============================================================
   OMOR — Global Design System
   Deep navy + warm sand palette | Glassmorphism | RTL support
   ============================================================ */

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

/* ── CSS Variables ─────────────────────────────────────────── */
:root {
  --bg-0: #0a0f1c;
  --bg-1: #0f172a;
  --bg-2: #1e293b;
  --bg-3: #263347;
  --bg-glass: rgba(30, 41, 59, 0.55);
  --border: rgba(229, 201, 160, 0.12);
  --border-strong: rgba(229, 201, 160, 0.25);
  --text: #f5e9d4;
  --text-dim: #b8a688;
  --text-mute: #7a6d58;
  --accent: #d4af6f;
  --accent-light: rgba(212, 175, 111, 0.15);
  --accent-2: #5b8aa8;
  --accent-2-light: rgba(91, 138, 168, 0.15);
  --accent-3: #c8956d;
  --accent-3-light: rgba(200, 149, 109, 0.12);
  --success: #7fa878;
  --success-light: rgba(127, 168, 120, 0.15);
  --warn: #d4a04f;
  --warn-light: rgba(212, 160, 79, 0.15);
  --danger: #c76b5c;
  --danger-light: rgba(199, 107, 92, 0.15);
  --shadow-glow: 0 0 40px rgba(212, 175, 111, 0.12);
  --shadow-card: 0 4px 24px rgba(0,0,0,0.35);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
  --sidebar-width: 240px;
  --topbar-height: 60px;
  --font-display: 'Fraunces', Georgia, serif;
  --font-body: 'Inter', sans-serif;
  --transition: 0.2s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-0);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.8; }
button { cursor: pointer; font-family: var(--font-body); }
input, textarea, select {
  font-family: var(--font-body);
  background: var(--bg-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.9rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(212,175,111,0.12);
}
input::placeholder, textarea::placeholder { color: var(--text-mute); }
select option { background: var(--bg-2); }
img { max-width: 100%; display: block; }
ul { list-style: none; }
h1,h2,h3,h4,h5,h6 { font-weight: 600; line-height: 1.3; }

/* ── Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ── Layout shell ───────────────────────────────────────────── */
#app-shell { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition), width var(--transition);
  z-index: 100;
  position: relative;
}
#sidebar.collapsed { width: 56px; min-width: 56px; }
.sidebar-logo {
  padding: 1.2rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-height);
}
.logo-mark {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-display);
  font-size: 1.1rem; font-weight: 600;
  color: #0a0f1c;
  flex-shrink: 0;
}
.logo-text { line-height: 1.2; overflow: hidden; white-space: nowrap; }
.logo-text .name { font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--text); letter-spacing: 0.05em; }
.logo-text .name-ar { font-size: 0.65rem; color: var(--accent); letter-spacing: 0.1em; }

.sidebar-section-label {
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  padding: 1rem 1rem 0.35rem;
  overflow: hidden; white-space: nowrap;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.6rem 1rem;
  color: var(--text-dim);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  margin: 2px 8px;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.nav-item:hover { background: var(--bg-glass); color: var(--text); }
.nav-item.active {
  background: var(--accent-light);
  color: var(--accent);
}
.nav-item .nav-icon { width: 18px; text-align: center; flex-shrink: 0; font-size: 0.9rem; }
.nav-item .nav-badge {
  margin-left: auto;
  background: var(--accent);
  color: #0a0f1c;
  font-size: 0.6rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 20px;
}
.nav-item .nav-badge.red { background: var(--danger); color: #fff; }
.nav-item .nav-badge.blue { background: var(--accent-2); color: #fff; }

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  border-top: 1px solid var(--border);
  padding: 0.75rem;
}
.ws-switcher {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  transition: border-color var(--transition);
}
.ws-switcher:hover { border-color: var(--border-strong); }
.ws-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.ws-info { overflow: hidden; flex: 1; }
.ws-name { font-size: 0.8rem; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ws-plan { font-size: 0.65rem; color: var(--text-mute); }

/* Main content area */
#main-wrap { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* Topbar */
#topbar {
  height: var(--topbar-height);
  min-height: var(--topbar-height);
  background: var(--bg-1);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  gap: 1rem;
  z-index: 90;
}
.topbar-left { display: flex; align-items: center; gap: 0.75rem; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.breadcrumb { font-size: 0.85rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.breadcrumb span { color: var(--text); font-weight: 600; }

.search-bar {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem 0.75rem;
  cursor: pointer;
  transition: border-color var(--transition);
  min-width: 180px;
}
.search-bar:hover { border-color: var(--border-strong); }
.search-bar span { font-size: 0.8rem; color: var(--text-mute); }
.search-bar kbd {
  margin-left: auto;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.6rem;
  color: var(--text-mute);
  font-family: var(--font-body);
}

.lang-switcher {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 0.35rem 0.6rem;
  cursor: pointer;
  display: flex; align-items: center; gap: 0.3rem;
}
.lang-switcher:hover { border-color: var(--accent); color: var(--accent); }

.topbar-icon-btn {
  width: 34px; height: 34px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.topbar-icon-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.topbar-icon-btn.has-dot { position: relative; }
.topbar-icon-btn.has-dot::after {
  content: '';
  position: absolute;
  top: 5px; right: 5px;
  width: 7px; height: 7px;
  background: var(--accent);
  border-radius: 50%;
  border: 1.5px solid var(--bg-1);
}

.user-avatar-btn {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  border-radius: 50%;
  border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700;
  color: #0a0f1c;
  cursor: pointer;
}

/* Main page content */
#page-content {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
  position: relative;
}

/* ── Page header ─────────────────────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 1.5rem; gap: 1rem; flex-wrap: wrap;
}
.page-title { font-family: var(--font-display); font-size: 1.6rem; font-weight: 400; color: var(--text); }
.page-sub { font-size: 0.85rem; color: var(--text-dim); margin-top: 0.2rem; }
.page-actions { display: flex; gap: 0.5rem; flex-shrink: 0; }

/* ── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  border: none;
  transition: all var(--transition);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #0a0f1c;
  font-weight: 600;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); box-shadow: 0 4px 16px rgba(212,175,111,0.3); }
.btn-secondary {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
}
.btn-ghost:hover { border-color: var(--border-strong); color: var(--text); }
.btn-danger {
  background: var(--danger-light);
  border: 1px solid var(--danger);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.78rem; }
.btn-lg { padding: 0.75rem 1.5rem; font-size: 1rem; }
.btn-icon { padding: 0.55rem; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.card-pad { padding: 1.25rem; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 0.875rem; font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 0.5rem; }
.card-body { padding: 1.25rem; }

/* ── KPI Cards ───────────────────────────────────────────────── */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.kpi-card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem;
  backdrop-filter: blur(12px);
  transition: border-color var(--transition), transform var(--transition);
}
.kpi-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.kpi-label { font-size: 0.72rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.08em; margin-bottom: 0.5rem; }
.kpi-value { font-size: 1.6rem; font-weight: 700; color: var(--text); line-height: 1; }
.kpi-value.gold { color: var(--accent); }
.kpi-value.blue { color: var(--accent-2); }
.kpi-sub { font-size: 0.72rem; color: var(--text-mute); margin-top: 0.4rem; display: flex; align-items: center; gap: 0.3rem; }
.kpi-sub .up { color: var(--success); }
.kpi-sub .down { color: var(--danger); }

/* ── Grid layouts ────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-auto { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }

/* ── Badges / Pills ──────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 0.3rem;
  padding: 0.18rem 0.6rem;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.badge-live { background: var(--success-light); color: var(--success); border: 1px solid var(--success); }
.badge-draft { background: var(--bg-3); color: var(--text-mute); border: 1px solid var(--border); }
.badge-paused { background: var(--warn-light); color: var(--warn); border: 1px solid var(--warn); }
.badge-gold { background: var(--accent-light); color: var(--accent); border: 1px solid var(--accent); }
.badge-blue { background: var(--accent-2-light); color: var(--accent-2); border: 1px solid var(--accent-2); }
.badge-danger { background: var(--danger-light); color: var(--danger); border: 1px solid var(--danger); }
.badge-v2 { background: linear-gradient(135deg,#5b8aa8,#7fa878); color:#fff; border:none; font-size:0.6rem; }
.pulse-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; }
.pulse-dot.green { background: var(--success); box-shadow: 0 0 0 0 var(--success); animation: pulse-anim 1.5s infinite; }
.pulse-dot.gold { background: var(--accent); box-shadow: 0 0 0 0 var(--accent); animation: pulse-anim 1.5s infinite; }
@keyframes pulse-anim {
  0% { box-shadow: 0 0 0 0 rgba(127,168,120,0.6); }
  70% { box-shadow: 0 0 0 6px rgba(127,168,120,0); }
  100% { box-shadow: 0 0 0 0 rgba(127,168,120,0); }
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead th {
  text-align: left;
  padding: 0.6rem 1rem;
  color: var(--text-mute);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
}
tbody tr {
  border-bottom: 1px solid rgba(229,201,160,0.06);
  transition: background var(--transition);
}
tbody tr:hover { background: rgba(212,175,111,0.04); }
tbody td { padding: 0.75rem 1rem; color: var(--text-dim); vertical-align: middle; }
tbody td:first-child { color: var(--text); }

/* ── Tabs ─────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0.25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; }
.tab-btn {
  padding: 0.6rem 1rem;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  margin-bottom: -1px;
  transition: all var(--transition);
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Agent cards ──────────────────────────────────────────────── */
.agent-card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
}
.agent-card:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: var(--shadow-glow); }
.agent-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem;
  font-weight: 700;
  flex-shrink: 0;
  position: relative;
}
.agent-top { display: flex; align-items: flex-start; gap: 0.75rem; }
.agent-info { flex: 1; min-width: 0; }
.agent-name { font-size: 1rem; font-weight: 600; color: var(--text); }
.agent-role { font-size: 0.75rem; color: var(--text-mute); margin-top: 0.1rem; }
.agent-langs { display: flex; gap: 0.3rem; flex-wrap: wrap; margin-top: 0.4rem; }
.lang-flag { font-size: 0.75rem; background: var(--bg-3); border-radius: 4px; padding: 1px 5px; }
.agent-stats { display: flex; gap: 1rem; }
.agent-stat { text-align: center; }
.agent-stat-val { font-size: 1rem; font-weight: 700; color: var(--text); }
.agent-stat-lbl { font-size: 0.65rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; }
.agent-card-footer { display: flex; gap: 0.4rem; flex-wrap: wrap; }

/* ── Live call card ───────────────────────────────────────────── */
.live-call-card {
  background: var(--bg-2);
  border: 1px solid rgba(127,168,120,0.3);
  border-radius: var(--radius);
  padding: 1rem;
  position: relative;
  overflow: hidden;
}
.live-call-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--success), transparent);
  animation: scan 2s linear infinite;
}
@keyframes scan {
  0% { transform: scaleX(0) translateX(0); transform-origin: left; }
  50% { transform: scaleX(1); transform-origin: left; }
  100% { transform: scaleX(0) translateX(100%); transform-origin: right; }
}
.waveform { display: flex; align-items: center; gap: 2px; height: 24px; }
.waveform .bar { width: 3px; background: var(--accent); border-radius: 3px; animation: wave 0.8s ease-in-out infinite; }
.waveform .bar:nth-child(2) { animation-delay: 0.1s; }
.waveform .bar:nth-child(3) { animation-delay: 0.2s; }
.waveform .bar:nth-child(4) { animation-delay: 0.3s; }
.waveform .bar:nth-child(5) { animation-delay: 0.4s; }
.waveform .bar:nth-child(6) { animation-delay: 0.1s; }
.waveform .bar:nth-child(7) { animation-delay: 0.25s; }
@keyframes wave {
  0%,100% { height: 6px; }
  50% { height: 20px; }
}

/* ── Modals ───────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-sm { max-width: 420px; }
.modal-md { max-width: 580px; }
.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1100px; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: transparent; border: none; color: var(--text-mute); font-size: 1.1rem; cursor: pointer; padding: 0.3rem; }
.modal-close:hover { color: var(--text); }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.5rem; justify-content: flex-end; }

/* ── Command Palette ──────────────────────────────────────────── */
#cmd-palette {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.8);
  z-index: 2000;
  display: flex; align-items: flex-start; justify-content: center;
  padding-top: 10vh;
  backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.15s;
}
#cmd-palette.open { opacity: 1; pointer-events: all; }
.cmd-box {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 580px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.6);
  overflow: hidden;
}
.cmd-search {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}
.cmd-search input {
  flex: 1; background: transparent; border: none;
  font-size: 1rem; color: var(--text); outline: none;
}
.cmd-results { max-height: 340px; overflow-y: auto; padding: 0.5rem; }
.cmd-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-dim);
  font-size: 0.875rem;
  transition: all var(--transition);
}
.cmd-item:hover, .cmd-item.selected { background: var(--accent-light); color: var(--accent); }
.cmd-item .cmd-icon { width: 20px; text-align: center; }
.cmd-item .cmd-label { flex: 1; }
.cmd-item .cmd-shortcut { font-size: 0.7rem; color: var(--text-mute); background: var(--bg-3); border-radius: 4px; padding: 1px 6px; }
.cmd-group-label {
  font-size: 0.65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-mute);
  padding: 0.5rem 0.75rem 0.2rem;
}

/* ── Toasts ───────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 340px;
}
.toast {
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  box-shadow: var(--shadow-card);
  animation: slideIn 0.3s ease;
  font-size: 0.85rem;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.warn { border-left: 3px solid var(--warn); }
.toast.info { border-left: 3px solid var(--accent-2); }
.toast-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
.toast-body { flex: 1; }
.toast-title { font-weight: 600; color: var(--text); }
.toast-msg { color: var(--text-dim); font-size: 0.78rem; margin-top: 0.15rem; }
.toast-close { background: transparent; border: none; color: var(--text-mute); cursor: pointer; padding: 0; font-size: 0.9rem; }
@keyframes slideIn { from { transform: translateX(30px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(30px); opacity: 0; } }
.toast.removing { animation: slideOut 0.3s ease forwards; }

/* ── Workspace switcher dropdown ─────────────────────────────── */
.ws-dropdown {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0.75rem; right: 0.75rem;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  z-index: 200;
  overflow: hidden;
  display: none;
}
.ws-dropdown.open { display: block; }
.ws-dropdown-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  transition: background var(--transition);
  border-bottom: 1px solid var(--border);
}
.ws-dropdown-item:last-child { border-bottom: none; }
.ws-dropdown-item:hover { background: var(--accent-light); }
.ws-dropdown-item.active .ws-name { color: var(--accent); }

/* ── Form elements ───────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: 0.8rem; font-weight: 500; color: var(--text-dim); margin-bottom: 0.4rem; }
.form-input { width: 100%; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-hint { font-size: 0.72rem; color: var(--text-mute); margin-top: 0.3rem; }
.form-check { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; }
.form-check input[type=checkbox] {
  width: 16px; height: 16px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  accent-color: var(--accent);
}
.toggle-wrap { display: flex; align-items: center; gap: 0.75rem; }
.toggle {
  position: relative;
  width: 40px; height: 22px;
  background: var(--bg-3);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  cursor: pointer;
  transition: background var(--transition);
  flex-shrink: 0;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
}
.toggle.on::after { transform: translateX(18px); }

/* ── Slider ───────────────────────────────────────────────────── */
.slider-wrap { display: flex; align-items: center; gap: 0.75rem; }
.slider-label-l, .slider-label-r { font-size: 0.72rem; color: var(--text-mute); white-space: nowrap; }
input[type=range] {
  flex: 1;
  -webkit-appearance: none;
  height: 4px;
  background: var(--bg-3);
  border-radius: 4px;
  border: none;
  padding: 0;
  cursor: pointer;
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
}

/* ── Conversation / chat styles ──────────────────────────────── */
.transcript { display: flex; flex-direction: column; gap: 1rem; }
.transcript-turn { display: flex; gap: 0.75rem; }
.transcript-turn.agent-turn { }
.transcript-turn.user-turn { flex-direction: row-reverse; }
.turn-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: 700;
  flex-shrink: 0;
}
.turn-bubble {
  max-width: 75%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.6rem 0.9rem;
  font-size: 0.83rem;
  color: var(--text);
}
.transcript-turn.user-turn .turn-bubble {
  background: var(--accent-light);
  border-color: var(--accent);
}
.turn-meta { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.25rem; }
.turn-name { font-size: 0.7rem; font-weight: 600; color: var(--text-dim); }
.turn-time { font-size: 0.65rem; color: var(--text-mute); }
.lang-tag {
  font-size: 0.6rem;
  background: var(--bg-3);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-mute);
}

/* ── WhatsApp chat ────────────────────────────────────────────── */
.wa-chat { background: #0d1117; border-radius: var(--radius); padding: 1rem; display: flex; flex-direction: column; gap: 0.75rem; }
.wa-bubble {
  padding: 0.6rem 0.9rem;
  border-radius: 12px;
  max-width: 75%;
  font-size: 0.83rem;
  position: relative;
}
.wa-bubble.from { background: #1e2d24; color: #e9f5e1; align-self: flex-start; border-bottom-left-radius: 4px; }
.wa-bubble.to { background: #1c3a2e; color: #e9f5e1; align-self: flex-end; border-bottom-right-radius: 4px; }
.wa-time { font-size: 0.6rem; color: rgba(255,255,255,0.4); text-align: right; margin-top: 0.25rem; }

/* ── Empty state ──────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; opacity: 0.5; }
.empty-state h3 { font-size: 1rem; color: var(--text); margin-bottom: 0.35rem; }
.empty-state p { font-size: 0.83rem; max-width: 280px; margin: 0 auto; }

/* ── Loading skeletons ────────────────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg-2) 25%, var(--bg-3) 50%, var(--bg-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 14px; width: 100%; margin-bottom: 0.5rem; }
.skeleton-text.w60 { width: 60%; }
.skeleton-text.w40 { width: 40%; }

/* ── Mesh timeline ────────────────────────────────────────────── */
.mesh-timeline { display: flex; flex-direction: column; gap: 0; }
.mesh-event {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid rgba(229,201,160,0.06);
  position: relative;
}
.mesh-event::before {
  content: '';
  position: absolute;
  left: 13px; top: 100%;
  width: 1px; height: 100%;
  background: var(--border);
}
.mesh-event:last-child::before { display: none; }
.mesh-dot { width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700; }
.mesh-body { flex: 1; }
.mesh-meta { font-size: 0.7rem; color: var(--text-mute); margin-bottom: 0.2rem; }
.mesh-text { font-size: 0.82rem; color: var(--text); }
.mesh-tag { font-size: 0.7rem; color: var(--text-dim); }
.mesh-win { font-size: 0.82rem; font-weight: 700; color: var(--success); }

/* ── Step wizard ──────────────────────────────────────────────── */
.wizard-steps { display: flex; align-items: center; gap: 0; margin-bottom: 2rem; }
.wizard-step-item { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }
.wizard-step-item:not(:last-child)::after {
  content: '';
  position: absolute;
  top: 18px; left: 50%; right: -50%;
  height: 1px;
  background: var(--border);
  z-index: 0;
}
.wizard-step-item.done:not(:last-child)::after { background: var(--accent); }
.wizard-step-num {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 600;
  color: var(--text-mute);
  background: var(--bg-2);
  position: relative; z-index: 1;
  transition: all var(--transition);
}
.wizard-step-item.active .wizard-step-num { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.wizard-step-item.done .wizard-step-num { border-color: var(--accent); color: #0a0f1c; background: var(--accent); }
.wizard-step-label { font-size: 0.7rem; color: var(--text-mute); margin-top: 0.4rem; text-align: center; }
.wizard-step-item.active .wizard-step-label { color: var(--accent); }

/* ── Tile pickers ─────────────────────────────────────────────── */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 0.75rem; }
.tile {
  background: var(--bg-2);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.tile:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.tile.selected { border-color: var(--accent); background: var(--accent-light); }
.tile .tile-icon { font-size: 1.75rem; margin-bottom: 0.5rem; }
.tile .tile-label { font-size: 0.83rem; font-weight: 500; color: var(--text); }
.tile .tile-sub { font-size: 0.7rem; color: var(--text-mute); margin-top: 0.2rem; }

/* ── Knowledge / file upload ──────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 2.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}
.upload-zone:hover, .upload-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }
.upload-zone .upload-icon { font-size: 2rem; color: var(--text-mute); margin-bottom: 0.75rem; }

/* ── Pricing cards ────────────────────────────────────────────── */
.pricing-card {
  background: var(--bg-glass);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  display: flex; flex-direction: column; gap: 1rem;
  position: relative;
  backdrop-filter: blur(12px);
  transition: border-color var(--transition), transform var(--transition);
}
.pricing-card:hover { border-color: var(--border-strong); transform: translateY(-3px); }
.pricing-card.featured { border-color: var(--accent); box-shadow: var(--shadow-glow); }
.pricing-card .featured-badge {
  position: absolute;
  top: -12px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg, var(--accent), var(--accent-3));
  color: #0a0f1c;
  font-size: 0.7rem; font-weight: 700;
  padding: 3px 14px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pricing-name { font-size: 1.1rem; font-weight: 700; color: var(--text); }
.pricing-price { font-size: 2rem; font-weight: 700; color: var(--accent); line-height: 1; }
.pricing-price sup { font-size: 1rem; vertical-align: top; margin-top: 6px; color: var(--text-dim); }
.pricing-period { font-size: 0.78rem; color: var(--text-mute); }
.pricing-features { display: flex; flex-direction: column; gap: 0.5rem; flex: 1; }
.pricing-feature { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; color: var(--text-dim); }
.pricing-feature i { color: var(--accent); width: 14px; }

/* ── Compliance cards ─────────────────────────────────────────── */
.compliance-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; gap: 1rem; align-items: flex-start;
  transition: border-color var(--transition);
}
.compliance-card:hover { border-color: var(--border-strong); }
.compliance-icon { font-size: 1.5rem; flex-shrink: 0; }

/* ── RTL support ──────────────────────────────────────────────── */
html[dir="rtl"] body { font-family: 'Inter', 'Arabic', sans-serif; }
html[dir="rtl"] #sidebar { border-right: none; border-left: 1px solid var(--border); }
html[dir="rtl"] .nav-item { flex-direction: row-reverse; }
html[dir="rtl"] .nav-item .nav-badge { margin-left: 0; margin-right: auto; }
html[dir="rtl"] .page-header { flex-direction: row-reverse; }
html[dir="rtl"] table thead th { text-align: right; }
html[dir="rtl"] tbody td { text-align: right; }
html[dir="rtl"] .toast { border-left: none; border-right: 3px solid var(--success); }
html[dir="rtl"] .mesh-event::before { left: auto; right: 13px; }

/* ── Ambient background orbs ──────────────────────────────────── */
.orb {
  position: fixed; pointer-events: none; z-index: 0;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.07;
}
.orb-gold { width: 500px; height: 500px; background: var(--accent); top: -150px; right: -100px; }
.orb-blue { width: 400px; height: 400px; background: var(--accent-2); bottom: -100px; left: -100px; }
.orb-terra { width: 300px; height: 300px; background: var(--accent-3); top: 40%; left: 30%; }

/* ── Responsive ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-width: 240px; }
  #sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 500;
    box-shadow: 4px 0 20px rgba(0,0,0,0.5);
  }
  #sidebar.mobile-open { transform: translateX(0); }
  #main-wrap { width: 100%; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  #page-content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr 1fr; }
  .tile-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Activity feed ────────────────────────────────────────────── */
.activity-item {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.65rem 0;
  border-bottom: 1px solid rgba(229,201,160,0.06);
}
.activity-item:last-child { border-bottom: none; }
.activity-icon { width: 28px; height: 28px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 0.72rem; flex-shrink: 0; }
.activity-text { flex: 1; font-size: 0.8rem; color: var(--text-dim); }
.activity-text strong { color: var(--text); }
.activity-time { font-size: 0.68rem; color: var(--text-mute); flex-shrink: 0; }

/* ── Sidebar mobile overlay ───────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 499;
}
#sidebar-overlay.show { display: block; }

/* ── User dropdown ────────────────────────────────────────────── */
.user-dropdown {
  position: absolute;
  top: calc(100% + 8px); right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  min-width: 200px;
  box-shadow: var(--shadow-card);
  z-index: 400;
  display: none;
  overflow: hidden;
}
.user-dropdown.open { display: block; }
.user-dropdown-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); }
.user-dropdown-name { font-weight: 600; font-size: 0.85rem; }
.user-dropdown-email { font-size: 0.72rem; color: var(--text-mute); }
.user-dropdown-item {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.6rem 1rem;
  font-size: 0.83rem; color: var(--text-dim);
  cursor: pointer; transition: background var(--transition);
}
.user-dropdown-item:hover { background: var(--accent-light); color: var(--accent); }
.user-dropdown-item.danger:hover { background: var(--danger-light); color: var(--danger); }

/* ── Chart containers ─────────────────────────────────────────── */
.chart-container { position: relative; height: 200px; }
.chart-container.tall { height: 260px; }

/* ── Stat row ─────────────────────────────────────────────────── */
.stat-row { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.stat-item { text-align: center; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--text); }
.stat-label { font-size: 0.68rem; color: var(--text-mute); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Tag chips ────────────────────────────────────────────────── */
.chip {
  display: inline-flex; align-items: center; gap: 0.3rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 0.22rem 0.7rem;
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all var(--transition);
}
.chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }
.chip.active { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* ── Progress bar ─────────────────────────────────────────────── */
.progress { height: 6px; background: var(--bg-3); border-radius: 10px; overflow: hidden; }
.progress-bar { height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-3)); border-radius: 10px; transition: width 0.6s ease; }
.progress-bar.blue { background: linear-gradient(90deg, var(--accent-2), #7fa878); }

/* ── Version badge ────────────────────────────────────────────── */
.version-badge {
  font-size: 0.65rem; font-family: monospace;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-mute);
}

/* ── Notification bell ────────────────────────────────────────── */
.notif-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 320px;
  background: var(--bg-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  z-index: 400;
  display: none;
  overflow: hidden;
}
.notif-dropdown.open { display: block; }
.notif-header { padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.notif-item { display: flex; gap: 0.75rem; padding: 0.75rem 1rem; border-bottom: 1px solid rgba(229,201,160,0.06); cursor: pointer; transition: background var(--transition); }
.notif-item:hover { background: var(--accent-light); }
.notif-item.unread { background: rgba(212,175,111,0.04); }
.notif-text { font-size: 0.8rem; color: var(--text-dim); flex: 1; }
.notif-time { font-size: 0.68rem; color: var(--text-mute); margin-top: 0.2rem; }
