/* Cave Field — mobile first, desktop enhanced. */

:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef0f4;
  --border: #dce0e7;
  --border-soft: #e008;
  --text: #1a1d23;
  --text-dim: #5b6472;
  /* 4.58:1 on the dimmest surface it sits on. It was #8a93a2, which measured
     2.72:1 there — below the 4.5:1 floor, and this token carries the tab bar
     labels, every .meta line and the section headings, which is exactly the
     small type a rep reads in a cellar or in sunlight. */
  --text-faint: #646d7c;
  --accent: #d95f30;
  /* Dark ink on the orange, not white. White measured 3.01:1 on the dark
     accent and 3.73:1 on the light one, under the 4.5:1 floor, and this is
     every primary button in the app. Near-black gives 5.61:1 and 4.53:1 and
     keeps the orange exactly as it was. */
  --accent-ink: #1a1d23;
  --accent-soft: #fdeee7;
  --blue: #2f6fbf;
  --green: #2e8b57;
  --amber: #b8860b;
  --red: #c0392b;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 20, 28, .06), 0 4px 12px rgba(16, 20, 28, .06);
  --nav-h: 58px;
  /* Height of the demo / update bars sitting above the screens, measured and
     set by app.js. Only the map needs it — see #screen-map.active. */
  --banner-h: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151a;
    --surface: #191d24;
    --surface-2: #212630;
    --border: #2c3341;
    --text: #e6e9ef;
    --text-dim: #98a1b3;
    --text-faint: #828da1;   /* 4.53:1 on --surface-2; was #6b7688 at 3.30:1 */
    --accent: #e8734a;
    --accent-soft: #2a1a14;
    --blue: #5aa2ea;
    --green: #4bb573;
    --amber: #d9a441;
    --red: #e66363;      /* 4.57:1 on the dimmest surface; was #e05d5d at 4.26:1 */
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .3);
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: none; padding: 0; }
input, select, textarea { font-size: 16px; }  /* stops iOS zooming on focus */

/* iPhone Safari draws date and time boxes its own way: a minimum width of its
   choosing and the value centred, so in a narrow sheet the box spilled past
   the edge of the screen. Every one in the app — dates, times, follow-ups,
   forms — is sized like any other box instead. The native picker still opens. */
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="month"] {
  -webkit-appearance: none; appearance: none;
  display: block; width: 100%; min-width: 0; max-width: 100%;
  min-height: 46px; text-align: left; line-height: 22px;
}
input[type="date"]::-webkit-date-and-time-value,
input[type="time"]::-webkit-date-and-time-value,
input[type="datetime-local"]::-webkit-date-and-time-value,
input[type="month"]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 22px; }
/* And search boxes, which it rounds and pads to its own taste. */
input[type="search"] { -webkit-appearance: none; appearance: none; }
/* A field never pushes its container wider than the screen. */
.field { min-width: 0; }

/* ---------------------------------------------------------------- layout -- */

#app { display: flex; flex-direction: column; min-height: 100%; }

.screen { display: none; flex-direction: column; flex: 1; }
/*
 * Screens take focus on a route change so screen-reader users land in the new
 * content. That is a positioning device, not a control, so it must never draw
 * a ring around the whole page.
 */
.screen:focus, .screen:focus-visible { outline: none; }
.screen.active { display: flex; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--safe-t) + 10px) 14px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.topbar h1 { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.02em; flex: 1; }
.topbar .sub { font-size: 12px; color: var(--text-dim); font-weight: 400; }

.content {
  flex: 1;
  padding: 12px 14px calc(var(--nav-h) + var(--safe-b) + 24px);
  -webkit-overflow-scrolling: touch;
}

/* ------------------------------------------------------------------- nav -- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
}
.tabbar button {
  flex: 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px;
  height: var(--nav-h);
  color: var(--text-faint);
  font-size: 11px; font-weight: 500;
}
.tabbar button.on { color: var(--accent); }
.tabbar button svg { width: 22px; height: 22px; }
/* Five tabs on a 390px screen leaves ~78px each; keep labels on one line. */
.tabbar button span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 400px) { .tabbar button { font-size: 10px; } }
/* Keyboard up on a phone: the tab bar would ride up on top of it and cover the
   box being typed in (see followKeyboard in ui.js). On desktop it is the side
   bar and stays. */
@media (max-width: 859px) {
  .kb-open .tabbar { display: none; }
  .kb-open #toasts { bottom: calc(var(--kb, 0px) + 16px); }
}
.tabbar .badge {
  position: absolute; transform: translate(14px, -12px);
  background: var(--red); color: #fff;
  min-width: 17px; height: 17px; border-radius: 9px;
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center; padding: 0 4px;
}

/* ------------------------------------------------- new-account progress -- */

.track { display: flex; align-items: flex-start; margin-top: 8px; }
.track .step {
  flex: 1; position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 10.5px; line-height: 1.2; color: var(--text-faint); text-align: center;
}
.track .dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface); z-index: 1;
}
.track .step.done { color: var(--text-dim); }
.track .step.done .dot { background: var(--accent); border-color: var(--accent); }
.track .step.now .dot { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.track .step:not(:first-child)::before {
  content: ''; position: absolute; top: 6px; right: 50%; width: 100%; height: 2px; background: var(--border);
}
.track .step.done:not(:first-child)::before { background: var(--accent); }
.newrow { display: block; width: 100%; text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.newrow:last-child { border-bottom: none; }
.newrow .top { display: flex; align-items: center; gap: 10px; }
.newrow .grow { flex: 1; min-width: 0; }
.newrow .title { font-weight: 600; line-height: 1.3; }
.newrow .meta { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); display: inline-block; }
.new-banner { padding: 12px 14px; margin-bottom: 12px; }
.new-banner .head { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.new-banner .acts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.new-banner .meta { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* ----------------------------------------------------------------- cards -- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  overflow: hidden;
}
.card-head {
  padding: 12px 14px 0;
  font-size: 12px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-faint);
}
.card-body { padding: 14px; }

.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-faint);
  margin: 18px 2px 8px;
}

/* ----------------------------------------------------------------- lists -- */

.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  width: 100%; text-align: left;
  min-height: 60px;
}
.row:last-child { border-bottom: none; }
/* A row that is a link (phone, website) reads as a row, not as browser-blue text. */
a.row { color: inherit; text-decoration: none; }
.row:active { background: var(--surface-2); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 550; line-height: 1.3; }
.row .meta { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.row .meta.truncate, .row .title.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .title > .truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .chev { color: var(--text-faint); flex-shrink: 0; }

.avatar {
  width: 40px; height: 40px; border-radius: 11px;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: 14px; flex-shrink: 0;
  border: 1px solid var(--border);
}

/* ----------------------------------------------------------------- chips -- */

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 12px; font-weight: 550; white-space: nowrap;
}
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-scroll {
  display: flex; gap: 6px; overflow-x: auto; padding: 2px 14px 10px;
  margin: 0 -14px; scrollbar-width: none;
}
.chip-scroll::-webkit-scrollbar { display: none; }

