/*
 * ADMIN DASHBOARD STYLES
 * File: assets/css/admin.css
 *
 * WHAT THIS FILE DOES:
 *   Styles the internal admin dashboard that the AwareAI team uses to view leads,
 *   check pipeline errors, and edit the AI agents' instructions.
 *
 * USED BY:
 *   admin.html (password-protected, team use only)
 *
 * SECTIONS INSIDE:
 *   - Design tokens (colour palette — same dark navy as the rest of the app)
 *   - Microsoft lock screen overlay (shown until the user signs in)
 *   - Topbar / header
 *   - Tab navigation (Leads / Errors / Prompts tabs)
 *   - Leads table (one row per prospect session)
 *   - Error log list (failed pipeline runs)
 *   - Agent prompt editor modal (for editing AI system prompts)
 *   - Status badges (e.g. "complete", "failed", "pending")
 */

/* AwareAI Admin — clean dashboard styles */

/* ── Design tokens (same palette as intake.css) ── */
:root {
  --deep-bg:       #020C1B;
  --surface:       #0A1628;
  --surface-2:     #0D1E35;
  --border-navy:   #162342;
  --border-hover:  #243860;
  --background:    #020C1B;
  --foreground:    #EEF2FF;
  --primary:       #C4261F;
  --primary-light: #E53535;
  --primary-dark:  #A01F19;
  --primary-glow:  rgba(196, 38, 31, 0.2);
  --text-1:        #EEF2FF;
  --text-2:        #94AABF;
  --text-3:        #3D5070;
  --success:       #10B981;
  --warning:       #F59E0B;
  --error:         #EF4444;
  --error-bg:      rgba(239, 68, 68, 0.1);
  --radius-sm:     0.375rem;
  --radius-md:     0.625rem;
  --radius-lg:     1rem;
  --font:          'Plus Jakarta Sans', ui-sans-serif, system-ui, sans-serif;
  --transition:    180ms cubic-bezier(0.4, 0, 0.2, 1);
}

html { font-size: 16px; -webkit-font-smoothing: antialiased; }

/* Ensure the HTML hidden attribute is always respected, even when CSS sets display: flex/grid */
[hidden] { display: none !important; }

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

body {
  font-family: var(--font);
  background: var(--deep-bg);
  color: var(--text-1);
  min-height: 100vh;
}

/* ── Lock screen ────────────────────────────────────────── */
.lock-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: radial-gradient(ellipse at 50% 0%, rgba(196,38,31,0.1) 0%, transparent 60%), var(--deep-bg);
}

.lock-card {
  width: min(100%, 420px);
  background: var(--surface);
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.lock-logo {
  height: 40px;
  width: auto;
  margin-bottom: 20px;
}

.lock-title {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-1);
  margin-bottom: 8px;
}

.lock-sub {
  font-size: 0.9375rem;
  color: var(--text-2);
  margin-bottom: 28px;
  line-height: 1.55;
}

.lock-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  justify-content: center;
  padding: 12px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.9375rem;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  box-shadow: 0 4px 14px rgba(196,38,31,0.35);
}
.lock-btn:hover { background: var(--primary-light); transform: translateY(-1px); }

.lock-ms-icon {
  height: 20px;
  width: 20px;
  flex-shrink: 0;
}

.lock-error {
  margin-top: 16px;
  font-size: 0.875rem;
  color: var(--error);
}

/* ── Shell ──────────────────────────────────────────────── */
.shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Topbar ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(2,12,27,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-navy);
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-right: 28px;
  text-decoration: none;
}

.topbar-logo {
  height: 28px;
  width: auto;
}

.topbar-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.topbar-tabs {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.tab-btn:hover { background: rgba(255,255,255,0.05); color: var(--text-1); }
.tab-btn--active { background: rgba(196,38,31,0.12); color: var(--primary-light); }

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--error);
  color: #fff;
  border-radius: 100px;
  font-size: 0.6875rem;
  font-weight: 700;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
  margin-left: auto;
}

