/* Business Atlas — see DESIGN.md */
:root {
  --drape: #0E4A45; --drape-2: #1F6B63; --paper: #FFFFFF; --ground: #EEF3F2; --ink: #10201E;
  --muted: #5B6E6B; --line: #D3DEDC; --gum: #D2486A; --river: #7FB3C8;
  --shade-1: #F4F1E6; --shade-2: #EADFC4; --shade-3: #DCC79A; --shade-4: #C9A96E; --shade-5: #A88445;
  --on-drape: #FFFFFF;
  --r: 6px; --r-panel: 10px;
  --font: "Readex Pro", system-ui, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --drape: #0B3B37; --drape-2: #2B8A80; --paper: #10201E; --ground: #0A1615; --ink: #E7EFEE;
    --muted: #9DB2AE; --line: #23413D; --gum: #F06B8C; --river: #3E7186; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); background: var(--ground); color: var(--ink); line-height: 1.7;
  font-size: 15px; padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
@media (min-width: 820px) { body { padding-bottom: 0; } }
a { color: var(--drape-2); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 4px; line-height: 1.5; }
h2 { font-size: 16px; margin: 0 0 12px; line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 16px; }

/* top bar */
.top { background: var(--drape); color: var(--on-drape); display: flex; align-items: center; gap: 24px;
  padding: 10px 16px; position: sticky; top: 0; z-index: 10; }
.brand { color: var(--on-drape); font-weight: 700; font-size: 18px; white-space: nowrap; }
.brand span { font-weight: 400; opacity: .75; font-size: 14px; }
.topnav { display: none; gap: 4px; flex: 1; }
.topnav a { color: var(--on-drape); opacity: .8; padding: 6px 12px; border-radius: var(--r); }
.topnav a[aria-current] { opacity: 1; background: rgba(255,255,255,.14); }
.topnav a:hover { text-decoration: none; opacity: 1; }
.logout { margin-inline-start: auto; }
.logout button { background: transparent; color: var(--on-drape); border: 1px solid rgba(255,255,255,.35);
  border-radius: var(--r); padding: 4px 12px; font: inherit; font-size: 13px; cursor: pointer; }
@media (min-width: 820px) { .topnav { display: flex; } .logout { margin: 0; } }

/* phone bottom bar */
.bottombar { position: fixed; inset-inline: 0; bottom: 0; background: var(--paper); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(3, 1fr); padding-bottom: env(safe-area-inset-bottom); z-index: 10; }
.bottombar a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 4px 6px;
  color: var(--muted); font-size: 12px; line-height: 1.6; }
.bottombar a[aria-current] { color: var(--drape-2); font-weight: 500; }
.bottombar svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
@media (min-width: 820px) { .bottombar { display: none; } }

/* panels & tables */
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); padding: 16px; min-width: 0; }
table.tight { width: 100%; border-collapse: collapse; font-size: 14px; }
table.tight th { text-align: start; font-weight: 500; color: var(--muted); border-bottom: 1px solid var(--line); padding: 6px 4px; }
table.tight td { border-bottom: 1px solid var(--line); padding: 7px 4px; line-height: 1.5; }
table.tight td.num, table.tight th:not(:first-child) { text-align: end; }
.lead-text { margin: 0 0 6px; }

/* buttons & inputs */
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea { background: var(--paper); border: 1px solid var(--line); border-radius: var(--r);
  padding: 8px 10px; min-height: 40px; font-size: 16px; max-width: 100%; }
.primary { background: var(--drape); color: var(--on-drape); border: 0; border-radius: var(--r); padding: 8px 18px;
  min-height: 40px; cursor: pointer; font-weight: 500; }
.primary:hover { background: var(--drape-2); }
.ghost { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r);
  padding: 4px 12px; font-size: 14px; background: var(--paper); color: var(--drape-2); min-height: 34px; }
.ghost:hover { border-color: var(--drape-2); text-decoration: none; }
.badge { display: inline-block; font-size: 11px; line-height: 1.6; padding: 0 6px; border: 1px solid var(--line);
  border-radius: 4px; color: var(--muted); margin-inline-start: 4px; }
.badge.site { color: var(--drape-2); border-color: var(--drape-2); }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; background: var(--drape); }
.login-card { background: var(--paper); border-radius: var(--r-panel); padding: 28px 24px; width: min(380px, 100%);
  display: grid; gap: 14px; }
.login-card label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
.error { color: var(--gum); margin: 0; }

/* overview */
.overview { display: grid; gap: 16px; grid-template-columns: 1fr; }
.map-panel { position: relative; border-radius: var(--r-panel); overflow: hidden; border: 1px solid var(--line); }
.map { width: 100%; height: 56vh; min-height: 320px; background: var(--ground); }
.map.small { height: 220px; min-height: 0; border-radius: var(--r); margin: 12px 0 8px; }
.legend { position: absolute; inset-inline-start: 10px; bottom: 10px; background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r); padding: 4px 10px; display: flex; gap: 12px; font-size: 12px; flex-wrap: wrap; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-inline-end: 4px; vertical-align: -1px; }
.dot.hot { background: var(--gum); } .dot.mid { background: var(--drape-2); } .dot.low { background: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-panel); overflow: hidden; }
.fact { background: var(--paper); padding: 12px 14px; display: grid; color: var(--ink); }
.fact b { font-size: 22px; font-variant-numeric: tabular-nums; line-height: 1.3; }
.fact span { color: var(--muted); font-size: 13px; }
.fact.hot b { color: var(--gum); }
.fact.hot:hover { text-decoration: none; background: var(--ground); }
.runs { list-style: none; margin: 0 0 10px; padding: 0; font-size: 14px; }
.runs li { display: grid; grid-template-columns: 1fr auto auto auto; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.state.done { color: var(--drape-2); } .state.failed { color: var(--gum); } .state.running { color: var(--shade-5); }
@media (min-width: 820px) {
  .overview { grid-template-columns: 1fr 1fr; }
  .map-panel { grid-column: 1 / -1; }
  .facts { grid-column: 1 / -1; grid-template-columns: repeat(4, 1fr); }
  .map { height: 52vh; }
}

/* leads */
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--paper);
  border: 1px solid var(--line); border-radius: var(--r-panel); padding: 12px; }
