/* ═══════════════════════════════════════════════════════════════════
   Kazma Design System v4 — design-b-modern
   BG: #0a0f14 | Accent: #22d3ee (cyan) | Secondary: #a855f7 (purple)
   Font: Inter, system-ui, sans-serif | Grid texture background
   ═══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;700&family=Cairo:wght@300;400;500;600;700&display=swap');

/* ── 1. CSS Variables — kazma.ai palette ─────────────────────────── */
:root {

  /* Legacy aliases */
  --bg-deep: var(--bg);
  --bg-primary: var(--bg);
  /* Backgrounds — deep charcoal like kazma.ai */
  --bg: #0a0f14;
  --bg-2: #0e141b;
  --bg-panel: #11171f;
  --bg-surface: #141c25;
  --bg-elevated: #1a2332;
  --bg-hover: rgba(34, 211, 238, 0.06);
  --bg-active: rgba(34, 211, 238, 0.10);
  --tint: rgba(255, 255, 255, 0.025);
  --tint-strong: rgba(255, 255, 255, 0.05);

  /* Grid texture */
  --grid: rgba(34, 211, 238, 0.03);

  /* Text — cool slate */
  --text-primary: #e6edf3;
  --text-secondary: #b1bac4;
  --text-tertiary: #8b949e;
  --text-muted: #6e7681;
  --text-inverse: #0a0f14;

  /* Accent — cyan (design-b) */
  --accent: #22d3ee;
  --accent-hover: #38dff2;
  --accent-light: #67e8f9;
  --accent-subtle: rgba(34, 211, 238, 0.12);
  --accent-glow: rgba(34, 211, 238, 0.25);

  /* Secondary — purple (kazma.ai secondary) */
  --secondary: #a855f7;
  --secondary-hover: #c084fc;
  --secondary-light: #d8b4fe;
  --secondary-subtle: rgba(168, 85, 247, 0.12);
  --secondary-glow: rgba(168, 85, 247, 0.20);

  /* Gradient accents — matching kazma.ai heading gradient */
  --gradient-primary: linear-gradient(135deg, #a855f7, #ec4899, #00e5ff);
  --gradient-header: linear-gradient(135deg, #a855f7 0%, #ec4899 50%, #00e5ff 100%);

  /* Status */
  --success: #10b981;
  --success-subtle: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-subtle: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-subtle: rgba(239, 68, 68, 0.12);
  --info: #06b6d4;
  --info-subtle: rgba(88, 166, 255, 0.12);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border: rgba(255, 255, 255, 0.1);
  --border-strong: rgba(255, 255, 255, 0.15);

  /* Radii */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  /* Spacing (4px grid) */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Layout */
  --sidebar-width: 250px;
  --sidebar-collapsed: 60px;
  --header-height: 56px;

  /* Typography */
  --font-sans: 'Calibri', 'Inter', 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-arabic: 'Calibri', 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --font-features: 'cv01', 'ss03';

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.5);
  --shadow-xl: 0 16px 48px rgba(0,0,0,0.6);

  /* Transitions */
  --transition-fast: 150ms ease;
  --transition: 200ms ease;
  --transition-slow: 300ms ease;
}

/* ── 2. Reset ───────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; }
/* Arabic mode: bump the base font-size up — Arabic glyphs need larger
   rendering for readability. 16px base makes 0.7rem ≈ 11.2px (readable)
   vs 9.8px at the 14px default. */
html[dir="rtl"] { font-size: 16px; }
/* Arabic mode: enforce a minimum readable font-size on the elements
   that commonly use tiny inline 0.6–0.7rem values (badges, hints,
   metric labels/sub-text, breadcrumbs, page-specific spans). Arabic
   script is illegible below ~11px. Code blocks/terminals are excluded. */
html[dir="rtl"] .badge,
html[dir="rtl"] .metric-label,
html[dir="rtl"] .metric-sub,
html[dir="rtl"] .breadcrumb-current,
html[dir="rtl"] .breadcrumb-link,
html[dir="rtl"] .text-muted,
html[dir="rtl"] .text-tertiary,
html[dir="rtl"] .session-meta,
html[dir="rtl"] .message-meta,
html[dir="rtl"] .text-xs {
  font-size: 0.82rem !important;
}
/* MCP modal — constrain width */
.modal-body form {
  max-width: 640px;
  margin: 0 auto;
}

/* Font size persistence — controlled by Alpine settings.js applyFontSize() */

body {
  font-family: var(--font-sans);
  font-feature-settings: var(--font-features);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 32px 32px;
  color: var(--text-primary);
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
}
a { color: var(--accent-light); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--font-mono); font-size: 0.875em; }
img { max-width: 100%; display: block; }
button { cursor: pointer; font-family: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* RTL: use Arabic-capable font as primary when dir=rtl */
[dir="rtl"] body,
[dir="rtl"] input,
[dir="rtl"] textarea,
[dir="rtl"] button,
[dir="rtl"] select {
  font-family: var(--font-arabic);
}

/* ── 3. Layout ──────────────────────────────────────────────────── */
.app-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition);
}
.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-collapsed);
}
.page-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
}

/* ── 4. Sidebar ─────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: color-mix(in srgb, var(--bg-panel) 82%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  min-height: var(--header-height);
}
.logo {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}
.logo-icon {
  font-size: 1.5rem;
  line-height: 1;
}
.logo-text {
  font-size: 1.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-primary);
  white-space: nowrap;
  background: linear-gradient(110deg, var(--accent), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-label,
.sidebar.collapsed .nav-kbd,
.sidebar.collapsed .nav-section-title,
.sidebar.collapsed .sidebar-footer-info,
.sidebar.collapsed .sidebar-collapsed-hide {
  display: none;
}
.sidebar-toggle {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}
.sidebar-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* Nav */
.nav-links {
  flex: 1;
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  overflow-y: auto;
}
.nav-section-title {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: var(--sp-3) var(--sp-3) var(--sp-1);
  white-space: nowrap;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  text-decoration: none;
  transition: all var(--transition-fast);
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  position: relative;
}
.nav-link:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}
.nav-link.active {
  background: var(--accent-subtle);
  color: var(--accent-light);
  font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent);
}
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}
.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-kbd {
  margin-left: auto;
  font-size: 0.65rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border-subtle);
}
.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: var(--sp-2);
}
.sidebar.collapsed .nav-link.active::before {
  display: none;
}