.topbar-user {
  font-size: 0.8125rem;
  color: var(--text-3);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-sign-out {
  padding: 5px 12px;
  background: none;
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.topbar-sign-out:hover { border-color: var(--primary); color: var(--text-1); }

/* ── Device preview dropdown ─────────────────────────────── */
.device-preview-wrap {
  position: relative;
}

.topbar-device-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  background: none;
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
}
.topbar-device-btn:hover { border-color: var(--border-hover); color: var(--text-1); }

.device-preview-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 200;
  width: 280px;
  background: var(--surface);
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-md);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.device-preview-list {
  overflow-y: auto;
  max-height: 340px;
  padding: 4px 0;
}
.device-preview-list::-webkit-scrollbar { width: 4px; }
.device-preview-list::-webkit-scrollbar-track { background: transparent; }
.device-preview-list::-webkit-scrollbar-thumb { background: var(--border-navy); border-radius: 4px; }

.device-preview-group-label {
  padding: 8px 14px 3px;
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.device-preview-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 14px;
  background: none;
  border: none;
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-1);
  cursor: pointer;
  text-align: left;
  transition: background var(--transition);
}
.device-preview-item:hover { background: var(--surface-2); }
.device-preview-item span {
  font-size: 0.75rem;
  color: var(--text-3);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  margin-left: 8px;
}

/* ── Tab panels ─────────────────────────────────────────── */
.tab-panel {
  flex: 1;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.panel-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.panel-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-1);
  flex: 1;
}

.panel-sub {
  font-size: 0.9rem;
  color: var(--text-2);
  margin-top: -16px;
  margin-bottom: 24px;
  line-height: 1.55;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 700;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
  white-space: nowrap;
}
.btn-primary:hover { background: var(--primary-light); transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  background: none;
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-2);
  cursor: pointer;
  transition: border-color var(--transition), color var(--transition);
  white-space: nowrap;
}
.btn-secondary:hover { border-color: var(--primary); color: var(--text-1); }

/* ── Empty state ─────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--text-3);
}
.empty-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  opacity: 0.4;
}
.empty-icon svg { width: 100%; height: 100%; fill: currentColor; }
.empty-state p { font-size: 0.9375rem; }

/* ── Twenty CRM test result ──────────────────────────────── */
.twenty-test-result {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-3);
}
.twenty-test-result.success { color: var(--success); }
.twenty-test-result.error   { color: var(--error); }

/* ── Leads table ─────────────────────────────────────────── */
.leads-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-md);
}

.leads-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.leads-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border-navy);
  white-space: nowrap;
}

.leads-table td {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(22,35,66,0.5);
  color: var(--text-2);
  vertical-align: middle;
}

.leads-table tr:last-child td { border-bottom: none; }

.leads-table tr:hover td { background: rgba(255,255,255,0.015); }

.lead-name { font-weight: 600; color: var(--text-1); }

.lead-company { color: var(--text-1); font-weight: 500; }

.status-pill {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill--pending       { background: rgba(245,158,11,0.12);  color: var(--warning); }
.status-pill--generating    { background: rgba(196,38,31,0.1);   color: var(--primary-light); }
.status-pill--complete      { background: rgba(16,185,129,0.12); color: var(--success); }
.status-pill--failed        { background: rgba(239,68,68,0.12);  color: var(--error); }
.status-pill--approved      { background: rgba(16,185,129,0.12); color: var(--success); }
.status-pill--email-sent    { background: rgba(59,130,246,0.12); color: #60A5FA; gap: 5px; }
.status-pill--email-pending { background: transparent; color: var(--text-3); border: 1px solid var(--border-navy); font-weight: 500; }

.lead-time {
  font-size: 0.8125rem;
  color: var(--text-3);
  white-space: nowrap;
}

.lead-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.lead-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--primary-light);
  text-decoration: none;
  padding: 4px 0;
  white-space: nowrap;
}
.lead-link:hover { text-decoration: underline; }

/* ── Error list ──────────────────────────────────────────── */
.error-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.error-card {
  background: var(--surface);
  border: 1px solid var(--border-navy);
  border-left: 3px solid var(--error);
  border-radius: var(--radius-md);
  padding: 16px 20px;
}

.error-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.error-card-stage {
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--error);
}

.error-card-time {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
}

.error-card-company {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-1);
  margin-bottom: 4px;
}

