:root {
  --bg: #14171c;
  --surface: #1c2027;
  --surface-2: #242933;
  --border: #2e3440;
  --text: #e8eaed;
  --text-muted: #8b93a1;
  --accent: #d4a24c;
  --accent-dim: #a17e3a;
  --danger: #b25b5b;
  --success: #5fb878;

  --s-new: #6e93c0;
  --s-emailed: #7fa9c4;
  --s-responded: #8fbf8a;
  --s-communicating: #c4a45e;
  --s-acquired: #5fb878;
  --s-dead: #b25b5b;

  --font-display: "Space Grotesk", sans-serif;
  --font-body: "Inter", sans-serif;
  --font-mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

input, select, textarea {
  font-family: var(--font-body);
}

/* ---------- Layout shells ---------- */
.screen { min-height: 100vh; display: flex; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap {
  margin: auto;
  width: 100%;
  max-width: 380px;
  padding: 40px 36px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.login-wrap .brand {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 6px;
}
.login-wrap h1 {
  font-family: var(--font-display);
  font-size: 26px;
  margin: 0 0 28px 0;
  font-weight: 600;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: 0.03em;
}
.field input, .field select, .field textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 14px;
  font-weight: 500;
  transition: opacity 0.15s, background 0.15s;
}
.btn-primary { background: var(--accent); color: #1a1408; }
.btn-primary:hover { opacity: 0.88; }
.btn-primary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover { background: rgba(178,91,91,0.12); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.error-text { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 18px; }
.hint-text { color: var(--text-muted); font-size: 12px; margin-top: 18px; line-height: 1.5; }

/* ---------- App shell ---------- */
.app { display: none; flex-direction: column; width: 100%; min-height: 100vh; }
.app.active { display: flex; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand {
  font-family: var(--font-display);
  font-size: 15px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}
.topbar .who {
  color: var(--text-muted);
  font-size: 13px;
}
.topbar-right { display: flex; align-items: center; gap: 14px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  padding: 16px 28px;
  border-bottom: 1px solid var(--border);
}
.toolbar input[type="search"], .toolbar select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}
.toolbar input[type="search"] { min-width: 220px; flex: 1; }
.toolbar .spacer { flex: 1; }
.count-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.main {
  flex: 1;
  overflow: auto;
  padding: 0 28px 40px;
}

/* ---------- Table ---------- */
table.leads { width: 100%; border-collapse: collapse; margin-top: 16px; }
table.leads th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 500;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
}
table.leads td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
table.leads tbody tr { cursor: pointer; transition: background 0.1s; }
table.leads tbody tr:hover { background: var(--surface); }
.mono { font-family: var(--font-mono); font-size: 12px; color: var(--text-muted); }
.company-cell { font-weight: 600; }
.company-cell .site { display: block; font-size: 12px; color: var(--text-muted); font-weight: 400; font-family: var(--font-mono); }

.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-muted);
}
.empty-state h3 { font-family: var(--font-display); color: var(--text); font-size: 18px; margin-bottom: 8px; }

/* ---------- Pipeline / status ---------- */
.pipeline { display: flex; align-items: center; gap: 3px; }
.pipeline .dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--border);
}
.pipeline .dot.filled { background: var(--dot-color, var(--accent)); }
.pipeline .label {
  margin-left: 8px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  border: 1px solid transparent;
}

.status-new { color: var(--s-new); background: rgba(110,147,192,0.12); }
.status-emailed { color: var(--s-emailed); background: rgba(127,169,196,0.12); }
.status-responded { color: var(--s-responded); background: rgba(143,191,138,0.12); }
.status-communicating { color: var(--s-communicating); background: rgba(196,164,94,0.12); }
.status-acquired { color: var(--s-acquired); background: rgba(95,184,120,0.12); }
.status-dead_lead { color: var(--s-dead); background: rgba(178,91,91,0.12); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10,12,15,0.7);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  z-index: 100;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 100%;
  max-width: 640px;
  padding: 28px 32px 32px;
}
.modal h2 {
  font-family: var(--font-display);
  font-size: 20px;
  margin: 0 0 20px 0;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.modal-actions .right { display: flex; gap: 10px; }

.notes-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border); }
.notes-section h3 { font-family: var(--font-display); font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 12px; }
.note-item { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 10px 12px; margin-bottom: 8px; }
.note-item .meta { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; font-family: var(--font-mono); }
.note-item .content { font-size: 13px; line-height: 1.5; white-space: pre-wrap; }
.note-add { display: flex; gap: 8px; margin-top: 12px; }
.note-add textarea { flex: 1; min-height: 44px; resize: vertical; }

/* ---------- Import modal ---------- */
.import-drop {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.import-preview { max-height: 240px; overflow: auto; margin-top: 16px; border: 1px solid var(--border); border-radius: 6px; }
.import-preview table { width: 100%; border-collapse: collapse; font-size: 12px; }
.import-preview th, .import-preview td { padding: 6px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; font-family: var(--font-mono); }
.import-preview th { color: var(--text-muted); text-transform: uppercase; font-size: 10px; }

.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 200;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

@media (max-width: 720px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar, .toolbar, .main { padding-left: 16px; padding-right: 16px; }
  table.leads thead { display: none; }
  table.leads, table.leads tbody, table.leads tr, table.leads td { display: block; width: 100%; }
  table.leads tr { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; padding: 8px 4px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
