/* ════════════════════════════════════════════════════════════════
   Mailgrid Dashboard — design tokens, layout, components.
   Theme-aware via [data-theme] on <html>.
═══════════════════════════════════════════════════════════════════ */

/* ── DARK (default) ─────────────────────────────────────────────── */
:root,
[data-theme="dark"] {
  --bg:           #07070a;
  --bg-1:         #0c0c10;
  --bg-2:         #111116;
  --bg-3:         #16161d;
  --bg-4:         #1f1f28;
  --bg-5:         #2a2a36;
  --line:         rgba(255, 255, 255, 0.08);
  --line-strong:  rgba(255, 255, 255, 0.14);
  --text:         #ededf0;
  --text-muted:   #8b8b96;
  --text-faint:   #5a5a64;
  --flame:        #ff5b29;
  --flame-soft:   #ff7a51;
  --flame-glow:   rgba(255, 91, 41, 0.4);
  --teal:         #00d4b4;
  --indigo:       #7b6bff;
  --danger:       #ff5f56;
  --warn:         #ffbd2e;
  --good:         #27c93f;
  --shadow:       0 8px 24px -8px rgba(0,0,0,0.6);
  --shadow-lg:    0 24px 64px -12px rgba(0,0,0,0.6);
  --kbd-bg:       #2a2a36;
  --code-bg:      #111116;
}

/* ── LIGHT ──────────────────────────────────────────────────────── */
[data-theme="light"] {
  --bg:           #fafafb;
  --bg-1:         #ffffff;
  --bg-2:         #ffffff;
  --bg-3:         #f5f5f7;
  --bg-4:         #ebebee;
  --bg-5:         #e0e0e3;
  --line:         rgba(0, 0, 0, 0.08);
  --line-strong:  rgba(0, 0, 0, 0.14);
  --text:         #0c0c10;
  --text-muted:   #5a5a64;
  --text-faint:   #8b8b96;
  --flame:        #e94e1e;
  --flame-soft:   #ff5b29;
  --flame-glow:   rgba(233, 78, 30, 0.18);
  --shadow:       0 8px 24px -10px rgba(0,0,0,0.12);
  --shadow-lg:    0 24px 64px -16px rgba(0,0,0,0.18);
  --kbd-bg:       #e6e6ea;
  --code-bg:      #f5f5f7;
}

/* ── Reset + base ───────────────────────────────────────────────── */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }

html { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
  -webkit-font-smoothing: antialiased;
  font-size: 14px;
  line-height: 1.5;
}

::selection { background: var(--flame); color: white; }

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--flame-soft); text-decoration: none; }
a:hover { text-decoration: underline; }

kbd {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.72rem;
  padding: 0.1rem 0.4rem;
  background: var(--kbd-bg);
  border-radius: 0.25rem;
  border: 1px solid var(--line-strong);
}

.font-mono { font-family: 'JetBrains Mono', ui-monospace, monospace; }
.muted    { color: var(--text-muted); }
.faint    { color: var(--text-faint); }
.hidden   { display: none !important; }

/* ── App shell ──────────────────────────────────────────────────── */
.app {
  display: grid;
  grid-template-columns: 264px 1fr;
  min-height: 100vh;
}
@media (max-width: 880px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.mobile-open { display: flex; position: fixed; inset: 0; z-index: 90; }
  .mobile-bar { display: flex !important; }
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  background: var(--bg-1);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  font-size: 0.875rem;
}

.sidebar-brand {
  padding: 1.2rem 1.2rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-weight: 700;
  font-size: 1.05rem;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--bg-1);
  z-index: 5;
}

.brand-mark {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 0.55rem;
  background: linear-gradient(135deg, var(--flame), var(--flame-soft));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--flame-glow);
}

.sidebar-tenant { padding: 0.75rem 0.75rem 0; }

.tenant-switch {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  padding: 0.55rem 0.6rem;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  cursor: pointer;
  color: var(--text);
  text-align: left;
  transition: border-color 0.12s, background 0.12s;
}
.tenant-switch:hover { border-color: var(--line-strong); background: var(--bg-4); }
.tenant-switch-static { cursor: default; }

.tenant-mark {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 0.45rem;
  background: linear-gradient(135deg, var(--indigo), var(--flame));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}