.error-card-msg {
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.5;
  word-break: break-word;
}

.error-card-id {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-3);
  font-family: monospace;
}

.error-read {
  border-left-color: var(--border-navy);
  background: var(--deep-bg);
}
.error-read .error-card-stage { color: var(--text-3); }
.error-read .error-card-company,
.error-read .error-card-msg { color: var(--text-3); }

.error-mark-read-btn {
  margin-left: auto;
  flex-shrink: 0;
  padding: 2px 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-navy);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.error-mark-read-btn:hover {
  background: var(--surface-2);
  color: var(--text-1);
}

/* ── Agent prompt grid ───────────────────────────────────── */
.agent-prompt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.agent-prompt-card {
  background: var(--surface);
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: border-color var(--transition);
}
.agent-prompt-card:hover { border-color: var(--border-hover); }

.agent-card-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.agent-card-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.agent-card-icon svg { width: 22px; height: 22px; fill: currentColor; }

.agent-card-icon--orchestrator { background: rgba(196,38,31,0.12); color: var(--primary-light); }
.agent-card-icon--research      { background: rgba(59,130,246,0.12); color: #60A5FA; }
.agent-card-icon--selector      { background: rgba(16,185,129,0.12); color: var(--success); }
.agent-card-icon--datagen       { background: rgba(245,158,11,0.12); color: var(--warning); }
.agent-card-icon--synthesis     { background: rgba(139,92,246,0.12); color: #A78BFA; }

.agent-card-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-1);
}

.agent-card-desc {
  font-size: 0.8125rem;
  color: var(--text-3);
  margin-top: 2px;
}

.agent-edit-btn {
  align-self: flex-start;
}

/* ── Prompt modal ────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(2,12,27,0.85);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 500;
}

.modal-box {
  width: min(100%, 780px);
  background: var(--surface);
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 80px rgba(0,0,0,0.6);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-navy);
  flex-shrink: 0;
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-1);
}

.modal-sub {
  font-size: 0.8125rem;
  color: var(--text-3);
  margin-top: 3px;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,0.05); color: var(--text-1); }
.modal-close svg { width: 18px; height: 18px; fill: currentColor; }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
}

.prompt-textarea {
  width: 100%;
  height: 380px;
  resize: vertical;
  background: var(--deep-bg);
  border: 1.5px solid var(--border-navy);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.8125rem;
  color: var(--text-1);
  line-height: 1.6;
  outline: none;
  transition: border-color var(--transition);
}
.prompt-textarea:focus { border-color: var(--primary); }

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 24px;
  border-top: 1px solid var(--border-navy);
  flex-shrink: 0;
}

.modal-status {
  font-size: 0.8125rem;
  color: var(--text-3);
  flex: 1;
}
.modal-status.success { color: var(--success); }
.modal-status.error   { color: var(--error); }

.modal-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Renderer Test Lab ────────────────────────────────────── */
.renderer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.rnd-card {
  background: var(--surface-2);
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-md);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color var(--transition);
}
.rnd-card:hover { border-color: var(--border-hover); }

.rnd-card-header {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.rnd-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
  line-height: 1;
  margin-top: 2px;
}

.rnd-card-meta { flex: 1; min-width: 0; }

.rnd-card-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-1);
  margin-bottom: 2px;
}

.rnd-card-desc {
  font-size: 0.8125rem;
  color: var(--text-2);
  line-height: 1.45;
}

.rnd-patterns {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rnd-pattern-id {
  font-size: 0.6875rem;
  font-family: 'SFMono-Regular', Consolas, monospace;
  color: var(--text-3);
  background: var(--deep-bg);
  border: 1px solid var(--border-navy);
  border-radius: 4px;
  padding: 2px 7px;
}

.rnd-industries {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.rnd-industry-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #10B981;
  background: rgba(16, 185, 129, 0.08);
  border: 1px solid rgba(16, 185, 129, 0.2);
  border-radius: 100px;
  padding: 2px 8px;
}

.rnd-test-btn {
  align-self: flex-start;
  margin-top: auto;
}

/* ── Email Template Tab ──────────────────────────────────── */

.email-template-hint {
  margin: 0 0 20px;
  font-size: 0.875rem;
  color: var(--text-2);
  line-height: 1.6;
}
.email-template-hint code {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.8125rem;
  background: var(--deep-bg);
  border: 1px solid var(--border-navy);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--text-1);
}

