/* Numa CRM — base styles. Plain CSS, mobile-first, no build step.
   Kept deliberately small and readable so it's easy to maintain. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --ink: #1c2733;
  --muted: #5b6b7b;
  --line: #dce3ea;
  --brand: #1f6f8b;
  --brand-ink: #ffffff;
  --danger: #b3261e;
  --ok: #1d7a46;
  --radius: 10px;
  --gap: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Top bar ─────────────────────────────────────────────────────────────── */
.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gap);
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; }
.brand-logo { height: 28px; width: auto; display: block; }
.topnav { display: flex; gap: 14px; flex: 1 1 auto; flex-wrap: wrap; }
.topnav a { color: var(--muted); font-weight: 500; }
.topnav a:hover { color: var(--brand); }
.who { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.who-name { font-weight: 600; }
.who-role {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}
.logout-form { margin: 0; }

/* ── Content + cards ─────────────────────────────────────────────────────── */
.content { max-width: 960px; margin: 0 auto; padding: 24px 16px; }
/* Wide pages (e.g. the leads table) use more of the screen so every column
   fits without side-scrolling. */
.content-wide { max-width: 1400px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
}
.card + .card { margin-top: var(--gap); }
.card-narrow { max-width: 420px; margin: 8vh auto 0; }
.card h1 { margin-top: 0; font-size: 1.4rem; }
.muted { color: var(--muted); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--brand);
  background: var(--brand);
  color: var(--brand-ink);
  cursor: pointer;
}
.btn:hover { filter: brightness(.95); text-decoration: none; }
.btn-quiet {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.btn-quiet:hover { color: var(--ink); }
.btn-danger { background: var(--danger); border-color: var(--danger); }

/* ── Card heads + section titles ─────────────────────────────────────────── */
.card h2 { margin-top: 0; font-size: 1.1rem; }
.crumb { margin: 0 0 12px; }
.empty { color: var(--muted); padding: 8px 0; }

/* ── Today / list rows ───────────────────────────────────────────────────── */
.lead-rows { list-style: none; margin: 0; padding: 0; }
.lead-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}
.lead-row:first-child { border-top: 0; }
.lead-row-main { flex: 1 1 auto; }
.lead-row-name { font-weight: 600; color: var(--ink); }

