:root {
  --ink: #141B33;
  --ink-2: #1E2745;
  --coral: #FF5D5D;
  --coral-dark: #E23E3E;
  --stone: #F5F6F9;
  --slate: #8A94A6;
  --line: rgba(20, 27, 51, 0.10);
  --danger: var(--coral-dark);
  --bg: var(--stone);
  --text: var(--ink);
  --surface: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hide { display: none !important; }

/* --- Brandmark (inlined logo.svg — CSS vars let each usage recolor it independently) --- */
.brandmark {
  --logo-ink: var(--text);
  --logo-coral: var(--coral);
  --logo-coral-dark: var(--coral-dark);
  --logo-slate: var(--slate);
  height: 52px;
  width: auto;
  display: block;
}
.brandmark-lg { height: 80px; margin-bottom: 16px; }

/* --- Login screen --- */
#loginScreen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loginCard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 32px;
  width: 100%;
  max-width: 360px;
}
.loginCard p.sub {
  color: var(--slate);
  margin: 0 0 20px;
  font-size: 14px;
}
.loginCard label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin: 12px 0 4px;
}
.loginCard input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}
.loginCard button {
  width: 100%;
  margin-top: 20px;
  padding: 11px;
  border: none;
  border-radius: 8px;
  background: var(--coral);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.loginCard button:hover { background: var(--coral-dark); }
#loginMsg {
  margin-top: 12px;
  font-size: 13px;
  color: var(--slate);
}
#loginMsg.error { color: var(--danger); }

/* --- App shell --- */
#appShell header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.headerBrand { display: flex; align-items: center; gap: 12px; }
.headerTenant {
  /* The LeadBox SVG has a lot of built-in whitespace in its viewBox (its actual glyphs only fill
     ~37% of the 150-unit height), while this PNG's text fills almost the entire canvas — so equal
     CSS height renders very differently. Sized down to match visible ink height, not container height. */
  height: 24px;
  width: auto;
  display: block;
  padding-left: 14px;
  border-left: 1px solid var(--line);
}
#logoutBtn {
  border: 1px solid var(--line);
  background: none;
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  font-size: 13px;
}
main { padding: 20px; max-width: 1600px; margin: 0 auto; }

/* --- Lead Explorer --- */
.filterBar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.filterBar input, .filterBar select {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
}
.filterBar input[type="search"] { flex: 1 1 240px; }
.filterBar button {
  padding: 7px 12px;
  border: 1px solid var(--line);
  background: none;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}

.leadListMeta {
  font-size: 13px;
  color: var(--slate);
  margin-bottom: 10px;
}

.leadList { display: flex; flex-direction: column; gap: 10px; }
.leadEmpty { color: var(--slate); font-size: 14px; }
.leadError { color: var(--danger); }