.email-template-badge {
  font-size: 0.75rem;
  font-weight: 600;
  color: #10B981;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 100px;
  padding: 3px 10px;
  white-space: nowrap;
  align-self: center;
}

.email-template-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.email-save-status {
  font-size: 0.8125rem;
  color: var(--text-2);
  min-width: 80px;
  white-space: nowrap;
}
.email-save-status.success { color: #10B981; }
.email-save-status.error   { color: var(--error); }

.email-editor-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  height: calc(100vh - 260px);
  min-height: 480px;
}

.email-editor-pane,
.email-preview-pane {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
}

.email-pane-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
}

.email-template-textarea {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-md);
  color: var(--text-1);
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
  padding: 14px 16px;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
  box-sizing: border-box;
}
.email-template-textarea:focus {
  border-color: var(--border-hover);
}
.email-template-textarea::placeholder { color: var(--text-3); }

.email-preview-toolbar {
  display: flex;
  gap: 4px;
}

.email-preview-size-btn {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 100px;
  border: 1px solid var(--border-navy);
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: all var(--transition);
}
.email-preview-size-btn:hover {
  border-color: var(--border-hover);
  color: var(--text-1);
}
.email-preview-size-btn--active {
  background: var(--surface-2);
  border-color: var(--border-hover);
  color: var(--text-1);
}

.email-preview-frame-wrap {
  flex: 1;
  min-height: 0;
  transition: max-width 0.25s ease;
  max-width: 100%;
}

.email-preview-frame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border-navy);
  border-radius: var(--radius-md);
  background: #fff;
  display: block;
}

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Topbar: stack brand + actions on first row, tabs on second row */
  .topbar-inner {
    padding: 0 14px;
    height: auto;
    flex-wrap: wrap;
    gap: 0;
    padding-top: 8px;
    padding-bottom: 0;
  }
  .topbar-brand { margin-right: auto; }
  .topbar-user  { display: none; }
  .topbar-tabs {
    order: 3;
    width: 100%;
    flex: none;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    border-top: 1px solid var(--border-navy);
    margin-top: 6px;
    padding-bottom: 0;
    gap: 0;
  }
  .topbar-tabs::-webkit-scrollbar { display: none; }
  .tab-btn { padding: 8px 12px; white-space: nowrap; }
  .topbar-actions { flex-shrink: 0; }
  .device-preview-wrap { display: none; }

  /* Content */
  .tab-panel    { padding: 20px 14px 48px; }
  .panel-title  { font-size: 1.125rem; }
  .panel-header { gap: 8px; }

  /* Tables: horizontal scroll */
  .leads-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .leads-table { min-width: 580px; }
  .leads-table th,
  .leads-table td { padding: 10px 12px; }

  /* Grids: single column */
  .agent-prompt-grid { grid-template-columns: 1fr; }
  .renderer-grid     { grid-template-columns: 1fr; }

  /* Email editor: stack vertically */
  .email-editor-layout {
    grid-template-columns: 1fr;
    height: auto;
  }
  .email-template-textarea {
    height: 320px;
    flex: none;
  }
  .email-preview-frame-wrap {
    height: 420px;
    flex: none;
  }
  .email-preview-frame { height: 100%; }
  .email-template-actions { margin-left: 0; }
}

@media (max-width: 480px) {
  .lock-card { padding: 28px 20px; }
  .topbar-tabs .tab-btn { padding: 8px 10px; font-size: 0.8125rem; }
  .modal-box { max-height: calc(100vh - 16px); }
  .modal-header, .modal-body, .modal-footer { padding-left: 16px; padding-right: 16px; }
  .prompt-textarea { height: 260px; }

  /* Error cards: stack header items */
  .error-card-header { flex-direction: column; align-items: flex-start; gap: 6px; }
  .error-mark-read-btn { margin-left: 0; }
}

@media (hover: none) {
  .lock-btn:hover         { transform: none; }
  .btn-primary:hover      { transform: none; }
}
