/* =========================================================
   DeepDive — Design System
   Dark professional theme with indigo accents
   ========================================================= */

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

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg-0: #080b14;
  --bg-1: #0d1120;
  --bg-2: #141829;
  --bg-3: #1a2035;
  --bg-4: #202540;

  --accent: #7c6ff7;
  --accent-light: #a99cf9;
  --accent-dim: rgba(124, 111, 247, 0.15);
  --accent-glow: rgba(124, 111, 247, 0.3);

  --green: #10b981;
  --green-dim: rgba(16, 185, 129, 0.15);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.15);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.15);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.15);

  --text-0: #f1f5f9;
  --text-1: #cbd5e1;
  --text-2: #94a3b8;
  --text-3: #64748b;

  --border: rgba(255, 255, 255, 0.07);
  --border-hover: rgba(255, 255, 255, 0.14);

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

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-hover: 0 8px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  --transition: 180ms ease;
  --sidebar-w: 220px;
  --bottom-nav-h: 60px;
}

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

html { font-size: 15px; }

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg-0);
  color: var(--text-0);
  min-height: 100vh;
  line-height: 1.55;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.75' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)' opacity='0.03'/%3E%3C/svg%3E");
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, textarea { font-family: inherit; }
ul, ol { list-style: none; }
img { display: block; max-width: 100%; }

/* ── Layout ────────────────────────────────────────────── */
#app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-1);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 12px var(--accent-glow);
  flex-shrink: 0;
}

.logo-icon svg { width: 18px; height: 18px; color: #fff; }

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: -0.02em;
}

.logo-sub {
  font-size: 0.65rem;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 0.875rem;
  font-weight: 500;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
}

.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.nav-item:hover { background: var(--bg-3); color: var(--text-1); }
.nav-item.active { background: var(--accent-dim); color: var(--accent-light); }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid var(--border);
}

.btn-settings {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-3);
  font-size: 0.875rem;
  width: 100%;
  transition: background var(--transition), color var(--transition);
}

.btn-settings:hover { background: var(--bg-3); color: var(--text-2); }
.btn-settings svg { width: 16px; height: 16px; }

/* ── Page Header ───────────────────────────────────────── */
.page-header {
  padding: 28px 32px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-0);
  letter-spacing: -0.02em;
}

.page-subtitle { font-size: 0.875rem; color: var(--text-3); margin-top: 4px; }

/* ── View Container ────────────────────────────────────── */
#view-container { flex: 1; padding: 24px 32px 40px; }

/* ── Cards ─────────────────────────────────────────────── */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  transition: box-shadow var(--transition), border-color var(--transition);
}

.card:hover { box-shadow: var(--shadow-hover); border-color: var(--border-hover); }

/* ── Stat Cards ────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 24px;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-icon {
  width: 36px; height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg { width: 18px; height: 18px; }
.stat-icon.purple { background: var(--accent-dim); color: var(--accent-light); }
.stat-icon.green { background: var(--green-dim); color: var(--green); }
.stat-icon.amber { background: var(--amber-dim); color: var(--amber); }

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-0);
  line-height: 1;
  letter-spacing: -0.03em;
}

.stat-label { font-size: 0.8rem; color: var(--text-3); font-weight: 500; }

/* ── Contact Cards ─────────────────────────────────────── */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.contact-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
}

.contact-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent), #a78bfa);
  opacity: 0;
  transition: opacity var(--transition);
}

.contact-card:hover {
  border-color: var(--accent-glow);
  box-shadow: var(--shadow-hover), 0 0 0 1px var(--accent-dim);
  transform: translateY(-2px);
}

.contact-card:hover::before { opacity: 1; }

.contact-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.avatar {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
  letter-spacing: -0.02em;
}

.contact-name { font-size: 1rem; font-weight: 600; color: var(--text-0); }
.contact-meta { font-size: 0.8rem; color: var(--text-3); margin-top: 1px; }

.tag-row { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }

.tag {
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}

.tag.biz { background: var(--accent-dim); color: var(--accent-light); }
.tag.life { background: var(--green-dim); color: var(--green); }
.tag.amber { background: var(--amber-dim); color: var(--amber); }