.pill {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}
.pill.gold   { background: #f6e6bf; color: #6b5310; }
.pill.silver { background: #e3e6ea; color: #4a5160; }
.pill.bronze { background: #f0ddd0; color: #7a4a2a; }
.pill.iron   { background: #dfe3e8; color: #4a5464; }
.pill.website{ background: #dbe8f7; color: #23557f; }
.pill.warn   { background: #fbe3c9; color: #7a4a10; }
.pill.due    { background: #f8d7d3; color: #94271b; }
@media (prefers-color-scheme: dark) {
  .pill.gold   { background: #4a3c14; color: #f0d78a; }
  .pill.silver { background: #333a45; color: #cdd4de; }
  .pill.bronze { background: #4a3323; color: #e8b58a; }
  .pill.iron   { background: #333a45; color: #b3bcc8; }
  .pill.website{ background: #1e3a54; color: #9ccbf0; }
  .pill.warn   { background: #4a3616; color: #e8be7a; }
  .pill.due    { background: #4d1f1b; color: #f0a49c; }
}

/* --------------------------------------------------------------- buttons -- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 44px; padding: 0 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-weight: 550; font-size: 15px;
  /* Some buttons are anchors (mailto:, maps); keep them looking like buttons. */
  color: var(--text); text-decoration: none; cursor: pointer;
}
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-danger { color: var(--red); }
.btn-block { width: 100%; }
.btn-sm { min-height: 36px; font-size: 14px; padding: 0 12px; }
/* Icon-only, and still 44px square — the minimum a fingertip reliably hits. */
.btn-square { min-width: 44px; padding: 0; flex-shrink: 0; }
.btn:disabled { opacity: .45; }

.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------------------------------------------------------------- search -- */

.search {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 0 12px;
  min-height: 44px;
  /* The list it filters follows immediately after. Without this the field and
     the first row share an edge and read as one control. */
  margin-bottom: 12px;
}
.search input { flex: 1; background: none; border: none; outline: none; min-width: 0; }

/*
 * Keyboard focus.
 *
 * There was none outside form fields, so anyone navigating by keyboard had no
 * idea where they were — the manager screens are used at a desk, which is
 * exactly where that happens. `:focus-visible` rather than `:focus`, so it
 * appears for keyboard users and never on a tap: the phone experience is
 * unchanged.
 */
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
.row:focus-visible, .tabbar button:focus-visible { outline-offset: -3px; }
.search svg { color: var(--text-faint); flex-shrink: 0; }

/* ----------------------------------------------------------------- forms -- */

.field { margin-bottom: 14px; }
.field label {
  display: block; margin-bottom: 5px;
  font-size: 12px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-faint);
}
.field input, .field select, .field textarea {
  width: 100%; padding: 11px 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
.field textarea { min-height: 90px; resize: vertical; line-height: 1.5; }
.field .hint { font-size: 12px; color: var(--text-faint); margin-top: 5px; }

/* Dictation (lib/dictate.js): the note box and a strip under the text share
   one border, so the mic sits with the box but never on top of what was typed. */
.dictate-bar { display: none; }
.dictate.on {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.dictate.on:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dictate.on textarea, .dictate.on textarea:focus {
  display: block; width: 100%;
  border: 0; box-shadow: none; background: transparent; padding-bottom: 4px;
}
.dictate.on .dictate-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 6px 6px 12px; border-top: 1px solid var(--border);
}
.dictate-status {
  flex: 1; min-width: 0;
  font-size: 12px; color: var(--text-faint);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dictate-btn {
  flex: none; width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-dim); border: 1px solid var(--border);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
}
.dictate-btn[hidden] { display: none; }
.dictate[data-state="recording"] .dictate-btn { background: var(--red); border-color: var(--red); color: #fff; animation: dictate-pulse 1.2s ease-in-out infinite; }
.dictate[data-state="sending"] .dictate-btn,
.dictate[data-state="starting"] .dictate-btn { opacity: .55; }
.dictate[data-state="failed"] .dictate-btn { background: var(--amber); border-color: var(--amber); color: #fff; }
.dictate[data-state="recording"] .dictate-status { color: var(--red); font-weight: 600; }
@keyframes dictate-pulse { 50% { box-shadow: 0 0 0 6px rgba(192, 57, 43, .18); } }
@media (prefers-reduced-motion: reduce) { .dictate-btn { animation: none !important; } }

.opt-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.opt-grid button {
  padding: 9px 13px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: 14px; font-weight: 500;
}
.opt-grid button.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.switch-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
/* A switch row is often a <label> sitting inside a .field — the SKU pickers
   are built that way. Without this the field's own label styling wins on
   specificity and renders the row uppercase, bold and stacked, with the
   checkbox dropped below the text. */
.field label.switch-row {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 0;
  font-size: 15px; font-weight: 400; letter-spacing: normal;
  text-transform: none; color: var(--text);
}
.field label.switch-row small { color: var(--text-faint); }
.switch-row:last-child { border-bottom: none; }
.switch-row .grow { flex: 1; }
.switch-row .grow small { display: block; color: var(--text-faint); font-size: 13px; }
.switch-row input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); }

/* ----------------------------------------------------------------- sheet -- */

.scrim {
  position: fixed; inset: 0; z-index: 40;
  background: rgba(12, 16, 22, .45);
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  /* --kb is the height the on-screen keyboard covers (ui.js followKeyboard):
     the sheet rides above it rather than behind it. */
  position: fixed; left: 0; right: 0; bottom: var(--kb, 0px); z-index: 50;
  max-height: min(92vh, calc(var(--vvh, 100vh) - 12px));
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  box-shadow: 0 -8px 40px rgba(0, 0, 0, .28);
  transform: translateY(100%);
  transition: transform .24s cubic-bezier(.32, .72, 0, 1);
  display: flex; flex-direction: column;
}
.sheet.open { transform: translateY(0); }
.sheet-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 8px auto 0; flex-shrink: 0; }
.sheet-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 650; flex: 1; }
.sheet-body { padding: 16px; overflow-y: auto; flex: 1; -webkit-overflow-scrolling: touch; }
.sheet-foot {
  padding: 12px 16px calc(12px + var(--safe-b));
  border-top: 1px solid var(--border);
  display: flex; gap: 10px;
}
.sheet-foot .btn { flex: 1; }

/* ---------------------------------------------------------------- toasts -- */

#toasts {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  z-index: 60; display: flex; flex-direction: column; gap: 8px;
  align-items: center; pointer-events: none; width: max-content; max-width: 92vw;
}
.toast {
  background: #1f2530; color: #f0f2f6;
  padding: 11px 16px; border-radius: 999px;
  font-size: 14px; font-weight: 500;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
  animation: rise .2s ease;
}
.toast.err { background: var(--red); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

/* ----------------------------------------------------------------- misc  -- */

.empty { text-align: center; padding: 48px 24px; color: var(--text-faint); }
.empty h3 { margin: 0 0 6px; color: var(--text-dim); font-size: 16px; }
.empty p { margin: 0 0 16px; font-size: 14px; line-height: 1.55; }
/* An empty state offering a choice stacks it. Buttons are inline-flex, so
   without this they sit side by side and each ends up about a third of the
   width — two narrow targets where a thumb wants one wide one. The order
   restates the preference the primary colour already implies. */
.empty-actions { display: flex; flex-direction: column; gap: 8px; max-width: 320px; margin: 0 auto; }
.empty-actions .btn { width: 100%; }

/*
 * Fits whatever it is given rather than assuming three.
 * Three across stays three across; four fits on a 390px screen; five would
 * wrap badly, so no screen asks for five.
 */
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); gap: 10px; }
.stat {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 10px; text-align: center;
  /* The grid stretches every card to the tallest, so a value that wraps
     ("4 months ago") pushed its own label down and left the row of labels
     ragged. Pinning them to the bottom keeps them in line. */
  display: flex; flex-direction: column; justify-content: space-between; gap: 4px;
}
.stat .v { font-size: 22px; font-weight: 700; line-height: 1.1; }
.stat .k { font-size: 11px; color: var(--text-faint); margin-top: 3px; text-transform: uppercase; letter-spacing: .04em; }

/*
 * Demo banner. Deliberately loud: the one outcome worth avoiding is somebody
 * in the room believing they are looking at live Cave Direct data.
 */
.demo-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--accent); color: var(--accent-ink);
  padding: 7px 14px; font-size: 13px; font-weight: 550;
  flex-shrink: 0;
}
.demo-bar span { flex: 1; min-width: 0; }
.demo-switch {
  background: rgba(255, 255, 255, .18); color: var(--accent-ink);
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: var(--radius-sm);
  /* Small, but still a comfortable target on a phone. */
  min-height: 32px; padding: 0 12px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.demo-switch:active { background: rgba(255, 255, 255, .3); }

/* Says a newer version is waiting. Never reloads on its own — a rep half-way
   through a visit note would lose it. */
.update-bar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--accent-soft, #2a2118); color: var(--text);
  border-bottom: 1px solid var(--accent);
  padding: 8px 14px; font-size: 13px; font-weight: 550;
  flex-shrink: 0;
}
.update-bar span { flex: 1; min-width: 0; }
.update-reload {
  background: var(--accent); color: var(--accent-ink); border: none;
  border-radius: var(--radius-sm);
  min-height: 32px; padding: 0 14px;
  font-size: 13px; font-weight: 600; cursor: pointer;
}

.offline-bar {
  display: none; background: var(--amber); color: #fff;
  padding: 6px 14px; font-size: 13px; font-weight: 550; text-align: center;
}
body.offline .offline-bar { display: block; }

/* The team coverage map. Sized in dvh so a phone's address bar does not push
   the bottom of it off screen, as it once did with the area map. */
.teammap {
  position: relative;
  overflow: hidden;
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  height: 55vh;
  height: 55dvh;
  min-height: 320px;
  /* On a phone it shares the screen with the controls and the key. On a desktop
     it is the point of the screen, so it gets the room — a map squeezed into a
     short band zooms out to fit its width and shows half of Europe. */
  touch-action: none;
  cursor: grab;
}
.teammap:active { cursor: grabbing; }
.teammap-tiles, .teammap-pins { position: absolute; inset: 0; }
.teammap-pins { pointer-events: none; }

.teampin {
  position: absolute;
  width: 13px; height: 13px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .85);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .45);
  padding: 0;
  cursor: pointer;
  pointer-events: auto;
}
/* An account nobody has been to: present, but plainly not a visit. Hollow
   rather than a different colour, so it reads as absence at a glance. */
.teampin-cold {
  width: 9px; height: 9px; margin: -5px 0 0 -5px;
  border-color: rgba(255, 255, 255, .45);
  box-shadow: none;
}
.teampin:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

.teammap-layout { display: flex; flex-direction: column; }
/* Stacked at the top-left, matching the rep's area map rather than inventing
   a second place to look for the same control. */
.teammap-zoom {
  position: absolute; left: 10px; top: 10px; z-index: 2;
  display: flex; flex-direction: column; gap: 6px;
}
.teammap-zoom .btn { font-size: 18px; line-height: 1; box-shadow: var(--shadow); }

.teammap-filters { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 14px; }
.teammap-side { min-width: 0; }

/* What is at a pin, without leaving the map. Shared by both maps: the
   manager's coverage map and the rep's area map. */
.mappop {
  position: absolute;
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--rule, var(--border));
  border-radius: var(--radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  padding: 12px 14px 14px;
  z-index: 3;
}
.mappop-close {
  position: absolute; top: 6px; right: 6px;
  background: none; border: none; color: var(--text-faint);
  cursor: pointer; padding: 4px; line-height: 0;
}
.mappop-name { font-weight: 650; padding-right: 20px; line-height: 1.25; }
.mappop-reason { display: flex; align-items: center; gap: 7px; margin-top: 8px; padding: 6px 8px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12.5px; font-weight: 550; }
/* In Google's info window: Google draws the box, so the card is bare. */
.gm-style .mappop { position: static; width: 260px; box-shadow: none; border: none; padding: 2px 4px 4px; background: transparent; color: #1a1d23; }
.mappop-visits { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.mappop-visit { border-top: 1px solid var(--border); padding-top: 8px; }
.mappop-when { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 550; }
/* Notes run to a few lines; clamping keeps the card a predictable size rather
   than letting one long note push the button off the map. */
.mappop-note {
  font-size: 12.5px; color: var(--text-dim); margin-top: 3px;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;
}

/* The rep's card carries account facts and two ways to reach somebody, so it
   needs rows and a button pair the team map's visit list does not. */
.mappop-rows { margin-top: 8px; display: flex; flex-direction: column; gap: 5px; }
.mappop-row { display: flex; gap: 8px; font-size: 12.5px; align-items: baseline; }
.mappop-row dt { color: var(--text-faint); flex: 0 0 74px; }
.mappop-row dd { margin: 0; color: var(--text-dim); min-width: 0; }
.mappop-actions { display: flex; gap: 8px; margin-top: 10px; }
.mappop-actions > * { flex: 1; }

.teamkey { width: 13px; height: 13px; border-radius: 50%; flex-shrink: 0; border: 2px solid rgba(255,255,255,.85); }
.teamkey-cold { background: transparent; border-color: rgba(255,255,255,.45); }

.timeline-item { display: flex; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-icon {
  width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-dim);
}
.timeline-icon.visit { background: var(--accent-soft); color: var(--accent); }
.timeline-item .when { font-size: 12px; color: var(--text-faint); }
.timeline-item .note { font-size: 14px; margin-top: 4px; color: var(--text-dim); white-space: pre-wrap; }

.detail-grid { display: grid; grid-template-columns: 40% 1fr; }
.detail-grid dt, .detail-grid dd {
  padding: 9px 14px; margin: 0; font-size: 14px;
  border-bottom: 1px solid var(--border);
}
.detail-grid dt { color: var(--text-faint); }
.detail-grid dd { word-break: break-word; }
.detail-grid dt:last-of-type, .detail-grid dd:last-of-type { border-bottom: none; }

.tabs { display: flex; gap: 4px; padding: 0 14px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.tabs button {
  padding: 12px 4px; font-size: 15px; font-weight: 550; color: var(--text-faint);
  border-bottom: 2px solid transparent; flex: 1;
}
.tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

/* The map fills what is left of the viewport rather than scrolling — stopping
   above the tab bar, which is fixed, or the map's own controls sit under it.

   `dvh`, not `vh`: on a phone 100vh is the viewport with the browser's address
   bar hidden, which is taller than what you can actually see, so a vh-based
   height still ran the map off the bottom of the screen. `dvh` tracks the
   space really available. The vh line above it is the fallback for anything
   too old to know what dvh means. */
#screen-map.active {
  display: flex; flex-direction: column;
  /* `.screen` sets flex: 1, which grows the screen to fill its parent and
     overrides any height. The map is the one screen that must be exactly as
     tall as the space above the tab bar, so it opts out of growing. */
  flex: none;
  /* `--banner-h` because 100dvh measures from the top of the viewport, but a
     demo or update bar pushes this screen down. Without it the map ran under
     the fixed tab bar by exactly the bar's height, hiding its own controls —
     the "Plan run" button among them. */
  height: calc(100vh - var(--nav-h) - var(--safe-b) - var(--banner-h));
  height: calc(100dvh - var(--nav-h) - var(--safe-b) - var(--banner-h));
}
#screen-map .topbar { flex-shrink: 0; }
@media (min-width: 860px) { #screen-map.active { height: 100%; } }
/* Find places shares the Leads screen; while it is showing, that screen is
   sized like the map's (above), or its bar runs under the tab bar. */
#screen-prospects.active:has(.leadmap-slot) {
  display: flex; flex-direction: column; flex: none;
  height: calc(100vh - var(--nav-h) - var(--safe-b) - var(--banner-h));
  height: calc(100dvh - var(--nav-h) - var(--safe-b) - var(--banner-h));
}
#screen-prospects:has(.leadmap-slot) .topbar { flex-shrink: 0; }
@media (min-width: 860px) { #screen-prospects.active:has(.leadmap-slot) { height: 100%; } }

/* No navigation until somebody has signed in — there is nothing behind it. */
body.signing-in .tabbar, body.signing-in #demo-bar { display: none; }
/* Nothing of the app shows until it knows who is looking: while it asks the
   server whether this device is signed in, the menus stayed on screen and
   read as an app open to anyone. Hidden from the first paint, in the HTML. */
body.booting #app { visibility: hidden; }

/* Sync, while it is happening. Shown only during a pass — an empty track
   sitting there permanently reads as something stalled. */
.syncbar { margin-top: 12px; }
.syncbar-track {
  height: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.syncbar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  /* Eases between steps so the bar reads as movement rather than a jump.
     Honours the reduced-motion rule below like everything else. */
  transition: width .28s ease;
  min-width: 2px;
}
.syncbar-label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 6px;
}
.syncbar-count { font-variant-numeric: tabular-nums; flex-shrink: 0; }

.hidden { display: none !important; }
.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2.5px solid var(--border); border-top-color: var(--accent);
  animation: spin .7s linear infinite; margin: 24px auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/*
 * Someone who has told their phone to stop moving things has usually done so
 * for a reason — motion sickness, or a vestibular condition. Everything still
 * works, it just stops sliding.
 *
 * The spinner is the exception: it keeps turning, only slower. A frozen
 * spinner reads as a hung app, which is worse than the movement it was asked
 * to avoid, and a rotating disc is not the kind of motion that causes trouble.
 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
  .spinner {
    animation-duration: 1.4s !important;
    animation-iteration-count: infinite !important;
  }
}

/* ----------------------------------------------------------- page rhythm --
   Boxed blocks stacked in a page never touch. They were spaced one by one with
   margins, and every place that forgot one (a figures row straight onto a
   button, a list onto a card) read as overlapping. One rule, for every page. */
:is(.card, .list, .stat-row, .btn-block, .empty, .rp-table-wrap, .search)
  + :is(.card, .list, .stat-row, .btn-block, .empty, .rp-table-wrap, .ov-grid) { margin-top: 12px; }

/* ------------------------------------------------------ manager overview -- */

/* A segmented switch: Today / This week / 30 days. */
.seg { display: flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; flex-shrink: 0; }
.seg button { padding: 6px 11px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--text-dim); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); }

/* Phone: figures, map, reps, then the team's standing, one column. */
.ov-grid { display: flex; flex-direction: column; gap: 16px; }
.ov-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.ov-sub { font-size: 12px; font-weight: 600; color: var(--green); }
.ov-mapwrap { position: relative; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface-2); }
.ov-map { height: 380px; }
.ov-legend {
  position: absolute; left: 10px; top: 10px; z-index: 2; width: 220px; max-width: calc(100% - 20px);
  background: var(--surface); border-radius: var(--radius-sm); box-shadow: var(--shadow);
  padding: 6px; display: flex; flex-direction: column; gap: 2px;
}
.ov-legend:empty { display: none; }
.ov-key { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-radius: 6px; font-size: 13px; text-align: left; width: 100%; }
.ov-key:hover { background: var(--surface-2); }
.ov-key.off { opacity: .45; }
.ov-key .meta { font-size: 12px; color: var(--text-faint); }
.ov-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.ov-layers { position: absolute; right: 10px; top: 10px; z-index: 2; display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; max-width: 60%; }
.ov-layers .chip { box-shadow: var(--shadow); }
.ov-mapnote {
  /* Bottom centre: the map's own logo and controls take the corners. */
  position: absolute; left: 50%; transform: translateX(-50%); bottom: 10px; z-index: 2; white-space: nowrap; max-width: calc(100% - 220px); overflow: hidden; text-overflow: ellipsis; font-size: 11px; color: var(--text-dim);
  background: var(--surface); opacity: .92; border-radius: 6px; padding: 3px 8px;
}
.ov-side { min-width: 0; }
.teammap-credit { position: absolute; right: 6px; bottom: 4px; z-index: 3; font-size: 11px; color: #333; background: rgba(255, 255, 255, .8); padding: 1px 6px; border-radius: 4px; }
.mapcard-popup { z-index: 5; }
.mapcard-popup .mapboxgl-popup-content { padding: 0; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.mapcard-popup .mapboxgl-popup-tip { display: none; }
.mapcard-popup .mappop { position: static; width: auto; box-shadow: none; border: none; }
/* The same size on both maps: each map passes its own font down otherwise. */
.mapcard-popup .mappop { font-size: 13px; line-height: 1.4; }
.mapcard-popup .mappop-name { font-size: 15px; }
.mapcard-popup .mappop .meta { font-size: 12.5px; }
.mbx-pop { display: flex; flex-direction: column; gap: 2px; font: 13px/1.35 system-ui, sans-serif; color: #1a1d23; }
.mbx-pop span { color: #5b6472; font-size: 12px; }
.ov-mapwrap .mapboxgl-map { font: inherit; }
.ov-side .section-title:first-child { margin-top: 0; }
.ov-terr { font-weight: 400; font-size: 12px; color: var(--text-faint); }
.avatar.ov-mini { width: 28px; height: 28px; font-size: 11px; }
.ov-below { margin-top: 0; padding-top: 24px; border-top: 1px solid var(--border); }
.ov-grid { margin-bottom: 24px; }
.pill.ok { background: #d8efe2; color: #1f6a40; }
@media (prefers-color-scheme: dark) { .pill.ok { background: #183526; color: #8fd9ad; } }
@media (max-width: 640px) { .ov-legend { display: none; } .ov-layers { max-width: 100%; left: 10px; justify-content: flex-start; } }

/* --------------------------------------------------------------- rep page -- */

.rep-tabs { overflow-x: auto; scrollbar-width: none; }
.rep-tabs button { white-space: nowrap; flex-shrink: 0; }
.rep-diary { display: flex; flex-direction: column; gap: 16px; }
.rep-week { overflow: hidden; }
.rep-week-head { display: flex; align-items: center; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.wk-key { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--text-dim); margin-left: 8px; }
.wk-sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; border-left: 3px solid; }
.wk-scroll { overflow-x: auto; }
/* A column of hours, then a column per day; entries are placed by time. */
.wk { display: grid; grid-template-columns: 52px repeat(var(--days), minmax(110px, 1fr)); min-width: calc(52px + var(--days) * 110px); }
.wk-corner { border-bottom: 1px solid var(--border); }
.wk-head { padding: 9px 4px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); color: var(--text-dim); }
.wk-head.today { color: var(--accent); }
.wk-head.on { background: var(--accent-soft); color: var(--accent); }
.wk-hours { display: flex; flex-direction: column; }
.wk-hour { height: 52px; flex-shrink: 0; font-size: 11px; color: var(--text-faint); text-align: right; padding: 2px 8px 0 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.wk-col {
  position: relative; border-left: 1px solid var(--border);
  background-image: linear-gradient(to bottom, var(--border) 1px, transparent 1px);
  background-size: 100% 52px;
}
.wk-ev {
  position: absolute; left: 3px; right: 3px; border-radius: 6px; padding: 2px 6px;
  font-size: 11.5px; line-height: 1.25; text-align: left; overflow: hidden;
  border-left: 3px solid; color: var(--text);
  white-space: nowrap; text-overflow: ellipsis;
}
.wk-ev:hover { filter: brightness(.97); box-shadow: var(--shadow); z-index: 2; }
.wk-allday { border-left: 1px solid var(--border); border-top: 1px solid var(--border); padding: 3px; display: flex; flex-direction: column; gap: 3px; min-height: 30px; }
.wk-allday-label { height: auto; min-height: 30px; }
.wk-ev.wk-chip { position: static; height: auto; white-space: nowrap; text-overflow: ellipsis; }
.wk-t { font-weight: 700; font-variant-numeric: tabular-nums; }
.wk-ev.done, .wk-sw.done { background: #e3f2ea; border-color: var(--green); }
.wk-ev.planned, .wk-sw.planned { background: #e6eefa; border-color: var(--blue); }
.wk-ev.missed, .wk-sw.missed { background: #fbe6e3; border-color: var(--red); }
.wk-ev.logged, .wk-sw.logged { background: var(--surface-2); border-color: var(--text-faint); border-left-style: dashed; }
@media (prefers-color-scheme: dark) {
  .wk-ev.done, .wk-sw.done { background: #17301f; }
  .wk-ev.planned, .wk-sw.planned { background: #172538; }
  .wk-ev.missed, .wk-sw.missed { background: #3a1b19; }
}
.rep-side { min-width: 0; }
.rep-side .section-title:first-of-type { margin-top: 16px; }
.rep-stats { grid-template-columns: 1fr 1fr !important; }
.rep-table { border-collapse: collapse; width: 100%; font-size: 14px; }
.rep-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); text-align: left; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.rep-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; font-variant-numeric: tabular-nums; }
.rep-table tr:last-child td { border-bottom: none; }
.rep-table .n { text-align: right; width: 72px; }
.rep-table summary { cursor: pointer; font-weight: 600; }
.rep-lines { margin: 8px 0 2px; padding-left: 18px; font-size: 13px; color: var(--text-dim); display: flex; flex-direction: column; gap: 4px; }

/* ---------------------------------------------------------------- reports -- */

/* Phone: the reports as a scrolling row of choices above the report. */
.rp { display: flex; flex-direction: column; gap: 16px; }
.rp-list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.rp-item { flex-shrink: 0; display: flex; flex-direction: column; gap: 2px; text-align: left; padding: 9px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.rp-item b { font-size: 14px; white-space: nowrap; }
.rp-item span { display: none; font-size: 12px; color: var(--text-faint); line-height: 1.35; }
.rp-item.on { background: var(--accent-soft); border-color: var(--accent); }
.rp-item.on b { color: var(--accent); }
.rp-main { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.rp-filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; }
.rp-field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.rp-field span { font-size: 12px; font-weight: 600; color: var(--text-dim); }
.rp-field select, .rp-field input { min-height: 38px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; max-width: 100%; }
.rp-field input[type=date] { width: 160px; min-height: 38px; }
.rp-actions { display: flex; gap: 8px; }
.rp-heading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 12px; }
.rp-heading h2 { margin: 0; font-size: 18px; }
.rp-note { color: var(--text-faint); font-weight: 500; }
.rp-table-wrap { overflow-x: auto; }
.rp-table { border-collapse: collapse; width: 100%; font-size: 13px; }
.rp-table th { position: sticky; top: 0; background: var(--surface); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); text-align: left; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.rp-table td { padding: 9px 12px; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; vertical-align: top; white-space: nowrap; }
.rp-table td.wrap { white-space: normal; min-width: 240px; max-width: 360px; }
.rp-table tr:last-child td { border-bottom: none; }
.rp-table .n { text-align: right; white-space: nowrap; }
.rp-empty { padding: 16px; }
.rp-table td.rp-photos .photo-thumb { width: 56px; height: 56px; }
.rp-hint { margin: 0; }

/* ----------------------------------------------------------- form builder -- */

.desk-only { display: none !important; }
.form-heading { padding: 6px 0 2px; margin-top: 4px; border-top: 1px solid var(--border); }
.form-heading h3 { margin: 6px 0 2px; font-size: 16px; }
.form-unit { display: flex; align-items: center; gap: 8px; }
.form-unit input { flex: 1; min-width: 0; }
.form-unit span { color: var(--text-dim); font-weight: 600; }
.form-warn { color: var(--amber); margin-top: 6px; }
.photo-picker { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.photo-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.photo-thumbs:empty { display: none; }
.photo-thumb { position: relative; width: 84px; height: 84px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); display: grid; place-items: center; text-align: center; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .hint { font-size: 11px; padding: 4px; margin: 0; }
.photo-remove { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: #fff; font-size: 16px; line-height: 1; }
.photo-add { cursor: pointer; }
.photo-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.photo-status { margin: 0; }

/* Phone: list, editor and preview stacked. */
.fb { display: flex; flex-direction: column; gap: 18px; }
.fb-list { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; align-items: stretch; }
.fb-list .section-title { display: none; }
.fb-new { flex-shrink: 0; align-self: center; }
.fb-editor { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.fb-meta { display: grid; gap: 0 14px; }
.fb-add { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.fb-questions { display: flex; flex-direction: column; gap: 10px; }
.fb-q { padding: 0; }
.fb-q.open { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.fb-q.heading { background: var(--surface-2); }
.fb-q.dragging { opacity: .45; }
.fb-q.drop { box-shadow: 0 -3px 0 var(--accent); }
.fb-q-head { display: flex; align-items: center; gap: 8px; padding: 10px 10px 10px 12px; }
.fb-grip { color: var(--text-faint); cursor: grab; letter-spacing: -2px; user-select: none; }
.fb-q-open { flex: 1; min-width: 0; text-align: left; display: flex; flex-direction: column; gap: 2px; }
.fb-q-title { font-size: 15px; }
.fb-q-meta { font-size: 12.5px; color: var(--text-dim); }
.fb-q-tools { display: flex; gap: 2px; flex-shrink: 0; }
.fb-q-body { padding: 4px 14px 14px; border-top: 1px solid var(--border); }
.fb-grid { display: grid; gap: 0 14px; }
.fb-q-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.fb-delete { color: var(--red); }
.fb-problems { padding: 12px 16px; border-color: var(--red); }
.fb-problems ul { margin: 6px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 3px; }
.fb-empty { padding: 14px 16px; }
.fb-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 4px; }
.fb-preview { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 0; }
.fb-preview-head { display: flex; justify-content: space-between; align-items: baseline; width: 100%; max-width: 330px; }
.fb-phone {
  width: 100%; max-width: 330px; height: 620px; overflow-y: auto;
  border: 10px solid #1a1d23; border-radius: 34px; background: var(--bg);
}
.fb-phone-body { padding: 18px 14px 24px; }
.fb-phone-title { font-weight: 700; font-size: 17px; margin-bottom: 8px; }
@media (min-width: 640px) { .fb-meta, .fb-grid { grid-template-columns: 1fr 1fr; } .fb-grid-3 { grid-template-columns: 1fr 1fr 1fr; } }

/* ------------------------------------------------------------------ today -- */

.today { display: flex; flex-direction: column; gap: 10px; }
.today-head { display: flex; align-items: center; gap: 8px; margin: 12px 2px 0; }
.today-head .meta { font-size: 12.5px; color: var(--text-faint); }
.next-card { padding: 14px 16px; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); display: flex; flex-direction: column; gap: 4px; }
.next-card.quiet { border-color: var(--border); box-shadow: none; }
.next-label { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.next-card.quiet .next-label { color: var(--text-faint); }
.next-name { font-size: 21px; font-weight: 700; line-height: 1.2; text-align: left; color: var(--text); padding: 0; }
.next-name.static { cursor: default; }
.next-facts { font-size: 13.5px; }
.next-open.ok { color: var(--green); font-weight: 600; }
.next-open.shut { color: var(--red); font-weight: 600; }
.next-last { font-size: 13.5px; color: var(--text-dim); line-height: 1.45; margin-top: 4px; }
.next-last b { color: var(--text); font-weight: 600; }
.next-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.next-actions.two { grid-template-columns: 1fr 1fr; }
.next-actions .btn { min-height: 44px; padding: 0 6px; gap: 5px; white-space: nowrap; font-size: 14.5px; }
.next-actions .btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.todo-bucket { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); margin: 8px 2px 0; }
.todo-row { padding-right: 12px; }
.todo-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.todo-title { display: flex; align-items: center; gap: 6px; min-width: 0; }
.todo-title .truncate { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.todo-title .pill { flex-shrink: 0; }
.week-card { width: 100%; text-align: left; padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.week-sales, .week-visits { display: flex; flex-direction: column; gap: 4px; width: 100%; text-align: left; }
.week-visits { gap: 7px; padding-top: 10px; border-top: 1px solid var(--border); }
.week-k { font-size: 11.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-faint); }
.week-money { font-size: 26px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 10px; }
.week-change { font-size: 14px; font-weight: 700; }
.week-change.up { color: var(--green); }
.week-change.down { color: var(--red); }
.week-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.week-bar { height: 9px; border-radius: 5px; background: var(--surface-2); overflow: hidden; }
.week-bar i { display: block; height: 100%; border-radius: 5px; background: var(--accent); }

/* ------------------------------------------------------------- desktop  -- */

@media (min-width: 860px) {
  :root { --nav-h: 0px; }

  #app { flex-direction: row; height: 100vh; }

  .tabbar {
    position: static; flex-direction: column; width: 208px;
    border-top: none; border-right: 1px solid var(--border);
    padding: 14px 10px; gap: 4px; flex-shrink: 0;
  }
  .tabbar button {
    flex: none; flex-direction: row; justify-content: flex-start;
    height: 44px; gap: 12px; padding: 0 12px;
    border-radius: var(--radius-sm); font-size: 15px;
  }
  .tabbar button.on { background: var(--accent-soft); }
  .tabbar .badge { position: static; transform: none; margin-left: auto; }

  .screen { overflow: hidden; }
  .screen.active { display: flex; }
  .content { overflow-y: auto; padding: 18px 24px 40px; }
  .topbar { padding: 16px 24px; }

  .content-inner { max-width: 940px; margin: 0 auto; }

  /* The overview uses the whole width: map beside the reps panel. */
  .ov-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; align-items: start; gap: 20px; }
  .ov-map { height: calc(100dvh - 280px - var(--banner-h)); min-height: 400px; }
  .ov-side { position: sticky; top: 0; }
  .ov-below { max-width: none; }
  .content-inner.rep-wide { max-width: none; }
  .desk-only { display: flex !important; }
  /* The builder: forms, questions, and the phone, side by side. */
  .fb { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 22px; align-items: start; }
  .fb-preview { grid-column: 2; }
  .fb-list { flex-direction: column; overflow: visible; position: sticky; top: 0; gap: 2px; }
  .fb-list .section-title { display: block; margin: 0 0 6px 12px; }
  .fb-new { align-self: flex-start; margin: 10px 0 0 10px; }
  @media (min-width: 1250px) {
    .fb { grid-template-columns: 210px minmax(0, 1fr) 350px; }
    .fb-preview { grid-column: auto; position: sticky; top: 0; }
  }
  /* Reports: the list down the left, the report beside it. */
  .rp { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }
  .rp-list { flex-direction: column; overflow: visible; position: sticky; top: 0; }
  .rp-item { border-color: transparent; background: none; }
  .rp-item span { display: block; }
  .rp-item.on { border-color: transparent; }
  .rp-more { margin-top: 10px; border-top: 1px solid var(--border); border-radius: 0; padding-top: 14px; }
  .rep-diary { display: grid; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; gap: 18px; }
  @media (max-width: 1099px) { .rep-diary { grid-template-columns: 1fr; } }
  @media (max-width: 1099px) { .ov-grid { grid-template-columns: 1fr; } .ov-map { height: 460px; } }

  /* Map beside its key: the space is used, and a narrower map puts Britain
     back in the frame instead of half of northern Europe. */
  .teammap-layout {
    display: grid;
    grid-template-columns: 1fr minmax(300px, 380px);
    gap: 0;
    align-items: stretch;
  }
  /* Fits under the top bar and any banner, so its bottom is never off-screen. */
  .teammap { height: calc(100dvh - 125px - var(--banner-h)); min-height: 420px; border-top: none; }
  .teammap-side { overflow-y: auto; border-left: 1px solid var(--border); padding-top: 8px; }
  .teammap-filters { grid-template-columns: 1fr; }

  /*
   * Master and detail, side by side.
   *
   * Only from 1100px: a list and a dossier each need real width, and squeezing
   * both into a small laptop window makes each worse than either alone. Below
   * that the manager screens stay a single column and opening an account
   * navigates, exactly as on a phone.
   */
  @media (min-width: 1100px) {
    .content.split {
      display: grid;
      grid-template-columns: minmax(320px, 400px) 1fr;
      gap: 0;
      padding: 0;
      overflow: hidden;
      align-items: stretch;
    }
    .split-list {
      overflow-y: auto;
      padding: 18px 18px 40px;
      border-right: 1px solid var(--border);
      min-width: 0;
    }
    .split-detail { overflow-y: auto; padding: 18px 24px 40px; min-width: 0; }
    .split-detail .content-inner { max-width: 720px; margin: 0; }
    /* Which row the detail belongs to. */
    .row-on { background: var(--accent-soft); box-shadow: inset 3px 0 0 var(--accent); }
  }

  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%;
    transform: translate(-50%, -46%) scale(.98);
    width: 560px; max-height: 84vh;
    border-radius: 16px; opacity: 0;
    transition: opacity .18s, transform .18s;
  }
  .sheet.open { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  .sheet-grip { display: none; }
  .sheet-foot { padding-bottom: 12px; }

  #toasts { bottom: 24px; }

  .stat-row { grid-template-columns: repeat(4, 1fr); }
  .row { min-height: 56px; }
}

/* ------------------------------------------------------------ google maps --
   The route planner's look on a Google map: numbered pins and the route line
   are drawn by the map itself (lib/gmaps.js); this only sizes the boxes. */

.gmap { position: relative; width: 100%; overflow: hidden; background: var(--surface-2); }
.gmap-card { height: 300px; border-radius: var(--radius); border: 1px solid var(--border); }

/* ------------------------------------------------------- planning the day -- */
.plan-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; }
.plan-controls .field { margin: 0; min-width: 0; }
/* iOS draws a time input with its own height and minimum width, so beside a
   select it stood taller and ran into its neighbour. Same box for both. */
/* Beside a time box (sized globally above), the select is given the same
   height and its own arrow, so the two read as a pair. */
.plan-controls select {
  height: 46px; min-width: 0; width: 100%;
  -webkit-appearance: none; appearance: none;
  display: block; text-align: left; line-height: 22px;
  padding-right: 34px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-faint) 50%), linear-gradient(135deg, var(--text-faint) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.plan-sum { margin-top: 10px; }
.plan-line { font-size: 15px; }
.plan-line span { color: var(--text-dim); font-size: 13.5px; }
.plan-fixes { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
/* A suggestion is a sentence: read from the left, icon beside the first line. */
.plan-fixes .btn { justify-content: flex-start; text-align: left; align-items: flex-start; line-height: 1.35; padding: 10px 12px; }
.plan-fixes .btn svg { flex-shrink: 0; margin-top: 1px; }
/* The two reorders are buttons, not sentences. */
.plan-fixes .action-grid .btn { justify-content: center; text-align: center; align-items: center; }
.plan-fixes:empty { display: none; }
.avatar.avatar-warn { background: color-mix(in srgb, var(--red) 22%, var(--surface)); color: var(--red); }
.row .meta.warn-text, .meta.warn-text { color: var(--red); }


/* A button that reads as a link, for an action inside a sentence. */
.linkish { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

/* The "my location" button on the Google maps, sized and placed like Google's
   own zoom control so the two read as one set. */
.gmap-locate {
  width: 40px; height: 40px; margin: 0 10px 10px 0;
  display: grid; place-items: center;
  background: #fff; color: #5f6368; border: 0; border-radius: 2px;
  box-shadow: rgba(0, 0, 0, .3) 0 1px 4px -1px; cursor: pointer;
}
.gmap-locate:hover { color: #1a73e8; }
.gmap-locate.busy { color: #1a73e8; animation: gmap-pulse 1s ease-in-out infinite; }
@keyframes gmap-pulse { 50% { opacity: .45; } }
@media (prefers-reduced-motion: reduce) { .gmap-locate.busy { animation: none; } }

/* The area map's opening filter: a small panel under its buttons. */
.mapfilter {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 8px; display: flex; flex-direction: column; gap: 6px;
  max-width: 100%;
}
.mapfilter-row { display: flex; gap: 6px; flex-wrap: wrap; }
.mapfilter .chip { padding: 5px 10px; font-size: 13px; }
.mapfilter-status {
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  box-shadow: var(--shadow); padding: 5px 12px; font-size: 13px; color: var(--text-dim);
}

/* ------------------------------------------------- core brands (Brands tab) -- */

.core-grid { display: grid; gap: 10px; }
@media (min-width: 860px) { .core-grid { grid-template-columns: repeat(3, 1fr); } }
.core-tile { display: block; width: 100%; text-align: left; padding: 14px; }
.core-grid > .card { margin: 0; }
.core-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.core-pct { font-weight: 700; font-size: 15px; }
.core-money { font-size: 24px; font-weight: 700; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.core-money .meta { font-size: 14px; font-weight: 500; }
.core-bar { position: relative; overflow: visible; margin-bottom: 8px; }
.core-pace { position: absolute; top: -3px; width: 2px; height: 15px; margin-left: -1px; background: var(--text); border-radius: 1px; opacity: .55; }
.core-line { margin-bottom: 2px; }
.core-pct.up, .core-line.up { color: var(--green); }
.core-pct.down, .core-line.down { color: var(--red); }
.core-table { display: grid; gap: 2px; margin-bottom: 16px; }
.core-row { display: grid; grid-template-columns: 34px 1fr 84px 40px 1fr; gap: 8px; align-items: center; padding: 6px 4px; border-radius: 8px; font-variant-numeric: tabular-nums; }
.core-row.now { background: var(--accent-soft); }
.core-row input { width: 100%; min-width: 0; padding: 6px 8px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.core-row input::placeholder { color: var(--text-faint); }
.core-headrow span { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.core-total { border-top: 1px solid var(--border); border-radius: 0; margin-top: 4px; padding-top: 10px; }

/* ------------------------------------------------- targets (manager) -- */

.targets-card { margin-bottom: 14px; }
.targets-head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 4px; }
.targets-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.targets-table { min-width: 640px; padding: 6px 14px 12px; }
.targets-row { display: grid; grid-template-columns: 120px repeat(5, 1fr); gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.targets-row:last-child { border-bottom: none; }
.targets-headrow span { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.targets-cell { white-space: nowrap; }
.targets-cell.now { background: var(--accent-soft); border-radius: 6px; padding: 2px 6px; margin: -2px -6px; }
.targets-pct { margin-left: 6px; font-weight: 700; font-size: 12px; }
.targets-pct.up { color: var(--green); }
.targets-pct.down { color: var(--red); }
.targets-edit { display: grid; grid-template-columns: 110px repeat(4, 1fr); gap: 8px; align-items: center; }
.targets-edit input { width: 100%; min-width: 0; padding: 6px 8px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); border-radius: 8px; font: inherit; }
.targets-head .grow { flex: 1; min-width: 0; }
.targets-head .title { font-weight: 650; font-size: 16px; }
.targets-head .meta { font-size: 13px; color: var(--text-dim); margin-top: 2px; }

/* Invoices tab: where the figures came from, and its small messages. */
.inv-source { display: flex; align-items: center; justify-content: center; gap: 6px; margin: 10px 0 2px; font-size: 12px; color: var(--text-faint); }
.inv-source:empty { display: none; }
.inv-source.warn { color: var(--amber); }
.empty .inv-source { margin-top: 4px; }
.inv-note { margin: 18px 0; text-align: center; font-size: 14px; color: var(--text-faint); }

/* Manager Reps table: the team at a desk. */
@media (min-width: 860px) { .content-inner.team-wide { max-width: 1200px; } }
.reps-toolbar { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; flex-wrap: wrap; }
.reps-card { padding: 0; overflow: hidden; }
.reps-scroll { overflow-x: auto; }
.reps-table { min-width: 860px; }
.reps-table th, .reps-table td.n { white-space: nowrap; }
.reps-table .n { width: auto; }
.reps-table .th-sort { background: none; border: 0; padding: 0; font: inherit; color: inherit; text-transform: inherit; letter-spacing: inherit; cursor: pointer; }
.reps-row { cursor: pointer; }
.reps-row:hover td, .reps-row:focus-visible td { background: var(--surface-2); }
.reps-row:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.reps-table td { vertical-align: middle; }
.reps-name { font-weight: 600; }
.reps-sub { font-size: 12px; color: var(--text-faint); }
.reps-areas { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.reps-set { font-size: 12px; }
.reps-bar { display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.reps-bar-track { width: 70px; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; display: inline-block; }
.reps-bar-fill { display: block; height: 100%; background: var(--accent); }
.reps-stale { color: var(--amber); }
.reps-chev { width: 24px; color: var(--text-faint); }
.reps-foot { margin-top: 12px; font-size: 13px; color: var(--text-faint); line-height: 1.5; }
.reps-foot p { margin: 0 0 6px; }
.reps-warn { color: var(--amber); }

/* A site lent to this rep by a manager's cover. */
.cover-banner { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding: 9px 12px; border-radius: var(--radius-sm); background: #dbe8f7; color: #23557f; font-size: 14px; font-weight: 500; }
@media (prefers-color-scheme: dark) { .cover-banner { background: #1f3247; color: #a9c9ec; } }

/* Cover: the manager's sheet and list. */
.cover-h { font-size: 13px; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); margin: 18px 0 8px; }
.cover-sheet .cover-h:first-child { margin-top: 0; }
.cover-help { font-size: 13px; color: var(--text-faint); margin: 8px 0; }
.cover-count { margin-top: 8px; font-size: 14px; font-weight: 600; }
.cover-search { width: 100%; padding: 10px 12px; margin-top: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cover-actions { display: flex; gap: 8px; margin: 8px 0; }
.cover-list { max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.cover-quick { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.cover-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reps-covers { margin-top: 18px; }
.reps-covering { color: #23557f; margin-top: 4px; }
.reps-past td { color: var(--text-faint); }

/* Area map: another site at the same position as the open one. */
.map-also { font-size: 12px; color: var(--text-dim); padding: 8px 10px; background: var(--surface-2); border-radius: var(--radius-sm); margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px; }

/* A run's travel mode: drive, walk or cycle. */
.mode-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 10px 0 0; flex-wrap: wrap; }
.mode-label { font-size: 13px; color: var(--text-dim); }

/* New lead: Google suggestions under the name box. */
.lead-suggest { margin-top: 6px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); overflow: hidden; }
.lead-suggest-row { display: block; width: 100%; text-align: left; padding: 10px 12px; background: none; border: 0; border-bottom: 1px solid var(--border); cursor: pointer; }
.lead-suggest-row:hover, .lead-suggest-row:focus-visible { background: var(--surface-2); }
.lead-suggest-main { font-weight: 600; font-size: 15px; }
.lead-suggest-sub { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
.lead-suggest-attr { font-size: 11px; color: var(--text-faint); padding: 6px 12px; text-align: right; }

/* Find places (Leads): search Google on a map, pick places as leads. */
.leadmap-controls { position: absolute; left: 10px; right: 10px; top: 10px; z-index: 4; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; pointer-events: none; }
.leadmap-controls > * { pointer-events: auto; }
.leadmap-search { display: flex; gap: 8px; width: 100%; max-width: 520px; }
.leadmap-input { flex: 1; min-width: 0; padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow); font-size: 16px; }
.leadmap-row { display: flex; gap: 8px; flex-wrap: wrap; }
.leadmap-here { align-self: center; box-shadow: var(--shadow); }
.leadmap-bar { position: absolute; left: 10px; right: 60px; bottom: 24px; z-index: 4; display: flex; gap: 8px; align-items: center; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; box-shadow: var(--shadow); }
.kb-open .leadmap-bar { display: none; }
.leadmap-card { position: absolute; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px 12px; font-size: 14px; }
.leadmap-card-close { position: absolute; top: 6px; right: 6px; width: 36px; height: 36px; display: flex; align-items: center; justify-content: center; background: none; border: 0; border-radius: 50%; color: var(--text-faint); cursor: pointer; }
.leadmap-card-close:hover, .leadmap-card-close:focus-visible { background: var(--surface-2); color: var(--text); }
.leadmap-card-title { font-weight: 700; font-size: 15px; padding-right: 34px; }
.leadmap-card-meta { font-size: 12px; color: var(--text-dim); margin: 2px 0 6px; }
.leadmap-card-line { display: block; font-size: 13px; color: var(--text-dim); margin-top: 3px; }
.leadmap-card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }

/* While Google's map loads (a relaunch on weak signal): never an empty box. */
.map-loading-wrap { position: relative; }
.map-loading-chip { position: absolute; top: 18px; left: 18px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); font-size: 13px; color: var(--text-dim); }
.map-loading-full { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 15px; color: var(--text-dim); background: var(--surface-2); }
.map-loading-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); animation: map-loading-pulse 1s ease-in-out infinite alternate; }
@keyframes map-loading-pulse { from { opacity: .25; transform: scale(.8); } to { opacity: 1; transform: scale(1.1); } }
@media (prefers-reduced-motion: reduce) { .map-loading-dot { animation: none; } }

/* Customers on a desk: the account drawn beside the list. */
@media (min-width: 1100px) {
  .split-detail.split-account { padding: 0; }
  .split-account .content { overflow: visible; padding: 0 24px 40px; }
  .split-account .topbar { position: sticky; top: 0; z-index: 2; }
  .split-account .content-inner { max-width: 820px; margin: 0; }
}

/* Today on a desk: the day, the to-do list and the week side by side. */
@media (min-width: 1100px) {
  .content-inner.today-desk { max-width: 1400px; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .today-col { min-width: 0; }
  .today-col > :first-child { margin-top: 0; }
  .today-desk .core-grid { grid-template-columns: 1fr; }
}

/* Diary on a desk: plan the week — five days and who to see. */
@media (min-width: 1100px) {
  .wk-content { padding: 16px 20px 24px; }
  .wk-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
  .wk-board { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
  .wk-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 10px; min-height: 420px; display: flex; flex-direction: column; gap: 6px; }
  .wk-day.wk-today { border-color: var(--accent); }
  .wk-day.wk-past { opacity: .7; }
  .wk-day.wk-over { background: var(--accent-soft); border-style: dashed; }
  .wk-head { display: flex; align-items: flex-start; justify-content: space-between; }
  .wk-name { font-weight: 700; }
  .wk-date, .wk-count { font-size: 12px; color: var(--text-faint); }
  .wk-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
  .wk-visit { display: flex; gap: 8px; align-items: baseline; padding: 7px 8px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; cursor: grab; }
  .wk-visit:hover, .wk-visit:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .wk-visit.done { opacity: .6; }
  .wk-time { font-variant-numeric: tabular-nums; color: var(--text-dim); flex-shrink: 0; }
  .wk-who { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
  .wk-tick { color: var(--green); }
  .wk-side { position: sticky; top: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; max-height: calc(100dvh - 140px); display: flex; flex-direction: column; }
  .wk-side-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
  .wk-search, .wk-near { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
  .wk-near { margin-bottom: 8px; }
  .wk-cands { overflow-y: auto; flex: 1; }
  .wk-cand { cursor: grab; }
  .wk-cand-name { text-decoration: none; color: var(--text); font-weight: 600; font-size: 14px; text-align: left; }
  .wk-book { display: flex; gap: 4px; margin-top: 6px; flex-wrap: wrap; }
  .wk-book .btn { padding: 2px 8px; min-height: 0; height: 26px; font-size: 12px; }
}

/* A run on a desk: map on the left, the day's plan and stops on the right. */
@media (min-width: 1100px) {
  .content-inner.run-desk { max-width: 1400px; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; align-items: start; }
  .run-desk-map { position: sticky; top: 0; }
  .run-desk-map .gmap-card, .run-desk-map .gmap { height: calc(100dvh - 330px); min-height: 380px; }
  .run-desk-plan > .section-title:first-child { margin-top: 0; }
}

/* Leads on a desk: the pipeline as a board. */
@media (min-width: 1100px) {
  .content-inner.lead-board-wrap { max-width: none; }
  .lead-board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(140px, 1fr); gap: 10px; overflow-x: auto; padding-bottom: 8px; }
  .lead-col { background: var(--surface-2); border-radius: var(--radius); padding: 10px; min-height: 360px; display: flex; flex-direction: column; gap: 8px; }
  .lead-col.closed { opacity: .85; }
  .lead-col.lead-over { outline: 2px dashed var(--accent); outline-offset: -2px; background: var(--accent-soft); }
  .lead-col-head { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px; }
  .lead-col-list { display: flex; flex-direction: column; gap: 8px; }
  .lead-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 9px 10px; cursor: grab; }
  .lead-card:hover, .lead-card:focus-visible { border-color: var(--accent); }
  .lead-card-name { font-weight: 600; font-size: 14px; }
  .lead-card .meta { font-size: 12px; line-height: 1.4; }
  .lead-add { justify-content: flex-start; }
}

/* Routes on a desk: the map always up, the runs in a panel beside it. */
#screen-routes.active:has(.rd-layout) { display: flex; flex-direction: column; height: 100%; }
@media (min-width: 1100px) {
  .rd-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: 380px minmax(0, 1fr); }
  .rd-side { overflow-y: auto; padding: 14px 16px 30px; border-right: 1px solid var(--border); background: var(--surface); }
  .rd-map { position: relative; min-height: 0; background: var(--surface-2); }
  .rd-seg { margin-bottom: 12px; }
  .rd-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; margin-right: 4px; }
  .rd-back { font-size: 13px; text-decoration: none; }
  .rd-title { font-size: 18px; margin: 6px 0 4px; }
  .rd-actions { display: flex; gap: 8px; margin: 12px 0; }
  .rd-num.warn { background: var(--red); color: #fff; }
  .rd-hours { margin-top: 4px; }
  .rd-num { width: 26px; height: 26px; border-radius: 50%; background: var(--accent); color: #16191f; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; margin-right: 6px; }
}

/* A lead's target: brands and estimated HL. */
.lead-target { display: block; width: 100%; text-align: left; padding: 0; }
.lead-target-brands { display: flex; gap: 6px; flex-wrap: wrap; }
.lead-monthly { margin: 6px 0 0; font-size: 13px; color: var(--text-dim); }
.lead-card-target { color: var(--accent) !important; font-weight: 600; }

/* Stock: the rep's warehouse first, the other beside it. */
.today-top-btns { display: flex; gap: 8px; }
.stock-row { align-items: center; }
.stock-cols { display: flex; gap: 10px; flex-shrink: 0; }
.stock-col { text-align: right; min-width: 74px; }
.stock-col.mine .stock-v { color: var(--text); }
.stock-k { font-size: 10.5px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-faint); }
.stock-v { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--text-dim); }
.stock-v.bad { color: var(--red); }
.stock-h { font-size: 11px; color: var(--text-faint); }
@media (max-width: 420px) { .stock-col { min-width: 62px; } .stock-v { font-size: 16px; } }
/* A phone: the product full width, its figures underneath. */
@media (max-width: 700px) {
  .stock-row { flex-wrap: wrap; row-gap: 6px; }
  .stock-row > .grow { flex: 1 0 100%; }
  .stock-row .stock-cols { flex: 1; justify-content: flex-start; gap: 18px; }
  .stock-row .stock-col { text-align: left; }
}

/* An account's stock: folded to one line until opened. */
.fold { margin-top: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.fold-head { display: flex; align-items: center; gap: 12px; cursor: pointer; list-style: none; padding: 12px 14px; -webkit-tap-highlight-color: transparent; user-select: none; }
.fold-head::-webkit-details-marker { display: none; }
.fold-head:active { background: var(--surface-2); }
.fold-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.fold-title { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-dim); }
.fold-pills { display: flex; flex-wrap: wrap; gap: 6px; }
.fold-btn { display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0; padding: 6px 10px 6px 12px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 600; }
.fold-chev { display: inline-flex; transform: rotate(90deg); transition: transform .15s; }
.fold[open] .fold-chev { transform: rotate(-90deg); }
.fold .when-open, .fold[open] .when-shut { display: none; }
.fold[open] .when-open { display: inline; }
.fold[open] .fold-head { border-bottom: 1px solid var(--border); }
.fold > .list { margin: 0; border: 0; box-shadow: none; border-radius: 0; }
.fold > .inv-note { padding: 0 14px 12px; }
.fold-pills .pill:not(.due):not(.warn):not(.ok) { background: var(--surface-2); color: var(--text-dim); }

/* The phone's To do on Today, folded like an account's stock. */
.fold-todo { margin-top: 12px; }
.fold-body { padding: 0 12px 12px; }
.fold-body .todo-bucket { margin-top: 12px; }
.fold-body .list { margin-top: 6px; }
.fold-more { margin-top: 10px; }
/* Recent activity: a row with an icon and a chevron, so it reads as a link. */
.activity-link { margin-top: 12px; }
.activity-link .row { width: 100%; text-align: left; }
.activity-link-icon { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.today-head .btn-ghost { border: 1px solid var(--border); }

/* ------------------------------------------------ Customers on a desk -- */
@media (min-width: 1100px) {
  /* The table fills the screen; picking an account narrows it beside the panel. */
  .content.split.acct-split { grid-template-columns: 1fr; }
  .content.split.acct-split.has-detail { grid-template-columns: minmax(360px, 440px) 1fr; }
  .acct-split:not(.has-detail) .split-detail { display: none; }
  .acct-split:not(.has-detail) .split-list { border-right: 0; padding: 18px 28px 40px; }
  .acct-split .split-list > .search, .acct-split .split-list > .chip-row { max-width: 640px; }

  .acct-table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
  .acct-table { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: auto; }
  .acct-table thead th { position: sticky; top: 0; z-index: 1; background: var(--surface-2); border-bottom: 1px solid var(--border); padding: 0; text-align: left; white-space: nowrap; }
  .acct-table th.num { text-align: right; }
  .th-sort { width: 100%; display: inline-flex; align-items: center; gap: 4px; padding: 10px 12px; font-size: 11.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--text-dim); cursor: pointer; }
  .th-sort:hover, .th-sort.on { color: var(--text); }
  th.num .th-sort { justify-content: flex-end; }
  .th-arrow { font-size: 9px; color: var(--accent); min-width: 9px; }
  .acct-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
  .acct-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
  .acct-table tbody tr { cursor: pointer; }
  .acct-table tbody tr:hover { background: var(--surface-2); }
  .acct-table tbody tr:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
  .acct-table tbody tr:last-child td { border-bottom: 0; }
  .acct-table td:first-child { max-width: 380px; }
  .acct-name { display: flex; align-items: baseline; gap: 8px; font-weight: 600; min-width: 0; }
  .acct-name .truncate { min-width: 0; }
  .acct-pc { font-size: 12px; font-weight: 400; color: var(--text-faint); white-space: nowrap; flex-shrink: 0; }
  .acct-table .meta { font-size: 12.5px; }
  .acct-table .faint { color: var(--text-faint); }
  .acct-table .up { color: var(--green); font-weight: 600; }
  .acct-table .down { color: var(--red); font-weight: 600; }
  .acct-table .pill { font-size: 10.5px; }
  /* Beside an open account: the name and the money. */
  .has-detail .acct-table .col-x { display: none; }
  /* The name column takes what is left and truncates, so the figures never clip. */
  .has-detail .acct-table td:first-child { width: 100%; max-width: 0; }
  .has-detail .acct-name { overflow: hidden; }
  .has-detail .acct-pc { display: none; }

  /* The account as a dashboard. */
  .acct-top { gap: 12px; }
  .acct-desk { max-width: 1240px !important; }
  .acct-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
  .acct-actions .btn { width: auto; }
  .kpi-strip { grid-template-columns: repeat(6, minmax(0, 1fr)); margin-top: 14px; }
  .kpi-strip .stat .v { font-size: 20px; }
  .stat-up .v { color: var(--green); }
  .stat-down .v { color: var(--red); }
  .kpi-note { margin: 6px 2px 0; font-size: 12.5px; }
  .acct-dash { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, 1fr); gap: 24px; align-items: start; }
  .acct-main, .acct-side { min-width: 0; }
  .acct-side > .section-title:first-child, .acct-side > :first-child .section-title { margin-top: 0; }
  .acct-main .today-head { margin-top: 22px; }
  .clamp-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

  .month-chart-card { padding: 14px 16px 10px; }
  .month-chart-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; margin-bottom: 10px; }
  .month-chart { display: grid; grid-template-columns: repeat(12, 1fr); gap: 6px; height: 170px; }
  .month-col { display: flex; flex-direction: column; align-items: stretch; min-width: 0; }
  .month-val { font-size: 10.5px; color: var(--text-faint); text-align: center; height: 14px; white-space: nowrap; overflow: hidden; }
  .month-bar-track { flex: 1; display: flex; align-items: flex-end; }
  .month-bar { width: 100%; background: var(--accent); opacity: .55; border-radius: 4px 4px 0 0; min-height: 0; }
  .month-col.now .month-bar { opacity: 1; }
  .month-col:hover .month-bar { opacity: .85; }
  .month-label { font-size: 11px; color: var(--text-dim); text-align: center; margin-top: 4px; }
}
/* A narrow panel (table beside it, a smaller laptop): one column again. */
@media (min-width: 1100px) and (max-width: 1499px) {
  .has-detail .acct-dash { grid-template-columns: 1fr; }
  .has-detail .kpi-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
