/* ============================================================================
   Lead Crawler — premium dark SaaS dashboard
   Brand-aligned with the Apis Development visual system:
   charcoal + white + violet accent, sharp grid, bold display typography.
   ============================================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  /* Surfaces — charcoal/near-black to match the Apis Development hero */
  --bg: #0a0a0d;
  --bg-2: #0e0e12;
  --panel: #111114;
  --panel-2: #141418;
  --panel-3: #181820;
  --border: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);

  /* Type */
  --text: #ecedf2;
  --text-muted: #9ca3b1;
  --text-faint: #5e6473;
  --font-display: 'Space Grotesk', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-body:    'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

  /* Brand accent — Apis violet */
  --primary:     #8b5cf6;   /* violet-500 */
  --primary-2:   #a78bfa;   /* violet-400 (lighter, for links) */
  --primary-deep:#6d28d9;   /* violet-700 (for shadow/glow base) */
  --primary-grad: linear-gradient(135deg, #8b5cf6 0%, #6d28d9 100%);

  /* Functional accent colours kept for status semantics */
  --accent-cyan: #22d3ee;
  --accent-green: #22c55e;
  --accent-pink: #f472b6;
  --accent-orange: #f59e0b;

  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --success: #22c55e;
  --success-bg: rgba(34, 197, 94, 0.12);
  --info: #38bdf8;
  --info-bg: rgba(56, 189, 248, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.45);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 28px 56px rgba(0, 0, 0, 0.55);
  --glow:      0 0 0 1px rgba(139, 92, 246, 0.45), 0 10px 36px rgba(139, 92, 246, 0.22);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --sidebar-w: 248px;
  --sidebar-w-collapsed: 72px;
  --topbar-h: 64px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    /* violet glow top-left (matches Apis hero) */
    radial-gradient(1000px 620px at -5% -10%, rgba(139, 92, 246, 0.22), transparent 60%),
    radial-gradient(700px 400px at 100% -5%, rgba(109, 40, 217, 0.10), transparent 60%),
    /* subtle dot grid */
    linear-gradient(rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 28px 28px,
    linear-gradient(90deg, rgba(255,255,255,0.025) 1px, transparent 1px) 0 0 / 28px 28px,
    var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
}

a { color: var(--primary-2); text-decoration: none; }
a:hover { color: #c4b5fd; }

::selection { background: rgba(139, 92, 246, 0.40); color: #fff; }

h1 {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: #ffffff;
}
h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #ffffff;
}
h3 { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: #ffffff; }

/* Display-class for top-level page titles (Apis "BUILD. LAUNCH. GROW." energy,
   dialled down for a SaaS interior). */
.display-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: #ffffff;
}

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.hidden { display: none !important; }

/* =============================================================================
   Layout: sidebar + topbar + content
   ============================================================================= */

.app-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  grid-template-rows: var(--topbar-h) 1fr;
  grid-template-areas:
    'sidebar topbar'
    'sidebar content';
  min-height: 100vh;
  transition: grid-template-columns 200ms ease;
}

.app-layout.sidebar-collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ---------------- Sidebar ---------------------------------------------------- */

.app-sidebar {
  grid-area: sidebar;
  background:
    radial-gradient(420px 280px at 0% -10%, rgba(139, 92, 246, 0.18), transparent 70%),
    linear-gradient(180deg, #0c0c10 0%, #08080b 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  min-height: var(--topbar-h);
}
/* Apis Development logo. Keep the height fixed so the proportions stay
   crisp; let the width auto-size so the brand mark never distorts. */
.brand-mark {
  height: 32px;
  width: auto;
  flex: 0 0 auto;
  display: block;
  filter: drop-shadow(0 4px 14px rgba(139, 92, 246, 0.35));
}
.brand-mark--fallback {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: var(--primary-grad);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; letter-spacing: 0.02em;
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
  filter: none;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.01em;
  color: #ffffff;
}
.brand-sub {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.side-nav {
  display: flex; flex-direction: column;
  padding: 14px 10px;
  gap: 2px;
  overflow-y: auto;
  flex: 1;
}
.side-section {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  padding: 14px 12px 6px;
}

.side-nav a {
  display: flex; align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: #c5c8d4;
  font-weight: 500;
  font-size: 13.5px;
  white-space: nowrap;
  position: relative;
  transition: background 140ms, color 140ms;
}
.side-nav a:hover { background: rgba(255, 255, 255, 0.04); color: #ffffff; }
.side-nav a.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(109, 40, 217, 0.10));
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.35);
}
.side-nav a.active::before {
  content: '';
  position: absolute;
  left: -10px; top: 6px; bottom: 6px;
  width: 3px; border-radius: 0 4px 4px 0;
  background: linear-gradient(180deg, #a78bfa, #8b5cf6);
  box-shadow: 0 0 14px rgba(167, 139, 250, 0.55);
}
.side-nav a.active .side-icon { color: #c4b5fd; }

.side-icon {
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px;
  color: #aab2d4;
}

.side-foot {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  font-size: 11px;
  color: var(--text-faint);
}

/* Collapsed desktop sidebar: hide labels, keep icons. */
.app-layout.sidebar-collapsed .brand-text,
.app-layout.sidebar-collapsed .side-nav .label,
.app-layout.sidebar-collapsed .side-section,
.app-layout.sidebar-collapsed .side-foot { display: none; }
.app-layout.sidebar-collapsed .side-nav a { justify-content: center; padding: 9px 8px; }
.app-layout.sidebar-collapsed .brand { justify-content: center; padding: 18px 8px; }

/* ---------------- Topbar ----------------------------------------------------- */

.app-topbar {
  grid-area: topbar;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  background: rgba(10, 10, 13, 0.72);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  backdrop-filter: blur(10px) saturate(140%);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  z-index: 20;
}

/* Demo Mode pill — sits in the topbar when the server reports DEMO_MODE=true.
   Intentional, not warning-flavoured. */
.demo-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: #e9defc;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.18), rgba(109, 40, 217, 0.12));
  border: 1px solid rgba(139, 92, 246, 0.45);
  box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.10), 0 6px 20px rgba(139, 92, 246, 0.20);
}
.demo-pill::before {
  content: '';
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #c4b5fd;
  box-shadow: 0 0 12px #a78bfa;
  animation: demoPulse 2.4s ease-in-out infinite;
}
@keyframes demoPulse {
  0%, 100% { opacity: 0.65; transform: scale(1); }
  50%      { opacity: 1;    transform: scale(1.15); }
}

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.08); border-color: var(--border-strong); }

