/* Savvy Leads — client CRM for Savvy Lead Engine
   Blue scheme, mobile-first. */

:root {
  --primary: #1668dc;
  --primary-dark: #0f4fb0;
  --navy: #0b2a5b;
  --bg: #f3f6fb;
  --card: #ffffff;
  --text: #16233a;
  --muted: #64748b;
  --border: #e2e8f0;
  --green: #16a34a;
  --red: #dc2626;
  --amber: #d97706;
  --purple: #7c3aed;
  --teal: #0d9488;
  --bark: #6d28d9;          /* Bark.com brand accent */
  --radius: 12px;
  --shadow: 0 1px 3px rgba(11,42,91,.08), 0 4px 12px rgba(11,42,91,.06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  padding-bottom: 76px; /* room for tab bar */
}
body.no-tabs { padding-bottom: 0; }

a { color: var(--primary); text-decoration: none; }
button { font: inherit; cursor: pointer; }

/* ---------- Header ---------- */
.app-header {
  background: var(--navy);
  color: #fff;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header .logo-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 18px; color: #fff;
  flex-shrink: 0;
}
.app-header .titles { flex: 1; min-width: 0; }
.app-header .titles h1 { font-size: 17px; font-weight: 700; letter-spacing: .2px; }
.app-header .titles p { font-size: 12px; color: #b9cdf2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  background: rgba(255,255,255,.12); border: none; color: #fff;
  width: 36px; height: 36px; border-radius: 10px; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}

/* ---------- Views ---------- */
.view { display: none; max-width: 1080px; margin: 0 auto; padding: 16px 14px 24px; }
.view.active { display: block; }
.view h2.page-title { font-size: 20px; margin: 4px 2px 12px; }
.view .page-sub { color: var(--muted); font-size: 13px; margin: -8px 2px 14px; }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; margin-bottom: 14px;
  border: 1px solid var(--border);
}
.card h3 { font-size: 15px; margin-bottom: 10px; }

/* ---------- Stat grid ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow);
}
.stat .num { font-size: 26px; font-weight: 800; color: var(--navy); }
.stat .lbl { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stat.accent { background: linear-gradient(135deg, var(--navy), var(--primary-dark)); border: none; }
.stat.accent .num, .stat.accent .lbl { color: #fff; }

/* ---------- Badges ---------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px; letter-spacing: .3px;
  text-transform: uppercase; white-space: nowrap;
}
.badge.stage-new { background: #dbeafe; color: #1d4ed8; }
.badge.stage-contacted { background: #ede9fe; color: #6d28d9; }
.badge.stage-qualified { background: #ccfbf1; color: #0f766e; }
.badge.stage-appointment { background: #fef3c7; color: #b45309; }
.badge.stage-won { background: #dcfce7; color: #15803d; }
.badge.stage-lost { background: #f1f5f9; color: #64748b; }
.badge.source-bark { background: #ede9fe; color: var(--bark); border: 1px solid #c4b5fd; }
.badge.source-default { background: #eff6ff; color: var(--primary-dark); }
.badge.overdue { background: #fee2e2; color: #b91c1c; }

/* ---------- Lead rows ---------- */
.lead-row {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
  width: 100%; text-align: left;
}
.lead-row:active { background: #f8fafc; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.avatar.bark { background: linear-gradient(135deg, var(--bark), #a78bfa); }
.lead-row .info { flex: 1; min-width: 0; }
.lead-row .info .name { font-weight: 700; font-size: 15px; }
.lead-row .info .meta { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lead-row .right { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; gap: 5px; align-items: flex-end; }
.lead-row .date { font-size: 11px; color: var(--muted); }

/* ---------- Filter chips ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; -webkit-overflow-scrolling: touch; }
.chip {
  border: 1px solid var(--border); background: #fff; color: var(--muted);
  padding: 7px 14px; border-radius: 999px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.chip.bark-chip.on { background: var(--bark); border-color: var(--bark); }

/* ---------- Search ---------- */
.search-wrap { position: relative; margin-bottom: 10px; }
.search-wrap input {
  width: 100%; padding: 12px 14px 12px 40px; font-size: 15px;
  border: 1px solid var(--border); border-radius: var(--radius); background: #fff;
}
.search-wrap .sicon { position: absolute; left: 13px; top: 12px; color: var(--muted); font-size: 17px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text); }
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px; font-size: 15px;
  border: 1px solid var(--border); border-radius: 10px; background: #fff; font-family: inherit;
}
.field textarea { resize: vertical; min-height: 70px; }
.btn {
  display: inline-block; border: none; border-radius: 10px; font-weight: 700; font-size: 15px;
  padding: 12px 20px; text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; }