/* Sidebar footer */
.sidebar-footer {
  padding: var(--sp-3);
  border-top: 1px solid var(--border-subtle);
}

/* Sidebar model selector dropdown */
.sidebar-model-selector {
  margin-bottom: var(--sp-2);
}
.sidebar-model-dropdown {
  width: 100%;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition-fast);
}
.sidebar-model-dropdown:hover {
  border-color: var(--accent);
}
.sidebar-model-dropdown:focus {
  border-color: var(--accent);
}
.sidebar-model-dropdown optgroup {
  font-style: normal;
  font-weight: 600;
  color: var(--text-secondary);
}
.sidebar-model-dropdown option {
  font-weight: 400;
  color: var(--text-primary);
}
.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.sidebar-user:hover {
  background: var(--bg-hover);
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-light);
  flex-shrink: 0;
}
.sidebar-footer-info {
  flex: 1;
  min-width: 0;
}
.user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}
.sidebar-model-select {
  padding: 8px 12px;
  border-top: 1px solid var(--border-subtle);
}
.sidebar-collapsed .sidebar-model-select { display: none; }
.model-select-input:focus {
  outline: none;
  border-color: var(--accent);
}
.model-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  background: var(--tint);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  margin-top: var(--sp-2);
}
.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}
.status-dot.status-ok,
.status-dot.status-running { background: var(--success); }
.status-dot.status-warning { background: var(--warning); }
.status-dot.status-error,
.status-dot.status-stopped { background: var(--danger); }

/* ── 5. Header ──────────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
  background: color-mix(in srgb, var(--bg-panel) 78%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  min-height: var(--header-height);
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  min-width: 0;
}
.header-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
  background: linear-gradient(110deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.breadcrumbs {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  font-size: 0.8rem;
  color: var(--text-muted);
}
.breadcrumb-sep {
  color: var(--text-muted);
  user-select: none;
}
.breadcrumb-link {
  color: var(--text-tertiary);
  transition: color var(--transition-fast);
}
.breadcrumb-link:hover {
  color: var(--text-primary);
  text-decoration: none;
}
.breadcrumb-current {
  color: var(--text-secondary);
}
.header-right {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}
.header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-1);
  padding: var(--sp-1) var(--sp-2);
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  font-size: 0.8rem;
  transition: all var(--transition-fast);
  position: relative;
}
.header-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}
.header-btn svg {
  width: 16px;
  height: 16px;
}
.notification-dot {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid var(--bg-panel);
}

/* User dropdown */
.user-menu {
  position: relative;
}
.user-menu-btn {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) var(--sp-2);
  background: none;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}
.user-menu-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border);
}
.user-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: var(--sp-1);
  min-width: 200px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 200;
  padding: var(--sp-1);
  animation: dropdown-enter var(--transition-fast) ease;
}
.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-xs);
  color: var(--text-secondary);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.dropdown-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-subtle); }
.dropdown-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--sp-1) 0;
}

/* ── 6. Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--sp-4);
  letter-spacing: -0.01em;
}
.card-subtitle {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-4);
}
.settings-group {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-5);
}
.settings-group h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: var(--sp-4);
  padding-bottom: var(--sp-2);
  border-bottom: 1px solid var(--border-subtle);
}

/* Settings navigation (12-tab system) */
.settings-nav {
  display: flex; gap: 4px; overflow-x: auto; scrollbar-width: thin;
  border-bottom: 1px solid var(--border-subtle); padding-bottom: 0;
  -webkit-overflow-scrolling: touch; margin-bottom: var(--sp-5);
}
.settings-tab {
  padding: 8px 14px; background: none; border: none;
  border-bottom: 2px solid transparent; white-space: nowrap;
  color: var(--text-tertiary); cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.85rem; transition: all 0.15s;
}
.settings-tab:hover { color: var(--text-primary); }
.settings-tab.active { color: var(--accent-light); border-bottom-color: var(--accent); }
.provider-card { transition: border-color 0.15s; }
.provider-card:hover { border-color: var(--border-strong) !important; }

/* ── 7. Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary {
  background: var(--accent);
  color: #001016;
  border-color: transparent;
  font-weight: 700;
}
.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 8px 24px -8px var(--accent-glow);
}

.btn-secondary {
  background: var(--bg-panel);
  color: var(--text-secondary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-strong);
}

.btn-danger {
  background: var(--danger-subtle);
  color: var(--danger);
  border-color: rgba(248, 81, 73, 0.2);
}
.btn-danger:hover:not(:disabled) {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-ghost {
  background: transparent;
  color: var(--text-tertiary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.btn-sm { padding: 3px 10px; font-size: 0.8rem; }
.btn-lg { padding: 10px 20px; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-icon {
  padding: var(--sp-1);
  background: none;
  border: none;
  color: var(--text-tertiary);
  border-radius: var(--radius-sm);
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── 8. Forms ───────────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  margin-bottom: var(--sp-4);
}
.form-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.form-input,
.form-select,
.form-textarea {
  padding: var(--sp-2) var(--sp-3);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.form-input::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 80px; }
.form-select { cursor: pointer; }
.form-range { width: 100%; accent-color: var(--accent); }
.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.form-error {
  font-size: 0.75rem;
  color: var(--danger);
  margin-top: 2px;
}

.form-row { display: flex; gap: var(--sp-4); }
.form-row .form-group { flex: 1; }
.form-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
}

/* ── 9. Tables ──────────────────────────────────────────────────── */
.table-container {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
table {
  width: 100%;
  border-collapse: collapse;
}
thead th {
  text-align: left;
  padding: var(--sp-2) var(--sp-3);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: var(--sp-2) var(--sp-3);
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}
tbody tr:hover {
  background: var(--bg-hover);
}
tbody tr:last-child td {
  border-bottom: none;
}

/* ── 10. Tabs ───────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--sp-5);
}
.tab {
  padding: var(--sp-2) var(--sp-4);
  font-size: 0.875rem;
  color: var(--text-tertiary);
  cursor: pointer;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  font-family: inherit;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.tab:hover { color: var(--text-primary); }
.tab.active {
  color: var(--accent-light);
  border-bottom-color: var(--accent);
}

.tab-btn {
  padding: var(--sp-2) var(--sp-4);
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-tertiary);
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
}
.tab-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tab-btn.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* ── 11. Modal ──────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fade-in var(--transition-fast) ease;
}
.modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;   /* default — prevents edge-to-edge; overridden by -sm/-lg/-xl */
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
  animation: scale-in var(--transition) ease;
}
.modal.modal-sm { max-width: 400px; }
.modal.modal-md { max-width: 560px; }
.modal.modal-lg { max-width: 720px; }
.modal.modal-xl { max-width: 960px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-5) var(--sp-6);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.modal-header h2 {
  font-size: 1.1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--radius-xs);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.modal-close svg { width: 18px; height: 18px; }