.contact-date {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 5px;
}

.contact-date svg { width: 12px; height: 12px; }

/* ── Briefing ──────────────────────────────────────────── */
.briefing-section { margin-top: 24px; }

.briefing-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
}

.level1-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.level1-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.level1-card:hover, .level1-card.expanded {
  border-color: var(--accent-glow);
  background: var(--bg-3);
  box-shadow: 0 0 0 1px var(--accent-dim);
}

.level1-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
}

.level1-icon svg { width: 15px; height: 15px; }
.level1-icon.history { background: var(--amber-dim); color: var(--amber); }
.level1-icon.biz { background: var(--accent-dim); color: var(--accent-light); }
.level1-icon.life { background: var(--green-dim); color: var(--green); }

.level1-type {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-3);
  margin-bottom: 6px;
}

.level1-text { font-size: 0.875rem; color: var(--text-1); line-height: 1.5; }

.level2-panel {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-top: 12px;
  animation: slideDown 0.2s ease;
  grid-column: 1 / -1;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.level2-summary {
  font-size: 0.875rem;
  color: var(--text-1);
  line-height: 1.65;
  margin-bottom: 16px;
}

.followup-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 8px;
}

.followup-list { display: flex; flex-direction: column; gap: 8px; }

.followup-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.875rem;
  color: var(--text-1);
  background: var(--bg-2);
}

.followup-item:hover, .followup-item.active {
  background: var(--accent-dim);
  border-color: var(--accent-glow);
  color: var(--text-0);
}

.followup-num {
  width: 20px; height: 20px;
  background: var(--bg-4);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-light);
  flex-shrink: 0;
  margin-top: 1px;
}

.level3-panel {
  background: linear-gradient(135deg, var(--bg-4), var(--bg-3));
  border: 1px solid var(--accent-glow);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-top: 10px;
  animation: slideDown 0.2s ease;
}

.level3-badge {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-light);
  background: var(--accent-dim);
  padding: 3px 8px;
  border-radius: 20px;
  display: inline-block;
  margin-bottom: 10px;
}

.level3-text { font-size: 0.875rem; color: var(--text-0); line-height: 1.7; }

/* ── Buttons ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
}

.btn svg { width: 15px; height: 15px; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
  background: var(--accent-light);
  box-shadow: 0 4px 20px var(--accent-glow);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-3);
  color: var(--text-1);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-4);
  border-color: var(--border-hover);
  color: var(--text-0);
}

.btn-danger { background: var(--red-dim); color: var(--red); border: 1px solid transparent; }
.btn-danger:hover { background: rgba(239, 68, 68, 0.25); }

.btn-sm { padding: 5px 11px; font-size: 0.8rem; }
.btn-lg { padding: 11px 22px; font-size: 0.9375rem; }

.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }

/* ── Forms ─────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }

/* Two-column grid used in modals — stacks on mobile */
.modal-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

label { font-size: 0.8rem; font-weight: 500; color: var(--text-2); }

input, textarea, select {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-0);
  padding: 9px 13px;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  width: 100%;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

input::placeholder, textarea::placeholder { color: var(--text-3); }
textarea { resize: vertical; line-height: 1.6; min-height: 120px; }

/* ── Note meta row (name + date) ──────────────────────── */
.note-meta-row {
  display: grid;
  grid-template-columns: 1fr 160px;
  gap: 10px;
  margin-bottom: 12px;
}

.note-name-wrap {
  position: relative;
}

.note-date-input {
  width: 100%;
}

/* Name autocomplete suggestions */
.name-suggestions {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 200;
  overflow: hidden;
}

.name-suggestions.open {
  display: block;
}

.name-suggestion-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-1);
  transition: background .12s;
}

.name-suggestion-item:hover {
  background: var(--bg-3);
}

/* ── Note Input View ───────────────────────────────────── */
.note-area {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-top: 24px;
}

.note-textarea {
  font-size: 1rem;
  line-height: 1.7;
  min-height: 160px;
  background: var(--bg-1);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 16px;
  color: var(--text-0);
  width: 100%;
}

.note-textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
  outline: none;
}

.note-actions {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  justify-content: flex-end;
}

