/* JobSmart Client App - mobile-first, premium-clean. No inline styles anywhere
   (strict CSP). Palette: deep navy brand chrome, light working surface. */
:root {
  --brand: #0b1220;
  --brand-2: #101c33;
  --accent: #f5b301;
  --surface: #f6f7f9;
  --card: #ffffff;
  --ink: #16202e;
  --ink-2: #5b6878;
  --line: #e3e7ec;
  --new: #2f6fed;
  --contacted: #e8930c;
  --won: #1e9e5a;
  --lost: #8a94a1;
  --danger: #c92f2f;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--surface);
  color: var(--ink);
  font: 16px/1.45 -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
#app { min-height: 100%; display: flex; flex-direction: column; }
button { font: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--ink); }

/* ---------- login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  background: linear-gradient(160deg, var(--brand) 0%, var(--brand-2) 100%);
  padding: 24px;
}
.login-logo { color: #fff; font-size: 30px; font-weight: 800; letter-spacing: .5px; }
.login-logo span { color: var(--accent); }
.login-sub { color: #8fa1bd; margin: 6px 0 28px; font-size: 14px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--card);
  border-radius: var(--radius); padding: 22px;
  box-shadow: 0 18px 50px rgba(0,0,0,.35);
}
.login-card label { display: block; font-size: 13px; color: var(--ink-2); margin: 12px 0 4px; }
.login-card input {
  width: 100%; padding: 12px; border: 1px solid var(--line);
  border-radius: 10px; background: #fbfcfd;
}
.login-card input:focus { outline: 2px solid var(--new); border-color: transparent; }

/* ---------- app shell ---------- */
.topbar {
  background: var(--brand); color: #fff;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 18px 12px;
  display: flex; align-items: baseline; justify-content: space-between;
}
.topbar .brand { font-weight: 800; font-size: 19px; }
.topbar .brand span { color: var(--accent); }
.topbar .cobrand { font-size: 13px; color: #9fb0ca; max-width: 55%; text-align: right;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
main { flex: 1; padding: 16px 16px 90px; max-width: 720px; width: 100%; margin: 0 auto; }
.bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottomnav button {
  flex: 1; background: none; border: none; padding: 10px 0 8px;
  color: var(--ink-2); font-size: 11.5px; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
}
.bottomnav button .ic { font-size: 20px; line-height: 1; }
.bottomnav button.active { color: var(--new); font-weight: 600; }

/* ---------- shared bits ---------- */
.h1 { font-size: 21px; font-weight: 750; margin: 6px 0 14px; }
.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
}
.muted { color: var(--ink-2); font-size: 13.5px; }
.btn {
  border: none; border-radius: 10px; padding: 12px 16px;
  background: var(--brand); color: #fff; font-weight: 650; width: 100%;
}
.btn:disabled { opacity: .55; cursor: default; }
.btn.secondary { background: #eef1f5; color: var(--ink); }
.btn.small { width: auto; padding: 8px 14px; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 7px 14px; font-size: 13.5px; color: var(--ink-2);
}
.pill.sel { border-color: currentColor; font-weight: 650; }
.pill.s-new.sel { color: var(--new); }
.pill.s-contacted.sel { color: var(--contacted); }
.pill.s-won.sel { color: var(--won); }
.pill.s-lost.sel { color: var(--lost); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.s-new { background: var(--new); }
.dot.s-contacted { background: var(--contacted); }
.dot.s-won { background: var(--won); }
.dot.s-lost { background: var(--lost); }
.err { color: var(--danger); font-size: 13.5px; min-height: 18px; margin-top: 8px; }
/* success notice (e.g. "password saved") - collapses to nothing when empty, so
   it never leaves a gap on the normal login screen */
.ok { color: var(--won); font-size: 13.5px; margin-bottom: 6px; }
.ok:empty { display: none; }
/* field hint, e.g. the password length rule */
.hint { color: #8fa1bd; font-size: 12.5px; margin-top: 6px; }
.up { color: var(--won); font-weight: 650; }
.down { color: var(--danger); font-weight: 650; }
.pay-row { margin-top: 10px; }
.card.health { display: block; width: 100%; text-align: left; cursor: pointer; font: inherit; color: inherit; }
.card.health:active { background: #f0f2f5; }
#healthline { margin-top: 4px; font-weight: 600; }

/* ---------- home ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.stat .n { font-size: 26px; font-weight: 800; }
.stat .l { font-size: 12.5px; color: var(--ink-2); }

/* ---------- leads ---------- */
.search {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 12px; margin-bottom: 12px; background: var(--card);
}
.lead-item {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 10px;
}
.lead-item .name { font-weight: 650; }
.lead-item .sub { font-size: 13px; color: var(--ink-2); }
.lead-item .when { font-size: 12px; color: var(--ink-2); white-space: nowrap; }

/* ---------- lead detail ---------- */
.back { background: none; border: none; color: var(--new); padding: 0; font-size: 15px; margin-bottom: 10px; }
.contact-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 12px 0; }
.field-label { font-size: 13px; color: var(--ink-2); margin: 10px 0 4px; }
textarea.notes, input.followup {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; background: #fbfcfd;
}
.thread { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.msg { max-width: 82%; padding: 10px 12px; border-radius: 14px; font-size: 14.5px;
  white-space: pre-wrap; word-break: break-word; }
.msg.inbound { background: #eef1f5; align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.outbound { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg .mt { display: block; font-size: 11px; opacity: .65; margin-top: 4px; }
.compose { margin-top: 12px; }
.compose textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; background: #fff; min-height: 64px;
}
.compose input.subject {
  width: 100%; border: 1px solid var(--line); border-radius: 10px;
  padding: 10px; background: #fff; margin-bottom: 8px;
}

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: all .25s ease;
  max-width: 88vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (min-width: 720px) {
  .contact-actions { grid-template-columns: repeat(3, 1fr); }
}

/* lead capture: channel/status badges + the receptionist "what they need" block */
.badge {
  display: inline-block; margin-left: 6px; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 650; vertical-align: middle;
  background: #eef1f5; color: var(--ink-2); border: 1px solid var(--line);
}
.badge.urg { margin-left: 0; background: #fdecec; color: var(--danger); border-color: #f4caca; }
.capture {
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  background: var(--surface); margin-bottom: 4px;
}
.capture .cap-job { font-weight: 600; margin: 4px 0 2px; }
