/* ── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #0d0e14;
  --ink-2: #1a1c2a;
  --ink-3: #252840;
  --surface: #12141f;
  --surface-2: #1c1f30;
  --surface-3: #242740;
  --border: rgba(255,255,255,0.07);
  --border-2: rgba(255,255,255,0.12);
  --gold: #e8c97a;
  --gold-dim: rgba(232,201,122,0.15);
  --gold-glow: rgba(232,201,122,0.3);
  --text: #e8e9f0;
  --text-2: #9a9db8;
  --text-3: #5c5f7a;
  --green: #6fcf97;
  --yellow: #f2c94c;
  --red: #eb5757;
  --radius: 12px;
  --radius-lg: 20px;
  --shadow: 0 4px 24px rgba(0,0,0,0.5);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.7);
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--ink);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Grain overlay */
.grain {
  position: fixed; inset: 0; pointer-events: none; z-index: 9999; opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noise'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noise)' opacity='1'/%3E%3C/svg%3E");
  background-size: 128px;
}

/* ── Header ─────────────────────────────────────────────── */
.header {
  position: sticky; top: 0; z-index: 100;
  background: rgba(13,14,20,0.85);
  backdrop-filter: blur(20px) saturate(1.5);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  max-width: 1200px; margin: 0 auto;
  padding: 0 2rem;
  height: 64px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-mark { font-size: 1.4rem; color: var(--gold); line-height: 1; }
.logo-text { font-family: 'DM Serif Display', serif; font-size: 1.25rem; letter-spacing: -0.02em; color: var(--text); }

.nav { display: flex; gap: 4px; }
.nav-btn {
  padding: 6px 16px; border-radius: 8px; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 0.875rem; font-weight: 500;
  background: transparent; color: var(--text-2);
  transition: all 0.2s;
}
.nav-btn:hover { color: var(--text); background: var(--surface-2); }
.nav-btn.active { background: var(--surface-3); color: var(--text); }

/* ── Views ──────────────────────────────────────────────── */
.view { display: none; max-width: 1200px; margin: 0 auto; padding: 3rem 2rem 4rem; }
.view.active { display: block; }

/* ── Hero ───────────────────────────────────────────────── */
.hero {
  text-align: center;
  padding: 4rem 0 3rem;
  position: relative;
}
.hero::before {
  content: '';
  position: absolute;
  top: -100px; left: 50%; transform: translateX(-50%);
  width: 600px; height: 400px;
  background: radial-gradient(ellipse at center, rgba(232,201,122,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.hero-eyebrow {
  font-size: 0.75rem; font-weight: 500; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--gold); margin-bottom: 1.25rem;
}
.hero-title {
  font-family: 'DM Serif Display', serif;
  font-size: clamp(2.5rem, 5vw, 4rem);
  line-height: 1.1; letter-spacing: -0.03em;
  color: var(--text); margin-bottom: 1.25rem;
}
.hero-title em { font-style: italic; color: var(--gold); }
.hero-sub { font-size: 1.0625rem; color: var(--text-2); max-width: 520px; margin: 0 auto 2.5rem; }

/* ── Search Box ─────────────────────────────────────────── */
.search-box { max-width: 720px; margin: 0 auto; }

.search-input-wrap {
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}
.search-input-wrap:focus-within {
  border-color: rgba(232,201,122,0.4);
  box-shadow: 0 0 0 4px var(--gold-dim), var(--shadow);
}

.search-textarea {
  width: 100%; padding: 1.25rem 140px 1.25rem 1.5rem;
  background: transparent; border: none; outline: none; resize: none;
  font-family: 'DM Sans', sans-serif; font-size: 1rem; color: var(--text);
  line-height: 1.5;
}
.search-textarea::placeholder { color: var(--text-3); }

.search-btn {
  position: absolute; right: 12px; bottom: 12px;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 20px; border-radius: 10px; border: none; cursor: pointer;
  background: var(--gold); color: var(--ink);
  font-family: 'DM Sans', sans-serif; font-weight: 600; font-size: 0.9rem;
  transition: all 0.2s; white-space: nowrap;
}
.search-btn:hover { background: #f0d485; transform: translateY(-1px); }
.search-btn:active { transform: translateY(0); }
.search-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-icon { font-size: 1.1rem; }

.search-hints {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; margin-top: 1rem;
}
.hint {
  padding: 5px 12px; border-radius: 20px; cursor: pointer;
  font-size: 0.78rem; color: var(--text-3);
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.hint:hover { color: var(--gold); border-color: var(--gold-dim); background: var(--gold-dim); }

/* ── Loading State ──────────────────────────────────────── */
.loading-state {
  text-align: center; padding: 4rem 0;
}
.loading-orb {
  width: 56px; height: 56px; margin: 0 auto 1.5rem;
  border-radius: 50%;
  border: 2px solid var(--border-2);
  border-top-color: var(--gold);
  animation: spin 1s linear infinite;
  position: relative;
}
.loading-orb::after {
  content: ''; position: absolute; inset: 6px;
  border-radius: 50%; background: var(--gold-dim);
  animation: pulse 1.5s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 0.3; } 50% { opacity: 0.8; } }

.loading-text { font-size: 1.0625rem; font-weight: 500; color: var(--text); margin-bottom: 0.5rem; }
.loading-sub { font-size: 0.875rem; color: var(--text-3); }

/* ── Results ────────────────────────────────────────────── */
.results-section { animation: fadeUp 0.4s ease; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.results-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem; flex-wrap: wrap; gap: 1rem;
}
.results-meta { display: flex; flex-direction: column; gap: 2px; }
.results-count {
  font-family: 'DM Serif Display', serif;
  font-size: 1.5rem; color: var(--text);
}
.results-query { font-size: 0.8rem; color: var(--text-3); font-style: italic; }
.results-actions { display: flex; gap: 10px; }

.action-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 10px; border: none; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-weight: 500; font-size: 0.875rem;
  transition: all 0.15s;
}
.action-btn.primary { background: var(--gold); color: var(--ink); }
.action-btn.primary:hover { background: #f0d485; }
.action-btn.secondary {
  background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border-2);
}
.action-btn.secondary:hover { background: var(--surface-3); color: var(--text); }

/* Summary banner */
.summary-banner {
  padding: 12px 16px; margin-bottom: 1.25rem;
  background: var(--gold-dim); border: 1px solid rgba(232,201,122,0.2);
  border-radius: var(--radius); font-size: 0.875rem; color: var(--text-2);
  border-left: 3px solid var(--gold);
}
.summary-banner:empty { display: none; }

/* ── Table ──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}
.contacts-table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }

.contacts-table thead { background: var(--surface-2); }
.contacts-table th {
  padding: 13px 16px; text-align: left;
  font-weight: 600; font-size: 0.75rem; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--text-3);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.contacts-table td {
  padding: 12px 16px; color: var(--text-2);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.contacts-table tbody tr:last-child td { border-bottom: none; }
.contacts-table tbody tr:hover { background: var(--surface-2); }

.td-name { color: var(--text); font-weight: 500; white-space: nowrap; }
.td-email { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; color: var(--gold); }
.td-phone { font-family: 'JetBrains Mono', monospace; font-size: 0.8rem; }
.td-website a { color: var(--text-3); text-decoration: none; font-size: 0.8rem; }
.td-website a:hover { color: var(--gold); }
.td-num { color: var(--text-3); font-size: 0.8rem; }

.confidence-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.conf-high { background: rgba(111,207,151,0.15); color: var(--green); }
.conf-medium { background: rgba(242,201,76,0.15); color: var(--yellow); }
.conf-low { background: rgba(235,87,87,0.15); color: var(--red); }

/* ── Error State ────────────────────────────────────────── */
.error-state {
  text-align: center; padding: 3rem;
  background: var(--surface-2);
  border: 1px solid rgba(235,87,87,0.2);
  border-radius: var(--radius-lg);
  margin-top: 2rem;
}
.error-icon { font-size: 2rem; margin-bottom: 1rem; color: var(--red); }
.error-msg { color: var(--text-2); margin-bottom: 1.5rem; }

/* ── History ────────────────────────────────────────────── */
.history-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.section-title {
  font-family: 'DM Serif Display', serif;
  font-size: 1.75rem; color: var(--text); letter-spacing: -0.02em;
}

.history-list { display: flex; flex-direction: column; gap: 10px; }

.history-card {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius); transition: border-color 0.15s;
  gap: 1rem;
}
.history-card:hover { border-color: var(--border-2); }

.history-info { flex: 1; min-width: 0; }
.history-query {
  font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-bottom: 4px;
}
.history-meta { font-size: 0.78rem; color: var(--text-3); }

.history-actions { display: flex; gap: 8px; flex-shrink: 0; }
.history-btn {
  padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border-2);
  cursor: pointer; font-size: 0.8rem; font-family: 'DM Sans', sans-serif;
  background: transparent; color: var(--text-2); transition: all 0.15s;
}
.history-btn:hover { background: var(--surface-3); color: var(--text); }
.history-btn.export { color: var(--gold); border-color: rgba(232,201,122,0.2); }
.history-btn.export:hover { background: var(--gold-dim); }
.history-btn.delete:hover { background: rgba(235,87,87,0.1); color: var(--red); border-color: rgba(235,87,87,0.2); }

.status-dot {
  display: inline-block; width: 7px; height: 7px;
  border-radius: 50%; margin-right: 5px;
}
.status-completed { background: var(--green); }
.status-failed { background: var(--red); }
.status-processing { background: var(--yellow); animation: pulse 1s ease-in-out infinite; }

/* ── Empty & Toast ──────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  color: var(--text-3); font-size: 0.9rem;
  background: var(--surface-2); border-radius: var(--radius-lg);
  border: 1px dashed var(--border);
}

.toast {
  position: fixed; bottom: 24px; right: 24px;
  padding: 12px 20px; border-radius: var(--radius);
  background: var(--surface-3); color: var(--text);
  font-size: 0.875rem; font-weight: 500;
  border: 1px solid var(--border-2);
  box-shadow: var(--shadow-lg);
  transform: translateY(80px); opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── Utility ────────────────────────────────────────────── */
.hidden { display: none !important; }

@media (max-width: 640px) {
  .header-inner { padding: 0 1rem; }
  .view { padding: 1.5rem 1rem 3rem; }
  .hero { padding: 2rem 0 2rem; }
  .search-textarea { padding-right: 1.5rem; padding-bottom: 60px; }
  .search-btn { right: 12px; bottom: 12px; left: 12px; justify-content: center; width: calc(100% - 24px); position: static; margin-top: 8px; }
  .search-input-wrap { display: flex; flex-direction: column; padding: 0; }
  .search-textarea { padding: 1.25rem 1.5rem 0.75rem; }
  .results-header { flex-direction: column; align-items: flex-start; }
}

/* ── Missing / Extended Styles ───────────────────────────── */

/* Badge — used by JS for confidence column */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 9px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
}
.conf-high  { background: rgba(111,207,151,0.15); color: var(--green); }
.conf-med   { background: rgba(242,201,76,0.15);  color: var(--yellow); }
.conf-low   { background: rgba(235,87,87,0.15);   color: var(--red); }

