/* ============================================================
   app.css — PVS Prospect Hub SPA. Themed with CSS variables;
   dark mode via html[data-theme="dark"]. Field-friendly, no framework.
   ============================================================ */
:root {
  --bg: #f4f6f9; --panel: #ffffff; --panel-2: #f8fafc;
  --ink: #1c2733; --muted: #6b7886; --line: #e2e8f0; --row-hover: #f3f8ff;
  --brand: #0b5cab; --brand-dk: #07457f;
  --hot: #d92d20; --warm: #dd6b20; --purple: #6d28d9; --slate: #475569; --ok: #15803d;
  --shadow: 0 1px 3px rgba(16,32,48,.08), 0 1px 2px rgba(16,32,48,.06);
  color-scheme: light;
}
html[data-theme="dark"] {
  --bg: #0e1622; --panel: #18222f; --panel-2: #1f2a38;
  --ink: #e6edf3; --muted: #95a4b3; --line: #2a3744; --row-hover: #202d3c;
  --brand: #2b7fd6; --brand-dk: #1c6cc0;
  --hot: #ff6f63; --warm: #f59e4b; --purple: #a78bfa; --slate: #94a3b8; --ok: #4caf6e;
  --shadow: 0 1px 3px rgba(0,0,0,.4), 0 1px 2px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body {
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink);
}
button { font: inherit; cursor: pointer; }
input, select, textarea { background: var(--panel); color: var(--ink); }

/* ── Top bar ───────────────────────────────────────────── */
.topbar { display: flex; align-items: center; gap: 16px; background: var(--brand); color: #fff;
  padding: 0 14px; height: 54px; position: sticky; top: 0; z-index: 50; box-shadow: var(--shadow); }