.leadCard {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px 16px;
}
.leadCardTop {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.sourceBadge, .priorityBadge, .typeBadge {
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--stone);
  color: var(--ink-2);
}
.priorityBadge.priority-P1 { background: var(--danger); color: #fff; }
.priorityBadge.priority-P2 { background: rgba(255, 93, 93, 0.15); color: var(--coral-dark); }

.agePill {
  margin-left: auto;
  font-weight: 700;
  text-transform: none;
  padding: 2px 8px;
  border-radius: 100px;
  border: 1px solid var(--line);
  color: var(--slate);
}
.agePill.ageFresh { color: #1e8e5a; border-color: rgba(30, 142, 90, .35); background: rgba(30, 142, 90, .08); }
.agePill.ageWarm { color: #b8860b; border-color: rgba(184, 134, 11, .35); background: rgba(184, 134, 11, .08); }
.agePill.ageHot { color: var(--danger); border-color: rgba(192, 57, 43, .35); background: rgba(192, 57, 43, .08); }

.leadName { font-size: 16px; font-weight: 700; }
.leadAddress { font-size: 13px; color: var(--slate); margin-top: 2px; }
.leadPostcode { font-weight: 700; color: var(--text); }
.leadValuation { font-size: 13px; font-weight: 600; margin-top: 4px; }

.leadContact { display: flex; gap: 14px; margin-top: 8px; font-size: 13px; }
.leadContact a { color: var(--ink); }

.leadMessage {
  margin-top: 8px;
  font-size: 13px;
  color: var(--ink-2);
  background: var(--stone);
  border-radius: 8px;
  padding: 8px 10px;
}

.leadCardFooter {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}
.leadOwner { font-size: 12px; color: var(--slate); }
.leadOwnerUnclaimed { font-weight: 700; color: var(--ink); }
.leadStatusSelect { margin-left: auto; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--line); font-size: 12px; }
.btnClaim, .btnUnclaim {
  padding: 6px 12px;
  border-radius: 8px;
  border: none;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.btnClaim { background: var(--coral); color: #fff; }
.btnClaim:hover { background: var(--coral-dark); }
.btnUnclaim { background: var(--stone); color: var(--ink); }

/* --- Property tabs --- */
.leadTabs { display: flex; gap: 8px; margin-bottom: 14px; }
.leadTab {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 100px;
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}
.leadTab.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.leadTabBadge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 100px;
  background: rgba(0, 0, 0, .08);
  font-size: 11px;
}
.leadTab.active .leadTabBadge { background: rgba(255, 255, 255, .22); }

/* --- Property groups grid (4 per row at desktop widths, matching Opportunity Hub's own
   repeat(auto-fill, minmax(360px,1fr)) — align-items:start so an expanded card doesn't stretch
   its row-mates to match its height) --- */
.leadGroups {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
  align-items: start;
}
@media (max-width: 640px) {
  .leadGroups { grid-template-columns: 1fr; }
}

.leadPager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 12px;
  font-size: 12px;
  color: var(--slate);
}
.leadPagerBtns { display: flex; align-items: center; gap: 8px; }
.leadPagerBtns .btn { padding: 5px 10px; font-size: 12px; }
.leadPagerBtns .btn:disabled { opacity: .4; cursor: default; }
.leadPagerCount { font-weight: 700; }

/* --- Property group card --- */
.leadGroup {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  overflow: hidden;
  height: auto;
  align-self: start;
}
.leadGroupHero {
  display: grid;
  grid-template-columns: 120px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  cursor: pointer;
}
@media (max-width: 640px) {
  .leadGroupHero { grid-template-columns: 72px minmax(0, 1fr) auto; }
}
.leadGroupImage {
  width: 120px;
  min-height: 90px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(20, 27, 51, .08), rgba(255, 93, 93, .12));
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 640px) { .leadGroupImage { width: 72px; min-height: 64px; } }
.leadGroupImage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.leadGroupImage.noPhoto { background: linear-gradient(135deg, rgba(20, 27, 51, .08), rgba(255, 93, 93, .12)); }
.leadGroupGraphic {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  font-weight: 900;
  text-align: center;
}
.leadGroupGraphicIcon { width: 30px; height: 30px; color: var(--coral); }
.leadGroupGraphic .luLabel { font-size: 9px; font-weight: 700; letter-spacing: .03em; color: var(--slate); margin-top: 4px; text-transform: uppercase; }

.leadGroupTitle { font-weight: 700; font-size: 15px; line-height: 1.3; }
.leadGroupBranchPrice { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.branchPill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 100px;
  border: 1px solid var(--line);
  font-size: 11px;
  color: var(--slate);
  font-weight: 700;
}
.leadGroupPrice { font-size: 12px; font-weight: 800; color: var(--ink); }
.leadTypeBadge {
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 800;
  color: #fff;
}
.leadTypeBadge.sales { background: var(--ink); }
.leadTypeBadge.lettings { background: var(--coral); color: #fff; }
.leadTypeBadge.valuation { background: var(--danger); }

.leadGroupChevron { color: var(--slate); font-size: 12px; }

.leadGroupStats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0 12px 12px;
}
.leadGroupStat {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 6px;
  text-align: center;
  background: var(--stone);
}
.leadGroupStat b { display: block; font-size: 17px; line-height: 1; }
.leadGroupStat span { display: block; color: var(--slate); font-size: 10px; margin-top: 4px; }

.leadGroupBody {
  border-top: 1px solid var(--line);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--stone);
}

/* --- Claim-all / Assign-all bar --- */
.leadPropertyActionBar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding-top: 6px;
}
.btn {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.btn.btnPrimary { background: var(--coral); color: #fff; border-color: var(--coral); }
.btn.btnPrimary:hover { background: var(--coral-dark); border-color: var(--coral-dark); }
.leadAssignRow { display: flex; gap: 8px; align-items: center; }
.leadAssignSelect {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  background: var(--surface);
}