.modal-body {
  padding: var(--sp-6);
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

/* ── 12. Toast ──────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: var(--sp-5);
  right: var(--sp-5);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-size: 0.85rem;
  max-width: 380px;
  pointer-events: auto;
  cursor: pointer;
  border: 1px solid;
  animation: slide-up var(--transition) ease;
  box-shadow: var(--shadow-lg);
}
.toast-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.toast-message { flex: 1; line-height: 1.4; }
.toast-dismiss {
  background: none;
  border: none;
  color: inherit;
  opacity: 0.6;
  cursor: pointer;
  padding: 2px;
  display: flex;
  align-items: center;
}
.toast-dismiss:hover { opacity: 1; }
.toast-dismiss svg { width: 14px; height: 14px; }

.toast-success {
  background: rgba(63, 185, 80, 0.1);
  border-color: rgba(63, 185, 80, 0.3);
  color: var(--success);
}
.toast-error {
  background: rgba(248, 81, 73, 0.1);
  border-color: rgba(248, 81, 73, 0.3);
  color: var(--danger);
}
.toast-warning {
  background: rgba(210, 153, 34, 0.1);
  border-color: rgba(210, 153, 34, 0.3);
  color: var(--warning);
}
.toast-info {
  background: rgba(88, 166, 255, 0.1);
  border-color: rgba(88, 166, 255, 0.3);
  color: var(--info);
}

/* Toast progress bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 2px;
  border-radius: 0 0 var(--radius) var(--radius);
  animation: toast-progress 5s linear forwards;
}
.toast-success .toast-progress { background: var(--success); }
.toast-error .toast-progress { background: var(--danger); }
.toast-warning .toast-progress { background: var(--warning); }
.toast-info .toast-progress { background: var(--info); }

/* ── 13. Chat ───────────────────────────────────────────────────── */
.chat-container { display: flex; flex: 1; overflow: hidden; }
.chat-sidebar {
  width: 240px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border-subtle);
  padding: var(--sp-3);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.session-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}
.session-item {
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.session-item:hover { background: var(--bg-hover); }
.session-title { display: block; font-weight: 500; font-size: 0.875rem; }
.session-meta { display: block; font-size: 0.75rem; color: var(--text-tertiary); }

.chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-6);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}
.chat-welcome {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}
.welcome-icon { font-size: 3rem; margin-bottom: var(--sp-4); }
.chat-welcome h2 { font-size: 1.5rem; margin-bottom: var(--sp-2); color: var(--text-primary); }

.message {
  display: flex;
  gap: var(--sp-3);
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
}
.message-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}
.message-user .message-avatar { background: var(--accent); }
.message-assistant .message-avatar { background: var(--bg-surface); }

.message-content { flex: 1; min-width: 0; }
.message-text {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  line-height: 1.7;
  word-wrap: break-word;
}
.message-user .message-text { background: var(--accent); color: #001016; font-weight: 500; }
.message-assistant .message-text {
  background: var(--bg-panel);
  border: 1px solid var(--border);
}
.message-meta { font-size: 0.75rem; color: var(--text-tertiary); margin-top: var(--sp-1); }

.tool-call-box {
  margin-top: var(--sp-2);
  padding: var(--sp-2) var(--sp-3);
  background: var(--tint);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--warning);
  font-size: 0.875rem;
}
.tool-call-box .tool-name { font-weight: 600; color: var(--warning); }
.tool-result-box {
  margin-top: var(--sp-1);
  padding: var(--sp-2) var(--sp-3);
  background: var(--tint);
  border-radius: var(--radius-sm);
  border-left: 3px solid var(--success);
  font-size: 0.875rem;
  max-height: 200px;
  overflow-y: auto;
}

/* ── HITL approval card (in-chat danger-tool gate) ─────────────── */
.hitl-approval-card {
  margin-top: var(--sp-2);
  padding: var(--sp-3);
  background: var(--tint);
  border-radius: var(--radius-sm);
  border: 1px solid var(--warning);
  font-size: 0.875rem;
}
.hitl-approval-header {
  font-weight: 700;
  color: var(--warning);
  margin-bottom: var(--sp-2);
}
.hitl-approval-body p { margin: var(--sp-1) 0; word-break: break-word; }
.hitl-approval-body code {
  background: var(--bg-elevated, rgba(0,0,0,0.05));
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.8rem;
}
.hitl-approval-actions {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-3);
  align-items: center;
}
.hitl-approval-card.hitl-approved { border-color: var(--success); }
.hitl-approval-card.hitl-denied { border-color: var(--danger); }
.hitl-approval-card.hitl-error { border-color: var(--danger); }
.hitl-status { font-size: 0.8rem; font-weight: 600; }
.hitl-status.hitl-approved { color: var(--success); }
.hitl-status.hitl-denied { color: var(--danger); }
.hitl-status.hitl-error { color: var(--danger); }

.chat-model-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-2) var(--sp-4);
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}

.chat-input-area {
  padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-panel);
}
.input-wrapper {
  display: flex;
  gap: var(--sp-2);
  align-items: flex-end;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-2) var(--sp-3);
}
.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-glow);
}
.chat-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  resize: none;
  outline: none;
  max-height: 150px;
  line-height: 1.5;
}
.send-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--transition-fast);
}
.send-btn:hover { background: var(--accent-hover); }
.send-btn:disabled { background: var(--bg-surface); cursor: not-allowed; }