.tenant-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tenant-meta .tenant-name {
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tenant-meta .tenant-plan {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.tenant-chev { color: var(--text-faint); font-size: 0.85rem; }

.tenant-row {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 0.55rem;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color 0.12s, background 0.12s;
}
.tenant-row:hover { border-color: var(--flame); }
.tenant-row.current { border-color: var(--flame); background: var(--flame-glow); }

.sidebar-section { padding: 1rem 0.75rem 0.25rem; }
.sidebar-section h5 {
  font-size: 0.66rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-faint);
  margin: 0 0 0.4rem;
  padding: 0 0.6rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.7rem;
  border-radius: 0.42rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.1s;
  font-size: 0.875rem;
  text-decoration: none;
}
.sidebar-link:hover {
  background: var(--bg-3);
  color: var(--text);
  text-decoration: none;
}
.sidebar-link.active {
  background: var(--flame-glow);
  color: var(--flame-soft);
}
.sidebar-link .icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.85;
}
.sidebar-link .pill {
  margin-left: auto;
  font-size: 0.65rem;
}

.sidebar-user {
  margin-top: auto;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  cursor: pointer;
  position: sticky;
  bottom: 0;
  background: var(--bg-1);
}
.sidebar-user:hover { background: var(--bg-3); }

.avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 9999px;
  background: linear-gradient(135deg, var(--indigo), var(--flame));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.78rem;
  color: white;
  flex-shrink: 0;
}

.sidebar-footer-actions {
  display: flex;
  gap: 0.25rem;
  padding: 0 0.75rem 0.75rem;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 0.38rem;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.1s;
}
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--bg-3); }

/* ── Mobile top bar ─────────────────────────────────────────────── */
.mobile-bar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 0.75rem 1rem;
  background: var(--bg-1);
  border-bottom: 1px solid var(--line);
  align-items: center;
  gap: 0.6rem;
}

/* ── Main ───────────────────────────────────────────────────────── */
.main {
  padding: 1.75rem 2rem;
  min-width: 0;
  max-width: 1400px;
}
@media (max-width: 640px) { .main { padding: 1rem; } }

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}
.page-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.01em;
}
.page-subtitle {
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-size: 0.875rem;
}

/* ── Cards + grids ──────────────────────────────────────────────── */
.card {
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  padding: 1.25rem;
  transition: border-color 0.15s;
}
.card:hover { border-color: var(--line-strong); }
.card-tight { padding: 0.85rem 1.1rem; }
.card-flat  { padding: 0; }
.card-flame {
  background: linear-gradient(135deg, var(--flame-glow), transparent);
  border-color: var(--flame);
}

.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 960px) { .grid-3, .grid-4 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 640px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* ── Buttons ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.45rem;
  font-weight: 500;
  font-size: 0.875rem;
  border: 1px solid var(--line);
  background: var(--bg-3);
  color: var(--text);
  cursor: pointer;
  transition: all 0.12s;
  text-decoration: none;
  user-select: none;
}
.btn:hover { border-color: var(--line-strong); background: var(--bg-4); text-decoration: none; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--flame);
  border-color: var(--flame);
  color: white;
  box-shadow: 0 0 30px -6px var(--flame-glow);
}
.btn-primary:hover { background: var(--flame-soft); border-color: var(--flame-soft); }
.btn-ghost  { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255, 95, 86, 0.3); }
.btn-danger:hover { background: rgba(255, 95, 86, 0.1); }
.btn-sm { padding: 0.28rem 0.6rem; font-size: 0.8rem; }
.btn-lg { padding: 0.6rem 1.1rem; font-size: 0.95rem; }
.btn-block { width: 100%; justify-content: center; }
.btn-link {
  border: none;
  background: transparent;
  color: var(--flame-soft);
  padding: 0;
}

/* ── Form ───────────────────────────────────────────────────────── */
.form-row { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 1rem; }
.form-row label { font-size: 0.82rem; color: var(--text-muted); font-weight: 500; }
.form-row .hint { font-size: 0.78rem; color: var(--text-faint); margin-top: 0.2rem; }

.input, textarea, select {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.12s, background 0.12s;
  width: 100%;
}
.input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--flame);
  background: var(--bg-3);
}
textarea { resize: vertical; min-height: 96px; }
.input-mono { font-family: 'JetBrains Mono', monospace; font-size: 0.82rem; }
.input-lg { padding: 0.7rem 0.95rem; font-size: 1rem; }

.checkbox { display: inline-flex; align-items: center; gap: 0.45rem; cursor: pointer; font-size: 0.875rem; }
.checkbox input { width: auto; }