.filters { display: grid; gap: 8px; }
.searchrow { display: flex; gap: 8px; }
.searchrow input { flex: 1; min-width: 0; }
.morefilters summary { cursor: pointer; color: var(--drape-2); font-size: 14px; padding: 2px 0; }
.morebody { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 8px; }
.morebody select { flex: 1 1 140px; }
@media (min-width: 820px) {
  .morefilters summary { display: none; }
  .morebody { padding-top: 0; }
  .morebody select { flex: 0 1 auto; }
}
@media (max-width: 819px) { .clinic-head h1 { font-size: 19px; } }
.check { display: inline-flex; gap: 6px; align-items: center; font-size: 14px; }
.check input { min-height: 0; width: 18px; height: 18px; }
.listhead { display: flex; justify-content: space-between; align-items: center; margin: 12px 0 8px; }
.listhead p { margin: 0; }
.leadlist { list-style: none; margin: 0; padding: 0; background: var(--paper); border: 1px solid var(--line); border-radius: var(--r-panel); }
.leadlist li + li { border-top: 1px solid var(--line); }
.lead { display: grid; grid-template-columns: 44px 1fr; gap: 4px 12px; padding: 12px; color: var(--ink); align-items: center; }
.lead:hover { background: var(--ground); text-decoration: none; }
.lead .who { display: grid; min-width: 0; }
.lead .who b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lead .who .muted { font-size: 13px; }
.lead .contact { grid-column: 2; display: flex; gap: 8px; align-items: center; font-size: 14px; flex-wrap: wrap; }
.lead .shade { grid-column: 2; justify-self: start; }
@media (min-width: 820px) {
  .lead { grid-template-columns: 44px minmax(0, 1.6fr) minmax(0, 1fr) 110px; }
  .lead .contact, .lead .shade { grid-column: auto; }
  .lead .shade { justify-self: end; }
}
.score { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-weight: 700;
  border: 2px solid var(--line); color: var(--muted); grid-row: span 3; font-size: 14px; }
.score.mid { border-color: var(--drape-2); color: var(--drape-2); }
.score.hot { border-color: var(--gum); color: var(--gum); }
.score.inline { display: inline-grid; width: 34px; height: 34px; vertical-align: middle; margin-inline-start: 6px; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px; }
.empty { background: var(--paper); border: 1px dashed var(--line); border-radius: var(--r-panel); padding: 32px 16px; text-align: center; }

/* shade-guide tabs for pipeline stages */
.shade { display: inline-block; font-size: 12px; line-height: 1.7; padding: 1px 10px; border-radius: 999px;
  color: #3A2E14; white-space: nowrap; }
.s-new { background: var(--shade-1); } .s-contacted { background: var(--shade-2); } .s-replied { background: var(--shade-3); }
.s-demo_sent { background: var(--shade-4); } .s-won { background: var(--shade-5); color: #fff; }
.s-lost { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.shades { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.shades .shade { opacity: .45; }
.shades .shade.on { opacity: 1; outline: 2px solid var(--drape); outline-offset: 1px; }

/* clinic page */
.clinic-head { margin-bottom: 14px; }
.back::before { content: "‹ "; }
.dnc { background: var(--gum); color: #fff; padding: 8px 12px; border-radius: var(--r); margin: 8px 0 0; }
.clinic-grid { display: grid; gap: 16px; }
@media (min-width: 820px) { .clinic-grid { grid-template-columns: 1.1fr 1fr; } .clinic-grid .wide { grid-column: 1 / -1; } }
.phones { list-style: none; margin: 0 0 10px; padding: 0; }
.phones li { display: flex; gap: 8px; align-items: center; padding: 6px 0; flex-wrap: wrap; }
.phones li span { min-width: 130px; font-size: 16px; }
.links { display: flex; flex-wrap: wrap; gap: 6px 16px; margin: 0 0 16px; }
.event-form { display: grid; gap: 8px; grid-template-columns: 1fr 1fr; }
.event-form textarea, .event-form button { grid-column: 1 / -1; }
.events { list-style: none; padding: 0; margin: 14px 0 0; font-size: 14px; }
.events li { border-top: 1px solid var(--line); padding: 8px 0; }
.events p { margin: 2px 0 0; }
.why { list-style: none; margin: 0 0 12px; padding: 0; }
.why li { padding: 3px 0; }
.why .num { display: inline-block; min-width: 34px; color: var(--drape-2); font-weight: 500; }
.sources td { vertical-align: top; }
.changes { font-size: 13px; }

/* review */
.review-list { list-style: none; margin: 0; padding: 0; }
.review-list li { border-top: 1px solid var(--line); padding: 12px 0; display: grid; gap: 8px; }
.review-list p { margin: 0; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { border: 1px solid var(--line); background: var(--paper); border-radius: 999px; padding: 4px 12px; font-size: 13px;
  cursor: pointer; min-height: 34px; }
.chip:hover { border-color: var(--drape-2); }
.chip.suggested { border-color: var(--drape-2); color: var(--drape-2); }
.review .panel + .panel { margin-top: 16px; }

/* MapLibre popup in RTL */
.maplibregl-popup-content { font-family: var(--font); direction: rtl; padding: 8px 12px; }
.maplibregl-popup-content a { font-weight: 500; }