.btn-primary:active { background: var(--primary-dark); }
.btn-ghost { background: #eef2f7; color: var(--navy); }
.btn-sm { padding: 8px 14px; font-size: 13px; width: auto; }
.btn-bark { background: var(--bark); color: #fff; width: 100%; }

/* ---------- Login ---------- */
.login-wrap { max-width: 420px; margin: 8vh auto 0; padding: 0 18px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: var(--shadow); padding: 28px 24px; border: 1px solid var(--border); }
.login-card .brand { text-align: center; margin-bottom: 20px; }
.login-card .brand .logo-mark {
  width: 56px; height: 56px; border-radius: 15px; margin: 0 auto 10px;
  background: linear-gradient(135deg, var(--primary), #38bdf8);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 28px; color: #fff;
}
.login-card h1 { font-size: 22px; color: var(--navy); }
.login-card .tagline { color: var(--muted); font-size: 13px; margin-top: 4px; }
.demo-note { text-align: center; font-size: 12px; color: var(--muted); margin-top: 14px; }
.login-err { background: #fee2e2; color: #b91c1c; font-size: 13px; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; display: none; }

/* ---------- Tab bar ---------- */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  background: #fff; border-top: 1px solid var(--border);
  display: flex; padding: 6px 4px calc(8px + env(safe-area-inset-bottom));
}
.tabbar button {
  flex: 1; background: none; border: none; color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 6px 2px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.tabbar button .tico { font-size: 20px; line-height: 1; }
.tabbar button.on { color: var(--primary); }
.tabbar button .count {
  background: var(--red); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; padding: 1px 6px; margin-left: 4px;
}

/* ---------- Lead detail ---------- */
.back-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; margin-bottom: 12px; background: none; border: none; color: var(--primary); font-size: 14px; }
.detail-head { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.detail-head .avatar { width: 60px; height: 60px; font-size: 22px; }
.detail-head h2 { font-size: 20px; }
.detail-head .sub { font-size: 13px; color: var(--muted); }
.contact-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.contact-actions a {
  text-align: center; background: #eef4ff; color: var(--primary-dark); font-weight: 700; font-size: 13px;
  padding: 11px 4px; border-radius: 10px;
}
.stage-stepper { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.stage-step {
  border: 1px solid var(--border); background: #fff; border-radius: 999px;
  padding: 7px 13px; font-size: 12px; font-weight: 700; white-space: nowrap; color: var(--muted);
}
.stage-step.on { color: #fff; }
.stage-step.on.stage-new { background: #2563eb; border-color: #2563eb; }
.stage-step.on.stage-contacted { background: #7c3aed; border-color: #7c3aed; }
.stage-step.on.stage-qualified { background: #0d9488; border-color: #0d9488; }
.stage-step.on.stage-appointment { background: #d97706; border-color: #d97706; }
.stage-step.on.stage-won { background: #16a34a; border-color: #16a34a; }
.stage-step.on.stage-lost { background: #64748b; border-color: #64748b; }

.bark-panel {
  background: #faf5ff; border: 1px solid #ddd6fe; border-radius: var(--radius);
  padding: 14px; margin-bottom: 14px;
}
.bark-panel h3 { font-size: 14px; color: var(--bark); margin-bottom: 8px; }
.bark-panel dl { display: grid; grid-template-columns: 130px 1fr; gap: 6px 10px; font-size: 13px; }
.bark-panel dt { color: var(--muted); font-weight: 600; }
.bark-panel dd { font-weight: 600; color: var(--text); }

.kv { display: grid; grid-template-columns: 110px 1fr; gap: 7px 10px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { font-weight: 600; word-break: break-word; }

.note-item, .activity-item {
  border-left: 3px solid var(--border); padding: 8px 0 8px 12px; margin-bottom: 10px; font-size: 14px;
}
.note-item .who, .activity-item .when { font-size: 12px; color: var(--muted); }
.activity-item.type-call { border-color: var(--primary); }
.activity-item.type-sms { border-color: var(--teal); }
.activity-item.type-email { border-color: var(--purple); }
.activity-item.type-stage { border-color: var(--amber); }
.activity-item.type-note { border-color: var(--border); }
.activity-item.type-bark { border-color: var(--bark); }

/* ---------- Tasks ---------- */
.task-row {
  display: flex; gap: 12px; align-items: flex-start;
  background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.task-row.done { opacity: .55; }
.task-row.done .task-title { text-decoration: line-through; }
.task-check {
  width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--border);
  background: #fff; flex-shrink: 0; margin-top: 2px; font-size: 14px; color: #fff;
  display: flex; align-items: center; justify-content: center;
}
.task-row.done .task-check { background: var(--green); border-color: var(--green); }
.task-row .task-body { flex: 1; min-width: 0; }
.task-title { font-weight: 600; font-size: 14px; }
.task-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.task-due.overdue { color: var(--red); font-weight: 700; }
.task-group { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; margin: 16px 2px 8px; }

/* ---------- Empty / misc ---------- */
.empty { text-align: center; color: var(--muted); padding: 36px 16px; font-size: 14px; }
.empty .big { font-size: 38px; margin-bottom: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mt { margin-top: 14px; }
.hidden { display: none !important; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 18px 2px 10px; }
.section-head h3 { font-size: 15px; }
.section-head a { font-size: 13px; font-weight: 600; }

/* ================= Marketplace v2 additions ================= */

/* ---------- Role pill ---------- */
.role-pill {
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: .5px;
  padding: 5px 11px; border-radius: 999px; flex-shrink: 0;
}
.role-pill.pro { background: rgba(255,255,255,.18); color: #fff; }
.role-pill.cust { background: #38bdf8; color: #0b2a5b; }

/* ---------- Category grid ---------- */
.cat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 6px; }
@media (min-width: 700px) { .cat-grid { grid-template-columns: repeat(5, 1fr); } }
.cat-tile {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 8px; box-shadow: var(--shadow); display: flex; flex-direction: column;
  align-items: center; gap: 6px;
}
.cat-tile:active { background: #f8fafc; }
.cat-ico { font-size: 28px; }
.cat-lbl { font-size: 12px; font-weight: 700; color: var(--text); text-align: center; }

/* ---------- Request cards ---------- */
.req-card {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 13px 14px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.req-card:active { background: #f8fafc; }
.req-ico { font-size: 30px; flex-shrink: 0; }
.req-info { flex: 1; min-width: 0; }
.req-title { font-weight: 700; font-size: 15px; }
.req-meta { font-size: 12px; color: var(--muted); }
.req-right { display: flex; flex-direction: column; gap: 5px; align-items: flex-end; flex-shrink: 0; }

.badge.req-open { background: #dbeafe; color: #1d4ed8; }
.badge.req-in-progress { background: #fef3c7; color: #b45309; }
.badge.req-completed { background: #dcfce7; color: #15803d; }
.badge.req-cancelled { background: #f1f5f9; color: #64748b; }
.badge.pitch-n { background: #eff6ff; color: var(--primary-dark); border: 1px solid #bfdbfe; }
.badge.pitch-pending { background: #fef3c7; color: #b45309; }
.badge.pitch-accepted { background: #dcfce7; color: #15803d; }
.badge.pitch-declined { background: #f1f5f9; color: #64748b; }

/* ---------- Pitch cards ---------- */
.pitch-card { border-left: 4px solid var(--primary); }
.pro-head { display: flex; gap: 12px; align-items: center; }
.pro-name { font-weight: 800; font-size: 15px; }
.pro-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stars { color: #f59e0b; font-size: 13px; letter-spacing: 1px; }
.pitch-quote {
  display: inline-block; font-size: 22px; font-weight: 800; color: var(--navy);
  background: #eff6ff; border-radius: 10px; padding: 6px 14px; margin: 12px 0 8px;
}
.pitch-msg { font-size: 14px; color: var(--text); font-style: italic; }
.pitch-meta { font-size: 12px; color: var(--muted); margin-top: 8px; }
.pitch-actions { display: flex; gap: 8px; margin-top: 12px; }
.pitch-actions .btn { flex: 1; }

/* ---------- Tier badges ---------- */
.badge.tier-starter { background: #f1f5f9; color: #475569; border: 1px solid #cbd5e1; }
.badge.tier-pro { background: #dbeafe; color: #1d4ed8; border: 1px solid #93c5fd; }
.badge.tier-elite { background: #ede9fe; color: #6d28d9; border: 1px solid #c4b5fd; }
.badge.tier-savvy { background: linear-gradient(135deg, #b45309, #f59e0b); color: #fff; border: none; }
.badge.sm { font-size: 10px; padding: 2px 7px; }

/* ---------- Pricing ---------- */
.plan-card { position: relative; }
.plan-card.current { border: 2px solid var(--green); }
.plan-card.elite-card { border-color: #c4b5fd; }
.plan-card.savvy-card {
  border: 2px solid #f59e0b;
  background: linear-gradient(180deg, #fffbeb 0%, #ffffff 60%);
}
.plan-price { font-size: 34px; font-weight: 800; color: var(--navy); margin: 4px 0; }
.plan-price span { font-size: 15px; font-weight: 600; color: var(--muted); }
.plan-setup { font-size: 13px; color: var(--amber); font-weight: 700; margin-bottom: 6px; }
.plan-tag { font-size: 14px; color: var(--muted); margin-bottom: 10px; }
.plan-perks { list-style: none; font-size: 14px; }
.plan-perks li { padding: 5px 0; border-bottom: 1px dashed var(--border); }
.plan-perks li:last-child { border-bottom: none; }
.btn-savvy { background: linear-gradient(135deg, #b45309, #f59e0b); color: #fff; width: 100%; }

/* ---------- Savvy strip / explainer ---------- */
.savvy-strip { border: 1px solid #fcd34d; background: #fffbeb; }
.savvy-strip h3 { color: #92400e; }
.savvy-strip p { font-size: 13px; color: #57534e; }
.how-list { margin: 8px 0 12px 20px; font-size: 14px; }
.how-list li { margin-bottom: 8px; }

/* ---------- Forms ---------- */
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