.input-footer {
  display: flex;
  gap: var(--sp-2);
  margin-top: var(--sp-2);
  font-size: 0.75rem;
}
.cost-badge,
.token-badge {
  padding: 2px 8px;
  background: var(--tint);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  color: var(--text-tertiary);
}

/* Thinking indicator */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--sp-2) var(--sp-4);
  color: var(--text-tertiary);
  font-size: 0.875rem;
}
.thinking-indicator .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.4s infinite ease-in-out;
}
.thinking-indicator .dot:nth-child(1) { animation-delay: -0.32s; }
.thinking-indicator .dot:nth-child(2) { animation-delay: -0.16s; }

/* ── 14. Skills & MCP Cards ─────────────────────────────────────── */
.skills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--sp-4);
}
.skill-card,
.mcp-card {
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  transition: border-color var(--transition-fast);
}
.skill-card:hover,
.mcp-card:hover { border-color: var(--border-strong); }
.skill-header,
.mcp-card-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-2);
}
.skill-header h3,
.mcp-card-header h3 {
  font-size: 1rem;
  flex: 1;
}
.skill-desc,
.mcp-detail {
  font-size: 0.85rem;
  color: var(--text-tertiary);
  margin-bottom: var(--sp-2);
}
.skill-meta {
  display: flex;
  gap: var(--sp-3);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: var(--sp-3);
}
.skill-actions,
.mcp-card-actions {
  display: flex;
  gap: var(--sp-2);
  align-items: center;
}
.mcp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: var(--sp-4);
}

/* ── 15. Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
}
.badge-accent { background: var(--accent-subtle); color: var(--accent-light); }
.badge-success { background: var(--success-subtle); color: var(--success); }
.badge-warning { background: var(--warning-subtle); color: var(--warning); }
.badge-danger { background: var(--danger-subtle); color: var(--danger); }
.badge-info { background: var(--info-subtle); color: var(--info); }
.badge-basic { background: var(--accent-subtle); color: var(--accent-light); }
.badge-standard { background: var(--warning-subtle); color: var(--warning); }
.badge-premium { background: rgba(139, 92, 246, 0.12); color: #a78bfa; }
.badge-stdio { background: var(--success-subtle); color: var(--success); }
.badge-sse { background: var(--accent-subtle); color: var(--accent-light); }

/* ── 16. Toggle switch ──────────────────────────────────────────── */
.toggle {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--tint-strong);
  border-radius: 20px;
  transition: 0.2s;
  border: 1px solid var(--border);
}
.toggle-slider::before {
  content: '';
  position: absolute;
  height: 14px;
  width: 14px;
  left: 2px;
  bottom: 2px;
  background: var(--text-tertiary);
  border-radius: 50%;
  transition: 0.2s;
}
.toggle input:checked + .toggle-slider {
  background: var(--accent);
  border-color: var(--accent);
}
.toggle input:checked + .toggle-slider::before {
  transform: translateX(16px);
  background: #fff;
}

/* ── 17. Status Indicators ──────────────────────────────────────── */
.text-success { color: var(--success); }
.text-error { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-info { color: var(--info); }
.text-muted { color: var(--text-muted); }
.text-accent { color: var(--accent-light); }

.empty-state {
  text-align: center;
  padding: var(--sp-10);
  color: var(--text-muted);
}
.validation-result {
  margin-top: var(--sp-4);
  padding: var(--sp-4);
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Metrics */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
}
.metric-card {
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-4);
  text-align: center;
}
.metric-value { font-size: 1.75rem; font-weight: 700; margin-bottom: var(--sp-1); }
.metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* ── 18. Utility Classes ────────────────────────────────────────── */
/* Flex */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-row { flex-direction: row; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.gap-6 { gap: var(--sp-6); }

/* Grid */
.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Spacing */
.mt-1 { margin-top: var(--sp-1); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mt-6 { margin-top: var(--sp-6); }
.mb-1 { margin-bottom: var(--sp-1); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }
.mb-6 { margin-bottom: var(--sp-6); }
.ml-auto { margin-left: auto; }
.mr-auto { margin-right: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.p-2 { padding: var(--sp-2); }
.p-3 { padding: var(--sp-3); }
.p-4 { padding: var(--sp-4); }
.p-6 { padding: var(--sp-6); }

/* Sizing */
.w-full { width: 100%; }
.h-full { height: 100%; }
.min-w-0 { min-width: 0; }
.max-w-sm { max-width: 384px; }
.max-w-md { max-width: 560px; }
.max-w-lg { max-width: 720px; }

/* Text */
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.85rem; }
.text-base { font-size: 1rem; }
.text-lg { font-size: 1.25rem; }
.text-xl { font-size: 1.5rem; }
.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uppercase { text-transform: uppercase; }
.tracking-wide { letter-spacing: 0.05em; }

/* Display */
.hidden { display: none !important; }
.block { display: block; }
.inline-block { display: inline-block; }
.inline-flex { display: inline-flex; }
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.relative { position: relative; }
.absolute { position: absolute; }
.sticky { position: sticky; }

/* ── 19. Animations ─────────────────────────────────────────────── */
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes scale-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}
@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-16px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slide-in-left {
  from { opacity: 0; transform: translateX(-16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}
@keyframes dropdown-enter {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}
@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}
.animate-fade-in { animation: fade-in var(--transition) ease; }
.animate-slide-up { animation: slide-up var(--transition) ease; }
.animate-slide-down { animation: slide-down var(--transition) ease; }
.animate-spin { animation: spin 1s linear infinite; }

/* ── 20. Scrollbar ──────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── 21. Provider Card ──────────────────────────────────────────── */
.provider-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-3);
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: var(--sp-2);
}
.provider-card .provider-info {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: 0.875rem;
}
.provider-card .provider-actions {
  display: flex;
  gap: var(--sp-1);
}

