/* Joshua Vomberg · back office — app.css
   Same brand as joshuavomberg.co.za, but denser: a tool, not a brochure.
   Light theme only. Mobile first; the leads table becomes cards under 720px. */

/* ---------- tokens ---------- */
:root {
  --ink: #1b1714;
  --muted: #6b6258;
  --line: #e7e0d6;
  --paper: #fffdf9;
  --soft: #faf6ef;
  --ember: #e8480a;
  --ember2: #c2410c;
  --green: #3f7d52;
  --ember-tint: #fcebe2;
  --green-tint: #e6f0e9;
  --grey: #ebe7e1;
  --grey-text: #8a827a;
  --red: #b42318;            /* overdue only; not a brand colour */
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --sans: 'Hanken Grotesk', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --radius: 6px;
  --gutter: 16px;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 400 15px/1.45 var(--sans);
  color: var(--ink);
  background: var(--paper);
  min-height: 100vh;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; margin: 0; letter-spacing: -0.01em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }

/* ---------- centred screens: loading + login ---------- */
.centre {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--gutter);
  background: var(--soft);
}

/* ---------- login card ---------- */
.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 30px 28px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mark { display: block; width: 28px; height: 4px; background: var(--ember); border-radius: 2px; }
.wordmark {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 22px;
  line-height: 1.2;
  color: var(--ink);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.wordmark .dot { color: var(--ember); }
.lede { margin: -6px 0 6px; color: var(--muted); }
@media (max-width: 400px) { .login-card { padding: 26px 22px 24px; } .login-card .wordmark { font-size: 20px; } }
.error { margin: 0; color: var(--red); font-size: 14px; }

/* ---------- fields ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  font-size: 16px;            /* 16px stops iOS zooming into the field */
}
@media (min-width: 720px) { input, select, textarea { font-size: 15px; } }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ember);
  box-shadow: 0 0 0 3px rgba(232, 72, 10, 0.15);
}
textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
textarea.tall { min-height: 240px; }
select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 32px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path d='M1 1l5 5 5-5' fill='none' stroke='%236b6258' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
input[type="search"]::-webkit-search-cancel-button { -webkit-appearance: searchfield-cancel-button; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  font-weight: 600;
  font-size: 14px;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--soft); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-primary { background: var(--ember); border-color: var(--ember); color: #fff; }
.btn-primary:hover { background: var(--ember2); border-color: var(--ember2); }
.btn-block { width: 100%; padding: 12px 16px; font-size: 15px; margin-top: 4px; }
.btn-danger { color: var(--ember2); }
.btn-danger:hover { background: var(--ember-tint); border-color: var(--ember2); }
.btn-wa { color: var(--green); border-color: var(--green); }
.btn-wa:hover { background: var(--green-tint); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn svg { width: 16px; height: 16px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 20px;
  padding: 8px var(--gutter);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.topbar .wordmark { font-size: 17px; flex: 1 1 auto; padding: 4px 0; }
.nav { display: flex; align-items: center; gap: 16px; }
.nav-link {
  padding: 6px 0;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}
.nav-link:hover { color: var(--ink); }
.nav-link.is-active { color: var(--ink); border-bottom-color: var(--ember); }
.nav-link.is-disabled { color: var(--grey-text); cursor: not-allowed; }

/* ---------- main + page head ---------- */
.main { max-width: 1100px; margin: 0 auto; padding: 16px var(--gutter) 56px; }
.loading { padding: 24px 0; }
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; margin: 4px 0 18px; }
.page-head .back { flex: 1 1 100%; font-size: 13px; color: var(--muted); text-decoration: none; }
.page-head .back:hover { color: var(--ink); }
.page-title { font-size: 26px; flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }

/* ---------- leads list: search + chips ---------- */
.toolbar { margin-bottom: 10px; }
.search { max-width: 420px; }
.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 6px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(100% - 28px), transparent);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.chip:hover { background: var(--soft); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.is-empty { color: var(--grey-text); }
.chip-count { font-size: 12px; color: var(--muted); }
.chip.is-active .chip-count { color: rgba(255, 253, 249, 0.7); }
.chip-overdue { font-size: 12px; font-weight: 600; color: var(--red); }
.chip.is-active .chip-overdue { color: #ffa98f; }

/* ---------- stage pills ---------- */
.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.5;
  white-space: nowrap;
}
.pill-muted { background: var(--soft); color: var(--muted); border: 1px solid var(--line); }
.pill-ember { background: var(--ember-tint); color: var(--ember2); }
.pill-green { background: var(--green-tint); color: var(--green); }
.pill-solid { background: var(--green); color: #fff; }
.pill-grey  { background: var(--grey); color: var(--grey-text); }

/* ---------- leads table (desktop) ---------- */
.leads { width: 100%; border-collapse: collapse; font-size: 14px; }
.leads th {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.leads td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.lead-row { cursor: pointer; }
.lead-row:hover { background: var(--soft); }
.lead-row:focus-visible { outline: 2px solid var(--ember); outline-offset: -2px; }
.c-name strong { display: block; font-weight: 600; }
.c-name .sub { display: block; font-size: 13px; }
.c-follow { white-space: nowrap; font-weight: 500; }
.c-follow.is-overdue { color: var(--red); font-weight: 600; }
.c-follow.is-today { color: var(--ember2); font-weight: 600; }
.c-wa { width: 44px; text-align: right; }
.wa { display: inline-flex; padding: 13px; margin: -13px; border-radius: 50%; color: var(--green); }  /* 44px hit area */
.wa:hover { background: var(--green-tint); }
.wa svg { display: block; width: 18px; height: 18px; }
.c-last:empty::before { content: '—'; }
.empty { padding: 40px 0; text-align: center; color: var(--muted); }

/* ---------- leads as cards (phones) ---------- */
@media (max-width: 719.98px) {
  .leads, .leads tbody { display: block; }
  .leads thead { display: none; }
  .lead-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
  }
  .lead-row::after { content: ''; flex-basis: 100%; height: 0; order: 2; } /* forces the meta onto its own line */
  .leads td { display: block; padding: 0; border: 0; }
  .c-name { order: 0; flex: 1 1 0; min-width: 0; }
  .lead-row .c-wa { order: 1; width: auto; min-height: 44px; display: flex; align-items: center; }
  .c-stage { order: 3; }
  .c-follow { order: 4; font-size: 13px; }
  .c-last { order: 5; font-size: 13px; }
  .c-last::before { content: 'last '; }
  .c-last:empty { display: none; }
  .c-source { order: 6; margin-left: auto; font-size: 13px; }
}

/* ---------- lead form ---------- */
.lead-form { display: grid; grid-template-columns: 1fr; gap: 14px; margin-bottom: 36px; }
@media (min-width: 720px) {
  .lead-form { grid-template-columns: 1fr 1fr; gap: 16px 20px; }
  .span-2 { grid-column: 1 / -1; }
}
.actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 4px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.actions .spacer { flex: 1; }
.save-note { color: var(--green); font-weight: 600; font-size: 14px; }

/* ---------- activity ---------- */
.section-title { display: flex; align-items: baseline; gap: 8px; font-size: 18px; margin: 0 0 12px; }
.section-title .count { font-family: var(--sans); font-size: 13px; font-weight: 500; color: var(--muted); }
.activity-add {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin-bottom: 18px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.activity-add .row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.activity-add textarea { min-height: 96px; }
.activity-add .actions { border: 0; padding: 0; margin: 0; }
.activity-list { display: flex; flex-direction: column; }
.activity { padding: 12px 0; border-bottom: 1px solid var(--line); }
.activity-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  font-size: 13px;
  color: var(--muted);
}
.activity-meta time { font-variant-numeric: tabular-nums; }
.badge {
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.badge-in     { background: var(--green-tint); color: var(--green); }
.badge-out    { background: var(--ember-tint); color: var(--ember2); }
.badge-note   { background: var(--paper); color: var(--muted); border: 1px solid var(--line); }
.badge-system { background: var(--grey); color: var(--grey-text); }
.activity-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed;
  left: 50%;
  bottom: 16px;
  z-index: 100;
  width: min(calc(100% - 32px), 480px);
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  padding: 10px 14px;
  border-radius: 8px;
  border-left: 3px solid var(--green);
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
  box-shadow: 0 6px 20px rgba(27, 23, 20, 0.2);
  pointer-events: auto;
  transition: opacity 0.3s;
}
.toast.error { border-left-color: var(--ember); }
.toast.is-leaving { opacity: 0; }

/* ---------- today ---------- */
.nav-count {
  display: inline-block;
  min-width: 18px;
  margin-left: 6px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--ember);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  vertical-align: 1px;
}
.today-date { display: block; margin-top: 2px; font-family: var(--sans); font-size: 15px; font-weight: 400; letter-spacing: 0; color: var(--muted); }
.due { margin-bottom: 26px; }
.section-title.is-overdue { color: var(--red); }
.section-title.is-today { color: var(--ember2); }
.section-title .note { font-family: var(--sans); font-size: 13px; font-weight: 400; color: var(--muted); }
.due-list { display: flex; flex-direction: column; }
.due-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.due-row::after { content: ''; flex-basis: 100%; height: 0; order: 2; }  /* phones: stage + label drop to a second line */
.due-main { flex: 1 1 0; min-width: 0; order: 0; }
.due-name { display: block; font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
a.due-name:hover { text-decoration: underline; }
.due-main .sub { display: block; font-size: 13px; }
.due-main .sub a { color: inherit; }
.due-stage { order: 3; }
.due-when { order: 4; font-size: 13px; font-weight: 600; white-space: nowrap; }
.due-when.is-overdue { color: var(--red); }
.due-when.is-today { color: var(--ember2); }
.due-done { order: 1; }
.due-wa { order: 1; min-height: 44px; display: flex; align-items: center; }
.due-wa:empty { display: none; }
@media (min-width: 720px) {
  .due-row { flex-wrap: nowrap; gap: 16px; }
  .due-row::after { display: none; }
  .due-main { flex: 1 1 auto; }
  .due-stage, .due-when, .due-done { order: 0; }
  .due-when { min-width: 96px; text-align: right; }
  .due-wa, .due-wa:empty { display: flex; flex: 0 0 44px; justify-content: flex-end; order: 0; }
}