.brand { font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand span { font-weight: 400; opacity: .85; }
.tabs { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.tab { background: transparent; color: #dbe9f7; border: 0; padding: 8px 13px; border-radius: 7px;
  white-space: nowrap; font-weight: 600; }
.tab:hover { background: rgba(255,255,255,.14); color: #fff; }
.tab.active { background: #fff; color: var(--brand-dk); }
html[data-theme="dark"] .tab.active { background: #0e1622; color: #fff; }
.badge { background: var(--hot); color: #fff; border-radius: 10px; padding: 1px 7px; font-size: 12px; margin-left: 4px; }
.theme-toggle { background: rgba(255,255,255,.16); border: 0; color: #fff; width: 34px; height: 34px;
  border-radius: 8px; font-size: 16px; line-height: 1; }
.theme-toggle:hover { background: rgba(255,255,255,.3); }
.navsearch { position: relative; flex: 0 1 230px; min-width: 120px; }
.navsearch input { width: 100%; padding: 6px 10px; border: 0; border-radius: 7px; font: inherit; font-size: 13px;
  background: rgba(255,255,255,.16); color: #fff; }
.navsearch input::placeholder { color: rgba(255,255,255,.7); }
.navsearch input:focus { outline: 2px solid rgba(255,255,255,.55); background: rgba(255,255,255,.24); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: var(--panel); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 14px 34px rgba(0,0,0,.28); z-index: 60; max-height: 60vh; overflow-y: auto; }
.search-results .sr { padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 14px; }
.search-results .sr:last-child { border-bottom: 0; }
.search-results .sr:hover { background: var(--row-hover); }
.search-results .sr small { color: var(--muted); }
.search-results .sr-empty { padding: 12px; color: var(--muted); font-size: 13px; }
.who { font-size: 13px; opacity: .9; white-space: nowrap; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }

/* ── Layout ────────────────────────────────────────────── */
main { max-width: 1180px; margin: 0 auto; padding: 20px 16px 70px; }
.view-head { margin-bottom: 14px; }
.view-head h1 { font-size: 22px; margin: 0 0 2px; }
.sub { color: var(--muted); margin: 0; font-size: 14px; }
.empty { color: var(--muted); background: var(--panel); border: 1px dashed var(--line);
  border-radius: 10px; padding: 26px; text-align: center; }

/* ── Row list ──────────────────────────────────────────── */
.rowlist { display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-bottom: 1px solid var(--line);
  cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row:hover { background: var(--row-hover); }
.row .co { flex: 1 1 200px; min-width: 140px; font-weight: 600; }
.row .co small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.row .cell { flex: 0 0 auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.row .cell.loc { flex: 0 1 150px; min-width: 90px; overflow: hidden; text-overflow: ellipsis; }
.row .cell.fit { font-weight: 700; color: var(--ink); width: 34px; text-align: right; }
.row .duecell { font-size: 12px; }
.row .duecell.over { color: var(--hot); font-weight: 700; }

/* ── Pills / tags ──────────────────────────────────────── */
.pill { border-radius: 999px; padding: 2px 9px; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; white-space: nowrap; }
.pill.on  { color: var(--ok, #15803d); background: color-mix(in srgb, var(--ok, #15803d) 16%, transparent); }
.pill.off { color: var(--muted); background: color-mix(in srgb, var(--muted) 16%, transparent); }
.tier-hot       { color: var(--hot);    background: color-mix(in srgb, var(--hot) 16%, transparent); }
.tier-keepwarm  { color: var(--warm);   background: color-mix(in srgb, var(--warm) 16%, transparent); }
.tier-cantcrack { color: var(--purple); background: color-mix(in srgb, var(--purple) 16%, transparent); }
.tier-toofar    { color: var(--slate);  background: color-mix(in srgb, var(--slate) 18%, transparent); }
.tier-dropped   { color: var(--muted);  background: color-mix(in srgb, var(--muted) 16%, transparent); }
.due-yes { background: var(--hot); color: #fff; }
.stage-tag { font-size: 12px; color: var(--muted); white-space: nowrap; }
.threat-HIGH { color: var(--hot); font-weight: 700; }
.threat-MED  { color: var(--warm); font-weight: 700; }
.threat-LOW  { color: var(--ok); font-weight: 700; }

/* ── Buttons / chips ───────────────────────────────────── */
.btn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 6px 11px;
  border-radius: 7px; font-weight: 600; font-size: 13px; }
.btn:hover { background: var(--panel-2); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dk); }
.btn.warn { background: var(--hot); border-color: var(--hot); color: #fff; }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.star { background: none; border: 0; font-size: 18px; line-height: 1; padding: 0 2px; filter: grayscale(1); opacity: .5; }
.star.on { filter: none; opacity: 1; }
.tabchips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip { border: 1px solid var(--line); background: var(--panel); padding: 5px 13px; border-radius: 999px;
  font-weight: 600; font-size: 13px; color: var(--muted); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ── Upcoming controls ─────────────────────────────────── */
.controls { display: flex; gap: 14px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow); }
.controls > label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.controls select, .controls input { padding: 6px 9px; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.tierfilter { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.tierfilter label { display: inline-flex; align-items: center; gap: 5px; color: var(--ink); font-size: 13px; }

/* ── Radar ─────────────────────────────────────────────── */
.radar-wrap { display: flex; gap: 14px; align-items: stretch; }
.radar-panel { flex: 0 0 235px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; box-shadow: var(--shadow); overflow-y: auto; max-height: 74vh; }
.radar-panel h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 16px 0 8px; }
.radar-panel h3:first-child { margin-top: 0; }
.lyr { display: flex; align-items: center; gap: 7px; margin-bottom: 7px; font-size: 13px; }
.comp-list { max-height: 168px; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; padding: 6px 9px; }
.comp-list .lyr { margin-bottom: 4px; }
.lnk { background: none; border: 0; color: var(--brand); font: inherit; font-size: 11px; font-weight: 700;
  text-transform: none; letter-spacing: 0; cursor: pointer; padding: 0 2px; }
.lnk:hover { text-decoration: underline; }
.fld { display: flex; flex-direction: column; gap: 4px; margin-bottom: 9px; font-size: 12px; color: var(--muted); }
.fld input, .fld select { padding: 6px 8px; border: 1px solid var(--line); border-radius: 7px; font: inherit; color: var(--ink); }
.radar-note { font-size: 12px; color: var(--muted); margin: 8px 0 0; }
/* position+z-index:0 traps Leaflet's pane/control z-indexes (~400–1000) inside
   the map's own stacking context, so overlays (panel/scrim/modal) sit above it. */
#map { flex: 1; height: 74vh; min-height: 360px; border-radius: 12px; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; z-index: 0; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0,0,0,.15); flex: none; }
.dot.plant { background: #0b5cab; } .dot.tp { background: #0891b2; }
.dot.comp { background: #d92d20; } .dot.target { background: #15803d; }

/* ── Tables (reports) ──────────────────────────────────── */
.tablewrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { background: var(--panel-2); color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
tbody tr:last-child td { border-bottom: 0; }
.report-filters { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 14px; }
.report-filters label { display: flex; flex-direction: column; font-size: 12px; color: var(--muted); gap: 4px; }
.report-filters input { padding: 7px 9px; border: 1px solid var(--line); border-radius: 7px; font: inherit; }
.report-filters button { padding: 8px 16px; }
.chem { background: var(--panel-2); border: 1px solid var(--line); border-radius: 5px; padding: 1px 7px; font-size: 12px; }
.chems { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Slide-in detail panel ─────────────────────────────── */
/* Overlays sit ABOVE Leaflet (panes ~400–700, controls ~1000). */
.panel-scrim { position: fixed; inset: 0; background: rgba(8,16,26,.45); opacity: 0; pointer-events: none;
  transition: opacity .2s; z-index: 1100; }
.panel-scrim.open { opacity: 1; pointer-events: auto; }
.panel { position: fixed; top: 0; right: 0; height: 100vh; width: min(470px, 94vw); background: var(--panel);
  box-shadow: -10px 0 34px rgba(0,0,0,.22); transform: translateX(100%); transition: transform .22s ease;
  z-index: 1200; display: flex; flex-direction: column; }
.panel.open { transform: translateX(0); }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px;
  padding: 16px 18px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 19px; }
.panel-head .loc { color: var(--muted); font-size: 13px; }
.panel-close { background: none; border: 0; font-size: 26px; color: var(--muted); line-height: 1; }
.panel-body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.psec { margin-bottom: 20px; }
.psec h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.kv { display: grid; grid-template-columns: 116px 1fr; gap: 5px 10px; font-size: 14px; align-items: center; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; }
.inline-edit { padding: 4px 7px; border: 1px solid var(--line); border-radius: 6px; font: inherit; font-size: 13px;
  color: var(--ink); background: var(--panel); max-width: 100%; }
.inline-edit:focus { outline: 2px solid color-mix(in srgb, var(--brand) 45%, transparent); border-color: var(--brand); }
input.inline-edit { margin-top: 5px; width: 100%; }
.hintnote { font-size: 11px; color: var(--muted); }
.coach { background: color-mix(in srgb, var(--brand) 12%, transparent); border-left: 3px solid var(--brand);
  padding: 9px 11px; border-radius: 6px; font-size: 14px; margin-bottom: 10px; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.act-list { list-style: none; padding: 0; margin: 0; }
.act-list li { padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.act-list li:last-child { border-bottom: 0; }
.act-list .when { color: var(--muted); font-size: 12px; }
.contact-list { list-style: none; padding: 0; margin: 0; }
.contact-list li { padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.contact-list .role { color: var(--muted); font-size: 12px; }

/* ── Admin editor ──────────────────────────────────────── */
.branch-row { display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.branch-row:last-child { border-bottom: 0; }
.branch-row small { display: block; }
.prod-checks { display: flex; gap: 14px; flex-wrap: wrap; }
.prod-checks label { display: inline-flex; align-items: center; gap: 5px; }
.geo-result { margin-top: 8px; font-size: 13px; }
.geo-result .geo-ok { color: var(--ok); font-weight: 600; }
.geo-result .geo-cand { display: block; width: 100%; text-align: left; margin-bottom: 4px; white-space: normal; }
.modal h4 { margin: 18px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* ── Modal (forms) ─────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,30,45,.5); display: flex; align-items: center;
  justify-content: center; z-index: 1300; padding: 16px; }
.modal { background: var(--panel); color: var(--ink); border-radius: 14px; width: 100%; max-width: 440px;
  padding: 22px; position: relative; box-shadow: 0 12px 40px rgba(0,0,0,.35); max-height: 90vh; overflow-y: auto; }
.modal-close { position: absolute; top: 10px; right: 12px; border: 0; background: none; font-size: 24px; color: var(--muted); }
.modal h2 { margin: 0 0 14px; font-size: 18px; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; }
.field label { font-size: 13px; font-weight: 600; }
.field input, .field select, .field textarea { padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; font: inherit; width: 100%; color: var(--ink); }
.field.row { flex-direction: row; align-items: center; gap: 8px; }
.field.row input { width: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }

/* ── Toast ─────────────────────────────────────────────── */
.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #0b1622; color: #fff;
  padding: 10px 18px; border-radius: 8px; box-shadow: var(--shadow); z-index: 1400; font-size: 14px;
  display: flex; align-items: center; gap: 12px; }
.toast-act { background: rgba(255,255,255,.18); border: 0; color: #fff; border-radius: 6px; padding: 3px 10px; font-weight: 700; font-size: 13px; }
.toast-act:hover { background: rgba(255,255,255,.32); }

/* ── Rich rows (My Work) ───────────────────────────────── */
.row { flex-wrap: wrap; }
.rowmain { display: flex; align-items: center; gap: 10px; width: 100%; }
.rowsub { display: flex; align-items: center; gap: 10px; width: 100%; flex-wrap: wrap; font-size: 12.5px; color: var(--muted); }
.rowact { display: flex; gap: 5px; flex-wrap: wrap; width: 100%; margin-top: 2px; }
.qbtn { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 6px;
  padding: 3px 8px; font-size: 12px; font-weight: 600; }
.qbtn:hover { background: var(--panel-2); border-color: var(--brand); }
.qbtn.warn { color: var(--hot); }
.addr { color: var(--muted); }
.dir-link { color: var(--brand); text-decoration: none; font-weight: 600; white-space: nowrap; }
.dir-link:hover { text-decoration: underline; }
.lasttouch { color: var(--muted); }
.tag { font-size: 11px; font-weight: 700; border-radius: 5px; padding: 1px 6px; white-space: nowrap; }
.tag.nocontact { color: var(--warm); background: color-mix(in srgb, var(--warm) 16%, transparent); }
.tag.incumbent { color: var(--slate); background: color-mix(in srgb, var(--slate) 16%, transparent); }
.new-badge { font-size: 10px; font-weight: 800; letter-spacing: .04em; color: #fff; background: var(--ok);
  border-radius: 5px; padding: 1px 6px; }
.suggestion { width: 100%; font-size: 12.5px; color: var(--purple);
  background: color-mix(in srgb, var(--purple) 10%, transparent); border-radius: 6px; padding: 5px 9px; }
.suggestion::before { content: "💡 suggestion: "; font-weight: 700; }

/* ── Dense, scannable cards (separated surfaces) ───────────── */
/* Shared by My Work, Prospects, and Upcoming so all three match. */
/* container is just a spaced stack — each card is its own surface */
#workList, #prospectsList, #upcomingList { background: transparent; border: 0; border-radius: 0; box-shadow: none; overflow: visible; gap: 10px; }
#workList .row, #prospectsList .row, #upcomingList .row {
  display: flex; align-items: stretch; gap: 13px;
  padding: 10px 14px 10px 16px;            /* 16px left gutter between accent bar and content */
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid transparent;       /* tier accent (color set below) */
  border-radius: 10px;
  box-shadow: var(--shadow);
}
.row[data-tier="hot"]       { border-left-color: var(--hot); }
.row[data-tier="keepwarm"]  { border-left-color: var(--warm); }
.row[data-tier="cantcrack"] { border-left-color: var(--cool); }
.row[data-tier="toofar"]    { border-left-color: var(--slate); }
.row[data-tier="dropped"]   { border-left-color: var(--muted); }

/* fixed-width fit rail, chip vertically centered */
.wk-rail { flex: none; display: flex; align-items: center; justify-content: center; }
.wk-body { flex: 1 1 auto; min-width: 0; }
.fitchip { min-width: 30px; height: 28px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px; color: var(--ink); background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px; }

.wk-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.wk-co { flex: 1 1 auto; min-width: 0; font-weight: 700; font-size: 15.5px; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wk-co .new-badge { vertical-align: middle; }
.wk-status { margin-left: auto; display: inline-flex; align-items: center; gap: 7px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.wk-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 4px; font-size: 12px;
  color: var(--muted); line-height: 1.25; }
.wk-meta .sep { color: var(--line); }
.wk-meta .addr, .wk-meta .lasttouch { color: var(--muted); }
.wk-hint { margin-top: 4px; font-size: 12.5px; color: var(--ink); line-height: 1.3; }
.sugg-pill { display: inline-block; font-size: 11px; font-weight: 700; color: var(--purple);
  background: color-mix(in srgb, var(--purple) 14%, transparent); border-radius: 999px; padding: 1px 8px; margin-left: 4px; }
#workList .rowact, #prospectsList .rowact, #upcomingList .rowact { margin-top: 8px; gap: 5px; }

/* ── Upcoming summary + grouped sections ───────────────── */
.up-summary { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--ink); }
.radius-note { margin: 0 0 12px; font-size: 13px; font-weight: 600; color: var(--brand); }
.rowlist.grouped .group-head { display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  background: var(--panel-2); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.group-head .cnt { background: var(--line); color: var(--ink); border-radius: 999px; padding: 0 8px; font-size: 11px; }
.group-head.overdue { color: var(--hot); }
.group-head.overdue .cnt { background: color-mix(in srgb, var(--hot) 20%, transparent); color: var(--hot); }

/* ── Reallocation nudge banner ─────────────────────────── */
.nudge-banner { background: color-mix(in srgb, var(--warm) 16%, transparent); border: 1px solid color-mix(in srgb, var(--warm) 40%, transparent);
  color: var(--ink); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; font-size: 14px; }
.nudge-banner .x { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: 18px; line-height: 1; }

/* ============================================================
   Responsive / mobile. Desktop layout above is untouched; these
   only apply at narrow widths. Breakpoints: ≤768 (tablet/phone)
   and ≤480 (small phone). Adapts via the existing flex structure;
   no fixed pixel widths, so it survives further desktop changes.
   PWA/installable is intentionally NOT added (needs HTTPS + the
   real domain — deferred to the deploy phase).
   ============================================================ */
.nav-toggle, .radar-drawer-btn { display: none; } /* desktop: hidden, shown in media queries */

@media (max-width: 768px) {
  /* ---- Top nav: hamburger + collapsible stacked menu ---- */
  .topbar { gap: 10px; }
  .nav-toggle { display: inline-flex; align-items: center; justify-content: center; position: relative;
    width: 42px; height: 42px; min-width: 42px; border: 0; border-radius: 9px; font-size: 20px;
    background: rgba(255,255,255,.16); color: #fff; }
  .nav-toggle .badge { position: absolute; top: -4px; right: -4px; margin: 0; }
  .tabs { position: absolute; top: 54px; left: 0; right: 0; flex-direction: column; gap: 2px; overflow: visible;
    background: var(--brand); padding: 8px; box-shadow: var(--shadow); display: none; z-index: 49; }
  .tabs.open { display: flex; }
  .tab { width: 100%; text-align: left; padding: 12px 14px; min-height: 44px; }
  .navsearch { flex: 1 1 auto; min-width: 0; }
  .who { display: none; }

  main { padding: 14px 12px 84px; }
  .view-head h1 { font-size: 20px; }

  /* ---- Filter bars: wrap, full-width controls, tappable ---- */
  .controls { gap: 10px; padding: 12px; }
  .controls > label { flex: 1 1 140px; }
  .controls select, .controls input { width: 100%; min-height: 42px; }
  .tierfilter { width: 100%; gap: 8px 16px; }
  .tierfilter label, .lyr { min-height: 34px; }

  /* ---- Rows → stacked cards, thumb-friendly quick-log ---- */
  .row { padding: 12px; gap: 8px; }
  .rowmain { flex-wrap: wrap; gap: 6px 10px; }
  .row .co { flex: 1 1 100%; min-width: 0; }
  .rowact { gap: 6px; }
  .qbtn { min-height: 42px; padding: 8px 12px; font-size: 13px; flex: 1 1 auto; min-width: 90px; text-align: center; }
  .star { min-width: 42px; min-height: 42px; font-size: 22px; }
  .row .btn.sm { min-height: 40px; padding: 8px 12px; }

  /* ---- Detail panel → full-screen bottom sheet ---- */
  .panel { width: 100%; max-width: none; left: 0; right: 0; height: 100dvh;
    transform: translateY(100%); border-radius: 0; }
  .panel.open { transform: translateY(0); }
  .panel-head { padding: 14px 16px; position: sticky; top: 0; background: var(--panel); z-index: 1; }
  .panel-head h2 { font-size: 20px; }
  .panel-close { font-size: 30px; min-width: 44px; min-height: 44px; }
  .panel-body { padding: 16px; }
  .inline-edit, input.inline-edit { min-height: 44px; font-size: 16px; } /* 16px avoids iOS zoom */
  .panel-actions { gap: 8px; }
  .panel-actions .btn { min-height: 42px; flex: 1 1 auto; }

  /* ---- Radar: map fills, filters in a bottom drawer ---- */
  .radar-wrap { display: block; position: relative; }
  #map { width: 100%; height: calc(100dvh - 160px); min-height: 320px; }
  .radar-drawer-btn { display: inline-flex; align-items: center; gap: 6px; position: fixed; left: 50%; bottom: 18px;
    transform: translateX(-50%); z-index: 1000; min-height: 46px; padding: 11px 20px; border: 0; border-radius: 999px;
    background: var(--brand); color: #fff; font-weight: 700; box-shadow: 0 6px 20px rgba(0,0,0,.3); }
  .radar-panel { position: fixed; left: 0; right: 0; bottom: 0; max-height: 78vh; flex: none; max-width: none;
    border-radius: 16px 16px 0 0; transform: translateY(100%); transition: transform .22s ease; z-index: 1050; }
  .radar-panel.open { transform: translateY(0); }
  .radar-panel .fld input, .radar-panel .fld select { min-height: 42px; font-size: 16px; }
  #radMiles { width: 100%; height: 32px; }
  .radar-panel .btn { min-height: 42px; }

  .report-filters > label { flex: 1 1 140px; }
  .report-filters input { width: 100%; min-height: 42px; }
}

@media (max-width: 480px) {
  .brand span { display: none; }
  .brand { font-size: 16px; }
  .topbar { padding: 0 10px; gap: 8px; }
  .navsearch input { font-size: 16px; } /* avoid iOS zoom on focus */
  .qbtn { min-width: 0; flex: 1 1 30%; } /* ~3-up quick-log grid */
  /* Forms become bottom sheets too */
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92dvh; }
  .field input, .field select, .field textarea { min-height: 44px; font-size: 16px; }
}

/* ── Account packages (detail panel) ─────────────────────── */
.pkg-group { margin-bottom: 10px; }
.pkg-chem { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); margin: 6px 0 4px; }
.pkg-row { display: flex; align-items: flex-start; gap: 8px; padding: 7px 9px; border: 1px solid var(--line);
  border-radius: 8px; background: var(--panel-2); margin-bottom: 6px; }
.pkg-row .pkg-main { flex: 1 1 auto; font-size: 13.5px; }
.pkg-row .pkg-fmt { color: var(--muted); font-size: 12px; }
.pkg-row .pkg-meta { flex-basis: 100%; order: 3; color: var(--muted); font-size: 12px; margin-top: 2px; }
.pkg-row .pkg-act { flex: 0 0 auto; display: flex; gap: 4px; }
.pkg-row .pkg-meta .tag { background: color-mix(in srgb, var(--muted) 16%, transparent); color: var(--ink); margin-left: 2px; }

/* ── Multi-select (chips + dropdown) ─────────────────────── */
.ms { position: relative; }
.ms-control { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; min-height: 40px;
  padding: 6px 30px 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); cursor: pointer; }
.ms-control:focus { outline: 2px solid color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: 1px; }
.ms-ph { color: var(--muted); font-size: 13.5px; }
.ms-caret { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.ms-chip { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600;
  padding: 2px 4px 2px 9px; border-radius: 999px; background: color-mix(in srgb, var(--brand) 14%, transparent); color: var(--ink); }
.ms-x { border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 15px; line-height: 1; padding: 0 2px; }
.ms-x:hover { color: var(--ink); }
.ms-menu { position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 30; max-height: 220px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 10px 26px rgba(0,0,0,.24); }
.ms-opt { padding: 8px 10px; font-size: 13.5px; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.ms-opt::before { content: ""; width: 12px; display: inline-block; color: var(--brand); }
.ms-opt.sel::before { content: "✓"; }
.ms-opt.sel { font-weight: 600; }
.ms-opt:hover { background: var(--row-hover); }
.ms-empty { padding: 10px; color: var(--muted); font-size: 13px; }

/* ── Panel toolbar (Copy history etc.) ───────────────────── */
.panel-toolbar { display: flex; gap: 8px; justify-content: flex-end; margin-bottom: 10px; }

/* ── Discovery checklist (Stage 0 trust layer) ───────────── */
.discovery { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.discovery li { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.discovery li .dchk { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px;
  border-radius: 50%; font-size: 11px; font-weight: 700; flex: 0 0 auto; }
.discovery li.known { color: var(--ink); }
.discovery li.known .dchk { background: color-mix(in srgb, var(--ok, #16a34a) 18%, transparent); color: var(--ok, #16a34a); }
.discovery li.missing { color: var(--muted); }
.discovery li.missing .dchk { border: 1px solid var(--line); color: var(--muted); }
.disc-count { margin-top: 8px; font-weight: 600; }

/* ── Readiness line (Stage 2) ────────────────────────────── */
.readiness { margin-top: 10px; display: flex; align-items: center; gap: 8px; }
.readiness .rd-score { font-weight: 700; font-size: 14px; color: var(--ink); }
.readiness .rd-tag { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px;
  color: var(--warm); background: color-mix(in srgb, var(--warm) 16%, transparent); }
.rd-factors { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 6px; }
.rd-factors .rd-f { font-size: 11.5px; padding: 1px 7px; border-radius: 6px; border: 1px solid var(--line); color: var(--muted); }
.rd-factors .rd-f.earned { color: var(--ok, #16a34a); border-color: color-mix(in srgb, var(--ok, #16a34a) 35%, transparent);
  background: color-mix(in srgb, var(--ok, #16a34a) 12%, transparent); }
.rd-factors .rd-f.unknown { font-style: italic; }

/* "Show removed" toggle in the My Work / Prospects control bars */
/* match the tier checkboxes next to it (row, centered, 13px ink) — override .controls>label */
.controls > label.showremoved { display: inline-flex; flex-direction: row; align-items: center;
  align-self: flex-end; gap: 5px; font-size: 13px; color: var(--ink); white-space: nowrap; }

/* Prospect assignment chip + manager assign dropdown */
.assign-tag { font-size: 11px; font-weight: 700; border-radius: 999px; padding: 1px 8px; white-space: nowrap; }
.assign-tag.unassigned { color: var(--warm); background: color-mix(in srgb, var(--warm) 16%, transparent); }
.assign-tag.mine { color: var(--brand); background: color-mix(in srgb, var(--brand) 14%, transparent); }
.assign-tag.other { color: var(--slate); background: color-mix(in srgb, var(--slate) 16%, transparent); }
.assign-sel { font-size: 12px; padding: 4px 6px; border: 1px solid var(--line); border-radius: 7px; background: var(--panel); color: var(--ink); max-width: 150px; }

/* ── Manager coaching (behavioral health) — private, not a leaderboard ── */
.coach-intro { margin-bottom: 14px; }
.coach-rep { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 12px; box-shadow: var(--shadow); }
.coach-rep.flagged { border-left: 4px solid var(--warm); }
.coach-rep-head { display: flex; align-items: center; gap: 8px; font-size: 15px; margin-bottom: 10px; }
.coach-rep-head .sub { font-size: 13px; }
.support-flag { margin-left: auto; font-size: 11px; font-weight: 700; color: var(--warm);
  background: color-mix(in srgb, var(--warm) 16%, transparent); border-radius: 999px; padding: 2px 9px; }
.coach-signals { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.coach-sig { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel-2); }
.coach-sig.flag { border-color: color-mix(in srgb, var(--warm) 40%, transparent); background: color-mix(in srgb, var(--warm) 8%, transparent); }
.coach-sig .cs-label { font-size: 12px; color: var(--muted); }
.coach-sig .cs-vals { margin-top: 3px; }
.coach-sig .cs-cur { font-size: 16px; font-weight: 800; color: var(--ink); }
.coach-sig .cs-base { font-size: 11.5px; color: var(--muted); }
.coach-sig .cs-flag { margin-top: 5px; font-size: 11.5px; font-weight: 700; color: var(--warm); }
.coach-sig .cs-thin { margin-top: 5px; font-size: 11px; font-style: italic; color: var(--muted); }

/* contact role chip + inline edit button */
.contact-list .role-tag { font-weight: 600; color: var(--ink); }
.contact-list .cedit { padding: 1px 7px; margin-left: 4px; }

/* ── Coaching nudge (Stage 1) — private, soft, non-judgmental ── */
.nudge { margin: 0 0 12px; padding: 11px 13px; border-radius: 10px;
  background: color-mix(in srgb, var(--brand) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--brand) 30%, transparent); }
.nudge.nudge-log { background: color-mix(in srgb, var(--muted) 12%, transparent);
  border-color: color-mix(in srgb, var(--muted) 28%, transparent); }
.nudge .nudge-msg { font-size: 13.5px; line-height: 1.45; color: var(--ink); }
.nudge .nudge-action { margin-top: 6px; font-size: 12.5px; font-weight: 600; color: var(--brand); }
.nudge.nudge-log .nudge-action { color: var(--muted); }
/* timing nudge = time-critical → warmer, more urgent tint */
.nudge.nudge-timing { background: color-mix(in srgb, var(--hot) 9%, transparent);
  border-color: color-mix(in srgb, var(--hot) 32%, transparent); }
.nudge.nudge-timing .nudge-action { color: var(--hot); }
.nudge .nudge-btn { margin-top: 8px; }