/* Input with icon */
.input-with-icon { position: relative; }
.input-with-icon button {
  position: absolute;
  right: var(--sp-1);
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 0.75rem;
  padding: var(--sp-1) var(--sp-2);
}

/* Search bar */
.search-bar {
  margin-bottom: var(--sp-4);
}
.search-bar .form-input {
  padding-left: var(--sp-10);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%238b949e' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85zm-5.242.656a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

/* ── 22. Theme Toggle ───────────────────────────────────────────── */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: var(--sp-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}
.theme-toggle:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

/* ── 23. Light Theme ────────────────────────────────────────────── */
[data-theme="light"] {
  --bg: #f7f9fb;
  --bg-2: #eef2f6;
  --bg-deep: #f7f9fb;
  --bg-primary: #ffffff;
  --bg-panel: #f6f8fa;
  --bg-surface: #ffffff;
  --bg-elevated: #e6e8eb;
  --bg-hover: rgba(8, 145, 178, 0.06);
  --bg-active: rgba(8, 145, 178, 0.10);
  --grid: rgba(15, 23, 42, 0.04);
  --tint: rgba(15, 23, 42, 0.025);
  --tint-strong: rgba(15, 23, 42, 0.05);

  --text-primary: #0f1c2e;
  --text-secondary: #475569;
  --text-tertiary: #64748b;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  --accent: #0891b2;
  --accent-hover: #0e7490;
  --accent-light: #0891b2;
  --accent-subtle: rgba(8, 145, 178, 0.10);
  --accent-glow: rgba(8, 145, 178, 0.22);

  --secondary: #7c3aed;
  --secondary-hover: #6d28d9;
  --secondary-light: #7c3aed;
  --secondary-subtle: rgba(124, 58, 237, 0.10);
  --secondary-glow: rgba(124, 58, 237, 0.18);

  --success: #059669;
  --success-subtle: rgba(5, 150, 105, 0.12);
  --warning: #d97706;
  --warning-subtle: rgba(217, 119, 6, 0.12);
  --danger: #dc2626;
  --danger-subtle: rgba(220, 38, 38, 0.10);
  --info: #0284c7;
  --info-subtle: rgba(2, 132, 199, 0.10);

  --border-subtle: rgba(15, 23, 42, 0.07);
  --border: rgba(15, 23, 42, 0.10);
  --border-strong: rgba(15, 23, 42, 0.16);

  --shadow-sm: 0 1px 2px rgba(15,23,42,0.06);
  --shadow: 0 4px 12px rgba(15,23,42,0.08);
  --shadow-lg: 0 8px 24px rgba(15,23,42,0.12);
  --shadow-xl: 0 16px 48px rgba(15,23,42,0.16);
}

[data-theme="light"] .card,
[data-theme="light"] .settings-group,
[data-theme="light"] .skill-card,
[data-theme="light"] .mcp-card,
[data-theme="light"] .provider-card {
  background: var(--bg-surface);
  border-color: var(--border);
}
[data-theme="light"] .modal {
  background: var(--bg-surface);
  border-color: var(--border);
}
[data-theme="light"] .btn-secondary {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-secondary);
  border-color: var(--border);
}
[data-theme="light"] .btn-secondary:hover {
  background: rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}