.parse-preview { margin-top: 20px; animation: slideDown 0.2s ease; }

.json-preview {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'Fira Code', 'Cascadia Code', monospace;
  font-size: 0.78rem;
  color: var(--text-2);
  overflow: auto;
  max-height: 300px;
  white-space: pre-wrap;
  line-height: 1.6;
}

/* ── Search View ───────────────────────────────────────── */
.search-bar { display: flex; gap: 10px; margin-top: 24px; }

.search-input {
  flex: 1;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 1rem;
  color: var(--text-0);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-results { margin-top: 24px; display: flex; flex-direction: column; gap: 14px; }

.search-result-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  transition: all var(--transition);
  cursor: pointer;
}

.search-result-card:hover {
  border-color: var(--accent-glow);
  background: var(--bg-3);
}

.search-result-info { flex: 1; }
.search-result-name { font-size: 1rem; font-weight: 600; color: var(--text-0); }
.search-result-role { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; }

.search-result-reason {
  font-size: 0.875rem;
  color: var(--text-2);
  margin-top: 8px;
  line-height: 1.55;
}

.match-keywords { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }

/* ── Contact Detail ────────────────────────────────────── */
.contact-detail-header {
  display: flex;
  align-items: center;
  gap: 20px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 24px;
  margin-top: 24px;
}

.avatar-lg {
  width: 64px; height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  flex-shrink: 0;
}

.contact-detail-name { font-size: 1.4rem; font-weight: 700; letter-spacing: -0.02em; }
.contact-detail-meta { color: var(--text-3); font-size: 0.875rem; margin-top: 3px; }
.contact-detail-actions { margin-left: auto; display: flex; gap: 8px; }

.interest-section {
  margin-top: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.interest-block {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.interest-block-title {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.interest-block-title svg { width: 13px; height: 13px; }

.history-section {
  margin-top: 16px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.history-item {
  display: flex;
  gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.history-item:last-child { border-bottom: none; }

.history-date {
  font-size: 0.75rem;
  color: var(--text-3);
  white-space: nowrap;
  padding-top: 2px;
  min-width: 80px;
}

.history-text { font-size: 0.875rem; color: var(--text-1); line-height: 1.5; }
.history-location { font-size: 0.75rem; color: var(--text-3); margin-top: 3px; }

/* ── Modal ─────────────────────────────────────────────── */
body.modal-open { overflow: hidden; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  animation: modalIn 0.2s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 6px; }
.modal-subtitle { font-size: 0.875rem; color: var(--text-3); margin-bottom: 20px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; }

/* ── Photo upload area (direct add modal) ─────────────── */
.photo-upload-area {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--bg-3);
  border: 2px dashed var(--border-hover);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  margin: 0 auto 20px;
  overflow: hidden;
  position: relative;
  transition: border-color var(--transition);
  flex-shrink: 0;
}

.photo-upload-area:hover { border-color: var(--accent); }

.photo-upload-area .photo-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--text-3);
  font-size: 0.68rem;
  pointer-events: none;
  transition: color var(--transition);
}

.photo-upload-area:hover .photo-icon { color: var(--accent-light); }
.photo-upload-area .photo-icon svg { width: 20px; height: 20px; }

.photo-upload-area img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Toast ─────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 0.875rem;
  color: var(--text-0);
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 260px;
  animation: toastIn 0.25s ease;
}

.toast svg { width: 16px; height: 16px; flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--accent); }

@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── Loading & States ──────────────────────────────────── */
.loading-spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
  color: var(--text-3);
  gap: 12px;
}

.empty-state svg { width: 40px; height: 40px; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; color: var(--text-2); }
.empty-state p { font-size: 0.875rem; max-width: 280px; }

/* ── Helpers ───────────────────────────────────────────── */
.section-gap { margin-top: 24px; }
.mt-16 { margin-top: 16px; }
.mt-8 { margin-top: 8px; }

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px 0;
  transition: color var(--transition);
}

.back-btn:hover { color: var(--text-1); }
.back-btn svg { width: 15px; height: 15px; }

.api-key-hint {
  background: var(--amber-dim);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 0.8rem;
  color: var(--amber);
  margin-top: 16px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
  line-height: 1.5;
}