.topbar-search {
  flex: 1;
  max-width: 520px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  padding: 10px 14px 10px 38px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  font: inherit;
}
.topbar-search input::placeholder { color: var(--text-faint); }
.topbar-search input:focus { outline: none; border-color: rgba(139, 92, 246, 0.55); box-shadow: var(--glow); }
.topbar-search::before {
  content: '⌕';
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
  color: var(--text-faint); font-size: 16px;
}

.topbar-spacer { flex: 1; }

.health-pill {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
}
.health-pill::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--text-faint);
  box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
}
.health-pill.online { color: #b8f3c8; border-color: rgba(34, 197, 94, 0.35); background: var(--success-bg); }
.health-pill.online::before { background: var(--success); box-shadow: 0 0 12px var(--success); }
.health-pill.offline { color: #fbb4b4; border-color: rgba(239, 68, 68, 0.35); background: var(--danger-bg); }
.health-pill.offline::before { background: var(--danger); }
.health-pill.checking { color: #ffd99c; border-color: rgba(245, 158, 11, 0.35); background: var(--warning-bg); }
.health-pill.checking::before { background: var(--warning); }

/* ---------------- Content area ----------------------------------------------- */

.app-content {
  grid-area: content;
  padding: 24px 28px 56px;
  min-width: 0;
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  flex-wrap: wrap; gap: 16px;
  margin-bottom: 22px;
}
.page-head h1 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.1;
  color: #ffffff;
}

.breadcrumb { color: var(--text-faint); font-size: 12.5px; margin-top: 2px; }
.breadcrumb a { color: var(--text-muted); }
.breadcrumb .sep { padding: 0 6px; opacity: 0.6; }

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

/* =============================================================================
   Cards, panels
   ============================================================================= */

.card {
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 18px;
  position: relative;
}
.card-header {
  display: flex; justify-content: space-between; align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.card-title { font-size: 15px; font-weight: 700; color: #f5f7ff; }
.card-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.metric {
  position: relative;
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.metric::after {
  content: '';
  position: absolute; right: -30px; top: -30px;
  width: 130px; height: 130px;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(139, 92, 246, 0.18), transparent);
  pointer-events: none;
}
.metric-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  display: flex; align-items: center; gap: 8px;
}
.metric-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border-radius: 8px;
  background: rgba(139, 92, 246, 0.15);
  color: #c5b6ff;
  font-size: 14px;
}
.metric-value {
  font-size: 26px; font-weight: 700; letter-spacing: -0.01em;
  color: #f5f7ff;
  margin-top: 6px;
}
.metric.warn .metric-value { color: #ffb4b4; }
.metric.good .metric-value { color: #b8f3c8; }
.metric.info .metric-value { color: #a3e6ff; }
.metric.cyan .metric-icon { background: rgba(34, 211, 238, 0.15); color: #a6efff; }
.metric.green .metric-icon { background: rgba(34, 197, 94, 0.15); color: #b8f3c8; }
.metric.pink .metric-icon { background: rgba(244, 114, 182, 0.15); color: #ffb6dc; }
.metric.orange .metric-icon { background: rgba(245, 158, 11, 0.15); color: #ffd99c; }
.metric.red .metric-icon { background: rgba(239, 68, 68, 0.15); color: #fbb4b4; }

/* =============================================================================
   Forms
   ============================================================================= */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: end;
}
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-size: 12px; color: var(--text-muted); font-weight: 600; letter-spacing: 0.02em; }
.field.actions { flex-direction: row; gap: 10px; align-items: end; flex-wrap: wrap; }

input[type='text'],
input[type='number'],
input[type='email'],
input[type='search'],
select,
textarea {
  width: 100%;
  appearance: none;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  color: var(--text);
  outline: none;
  transition: border-color 120ms, box-shadow 120ms, background 120ms;
}
input::placeholder, textarea::placeholder { color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.18);
  background: rgba(255, 255, 255, 0.06);
}
select {
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) center, calc(100% - 13px) center;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 32px;
}
select option { background: var(--panel); color: var(--text); }
textarea { resize: vertical; min-height: 120px; font-family: inherit; }

/* =============================================================================
   Buttons
   ============================================================================= */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit; font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms, border-color 120ms, color 120ms, transform 80ms, box-shadow 120ms;
}
.btn:hover { background: rgba(255, 255, 255, 0.08); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.btn-primary {
  background: var(--primary-grad);
  color: #fff;
  border: none;
  box-shadow: 0 8px 24px rgba(139, 92, 246, 0.35);
}
.btn-primary:hover { filter: brightness(1.06); box-shadow: 0 10px 28px rgba(139, 92, 246, 0.45); }

.btn-secondary {
  background: transparent;
  border-color: var(--border-strong);
  color: var(--text);
}
.btn-secondary:hover { background: rgba(255, 255, 255, 0.04); border-color: rgba(255, 255, 255, 0.22); }

.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: rgba(255, 255, 255, 0.04); }

.btn-danger {
  background: var(--danger-bg);
  color: #fbb4b4;
  border-color: rgba(239, 68, 68, 0.35);
}
.btn-danger:hover { background: rgba(239, 68, 68, 0.18); }

.btn-sm { padding: 6px 10px; font-size: 12px; }

/* =============================================================================
   Status / alerts
   ============================================================================= */

.status {
  margin-top: 14px;
  padding: 11px 14px;
  border-radius: 10px;
  font-size: 13px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  display: flex; align-items: center; gap: 10px;
}
.status::before {
  content: ''; width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-faint);
  flex: 0 0 8px;
}
.status.loading { color: #ffd99c; border-color: rgba(245, 158, 11, 0.35); background: var(--warning-bg); }
.status.loading::before { background: var(--warning); animation: pulse 1.4s infinite; }
.status.success { color: #b8f3c8; border-color: rgba(34, 197, 94, 0.35); background: var(--success-bg); }
.status.success::before { background: var(--success); }
.status.error { color: #fbb4b4; border-color: rgba(239, 68, 68, 0.35); background: var(--danger-bg); }
.status.error::before { background: var(--danger); }
.status.info { color: #a3e6ff; border-color: rgba(56, 189, 248, 0.35); background: var(--info-bg); }
.status.info::before { background: var(--info); }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.45; } }

.alert {
  padding: 14px 16px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--text-muted);
}
.alert strong { color: var(--text); }
.alert-warning { border-color: rgba(245, 158, 11, 0.35); background: var(--warning-bg); color: #ffd99c; }
.alert-warning strong { color: #fff3d4; }
.alert-info { border-color: rgba(56, 189, 248, 0.35); background: var(--info-bg); color: #a3e6ff; }
.alert-info strong { color: #d3eeff; }

/* =============================================================================
   Badges
   ============================================================================= */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: capitalize;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
}
.badge-new { background: var(--info-bg); color: #a3e6ff; border-color: rgba(56, 189, 248, 0.35); }
.badge-crawled, .badge-success { background: var(--success-bg); color: #b8f3c8; border-color: rgba(34, 197, 94, 0.35); }
.badge-failed, .badge-error { background: var(--danger-bg); color: #fbb4b4; border-color: rgba(239, 68, 68, 0.35); }
.badge-no_contact_found, .badge-warning { background: var(--warning-bg); color: #ffd99c; border-color: rgba(245, 158, 11, 0.35); }
.badge-approved { background: var(--success-bg); color: #b8f3c8; border-color: rgba(34, 197, 94, 0.35); }
.badge-dnc { background: var(--danger-bg); color: #fbb4b4; border-color: rgba(239, 68, 68, 0.35); }

/* =============================================================================
   Bulk action toolbar
   ============================================================================= */

.bulk-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  box-shadow: var(--shadow-sm);
  transition: border-color 160ms, box-shadow 160ms;
}

.bulk-toolbar.active {
  border-color: rgba(139, 92, 246, 0.45);
  box-shadow: var(--glow);
}

.selected-count {
  font-weight: 700;
  color: var(--text);
  font-size: 13px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: rgba(139, 92, 246, 0.10);
  min-width: 80px;
  text-align: center;
}

.bulk-toolbar.active .selected-count {
  background: rgba(139, 92, 246, 0.22);
  border-color: rgba(139, 92, 246, 0.55);
  color: #fff;
}

.select-helpers {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.bulk-actions {
  display: none;
  gap: 8px;
  flex-wrap: wrap;
  margin-left: auto;
}

.bulk-toolbar.active .bulk-actions { display: flex; }

/* When idle, gray out the helpers slightly so the bar doesn't shout. */
.bulk-toolbar:not(.active) .select-helpers .btn { color: var(--text-muted); }

/* =============================================================================
   Tables
   ============================================================================= */

.table-wrap {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: auto;
  background: var(--panel);
}
.table {
  width: 100%;
  border-collapse: collapse;
  min-width: 1280px;
}
.table th, .table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-size: 13px;
}
.table th {
  background: linear-gradient(180deg, var(--panel-3), var(--panel-2));
  color: var(--text);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.06em;
}
.table tbody tr { transition: background 120ms; }
.table tbody tr:nth-child(odd) { background: rgba(255, 255, 255, 0.015); }
.table tbody tr:hover { background: rgba(139, 92, 246, 0.08); }

/* Highlight a row that just got updated (e.g. after a row-level Crawl).
   The animation auto-fades back to transparent after 5s. */
.table tbody tr.row-updated {
  animation: rowUpdatedPulse 5s ease;
}
@keyframes rowUpdatedPulse {
  0% {
    background-color: rgba(34, 197, 94, 0.30);
    box-shadow: inset 0 0 0 1px rgba(34, 197, 94, 0.75);
  }
  100% {
    background-color: transparent;
    box-shadow: none;
  }
}
.table .col-checkbox { width: 36px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.cell-strong { color: #f5f7ff; font-weight: 600; }
.cell-link { color: var(--primary-2); text-decoration: none; }
.cell-link:hover { text-decoration: underline; }

.pagination {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  margin-top: 14px;
  font-size: 12.5px;
  color: var(--text-muted);
}
.pagination .pages { display: flex; gap: 8px; align-items: center; }

/* =============================================================================
   Filters bar
   ============================================================================= */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

/* =============================================================================
   Recent searches list
   ============================================================================= */

.recent-list { display: flex; flex-direction: column; gap: 8px; }
.recent-item {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
}
.recent-item .meta { font-size: 12px; color: var(--text-muted); }
.recent-item strong { color: #f5f7ff; }
.empty {
  color: var(--text-muted);
  padding: 24px 12px;
  text-align: center;
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.015);
}

/* =============================================================================
   Campaign two-column
   ============================================================================= */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  align-items: start;
}
.variables { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0 16px; }
.chip {
  background: rgba(139, 92, 246, 0.12);
  color: #c5b6ff;
  border: 1px solid rgba(139, 92, 246, 0.35);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  cursor: pointer;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.chip:hover { background: rgba(139, 92, 246, 0.22); }

.preview-box {
  background: rgba(0, 0, 0, 0.25);
  border: 1px dashed var(--border-strong);
  border-radius: 12px;
  padding: 14px 16px;
  margin-top: 6px;
}
.preview-row { margin-bottom: 6px; color: var(--text); }
.preview-body {
  margin: 10px 0 0;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(0, 0, 0, 0.35);
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 320px;
  overflow: auto;
  color: #d6dbf2;
}
.metrics-mini { display: flex; gap: 18px; margin: 14px 0; font-size: 13px; flex-wrap: wrap; color: var(--text-muted); }
.metrics-mini strong { color: #f5f7ff; }

/* =============================================================================
   Dropdown menu (export)
   ============================================================================= */

.dropdown { position: relative; }
.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  min-width: 200px;
  display: none;
  z-index: 25;
  padding: 6px;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a {
  display: block;
  padding: 9px 12px;
  color: var(--text);
  font-size: 13px;
  border-radius: 8px;
}
.dropdown-menu a:hover { background: rgba(255, 255, 255, 0.06); text-decoration: none; }

/* =============================================================================
   Autocomplete dropdown
   ============================================================================= */

.ac-wrap { position: relative; }
.ac-dropdown {
  position: absolute;
  left: 0; right: 0;
  top: calc(100% + 6px);
  max-height: 280px;
  overflow-y: auto;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 50;
  padding: 6px;
}
.ac-item {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text);
  display: flex; align-items: center; gap: 10px;
}
.ac-item:hover, .ac-item.active { background: rgba(139, 92, 246, 0.18); color: #fff; }
.ac-item mark { background: rgba(139, 92, 246, 0.40); color: #fff; padding: 0 2px; border-radius: 3px; }
.ac-item .ac-meta { margin-left: auto; color: var(--text-faint); font-size: 11px; }
.ac-empty { padding: 12px; color: var(--text-faint); font-size: 12px; text-align: center; }

/* =============================================================================
   Mobile / responsive
   ============================================================================= */

.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 25;
  display: none;
}
.app-layout.sidebar-open .sidebar-overlay { display: block; }

@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-areas: 'topbar' 'content';
  }
  .app-sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: var(--sidebar-w);
    transform: translateX(-100%);
    transition: transform 220ms ease;
    z-index: 30;
  }
  .app-layout.sidebar-open .app-sidebar { transform: translateX(0); }
  .app-content { padding: 18px; }
  .two-col { grid-template-columns: 1fr; }
  .topbar-search { display: none; }
}

/* Tighter spacing at very small widths */
@media (max-width: 480px) {
  .app-content { padding: 14px; }
  .page-head h1 { font-size: 20px; }
  .metric-value { font-size: 22px; }
}

/* Utility classes */
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.text-right { text-align: right; }
.w-full { width: 100%; }

/* =============================================================================
   Quality badges
   ============================================================================= */

.quality-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  white-space: nowrap;
}
.quality-badge .quality-score {
  font-weight: 600;
  font-size: 11px;
  opacity: 0.85;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
}
.quality-badge.quality-excellent { background: rgba(34, 197, 94, 0.18); color: #b8f3c8; border-color: rgba(34, 197, 94, 0.45); }
.quality-badge.quality-good      { background: rgba(56, 189, 248, 0.18); color: #a3e6ff; border-color: rgba(56, 189, 248, 0.45); }
.quality-badge.quality-medium    { background: rgba(245, 158, 11, 0.18); color: #ffd99c; border-color: rgba(245, 158, 11, 0.45); }
.quality-badge.quality-weak      { background: rgba(239, 68, 68, 0.16); color: #fbb4b4; border-color: rgba(239, 68, 68, 0.40); }
.quality-badge.quality-unusable  { background: rgba(120, 120, 130, 0.18); color: var(--text-muted); border-color: var(--border-strong); }

/* =============================================================================
   Completeness chips
   ============================================================================= */

.completeness {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.completeness .chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
  border: 1px solid var(--border-strong);
  background: rgba(255, 255, 255, 0.03);
}
.completeness .chip-on  { color: #b8f3c8; border-color: rgba(34, 197, 94, 0.40); background: rgba(34, 197, 94, 0.12); }
.completeness .chip-off { color: var(--text-faint); }

/* =============================================================================
   Modals
   ============================================================================= */

body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 8, 22, 0.72);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
  animation: modal-fade 140ms ease-out;
}
.modal-overlay[hidden] { display: none; }
@keyframes modal-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-card {
  width: min(720px, 100%);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--panel-2) 0%, var(--panel) 100%);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modal-pop 160ms ease-out;
}
.modal-card-sm { width: min(480px, 100%); }
@keyframes modal-pop {
  from { transform: translateY(8px) scale(0.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-3);
}
.modal-title {
  font-size: 15px;
  margin: 0;
  font-weight: 700;
  color: var(--text);
}
.modal-body {
  padding: 18px;
  overflow-y: auto;
  flex: 1 1 auto;
}
.modal-actions {
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  background: var(--panel-2);
}

/* Detail rows (read-only) */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 6px 16px;
}
.detail-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--border);
  align-items: baseline;
  font-size: 13px;
  word-break: break-word;
}
.detail-label { color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }
.detail-value { color: var(--text); }
.detail-value a { color: #a3e6ff; text-decoration: none; }
.detail-value a:hover { text-decoration: underline; }
.detail-section { margin-top: 14px; }
.notes-pre {
  margin: 6px 0 0;
  padding: 10px 12px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow-y: auto;
}

/* Edit form */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-row { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--text-muted); }
.form-row-wide { grid-column: 1 / -1; }
.form-row input,
.form-row textarea {
  padding: 8px 10px;
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 13px;
}
.form-row input:focus,
.form-row textarea:focus {
  outline: none;
  border-color: rgba(139, 92, 246, 0.55);
  box-shadow: var(--glow);
}
.form-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
  padding: 6px 0;
}

#clear-all-input {
  width: 100%;
  margin-top: 8px;
  padding: 9px 11px;
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  font: inherit;
  letter-spacing: 0.04em;
}
#clear-all-input:focus {
  outline: none;
  border-color: rgba(239, 68, 68, 0.55);
  box-shadow: 0 0 0 1px rgba(239, 68, 68, 0.45);
}

/* =============================================================================
   Admin section
   ============================================================================= */

.admin-card { margin-top: 18px; }
.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.admin-hint { font-size: 12px; }

/* Section labels inside the export dropdown menu */
.dropdown-menu .menu-section {
  padding: 8px 12px 4px;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

@media (max-width: 720px) {
  .form-grid { grid-template-columns: 1fr; }
  .detail-row { grid-template-columns: 110px 1fr; }
}

/* =============================================================================
   Campaign page
   ============================================================================= */

.col-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Recipient-rules grid */
.recipient-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}
.recipient-stats .stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--panel-2);
}
.recipient-stats .stat span {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.recipient-stats .stat strong {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}
.recipient-stats .stat.skipped strong { color: #fbb4b4; }
.recipient-stats .stat.eligible {
  border-color: rgba(34, 197, 94, 0.35);
  background: rgba(34, 197, 94, 0.10);
}
.recipient-stats .stat.eligible strong { color: #b8f3c8; }

/* Prepared / send section */
.prepared-summary {
  margin-top: 10px;
  padding: 9px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
}
.confirm-check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 12px;
  background: rgba(245, 158, 11, 0.10);
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius-sm);
  color: #ffd99c;
  font-size: 13px;
  font-weight: 500;
}
.confirm-check input { transform: translateY(-1px); }

/* SMTP indicator pill */
.health-pill.ok {
  background: rgba(34, 197, 94, 0.12);
  color: #b8f3c8;
  border-color: rgba(34, 197, 94, 0.35);
}
.health-pill.error {
  background: rgba(239, 68, 68, 0.12);
  color: #fbb4b4;
  border-color: rgba(239, 68, 68, 0.35);
}

/* Compact campaigns table inside the right column */
.table.compact th, .table.compact td {
  padding: 8px 10px;
  font-size: 12px;
}
.table.compact { min-width: 0; }

/* Status badges for recipients / campaigns */
.badge-pending  { background: var(--info-bg); color: #a3e6ff; border-color: rgba(56, 189, 248, 0.35); }
.badge-prepared { background: var(--info-bg); color: #a3e6ff; border-color: rgba(56, 189, 248, 0.35); }
.badge-sending  { background: var(--warning-bg); color: #ffd99c; border-color: rgba(245, 158, 11, 0.35); }
.badge-sent     { background: var(--success-bg); color: #b8f3c8; border-color: rgba(34, 197, 94, 0.35); }
.badge-failed   { background: var(--danger-bg); color: #fbb4b4; border-color: rgba(239, 68, 68, 0.35); }
.badge-skipped  { background: rgba(120,120,130,0.18); color: var(--text-muted); border-color: var(--border-strong); }
.badge-draft    { background: rgba(120,120,130,0.18); color: var(--text-muted); border-color: var(--border-strong); }

/* =============================================================================
   Campaign Preparation Center — banner, checklist, instructions, disabled link
   ============================================================================= */

.send-disabled-banner {
  border-left: 4px solid #f59e0b;
  background: rgba(245, 158, 11, 0.10);
  color: var(--text);
}
.send-disabled-banner code {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

/* Checklist */
.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.checklist li {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  font-size: 13px;
  color: var(--text-muted);
}
.checklist li.ok {
  border-color: rgba(34, 197, 94, 0.30);
  background: rgba(34, 197, 94, 0.08);
  color: var(--text);
}
.checklist li .check-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  position: relative;
}
.checklist li.ok .check-dot {
  background: #22c55e;
  border-color: #22c55e;
}
.checklist li.ok .check-dot::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: linear-gradient(45deg, transparent 32%, #ffffff 32% 44%, transparent 44%),
                    linear-gradient(-45deg, transparent 52%, #ffffff 52% 64%, transparent 64%);
  background-position: 2px 1px, 0 1px;
  background-repeat: no-repeat;
}
.checklist li.todo .check-dot { border-color: #fbb4b4; }

/* Manual outreach + future setup lists */
.instructions {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text);
}
.instructions code {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}
.future-setup {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: var(--text);
}
.future-setup li {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
  line-height: 1.45;
}
.future-setup code {
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 12px;
}

/* Disabled <a class="btn">. Anchor tags ignore the disabled attribute, so we
   use a class. */
.btn.disabled,
a.btn.disabled {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
}

/* =============================================================================
   Settings page
   ============================================================================= */

.status-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 16px;
  margin-bottom: 14px;
}
.status-grid .kv {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.status-grid .kv .k {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.status-grid .kv strong {
  font-size: 13px;
  color: var(--text);
  word-break: break-word;
}
.status-grid .kv strong.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
}
.status-grid .kv strong.ok  { color: #b8f3c8; }
.status-grid .kv strong.err { color: #fbb4b4; }
.status-grid .kv.kv-wide { grid-column: 1 / -1; }

/* US-mode pill on the dashboard search card. Reuses .health-pill base; this
   block just gives the chip a US-flag-ish blue accent + dot. The pill stays
   hidden via the [hidden] attribute until app.js detects a US country. */
.us-mode-pill {
  color: #b8d6ff;
  border-color: rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.12);
}
.us-mode-pill::before { background: #60a5fa; box-shadow: 0 0 12px #60a5fa; }

/* Phase 3 — Search Sources card. Each row is a flex line with a status dot,
   the source name, a key/limit hint, and a Test button. Color of the dot
   reflects: green = enabled & usable, yellow = enabled but key missing,
   gray = explicitly disabled via env. */
.search-sources-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-source-row {
  display: grid;
  grid-template-columns: 16px 140px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--panel-2);
}
.search-source-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--text-muted);
  box-shadow: 0 0 8px transparent;
}
.search-source-dot.green  { background: var(--success);  box-shadow: 0 0 8px var(--success); }
.search-source-dot.yellow { background: var(--warning);  box-shadow: 0 0 8px var(--warning); }
.search-source-dot.gray   { background: var(--text-muted); }
.search-source-name { font-weight: 600; color: var(--text); }
.search-source-meta { font-size: 12px; color: var(--text-muted); }
.search-source-meta .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 11px;
  color: var(--text);
}
.search-source-test-result {
  font-size: 11px;
  margin-left: 8px;
  color: var(--text-muted);
}
.search-source-test-result.ok  { color: #b8f3c8; }
.search-source-test-result.err { color: #fbb4b4; }

.status-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.status-counts .count {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.02);
}
.status-counts .count span {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.status-counts .count strong {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
}

/* =============================================================================
   Phase 3.1 — suggestion chips (industry "did you mean?")
   ============================================================================= */

.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}
.suggestion-chips-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.suggestion-chip {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.suggestion-chip:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent, #6cf);
}
.suggestion-chip:focus-visible {
  outline: 2px solid var(--accent, #6cf);
  outline-offset: 2px;
}

/* =============================================================================
   Preloader — grid-reveal + logo + violet scan line. Shown on first paint.
   Fades out as soon as the page DOMContentLoaded fires (preloader.js).
   Designed to be visible for ~600ms minimum so it never flashes; capped at
   2000ms maximum so it never blocks the app if anything fails.
   ============================================================================= */

.preloader {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(600px 360px at 50% 35%, rgba(139, 92, 246, 0.22), transparent 65%),
    #08080b;
  opacity: 1;
  transition: opacity 380ms ease, visibility 0s linear 380ms;
}
.preloader.is-leaving {
  opacity: 0;
  visibility: hidden;
  /* Allow JS to remove the node after the fade. */
  pointer-events: none;
}

/* Subtle grid that activates by sliding diagonally — the "Apis grid" cue. */
.preloader__grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px);
  background-size: 36px 36px;
  mask-image: radial-gradient(closest-side, #000 30%, transparent 80%);
  -webkit-mask-image: radial-gradient(closest-side, #000 30%, transparent 80%);
  animation: preloaderGrid 1.6s ease-in-out infinite alternate;
}
@keyframes preloaderGrid {
  from { transform: translate3d(-6px, -6px, 0); opacity: 0.7; }
  to   { transform: translate3d( 6px,  6px, 0); opacity: 1;   }
}

.preloader__inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  z-index: 2;
}

.preloader__logo-wrap {
  position: relative;
  padding: 14px 22px;
  border-radius: 14px;
  background: rgba(20, 20, 24, 0.5);
  border: 1px solid rgba(139, 92, 246, 0.30);
  box-shadow:
    0 0 0 1px rgba(139, 92, 246, 0.10),
    0 24px 60px rgba(139, 92, 246, 0.25);
  overflow: hidden;
}

.preloader__logo {
  height: 56px;
  width: auto;
  display: block;
  filter: drop-shadow(0 6px 18px rgba(139, 92, 246, 0.45));
}

/* The violet scan line that sweeps top→bottom across the logo box. */
.preloader__scan {
  position: absolute;
  left: -10%; right: -10%;
  top: 0;
  height: 36%;
  background: linear-gradient(180deg,
    transparent 0%,
    rgba(196, 181, 253, 0.10) 40%,
    rgba(196, 181, 253, 0.35) 50%,
    rgba(196, 181, 253, 0.10) 60%,
    transparent 100%);
  mix-blend-mode: screen;
  animation: preloaderScan 1.8s cubic-bezier(.65,.05,.35,1) infinite;
  pointer-events: none;
}
@keyframes preloaderScan {
  0%   { transform: translateY(-100%); }
  100% { transform: translateY(280%); }
}

.preloader__label {
  font-family: var(--font-display);
  text-transform: uppercase;
  letter-spacing: 0.32em;
  font-size: 11px;
  font-weight: 600;
  color: #c4b5fd;
  opacity: 0.85;
}

/* Subtle progress bar — purely cosmetic (CSS-only fill, not tied to actual
   load progress so it works regardless of where the JS is in its lifecycle). */
.preloader__bar {
  width: 220px;
  height: 2px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.preloader__bar::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, #a78bfa, #8b5cf6, transparent);
  border-radius: 2px;
  animation: preloaderBar 1.4s ease-in-out infinite;
}
@keyframes preloaderBar {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* Reduced-motion: hide animations, keep the layout. */
@media (prefers-reduced-motion: reduce) {
  .preloader__grid,
  .preloader__scan,
  .preloader__bar::after { animation: none; }
}