[data-theme="light"] .form-input,
[data-theme="light"] .form-select,
[data-theme="light"] .form-textarea {
  background: var(--bg-primary);
  border-color: var(--border);
}
[data-theme="light"] .toggle-slider {
  background: rgba(0, 0, 0, 0.08);
  border-color: var(--border);
}
[data-theme="light"] .toggle-slider::before { background: #fff; }
[data-theme="light"] .message-user .message-text { color: #fff; }
[data-theme="light"] .message-assistant .message-text {
  background: var(--bg-panel);
}
[data-theme="light"] .input-wrapper {
  background: var(--bg-surface);
}

/* ── 23b. Dark Mode Dropdown Options ────────────────────────────── */
/* Bug 1: native <option> elements render with a browser-default white
   background while inheriting the light text color from the parent
   <select> in dark mode, making options invisible (white on white).
   Scope explicit dark background + light text under [data-theme="dark"]
   so light mode is unaffected. */
[data-theme="dark"] select option,
[data-theme="dark"] .form-select option,
[data-theme="dark"] select.form-select option {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}
[data-theme="dark"] select option:checked,
[data-theme="dark"] .form-select option:checked,
[data-theme="dark"] select.form-select option:checked {
  background-color: var(--accent);
  color: #fff;
}
/* Ensure the closed <select> itself keeps readable text in dark mode. */
[data-theme="dark"] .form-select {
  background-color: var(--bg-surface);
  color: var(--text-primary);
}

/* ── 24. RTL Overrides ──────────────────────────────────────────── */
[dir="rtl"] .sidebar {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
  left: auto;
  right: 0;
}
[dir="rtl"] .main-content {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}
[dir="rtl"] .main-content.sidebar-collapsed {
  margin-right: var(--sidebar-collapsed);
}

/* ── RTL: Navigation ── */
[dir="rtl"] .nav-link {
  padding-left: var(--sp-4);
  padding-right: var(--sp-3);
}
[dir="rtl"] .nav-link.active::before {
  left: auto;
  right: 0;
  border-radius: 2px 0 0 2px;
}
[dir="rtl"] .nav-kbd {
  margin-left: 0;
  margin-right: auto;
}
[dir="rtl"] .sidebar-toggle {
  margin-left: 0;
  margin-right: auto;
}

/* ── RTL: Header ── */
[dir="rtl"] .page-header .header-left,
[dir="rtl"] .page-header .header-right {
  flex-direction: row-reverse;
}
[dir="rtl"] .breadcrumbs .breadcrumb-sep {
  /* keep separator visual order correct in RTL */
  unicode-bidi: plaintext;
}
[dir="rtl"] .header-btn .sidebar-collapsed-hide,
[dir="rtl"] .header-right {
  flex-direction: row-reverse;
}

/* ── RTL: Chat messages ── */
[dir="rtl"] .chat-sidebar {
  border-right: none;
  border-left: 1px solid var(--border-subtle);
  order: 2; /* move session list to the right in RTL */
}
[dir="rtl"] .chat-main {
  order: 1;
}
[dir="rtl"] .message {
  flex-direction: row-reverse;
}
[dir="rtl"] .message-user {
  flex-direction: row-reverse;
}
[dir="rtl"] .message-assistant {
  flex-direction: row-reverse;
}
[dir="rtl"] .message-user .message-text {
  border-radius: var(--radius);
  border-top-right-radius: 0;
  border-top-left-radius: var(--radius);
  text-align: right;
}
[dir="rtl"] .message-assistant .message-text {
  text-align: right;
}
[dir="rtl"] .message-meta {
  text-align: right;
}
[dir="rtl"] .tool-call-box,
[dir="rtl"] .tool-result-box {
  border-left: none;
  border-right: 3px solid var(--warning);
  text-align: right;
}
[dir="rtl"] .tool-result-box {
  border-right-color: var(--success);
}
[dir="rtl"] .thinking-indicator {
  flex-direction: row-reverse;
}
[dir="rtl"] .input-wrapper {
  flex-direction: row-reverse;
}
[dir="rtl"] .chat-input-area .input-footer {
  flex-direction: row-reverse;
}
[dir="rtl"] .session-search-wrapper .form-input {
  padding-right: var(--sp-3);
  padding-left: var(--sp-10);
}

/* ── RTL: Chat sessions list ── */
[dir="rtl"] .session-item {
  text-align: right;
}

/* ── RTL: Tables ── */
[dir="rtl"] thead th,
[dir="rtl"] tbody td {
  text-align: right;
}
[dir="rtl"] tbody td:first-child,
[dir="rtl"] thead th:first-child {
  padding-right: var(--sp-3);
  padding-left: var(--sp-4);
}

/* ── RTL: Charts ── */
[dir="rtl"] .chart-card,
[dir="rtl"] .charts-row {
  direction: ltr; /* chart canvases render correctly LTR internally */
}
[dir="rtl"] .chart-title {
  text-align: right;
}
[dir="rtl"] .metric-card {
  text-align: right;
}
[dir="rtl"] .metric-sub {
  text-align: right;
}

/* ── RTL: Modals ── */
[dir="rtl"] .modal-header {
  flex-direction: row-reverse;
}
[dir="rtl"] .modal-header h2 {
  text-align: right;
}
[dir="rtl"] .modal-close {
  margin-left: 0;
  margin-right: auto;
}
[dir="rtl"] .modal-footer {
  flex-direction: row-reverse;
}

/* ── RTL: Settings forms ── */
[dir="rtl"] .settings-group,
[dir="rtl"] .settings-nav,
[dir="rtl"] .settings-tab {
  text-align: right;
}
[dir="rtl"] .form-row {
  flex-direction: row-reverse;
}
[dir="rtl"] .form-group label {
  text-align: right;
}
[dir="rtl"] .form-input,
[dir="rtl"] .form-select,
[dir="rtl"] .form-textarea {
  text-align: right;
}
[dir="rtl"] .form-hint {
  text-align: right;
}

/* ── RTL: Swarm panel ── */
[dir="rtl"] .swarm-container {
  text-align: right;
}
[dir="rtl"] .swarm-container .metrics-grid {
  direction: rtl;
}

/* ── RTL: Cards ── */
[dir="rtl"] .card {
  text-align: right;
}
[dir="rtl"] .card-header {
  flex-direction: row-reverse;
}

/* ── RTL: Toggles & badges ── */
[dir="rtl"] .toggle-slider::before { left: auto; right: 2px; }
[dir="rtl"] .toggle input:checked + .toggle-slider::before {
  transform: translateX(-16px);
}
[dir="rtl"] .badge {
  margin-left: 0;
  margin-right: var(--sp-1);
}

/* ── RTL: Toasts ── */
[dir="rtl"] .toast-container { right: auto; left: var(--sp-5); }
[dir="rtl"] .toast { animation-name: slide-in-right; }

/* ── RTL: Search bar ── */
[dir="rtl"] .search-bar .form-input {
  padding-left: var(--sp-3);
  padding-right: var(--sp-10);
  background-position: right 12px center;
}

/* ── RTL: Code blocks (keep code LTR) ── */
[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] .message-text pre,
[dir="rtl"] .message-text code {
  direction: ltr;
  text-align: left;
}

/* ── RTL: Pagination ── */
[dir="rtl"] .pagination {
  flex-direction: row-reverse;
}

/* ── RTL: Agents page ── */
[dir="rtl"] .agents-container {
  text-align: right;
}


/* ── 25. Responsive ─────────────────────────────────────────────── */

/* Hamburger button — hidden on desktop, shown on mobile (see 768px block) */
.hamburger-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}
.hamburger-btn:hover { color: var(--accent); border-color: var(--accent); }

/* Mobile nav backdrop — hidden on desktop */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  /* ── Mobile nav drawer ──
     The sidebar becomes a slide-in drawer. RTL (default) slides from the
     right; LTR slides from the left. Toggled by .mobile-open (Alpine state). */
  .hamburger-btn { display: inline-flex; }
  .sidebar-toggle { display: none; }     /* desktop collapse button hidden */

  .sidebar {
    display: flex;                        /* override previous display:none */
    z-index: 200;
    transform: translateX(100%);          /* off-screen right (RTL default) */
    transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }
  [dir="ltr"] .sidebar {
    transform: translateX(-100%);         /* off-screen left for English */
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }
  .sidebar.mobile-open {
    transform: translateX(0) !important;   /* slide into view */
  }
  .sidebar.collapsed { width: var(--sidebar-width); }  /* never collapsed on mobile */

  /* Backdrop fades in over the page content */
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 199;                          /* below the drawer (200), above content */
  }

  .main-content { margin-left: 0 !important; margin-right: 0 !important; }

  /* ── Chat sidebar drawer (session list) ── */
  .chat-sidebar {
    display: flex;
    position: fixed;
    top: 0;
    bottom: 0;
    width: 280px;
    max-width: 85vw;
    z-index: 200;
    transform: translateX(100%);           /* off-screen right (RTL default) */
    transition: transform 0.25s ease;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
  }
  [dir="ltr"] .chat-sidebar {
    left: 0;
    right: auto;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
  }
  .chat-sidebar.mobile-open {
    transform: translateX(0) !important;
  }

  /* ── Header overflow control ── */
  .header-right { flex-wrap: wrap; flex-shrink: 1; }
  .header-right .sidebar-collapsed-hide { display: none; }  /* hide "New Chat" label */
  .header-title {
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 45vw;
    white-space: nowrap;
  }

  /* ── Grids collapse to single column ── */
  .form-row { flex-direction: column; }
  .skills-grid { grid-template-columns: 1fr; }
  .mcp-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr; }
  .charts-row { grid-template-columns: 1fr; }
  .workspace-grid { grid-template-columns: 1fr; }
  .swarm-container .workspace-grid { grid-template-columns: 1fr; }
  .swarm-metrics-grid { grid-template-columns: 1fr !important; }
  .two-col-grid { grid-template-columns: 1fr !important; }   /* inline-grid helper */

  /* ── Padding reductions ── */
  .page-header { padding: 0 var(--sp-4); }
  .page-body { padding: var(--sp-4); }
  .header-left { gap: var(--sp-2); }
  .breadcrumbs { display: none; }

  /* ── Chat layout adjustments ──
     Override the inline margin:-24px / calc(100vh - 60px) from chat.html. */
  .chat-container {
    height: calc(100vh - var(--header-height)) !important;
    margin: 0 !important;
  }
  .chat-messages { padding: var(--sp-3); }
  .chat-input-area { padding: var(--sp-3); }
  .chat-welcome { padding: var(--sp-6) var(--sp-4); }
  .chat-input-footer-hint { display: none; }   /* hide "Enter / Ctrl+Enter" hint */

  /* ── Modals ── */
  .modal { margin: var(--sp-4); max-height: 90vh; }
  .modal.modal-lg, .modal.modal-xl { max-width: 100%; }

  /* ── Decorative overflow prevention ── */
  .hero-glow { display: none; }
}