.api-key-hint svg { width: 15px; height: 15px; flex-shrink: 0; margin-top: 1px; }

/* ── Briefing bullet list ──────────────────────────────── */
.bullet-list { display: flex; flex-direction: column; gap: 5px; }

.bullet-item {
  font-size: 0.875rem;
  color: var(--text-1);
  line-height: 1.5;
  padding-left: 2px;
}

.followup-wrap { display: flex; flex-direction: column; }

.followup-arrow {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--text-3);
  transition: transform var(--transition), color var(--transition);
}
.followup-arrow svg { width: 13px; height: 13px; }
.followup-item.active .followup-arrow { transform: rotate(90deg); color: var(--accent-light); }

/* ── Dashboard search card ─────────────────────────────── */
.dashboard-search-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
}

.dashboard-search-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}
.dashboard-search-header svg { width: 12px; height: 12px; }

.dashboard-search-card .search-bar { margin-top: 10px; }

.dash-search-result {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
  cursor: pointer;
  transition: opacity var(--transition);
  margin-top: 4px;
}
.dash-search-result:hover { opacity: 0.8; }

/* ── Contact filter input ──────────────────────────────── */
.filter-input {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-0);
  padding: 9px 13px;
  font-size: 0.875rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

/* ── Bottom Navigation (mobile only) ───────────────────── */
.bottom-nav { display: none; }

/* ── Onboarding Cards ──────────────────────────────────── */
.onboarding-hero {
  padding: 32px 0 8px;
  text-align: center;
}

.onboarding-hero-icon {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--accent), #a78bfa);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  box-shadow: 0 0 24px var(--accent-glow);
}

.onboarding-hero-icon svg { width: 28px; height: 28px; color: #fff; }
.onboarding-hero-title { font-size: 1.25rem; font-weight: 700; color: var(--text-0); letter-spacing: -0.02em; }
.onboarding-hero-sub { font-size: 0.875rem; color: var(--text-3); margin-top: 6px; line-height: 1.6; }

.onboarding-cards {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 24px;
}

.onboarding-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  transition: all var(--transition);
  -webkit-tap-highlight-color: transparent;
}

.onboarding-card.highlight {
  background: linear-gradient(135deg, rgba(124,111,247,0.18), rgba(124,111,247,0.08));
  border-color: var(--accent-glow);
}

.onboarding-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-hover); border-color: var(--border-hover); }
.onboarding-card.highlight:hover { border-color: var(--accent); }
.onboarding-card:active { transform: translateY(0); }

.onboarding-card-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.onboarding-card-icon.purple { background: var(--accent); box-shadow: 0 4px 12px var(--accent-glow); }
.onboarding-card-icon.amber  { background: var(--amber-dim); color: var(--amber); }
.onboarding-card-icon.green  { background: var(--green-dim); color: var(--green); }
.onboarding-card-icon svg { width: 18px; height: 18px; color: #fff; }

.onboarding-card-body { flex: 1; min-width: 0; }
.onboarding-card-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-0); }
.onboarding-card-sub { font-size: 0.8rem; color: var(--text-3); margin-top: 2px; }

.onboarding-card-arrow { color: var(--text-3); flex-shrink: 0; }
.onboarding-card-arrow svg { width: 16px; height: 16px; }

/* ── Responsive ────────────────────────────────────────── */

/* Tablet */
@media (max-width: 900px) {
  .level1-cards { grid-template-columns: 1fr; }
  .level2-panel { grid-column: 1; }
  .interest-section { grid-template-columns: 1fr; }
}