/* Table link styles */
.contacts-table a { color: inherit; text-decoration: none; }
.contacts-table a:hover { color: var(--gold); }
.td-email a { color: var(--gold); }

/* action-btn variants */
.action-btn.danger {
  background: rgba(235,87,87,0.1); color: var(--red);
  border: 1px solid rgba(235,87,87,0.2);
}
.action-btn.danger:hover { background: rgba(235,87,87,0.2); }
.action-btn.sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 8px; }

/* History card — updated flex layout */
.history-card {
  flex-wrap: wrap;
}
.hcard-top {
  display: flex; align-items: center; gap: 10px;
  width: 100%; flex: 1 1 100%;
}
.hcard-query {
  flex: 1; font-weight: 500; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hcard-badge {
  flex-shrink: 0;
  padding: 2px 8px; border-radius: 20px; font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.04em;
}
.status-completed { background: rgba(111,207,151,0.15); color: var(--green); }
.status-failed    { background: rgba(235,87,87,0.15);   color: var(--red); }
.status-processing{ background: rgba(242,201,76,0.15);  color: var(--yellow); }
.status-pending   { background: rgba(92,95,122,0.2);    color: var(--text-3); }

.hcard-meta {
  display: flex; gap: 16px;
  font-size: 0.78rem; color: var(--text-3);
  flex: 1;
}
.hcard-actions {
  display: flex; gap: 8px; flex-shrink: 0;
}

/* Department tag pill */
.dept-tag {
  display: inline-block;
  padding: 2px 8px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.03em;
  background: rgba(142, 130, 255, 0.12); color: #a89dff;
  white-space: nowrap;
}

/* Source column */
.td-source {
  font-size: 0.78rem; color: var(--text-3);
  max-width: 180px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis;
}

/* Summary banner enrichment */
.summary-banner strong { color: var(--gold); font-weight: 600; }
.summary-banner br + br { display: none; }

/* LinkedIn link in table */
.contacts-table td a[href*="linkedin"] {
  color: #6ba3d6; font-size: 0.8rem;
  display: inline-flex; align-items: center; gap: 3px;
}
.contacts-table td a[href*="linkedin"]:hover { color: var(--gold); }

/* Toast — colour variants & visible state */
.toast:not(.hidden) {
  transform: translateY(0) !important;
  opacity: 1 !important;
}
.toast-success { background: rgba(111,207,151,0.15); border-color: rgba(111,207,151,0.3); color: var(--green); }
.toast-error   { background: rgba(235,87,87,0.15);   border-color: rgba(235,87,87,0.3);   color: var(--red); }
.toast-info    { background: var(--surface-3); border-color: var(--border-2); color: var(--text); }

/* ── Auth Modal ─────────────────────────────────────────── */
.auth-modal {
  position: fixed; inset: 0; z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(13,14,20,0.92);
  backdrop-filter: blur(12px);
}
.auth-modal.hidden { display: none; }

.auth-card {
  background: var(--surface-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  padding: 2.5rem 2rem;
  width: 100%; max-width: 380px;
  box-shadow: var(--shadow-lg);
}
.auth-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 1.75rem; justify-content: center;
}
.auth-tabs {
  display: flex; gap: 4px;
  background: var(--surface);
  border-radius: 10px; padding: 4px;
  margin-bottom: 1.5rem;
}
.auth-tab {
  flex: 1; padding: 8px; border: none; border-radius: 8px; cursor: pointer;
  font-family: 'DM Sans', sans-serif; font-size: 0.875rem; font-weight: 500;
  background: transparent; color: var(--text-2);
  transition: all 0.2s;
}
.auth-tab.active { background: var(--surface-3); color: var(--text); }

#authForm label {
  display: block; font-size: 0.8rem; color: var(--text-2); margin-bottom: 4px; margin-top: 1rem;
}
#authForm input {
  width: 100%; padding: 10px 14px;
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: 8px; color: var(--text); font-size: 0.9rem;
  outline: none; transition: border-color 0.2s;
  font-family: 'DM Sans', sans-serif;
}
#authForm input:focus { border-color: var(--gold); }

.auth-error {
  margin-top: 0.75rem; padding: 8px 12px;
  background: rgba(235,87,87,0.1); border: 1px solid rgba(235,87,87,0.25);
  border-radius: 8px; color: var(--red); font-size: 0.825rem;
}
.auth-error.hidden { display: none; }

.auth-submit-btn {
  width: 100%; margin-top: 1.5rem; justify-content: center;
}

#logoutBtn { color: var(--text-3); font-size: 0.8rem; }
#logoutBtn:hover { color: var(--red); background: rgba(235,87,87,0.08); }