/* ── Filters ─────────────────────────────────────────────────────────────── */
.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}
.filter-check { display: flex; align-items: center; gap: 6px; }
.filter-status { display: flex; align-items: center; gap: 6px; }
.filters select {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

/* ── Lead table ──────────────────────────────────────────────────────────── */
/* Wrapper lets wide tables scroll sideways on a phone instead of squashing the
   columns into an unreadable mess. The min-width forces the scroll to kick in. */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-wrap .lead-table { min-width: 760px; }
.lead-table { width: 100%; border-collapse: collapse; }
.lead-table th, .lead-table td {
  text-align: left;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.lead-table th { font-size: .8rem; text-transform: uppercase; color: var(--muted); }

/* Latest note: one line, cut off with an ellipsis so the row height is fixed
   no matter how long the note is (full text shows on hover via the title). */
.lead-table .note-cell {
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Inline "log a contact attempt" form on the leads list: outcome + note on the
   left, the Log button to their right. Kept on one row (no wrap). */
.log-inline { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; }
.log-inline select,
.log-inline input {
  font: inherit;
  height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}
.log-inline select { min-width: 160px; }
.log-inline input { width: 200px; }
.log-inline input::placeholder { color: var(--muted); }
.log-inline select:focus,
.log-inline input:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(31, 111, 139, .15);
}
.log-inline .btn { height: 40px; padding: 8px 18px; margin-left: 4px; }

/* ── Status pills ────────────────────────────────────────────────────────── */
.pill {
  display: inline-block;
  font-size: .78rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  background: #eef2f5;
  color: var(--muted);
  white-space: nowrap;
}
.pill-new { background: #e7f0fb; color: #1f5fa8; }
.pill-in_process { background: #e9f3ee; color: var(--ok); }
.pill-qualified { background: #e3f6ea; color: #137a3c; }
.pill-cash_pay { background: #fff2d9; color: #8a5a00; }
.pill-cold { background: #eef0f2; color: #5b6b7b; }
.pill-dnc { background: #fdecea; color: var(--danger); }
.pill-due { background: #fff2d9; color: #8a5a00; }

/* ── Notifications (top-bar bell + alerts list) ──────────────────────────── */
.bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-weight: 500;
}
.bell:hover { color: var(--brand); }
.bell .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  font-size: .72rem;
  font-weight: 700;
  line-height: 1;
  color: #fff;
  background: var(--danger);
  border-radius: 999px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.inline-form { display: inline; margin: 0; }
.row-actions { display: flex; align-items: center; gap: 8px; }
.lead-row-unread { background: #f4f8ff; }
.lead-row-unread .lead-row-name { font-weight: 600; }

/* ── Detail page ─────────────────────────────────────────────────────────── */
.detail-head { display: flex; align-items: center; gap: 12px; }
.detail-head h1 { margin: 0; }
.facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 24px;
  margin: 16px 0 0;
}
.facts dt { font-size: .75rem; text-transform: uppercase; color: var(--muted); }
.facts dd { margin: 2px 0 0; font-weight: 500; }

.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.actions form { margin: 0; }
.action-inline { display: flex; gap: 6px; }
.action-inline input {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.stack select {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

/* ── Duplicate review ────────────────────────────────────────────────────── */
.dup-head { margin-bottom: 12px; }
.dup-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.dup-side {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfd;
}
.dup-name { font-weight: 600; font-size: 1.05rem; margin-right: 8px; }
.dup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.dup-actions form { margin: 0; }
.dup-foot { margin-top: 14px; }
.dup-foot form { margin: 0; }
@media (max-width: 560px) {
  .dup-cols { grid-template-columns: 1fr; }
}

/* ── Dashboard stats ─────────────────────────────────────────────────────── */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin: 16px 0 0;
}
.stat {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fbfcfd;
}
.stat dt { font-size: .72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.stat dd { margin: 4px 0 0; font-size: 1.3rem; font-weight: 700; }

/* ── Timeline ────────────────────────────────────────────────────────────── */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.timeline li:first-child { border-top: 0; }
.timeline-when { font-size: .78rem; color: var(--muted); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; }
.stack input {
  font: inherit;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
.stack input:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}
.small { font-size: .85rem; }

/* ── Alerts ──────────────────────────────────────────────────────────────── */
.alert { border-radius: 8px; padding: 10px 12px; margin: 0 0 14px; }
.alert-error { background: #fdecea; color: var(--danger); border: 1px solid #f5c6c2; }

/* ── QR enrollment ───────────────────────────────────────────────────────── */
.qr-box {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 6px 0 12px;
}
.qr-box svg { width: 200px; height: 200px; }
.manual-entry summary {
  cursor: pointer;
  color: var(--brand);
  font-weight: 600;
  margin-bottom: 8px;
}

/* ── Secret / setup key ──────────────────────────────────────────────────── */
.secret-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #f0f4f7;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin: 6px 0;
}
.secret-label {
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}
.secret-key {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 1.05rem;
  letter-spacing: .08em;
  word-break: break-all;
  user-select: all;
}

/* ── Small screens ───────────────────────────────────────────────────────── */
@media (max-width: 560px) {
  .topbar { gap: 8px; }
  .who { width: 100%; margin-left: 0; }
  .topnav { order: 3; width: 100%; }
  .content { padding: 16px 12px; }
  .card { padding: 16px; }
  .card h1 { font-size: 1.25rem; }
  /* Stacked action forms get full-width tap targets on a phone. */
  .actions { flex-direction: column; align-items: stretch; }
  .actions .btn { width: 100%; }
  .action-inline { width: 100%; }
  /* …but inside a table the row scrolls sideways as one unit, so keep its
     actions inline — full-width stacking there just bloats the row height. */
  .lead-table .actions { flex-direction: row; flex-wrap: nowrap; align-items: center; }
  .lead-table .actions .btn,
  .lead-table .action-inline { width: auto; white-space: nowrap; }
}