@media (max-width: 480px) {
  .header-title { font-size: 0.95rem; }
  .metrics-row { grid-template-columns: 1fr; }
  .metrics-grid { grid-template-columns: 1fr; }
  /* Toasts must fit narrow phones (was right:20px + max-width:380px → overflow). */
  .toast {
    left: 16px;
    right: 16px;
    max-width: calc(100vw - 32px);
  }
}

/* ── 26. New UI Components (Phase 3) ─────────────────────────────── */

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 1.5rem;
}
.metric-card {
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
  transition: border-color 0.15s;
}
.metric-card:hover { border-color: var(--border-strong); }
.metric-icon { font-size: 1.25rem; margin-bottom: 4px; }
.metric-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.metric-value { font-size: 1.75rem; font-weight: 600; letter-spacing: -0.03em; margin-bottom: 2px; }
.metric-sub { font-size: 0.72rem; color: var(--text-tertiary); }
.metric-value.text-success { color: var(--success); }
.metric-value.text-error { color: var(--danger); }
.metric-value.text-warning { color: var(--warning); }

/* Charts */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 1.5rem;
}
.chart-card {
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.chart-title {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
}
canvas { display: block; border-radius: 4px; }

/* Progress Bar */
.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--tint-strong);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 0.5s ease;
}