/* Mobile */
@media (max-width: 767px) {
  :root { --sidebar-w: 0px; }

  /* Sidebar hidden on mobile */
  .sidebar { display: none; }

  .main-content {
    margin-left: 0;
    padding-bottom: var(--bottom-nav-h);
  }

  /* Mobile header */
  .mobile-header {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    height: 52px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-1);
    position: sticky;
    top: 0;
    z-index: 50;
    flex-shrink: 0;
  }

  .mob-back-btn {
    width: 36px; height: 36px;
    display: flex; align-items: center; justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-2);
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
  }
  .mob-back-btn:active { background: var(--bg-3); }
  .mob-back-btn svg { width: 20px; height: 20px; }

  .mob-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-0);
  }

  /* Bottom navigation */
  .bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-h);
    background: var(--bg-1);
    border-top: 1px solid var(--border);
    z-index: 100;
    align-items: stretch;
  }

  .bnav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-3);
    font-size: 0.625rem;
    font-weight: 500;
    cursor: pointer;
    transition: color var(--transition);
    padding: 6px 0;
    -webkit-tap-highlight-color: transparent;
    letter-spacing: 0.02em;
  }

  .bnav-item svg { width: 21px; height: 21px; }
  .bnav-item.active { color: var(--accent-light); }
  .bnav-item:active { opacity: 0.65; }

  /* Page layout */
  .page-header { padding: 16px 16px 0; flex-wrap: wrap; gap: 10px; }
  .page-title { font-size: 1.2rem; }
  .page-subtitle { font-size: 0.8rem; }
  #view-container { padding: 14px 16px 20px; }

  /* Grids */
  .contacts-grid { grid-template-columns: 1fr; margin-top: 14px; gap: 10px; }
  .stats-grid { gap: 8px; margin-top: 16px; }
  .stat-card { padding: 12px 10px; gap: 6px; }
  .stat-icon { width: 28px; height: 28px; }
  .stat-icon svg { width: 14px; height: 14px; }
  .stat-value { font-size: 1.4rem; }
  .stat-label { font-size: 0.7rem; }

  /* Contact cards */
  .contact-card { padding: 14px 16px; }
  .avatar { width: 38px; height: 38px; border-radius: 10px; font-size: 0.875rem; }

  /* Contact detail */
  .contact-detail-header {
    flex-wrap: wrap;
    padding: 14px 16px;
    gap: 10px;
    margin-top: 14px;
  }
  .avatar-lg { width: 52px; height: 52px; border-radius: 13px; font-size: 1.2rem; }
  .contact-detail-name { font-size: 1.15rem; }
  .contact-detail-actions { margin-left: 0; width: 100%; }
  .contact-detail-actions .btn-primary { flex: 1; justify-content: center; }

  /* Note */
  .note-area { padding: 14px; margin-top: 14px; }
  .note-textarea { min-height: 130px; font-size: 0.9375rem; }
  .note-actions { gap: 8px; }
  .note-meta-row { grid-template-columns: 1fr 130px; }
  .note-date-input { width: 100%; }
  .note-actions .btn-primary { flex: 1; justify-content: center; }

  /* Search */
  .search-bar { flex-direction: column; margin-top: 14px; }
  .search-bar .btn { justify-content: center; padding: 11px; }

  /* History */
  .history-date { min-width: 68px; font-size: 0.7rem; }

  /* Briefing */
  .level1-cards { grid-template-columns: 1fr; gap: 8px; }
  .level2-panel { grid-column: 1; padding: 14px 16px; }
  .level1-card { padding: 12px 14px; }

  /* Toast above bottom nav */
  #toast-container { bottom: calc(var(--bottom-nav-h) + 10px); right: 12px; left: 12px; }
  .toast { min-width: unset; width: 100%; }

  /* Back button in content (hide on mobile — use header instead) */
  .page-header .back-btn { display: none; }

  /* Modal — bottom sheet on mobile */
  #modal-content { width: 100%; }

  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    border-radius: 20px 20px 0 0;
    max-width: 100%;
    width: 100%;
    max-height: 88dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 0 16px max(16px, env(safe-area-inset-bottom));
    animation: slideUp 0.28s cubic-bezier(0.32, 0.72, 0, 1);
  }

  /* Drag handle pseudo-element */
  .modal::before {
    content: '';
    display: block;
    width: 36px;
    height: 4px;
    background: var(--border-hover);
    border-radius: 2px;
    margin: 12px auto 14px;
  }

  /* Compact form spacing inside modal */
  .modal .form-group { margin-bottom: 8px; }
  .modal .photo-upload-area { margin-bottom: 12px; }
  .note-date-input { width: 100%; }
}

.mobile-header { display: none; }