/* ── Table ──────────────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}
.table th, .table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.table th {
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  background: var(--bg-2);
  position: sticky;
  top: 0;
}
.table tr:last-child td { border-bottom: none; }
.table tr:hover td { background: var(--bg-3); }
.table tr.selected td { background: var(--flame-glow); }
.table td.tight { padding: 0.3rem 0.5rem; width: 1px; white-space: nowrap; }
.table td.actions { text-align: right; }

/* ── Empty states ───────────────────────────────────────────────── */
.empty {
  padding: 3.5rem 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.empty .empty-icon {
  width: 48px;
  height: 48px;
  border-radius: 0.6rem;
  background: var(--bg-3);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 0.85rem;
  color: var(--flame-soft);
}
.empty h3 {
  color: var(--text);
  font-size: 1.05rem;
  margin: 0 0 0.4rem;
  font-weight: 600;
}
.empty .empty-actions {
  margin-top: 1.25rem;
  display: inline-flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

/* ── Stat cards ─────────────────────────────────────────────────── */
.stat .stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
  font-weight: 500;
}
.stat .stat-value {
  font-size: 1.85rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}
.stat .stat-delta {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
}
.stat .stat-delta.up   { color: var(--good); }
.stat .stat-delta.down { color: var(--danger); }

.quota-bar {
  height: 3px;
  background: var(--bg-4);
  border-radius: 9999px;
  margin-top: 0.6rem;
  overflow: hidden;
}
.quota-bar > span {
  display: block;
  height: 100%;
  background: var(--flame);
  transition: width 0.3s;
}

/* ── Pills + chips ──────────────────────────────────────────────── */
.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.12rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pill.green  { background: rgba(39,201,63,0.12); color: #5fdb9c; }
.pill.red    { background: rgba(255,95,86,0.12); color: #ff8a82; }
.pill.yellow { background: rgba(255,189,46,0.12); color: var(--warn); }
.pill.flame  { background: var(--flame-glow); color: var(--flame-soft); }
.pill.purple { background: rgba(123,107,255,0.15); color: #a194ff; }
.pill.gray   { background: var(--bg-4); color: var(--text-muted); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: 9999px;
  background: var(--bg-3);
  border: 1px solid var(--line);
  font-size: 0.78rem;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.chip:hover { color: var(--text); border-color: var(--line-strong); }
.chip.active { background: var(--flame-glow); color: var(--flame-soft); border-color: var(--flame); }
.chip-close {
  margin-left: 0.2rem;
  width: 14px;
  height: 14px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0.6;
}
.chip-close:hover { opacity: 1; }

/* ── Auth screen ────────────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 2rem;
  background:
    radial-gradient(ellipse 600px 400px at 50% 0%, var(--flame-glow), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-1);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: var(--shadow-lg);
}
.auth-card .brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
  color: var(--text);
}
.auth-card h1 { font-size: 1.3rem; margin: 0 0 0.4rem; font-weight: 700; }
.auth-card .lead { color: var(--text-muted); margin: 0 0 1.5rem; font-size: 0.9rem; }
.auth-error {
  background: rgba(255,95,86,0.1);
  border: 1px solid rgba(255,95,86,0.25);
  color: #ff8a82;
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.auth-success {
  background: rgba(39,201,63,0.1);
  border: 1px solid rgba(39,201,63,0.25);
  color: #5fdb9c;
  padding: 0.65rem 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  margin-bottom: 1rem;
}
.auth-footer { text-align: center; margin-top: 1rem; font-size: 0.82rem; color: var(--text-muted); }

/* ── Modal ──────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  padding: 2rem;
  z-index: 100;
}
.modal {
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 0.8rem;
  padding: 1.5rem;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
}
.modal h2 { margin: 0 0 0.5rem; font-size: 1.1rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }

/* ── Toast ──────────────────────────────────────────────────────── */
.toast-host {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 200;
  pointer-events: none;
}
.toast {
  background: var(--bg-3);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 0.7rem 1rem;
  border-radius: 0.55rem;
  font-size: 0.85rem;
  min-width: 240px;
  max-width: 380px;
  box-shadow: var(--shadow);
  animation: toast-in 0.18s ease-out;
  pointer-events: auto;
}
.toast.err { border-color: rgba(255,95,86,0.4); color: #ff8a82; }
.toast.ok  { border-color: rgba(39,201,63,0.4); color: #5fdb9c; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Spinner ────────────────────────────────────────────────────── */
.spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid var(--text-faint);
  border-top-color: var(--flame);
  border-radius: 9999px;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem;
  color: var(--text-muted);
}

/* ── Code blocks ────────────────────────────────────────────────── */
.codebox {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  padding: 0.85rem 1rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8rem;
  line-height: 1.6;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
}
.codebox .copy {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  opacity: 0;
  transition: opacity 0.1s;
}
.codebox:hover .copy { opacity: 1; }

/* ── Tabs ───────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1rem;
  overflow-x: auto;
}
.tab {
  padding: 0.55rem 0.85rem;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  font-size: 0.875rem;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--flame-soft); border-bottom-color: var(--flame); }

/* ── Filter bar ─────────────────────────────────────────────────── */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
}
.filter-bar .input { max-width: 280px; }

/* ── Command palette ────────────────────────────────────────────── */
.cmdk-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: flex-start center;
  padding: 6vh 1rem 1rem;
  z-index: 300;
}
.cmdk {
  width: 100%;
  max-width: 640px;
  background: var(--bg-1);
  border: 1px solid var(--line-strong);
  border-radius: 0.85rem;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
}
.cmdk-input {
  border: none;
  outline: none;
  background: transparent;
  padding: 1rem 1.2rem;
  font-size: 1rem;
  color: var(--text);
  border-bottom: 1px solid var(--line);
}
.cmdk-results {
  overflow-y: auto;
  padding: 0.5rem;
}
.cmdk-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.cmdk-section {
  padding: 0.3rem 0.6rem;
  font-size: 0.7rem;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.cmdk-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: 0.4rem;
  cursor: pointer;
  font-size: 0.875rem;
}
.cmdk-item:hover, .cmdk-item.focused {
  background: var(--flame-glow);
  color: var(--flame-soft);
}
.cmdk-item .icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}
.cmdk-item.focused .icon { color: var(--flame-soft); }
.cmdk-item .desc { color: var(--text-faint); font-size: 0.78rem; margin-left: auto; }
.cmdk-footer {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.5rem 1rem;
  font-size: 0.72rem;
  color: var(--text-faint);
  border-top: 1px solid var(--line);
  background: var(--bg-2);
}

/* ── Live tail terminal ─────────────────────────────────────────── */
.tail {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.65;
  min-height: 500px;
  max-height: 70vh;
  overflow-y: auto;
  position: relative;
}
.tail-row {
  padding: 0.35rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 0.6rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
}
.tail-row:last-child { border-bottom: none; }
.tail-row .t-time {
  color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.tail-row .t-rest {
  flex: 1;
  text-overflow: ellipsis;
  overflow: hidden;
  color: var(--text-muted);
}
.tail-row .t-rest .ms { color: var(--text); }
.tail-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}
.tail-pulse {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
  animation: pulse 1.4s infinite;
}
.tail-pulse.paused { background: var(--text-faint); animation: none; box-shadow: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ── Code snippet (cURL/SDK/MCP) panel ─────────────────────────── */
.snippet-panel {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 0.6rem;
  margin-top: 1rem;
  overflow: hidden;
}
.snippet-tabs {
  display: flex;
  background: var(--bg-3);
  border-bottom: 1px solid var(--line);
}
.snippet-tabs button {
  padding: 0.45rem 0.85rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.78rem;
  cursor: pointer;
  font-family: 'JetBrains Mono', monospace;
  border-right: 1px solid var(--line);
}
.snippet-tabs button:hover { color: var(--text); }
.snippet-tabs button.active { background: var(--bg-1); color: var(--flame-soft); }

/* ── Onboarding ─────────────────────────────────────────────────── */
.onboarding {
  background: linear-gradient(135deg, var(--flame-glow), transparent);
  border: 1px solid var(--flame);
  border-radius: 0.65rem;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1.5rem;
}
.onboarding h3 {
  font-size: 1rem;
  margin: 0 0 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.onboarding .steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.5rem;
  margin-top: 1rem;
}
.step {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.7rem;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.1s;
  text-decoration: none;
  color: var(--text);
}
.step:hover { border-color: var(--line-strong); text-decoration: none; }
.step .step-check {
  width: 18px;
  height: 18px;
  border-radius: 9999px;
  border: 2px solid var(--text-faint);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.step.done .step-check {
  border-color: var(--good);
  background: var(--good);
  color: var(--bg);
}
.step.done { color: var(--text-muted); }
.step.done .step-label { text-decoration: line-through; }

/* ── Plan gate banner ───────────────────────────────────────────── */
.plan-gate {
  background: linear-gradient(135deg, var(--flame-glow), transparent);
  border: 1px solid var(--flame);
  border-radius: 0.5rem;
  padding: 0.85rem 1.1rem;
  margin: 1rem 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.plan-gate-text {
  font-size: 0.9rem;
}
.plan-gate-text strong { color: var(--flame-soft); }

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: var(--bg-5); }

/* ── Utility ────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.78rem; }
.text-right { text-align: right; }
.w-full { width: 100%; }