/* Range Selector */
.range-selector {
  display: flex;
  gap: 2px;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.range-btn {
  padding: 4px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  background: none;
  border: none;
  border-radius: 3px;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: all 0.15s;
}
.range-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.range-btn.active { background: var(--accent); color: #fff; }

/* Skeleton Loading */
.skeleton {
  background: linear-gradient(90deg, var(--tint) 25%, var(--tint-strong) 50%, var(--tint) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: 4px;
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Welcome Hints */
.welcome-hints {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 16px;
}
.hint-chip {
  padding: 8px 14px;
  background: var(--tint);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  color: var(--text-secondary);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
  font-family: var(--font-sans);
}
.hint-chip:hover {
  background: rgba(94, 106, 210, 0.1);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Session Sidebar Enhancements */
.chat-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 0 8px 0;
}
.chat-sidebar-footer {
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
}
.session-search-wrapper {
  margin-bottom: 8px;
}
.session-item {
  position: relative;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.session-item:hover { background: var(--bg-hover); }
.session-item.active { background: rgba(94, 106, 210, 0.1); border: 1px solid rgba(94, 106, 210, 0.2); }
.session-delete {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 3px;
  opacity: 0;
  transition: opacity 0.15s;
}
.session-item:hover .session-delete { opacity: 1; }
.session-delete:hover { color: var(--danger); background: var(--danger-subtle); }
.session-empty {
  text-align: center;
  padding: 20px 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Message Actions */
.message-actions {
  display: flex;
  gap: 2px;
  margin-top: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.message:hover .message-actions { opacity: 1; }
.msg-action {
  background: var(--tint);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-size: 0.75rem;
  transition: all 0.15s;
}
.msg-action:hover { background: var(--bg-hover); color: var(--text-primary); }
.msg-action.active { color: var(--accent); }
.reaction-btn.active { background: rgba(94, 106, 210, 0.2); border-color: rgba(94, 106, 210, 0.3); }

/* Code Blocks */
.code-block {
  position: relative;
  padding: 12px 16px;
  padding-top: 24px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
  margin: 8px 0;
}
.code-block code { font-family: var(--font-mono); }
.code-lang {
  position: absolute;
  top: 4px;
  left: 12px;
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-family: var(--font-sans);
}
.copy-btn {
  position: absolute;
  top: 4px;
  right: 8px;
  background: var(--tint-strong);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.7rem;
  transition: all 0.15s;
}
.copy-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.copy-btn.copied { color: var(--success); border-color: rgba(16,185,129,0.3); }
.inline-code {
  padding: 1px 4px;
  background: var(--tint-strong);
  border: 1px solid var(--border-subtle);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 0.85em;
}
.error-message {
  padding: 12px;
  background: rgba(248, 81, 73, 0.08);
  border: 1px solid rgba(248, 81, 73, 0.2);
  border-radius: var(--radius);
  color: var(--danger);
}

/* TooL Status */
.tool-status {
  font-size: 0.7rem;
  padding: 1px 6px;
  border-radius: 3px;
  margin-left: 4px;
}
.tool-status.running { background: rgba(210, 153, 34, 0.1); color: var(--warning); }
.tool-status.done { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.tool-inputs {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  max-height: 60px;
  overflow-y: auto;
}

/* Typing Dots */
.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
}
.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.4s infinite ease-in-out;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

/* Toast Enhancements */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 0.85rem;
  z-index: 2000;
  animation: slideIn 0.3s ease;
  max-width: 380px;
  word-wrap: break-word;
}
.toast-success { background: rgba(16, 185, 129, 0.12); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.toast-error { background: rgba(248, 81, 73, 0.12); color: var(--danger); border: 1px solid rgba(248, 81, 73, 0.3); }
.toast-info { background: rgba(94, 106, 210, 0.12); color: var(--accent-light); border: 1px solid rgba(94, 106, 210, 0.3); }
@keyframes slideIn {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Dashboard */
.dashboard-container { max-width: 1400px; margin: 0 auto; }
.trace-row { transition: background 0.15s; }
.trace-row:hover { background: var(--bg-hover); }

/* Workspace */
.workspace-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
}
.card-header h3 { font-size: 0.9rem; font-weight: 600; }
.quick-actions-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.file-row:hover { background: var(--bg-hover); }
.file-row.is-directory { font-weight: 500; }
.terminal-output {
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-deep);
  padding: 16px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-primary);
  line-height: 1.5;
}

/* Swarm */
.worker-row { transition: background 0.15s; }
.worker-row:hover { background: var(--bg-hover); }

/* Modal (for logs) */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.3);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}
.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
  flex: 1;
}

/* Responsive (consolidated into the main @media block in §25 above). */

/* ── HITL Approval Panel ───────────────────────────────────────── */
.hitl-panel.has-pending {
  border-color: rgba(139, 92, 246, 0.3);
}
.hitl-approval-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
  transition: border-color 0.15s;
}
.hitl-approval-card:last-child { margin-bottom: 0; }
.hitl-approval-card:hover { border-color: var(--border-strong); }
.hitl-approval-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.hitl-tool-name {
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--text-primary);
}
.hitl-thread-id {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hitl-approval-message {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.hitl-approval-args {
  background: var(--bg-deep);
  border-radius: 6px;
  padding: 8px 12px;
  margin-bottom: 10px;
  overflow-x: auto;
}
.hitl-approval-args pre {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  white-space: pre-wrap;
  word-break: break-word;
}
.hitl-approval-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-success {
  background: var(--success-subtle);
  color: var(--success);
  border: 1px solid transparent;
}
.btn-success:hover:not(:disabled) {
  background: var(--success);
  color: #fff;
}

/* ═══════════════════════════════════════════════════════════════════
   design-b-modern component polish — reusable utilities + scrollbars
   ═══════════════════════════════════════════════════════════════════ */

/* Gradient text (cyan → violet, matches kazma.ai headings) */
.gradient-text {
  background: linear-gradient(110deg, var(--accent), var(--secondary));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Glassmorphism surface */
.glass {
  background: color-mix(in srgb, var(--bg-panel) 78%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
}

/* Eyebrow / kicker pill — small accent label with a live dot */
.eyebrow,
.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
}
.eyebrow .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
}

/* Icon chip — squared accent tile for card/section icons */
.icon-chip {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
  flex-shrink: 0;
}
.icon-chip svg { width: 20px; height: 20px; }
.icon-chip.violet { background: color-mix(in srgb, var(--secondary) 14%, transparent); color: var(--secondary-light); }
.icon-chip.green { background: var(--success-subtle); color: var(--success); }
.icon-chip.amber { background: var(--warning-subtle); color: var(--warning); }

/* Stat tiles lift on hover like bento cards */
.stat-card,
.metric-card,
.provider-card {
  transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.stat-card:hover,
.metric-card:hover {
  transform: translateY(-4px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-lg);
}

/* Large gradient values for stat cards */
.stat-value,
.metric-value {
  font-family: var(--font-mono);
  font-weight: 800;
  background: linear-gradient(110deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Page title gradient utility (used on dashboard/section headers) */
.page-title {
  background: linear-gradient(110deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Section heading kicker label */
.section-heading {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: var(--sp-2);
}

/* Custom scrollbars — thin, themed */
.page-body,
.chat-messages,
.nav-links,
.settings-nav,
.table-container,
.modal-body {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.page-body::-webkit-scrollbar,
.chat-messages::-webkit-scrollbar,
.nav-links::-webkit-scrollbar,
.settings-nav::-webkit-scrollbar,
.table-container::-webkit-scrollbar,
.modal-body::-webkit-scrollbar { width: 8px; height: 8px; }
.page-body::-webkit-scrollbar-thumb,
.chat-messages::-webkit-scrollbar-thumb,
.nav-links::-webkit-scrollbar-thumb,
.settings-nav::-webkit-scrollbar-thumb,
.table-container::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-pill);
}
.page-body::-webkit-scrollbar-thumb:hover,
.chat-messages::-webkit-scrollbar-thumb:hover,
.nav-links::-webkit-scrollbar-thumb:hover,
.settings-nav::-webkit-scrollbar-thumb:hover,
.table-container::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover { background: var(--accent-glow); }

/* Hero glow accent — soft radial behind page heroes */
.hero-glow {
  position: absolute;
  top: -180px;
  left: 50%;
  transform: translateX(-50%);
  width: 760px;
  height: 480px;
  background: radial-gradient(ellipse at center, var(--accent-glow), transparent 65%);
  pointer-events: none;
  z-index: 0;
}
.hitl-approval-status {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.hitl-status-ok { color: var(--success); }
.hitl-status-denied { color: var(--text-tertiary); }
.hitl-status-error { color: var(--danger); }

/* ── Brand icons — chat welcome + sidebar avatar ───────────────── */
.welcome-icon img.welcome-logo {
  width: 72px;
  height: auto;
  display: block;
  margin: 0 auto;
  border-radius: var(--radius);
}
.user-avatar-img {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-subtle);
}

