/* ============================================================
   Shop Schedule Calendar — styles
   Design intent (from PRD):
   - Quiet neutral base so resource colors are the only loud thing
   - Small, consistent corner radius (no pills)
   - No soft drop-shadow "card kit" look; thin borders/dividers instead
   - Large, legible type readable across a room on a TV
   - No all-caps eyebrows, no arrows, no gradients
   ============================================================ */

:root {
  /* Neutral base palette (cool grays, not cream, not near-black+neon) */
  --bg:            #eef0f2;   /* app background */
  --surface:       #ffffff;   /* panels, calendar body */
  --surface-2:     #f6f7f8;   /* subtle fills, headers */
  --border:        #d5d9dd;   /* thin dividers */
  --border-strong: #b9bfc6;
  --text:          #1b1f24;   /* primary text */
  --text-muted:    #5b636c;   /* secondary text */
  --text-faint:    #8b929a;

  /* One quiet action color for buttons/nav (not loud) */
  --accent:        #2f3a45;   /* slate */
  --accent-hover:  #3c4855;
  --focus-ring:    #5a7ea8;

  --danger:        #a03329;

  --radius:        4px;       /* small, consistent */
  --gap:           16px;

  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
          Helvetica, Arial, sans-serif;

  /* Sizes tuned to be legible from a distance */
  --fs-base: 16px;
  --fs-lg:   19px;
  --fs-xl:   24px;
  --fs-2xl:  32px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: var(--fs-base);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar .brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: 0.1px;
  margin-right: 8px;
  white-space: nowrap;
}
.brand-logo { height: 30px; width: auto; flex: none; }
body.display .brand-logo { height: 40px; }

.topbar .spacer { flex: 1 1 auto; }

.nav-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.range-label {
  font-size: var(--fs-lg);
  font-weight: 600;
  min-width: 220px;
  text-align: center;
}

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 9px 14px;
  cursor: pointer;
  line-height: 1;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }

.btn.primary {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}
.btn.primary:hover { background: var(--accent-hover); }

.btn.danger {
  color: #fff;
  background: var(--danger);
  border-color: var(--danger);
}

.btn.ghost {
  background: transparent;
  border-color: transparent;
}
.btn.ghost:hover { background: var(--surface-2); }

.btn.icon { padding: 9px 12px; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child  { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

/* ---------- Calendar area ---------- */
.calendar-wrap {
  flex: 1 1 auto;
  min-height: 0;
  padding: 16px 20px 8px;
  display: flex;
  flex-direction: column;
}

#calendar {
  flex: 1 1 auto;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px;
}

/* ---------- Legend strip ---------- */
.legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 20px;
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-base);
  font-weight: 600;
}
.legend .swatch {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.18);
  flex: none;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20,24,28,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
/* Delete warning sits above whatever opened it — including the Leads
   screen and its dialogs (z-index 200/210). */
#confirm-modal { z-index: 220; }
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow: auto;
}
.modal.wide { max-width: 680px; }
.modal header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.modal header h2 { margin: 0; font-size: var(--fs-lg); }
.modal .body { padding: 20px; }
.modal footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--border);
}
.modal footer .spacer { flex: 1 1 auto; }

/* ---------- Forms ---------- */
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="date"],
.field input[type="time"],
.field input[type="password"],
.field input[type="email"],
.field textarea,
.field select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.field textarea { min-height: 88px; resize: vertical; }
.field input:focus, .field textarea:focus, .field select:focus {
  outline: 2px solid var(--focus-ring);
  outline-offset: 0;
  border-color: var(--focus-ring);
}
.field .hint { color: var(--text-muted); font-size: 14px; margin-top: 6px; }

/* Address suggestions dropdown (Google Places, custom-rendered). */
.addr-wrap { position: relative; }
.addr-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 1100;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: 0 8px 24px rgba(20,24,28,0.18);
  max-height: 260px; overflow-y: auto;
}
.addr-item { padding: 10px 12px; font-size: 14px; cursor: pointer; }
.addr-item:hover { background: var(--focus-ring); color: #fff; }

.row { display: flex; gap: 12px; }
.row > * { flex: 1; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.checkbox-row input { width: 18px; height: 18px; }


/* ---------- Resource settings list ---------- */
.res-list { display: flex; flex-direction: column; gap: 8px; }
.res-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.res-item { flex-wrap: wrap; }
.res-item.inactive { opacity: 0.55; }
.always-visible { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); white-space: nowrap; cursor: pointer; }
.always-visible input { width: 16px; height: 16px; }
.res-palette {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
  padding-left: 30px;
}
.res-palette .pal-swatch {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.2);
  padding: 0;
  cursor: pointer;
}
.res-palette .pal-swatch.selected {
  outline: 2px solid var(--text);
  outline-offset: 1px;
}
.res-palette .pal-swatch.used { opacity: 0.28; cursor: not-allowed; }
/* Same palette, but in the Add-resource popup it's not indented under a row. */
#addres-palette { padding-left: 0; margin-top: 0; }
#addres-palette .pal-swatch { width: 26px; height: 26px; }

/* Role badge, visibility checkboxes, created-by line, People add form */
.who { font-weight: 600; color: var(--text-muted); padding: 4px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); white-space: nowrap; }
.visible-list { display: flex; flex-wrap: wrap; gap: 8px; }
.visible-list label { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 6px 10px; cursor: pointer; }
.visible-list input { width: 16px; height: 16px; }
.visible-list input:disabled { cursor: default; }
.visible-list label:has(input:disabled) { opacity: 0.5; cursor: default; }
.visible-note { font-weight: 600; color: #166534; background: #dcfce7; border: 1px solid #bbf7d0; border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; font-size: 14px; }
.entry-meta { color: var(--text-muted); font-size: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.add-person { border-top: 1px solid var(--border); margin-top: 16px; padding-top: 16px; }
.add-person h3 { margin: 0 0 12px; font-size: var(--fs-base); }
.res-item select { font: inherit; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); color: var(--text); }
.res-item .drag {
  cursor: grab;
  color: var(--text-faint);
  font-size: 18px;
  user-select: none;
}
.res-item input[type="text"] {
  flex: 1;
  font: inherit;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius);
  padding: 6px 8px;
}
.res-item input[type="text"]:hover { border-color: var(--border); }
.res-item input[type="text"]:focus { border-color: var(--focus-ring); outline: none; background: var(--surface); }
.res-item .text-toggle {
  font-weight: 700;
  min-width: 42px;
  padding: 8px 10px;
}
.res-item input[type="color"] {
  width: 38px; height: 34px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 2px;
  background: var(--surface);
  cursor: pointer;
}

/* ---------- Login ---------- */
.login-wrap {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
}
.login-logo { display: block; height: 64px; width: auto; margin: 0 auto 14px; }
.login-card h1 { font-size: var(--fs-xl); margin: 0 0 4px; }
.login-card p.sub { color: var(--text-muted); margin: 0 0 20px; }
.login-error { color: var(--danger); font-size: 14px; margin-top: 12px; min-height: 18px; }
.login-note { color: var(--text-muted); font-size: 14px; margin-top: 4px; min-height: 18px; }

/* ---------- FullCalendar restyle (quiet, TV-legible) ---------- */
.fc {
  --fc-border-color: var(--border);
  --fc-today-bg-color: #eef3f8;
  --fc-page-bg-color: var(--surface);
  --fc-neutral-bg-color: var(--surface-2);
  font-family: var(--font);
}
.fc .fc-col-header-cell-cushion {
  padding: 8px 4px;
  font-weight: 700;
  font-size: var(--fs-base);
  color: var(--text);
  text-decoration: none;
}
.fc .fc-daygrid-day-number,
.fc .fc-timegrid-slot-label-cushion {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}
/* Today: red header text so the current day is obvious at a glance. */
.fc .fc-day-today .fc-col-header-cell-cushion { color: #d7263d; }

/* Event chips: square-ish, solid resource color, legible label */
.fc .fc-event {
  border: none;
  border-radius: 3px;
  padding: 2px 6px;
  font-weight: 600;
  font-size: var(--fs-base);
  cursor: pointer;
}
.fc .fc-event .fc-event-main { color: inherit; }
.fc .fc-daygrid-event { white-space: normal; }
.fc .fc-h-event .fc-event-title { font-weight: 700; }

.fc .fc-button-primary,
.fc .fc-button { display: none; } /* we use our own toolbar */

.fc .fc-daygrid-event-harness { cursor: grab; margin-bottom: 2px; }
.fc .fc-daygrid-event-harness:active { cursor: grabbing; }

/* WEEK view: let each day's event area fill the tall column so entries
   can be dropped anywhere in a day (including empty days). */
.fc-dayGridWeek-view .fc-daygrid-day-frame { display: flex; flex-direction: column; }
.fc-dayGridWeek-view .fc-daygrid-day-events { flex: 1 1 auto; min-height: 60px; }

/* MONTH view: keep rows uniform and bars compact (one line, no wrapping).
   Every month cell is the same fixed height (content is capped at 3 bars +
   "more"), so a day with entries never grows taller than an empty day.
   Make the event area FILL the whole cell so a chip can be dropped anywhere
   in a day, not just in the top strip — otherwise a drop in the empty lower
   part of a cell lands on a neighbouring day. */
.fc-dayGridMonth-view .fc-daygrid-day-frame { min-height: 132px; display: flex; flex-direction: column; }
.fc-dayGridMonth-view .fc-daygrid-day-events { flex: 1 1 auto; min-height: 30px; }
.fc-dayGridMonth-view .fc-daygrid-event { white-space: nowrap; }
/* Entry text: single line, all one size; week view shrinks it to fit. */
.chip-content { overflow: hidden; }
.chip-title { white-space: normal; overflow-wrap: anywhere; }
.chip-time { white-space: nowrap; font-weight: 600; opacity: 0.9; font-size: 0.8em; }
/* SortableJS drag cues */
.sortable-ghost { opacity: 0.4; }
.sortable-chosen { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
/* Month view: keep day cells readable, allow the grid to scroll if a day is full */
.fc .fc-daygrid-day-number { padding: 4px 6px; }

/* "+N more" link and the day popover it opens */
.fc .fc-daygrid-more-link {
  font-weight: 600;
  color: var(--text-muted);
  padding: 1px 6px;
  text-decoration: none;
}
.fc .fc-daygrid-more-link:hover { color: var(--text); }
.fc .fc-popover {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: none;
}
.fc .fc-popover-header {
  background: var(--surface-2);
  color: var(--text);
  font-weight: 700;
  padding: 8px 10px;
}
.fc .fc-popover-body { padding: 8px; }

/* ---------- List / agenda view (friendly on phones) ---------- */
.fc .fc-list { border-color: var(--border); border-radius: var(--radius); }
.fc .fc-list-day-cushion { background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 15px; }
.fc .fc-list-event td { cursor: pointer; padding: 12px 14px; }
.fc .fc-list-event:hover td { background: var(--surface-2); }
.fc .fc-list-event-title { color: var(--text); font-weight: 600; font-size: 16px; }
.fc .fc-list-event-time { color: var(--text-muted); }
.fc .fc-list-event-dot { border-width: 7px; }
.fc .fc-list-empty { background: var(--surface); color: var(--text-muted); }

/* ---------- Display mode (wall TV): bigger, no chrome ---------- */
body.display .topbar .nav-group.editing,
body.display .topbar .brand-actions { display: none; }

/* --disp is a shrink factor (1 = full size) set by fitDisplay() so a busy
   week is scaled down just enough to fit the TV with no scrolling. */
body.display {
  --disp: 1;
  --fs-base: 20px;
  --fs-lg:   26px;
}
body.display .topbar {
  padding: 14px 24px;
}
body.display #calendar .fc-col-header-cell-cushion { font-size: calc(22px * var(--disp)); }
body.display .fc .fc-event {
  font-size: calc(20px * var(--disp));
  padding: calc(4px * var(--disp)) calc(8px * var(--disp));
}
body.display .fc .fc-daygrid-event-harness { margin-bottom: calc(2px * var(--disp)); }
body.display .legend { padding: 16px 24px; }
body.display .legend .legend-item { font-size: 20px; }
body.display .legend .swatch { width: 22px; height: 22px; }

/* Display mode: an invisible strip across the top; hovering it reveals
   an X to exit. Hidden entirely when not in display mode. */
#display-topbar { display: none; }
body.display #display-topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 60px;
  display: flex; align-items: center; justify-content: flex-end;
  padding: 0 16px; z-index: 60;
}
#exit-display {
  opacity: 0; transition: opacity 0.15s ease;
  background: rgba(20,24,28,0.6); color: #fff; border: none;
  font-size: 20px; line-height: 1; padding: 10px 14px; cursor: pointer;
}
#display-topbar:hover #exit-display,
#exit-display:focus-visible { opacity: 1; }

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.clock { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--text-muted); }

/* ---------- Overflow menu (⋮) ---------- */
/* A ⋮ dropdown everywhere — Resources / People / Display Mode / Sign out
   live behind it on desktop and phones alike. */
.menu-wrap { position: relative; display: inline-flex; }
.menu-toggle { display: inline-flex; font-size: 20px; line-height: 1; }
.menu-panel {
  display: none; position: absolute; right: 0; top: calc(100% + 8px);
  flex-direction: column; align-items: stretch; gap: 4px;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 6px; min-width: 190px; z-index: 55;
  box-shadow: 0 8px 28px rgba(0,0,0,0.16);
}
.menu-panel.open { display: flex; }
.menu-panel .btn { justify-content: flex-start; text-align: left; width: 100%; border: none; background: transparent; padding: 12px 12px; }
.menu-panel .btn:hover { background: var(--surface-2); }

/* View dropdown (List / Week / Month) */
.view-toggle { display: inline-flex; align-items: center; gap: 8px; min-width: 96px; justify-content: space-between; }
.view-toggle .caret { font-size: 12px; color: var(--text-muted); }
.view-menu .menu-panel { min-width: 140px; }
.view-menu .menu-panel .btn.active { background: var(--accent); color: #fff; }
.view-menu .menu-panel .btn.active:hover { background: var(--accent-hover); }

/* ============================================================
   Leads — private sales tracker (phone-first)
   ============================================================ */
.leads-screen {
  /* A full "page" above the calendar and ALL its top-bar chrome (menus,
     view dropdown). Its own dialogs (below) sit higher still. */
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; flex-direction: column;
}
/* The Leads editor / config dialogs must sit above the Leads screen,
   and the shared confirm dialog above those. */
#lead-modal, #leadcfg-modal { z-index: 210; }
/* Quick-add popups open from the lead form, so above it. */
#addstage-modal, #addstatus-modal { z-index: 215; }

/* ---------- Custom dropdown (app-styled select) ---------- */
/* Used for Stage / Status on the lead form so it matches the app instead of
   the browser's generic <select>, and can show status colors + a "+ New" row. */
.cselect { position: relative; }
.cselect-btn {
  width: 100%; display: flex; align-items: center; gap: 8px;
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  padding: 10px 12px; cursor: pointer; text-align: left;
}
.cselect-btn:hover { border-color: var(--border); }
.cselect-btn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 0; border-color: var(--focus-ring); }
.cselect-btn .cselect-label { flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-btn .caret { flex: none; font-size: 12px; color: var(--text-muted); }
.cselect-dot { width: 14px; height: 14px; border-radius: 50%; flex: none; border: 1px solid rgba(0,0,0,0.15); }
.cselect-menu {
  /* Fixed + JS-positioned so a scrolling modal can never clip it. */
  position: fixed; z-index: 3000;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 6px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.18);
  max-height: 264px; overflow-y: auto; overflow-x: hidden;
}
.cselect-opt .cselect-sub { white-space: nowrap; }
.cselect-opt {
  width: 100%; display: flex; align-items: center; gap: 8px;
  font: inherit; color: var(--text); background: transparent; border: none;
  padding: 10px 10px; border-radius: 8px; cursor: pointer; text-align: left;
}
.cselect-opt:hover { background: var(--surface-2); }
.cselect-opt.active { background: var(--surface-2); font-weight: 600; }
.cselect-opt .cselect-sub { color: var(--text-muted); font-weight: 400; font-size: 13px; }
.cselect-opt.add { color: var(--accent); font-weight: 600; border-top: 1px solid var(--border); margin-top: 4px; }
.cselect-opt .cselect-dot { width: 12px; height: 12px; }
.cselect-color { width: 48px; height: 38px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; }

/* ---------- Leads grid (PC / spreadsheet view) ---------- */
/* The "Columns" button only makes sense on the wide grid. */
.leads-cols-btn { display: none; }
.leads-screen.grid-mode .leads-cols-btn { display: inline-flex; }
.leads-grid-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.leads-grid { width: 100%; border-collapse: collapse; font-size: 14px; table-layout: fixed; }
.leads-grid th {
  text-align: left; font-weight: 600; color: var(--text-muted); font-size: 13px;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--surface); z-index: 1; white-space: nowrap;
}
.leads-grid td { padding: 0; border-bottom: 1px solid var(--border); vertical-align: middle; }
.leads-grid tr.lg-group td {
  padding: 10px 12px; background: var(--surface-2); font-weight: 700; color: var(--text);
  border-bottom: 1px solid var(--border); position: sticky; left: 0;
}
.leads-grid tr.lg-group.lost td { color: var(--danger, #e2445c); }
.lg-group-count { color: var(--text-muted); font-weight: 600; margin-left: 6px; }
.lg-empty-row td { padding: 10px 12px; color: var(--text-muted); font-style: italic; }
.leads-grid tbody tr.lg-row:hover td { background: var(--surface-2); }
.lg-cell { padding: 0; }
.lg-cell .lg-val { display: block; padding: 10px 12px; min-height: 20px; cursor: text; overflow-wrap: anywhere; }
.lg-cell .lg-val.lg-empty { color: var(--text-muted); }
.lg-cell.lg-meta .lg-val { cursor: default; color: var(--text-muted); }
.lg-input { width: 100%; box-sizing: border-box; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--focus-ring); border-radius: 4px; padding: 8px 10px; }
.lg-status { min-width: 150px; }
.lg-statuswrap { padding: 6px 10px; }
.lg-chip-btn { display: inline-flex; align-items: center; gap: 6px; background: transparent; border: none; padding: 2px; cursor: pointer; font: inherit; }
.lg-chip-btn:hover { opacity: 0.85; }
.lg-actions { width: 44px; text-align: center; }
.lg-actions .btn.icon { font-size: 15px; }
.lg-actions-h { width: 44px; }
.leads-topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.leads-topbar .spacer { flex: 1 1 auto; }
.leads-title { font-size: var(--fs-lg); font-weight: 700; }
#leads-config { font-size: 18px; }

.leads-tools {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border);
}
#leads-search {
  flex: 1 1 auto; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 10px 12px;
}
#leads-search:focus { outline: 2px solid var(--focus-ring); border-color: var(--focus-ring); }
.leads-showlost { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--text-muted); white-space: nowrap; cursor: pointer; }
.leads-showlost input { width: 16px; height: 16px; }

.leads-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 12px 16px 40px; }
.leads-empty { color: var(--text-muted); text-align: center; padding: 40px 20px; }

.leads-group { margin-bottom: 18px; }
.leads-group-head {
  display: flex; align-items: center; justify-content: space-between;
  font-weight: 700; color: var(--text); padding: 6px 2px;
  border-bottom: 2px solid var(--border-strong); margin-bottom: 8px;
}
.leads-group.lost .leads-group-head { color: var(--danger); border-bottom-color: var(--danger); }
.leads-count { font-size: 13px; color: var(--text-muted); font-weight: 600; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 1px 9px; }
.leads-group-empty { color: var(--text-faint); font-size: 14px; padding: 4px 2px 8px; }

.lead-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 12px; margin-bottom: 8px; cursor: pointer;
  font: inherit; color: var(--text);
}
.lead-row:hover { background: var(--surface-2); }
.lead-row:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 1px; }
.lead-row-main { flex: 1 1 auto; min-width: 0; }
.lead-row-name { font-weight: 700; font-size: var(--fs-base); overflow-wrap: anywhere; }
.lead-row-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-top: 5px; }
.lead-tag { font-size: 12px; font-weight: 700; border-radius: 3px; padding: 2px 8px; white-space: nowrap; }
.lead-follow { font-size: 13px; color: var(--text-muted); font-weight: 600; }
/* Overdue / due-today follow-up: stands out until dealt with. */
.lead-follow-due { color: var(--danger, #e2445c); font-weight: 800; }
.leads-grid .lg-val.lg-due { color: var(--danger, #e2445c); font-weight: 700; }
/* Count of overdue follow-ups on the "My Leads" menu item. */
.leads-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px; margin-left: 8px;
  border-radius: 999px; background: var(--danger, #e2445c); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 1;
}
/* A dot on the ⋮ button so overdue leads show even with the menu closed. */
#btn-menu.has-leads-due { position: relative; }
#btn-menu.has-leads-due::after {
  content: ""; position: absolute; top: 3px; right: 3px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--danger, #e2445c); border: 2px solid var(--surface, #fff);
}
.lead-phone-hint { font-size: 13px; color: var(--text-faint); }
.lead-row-caret { color: var(--text-faint); font-size: 22px; flex: none; }

/* Lead editor: notes + phone link */
.lead-notes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.lead-notes-empty { color: var(--text-faint); font-size: 14px; }
.lead-note { display: flex; align-items: flex-start; gap: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px 10px; }
.lead-note-text { flex: 1 1 auto; overflow-wrap: anywhere; }
.lead-note-date { color: var(--text-faint); font-size: 12px; white-space: nowrap; }
.lead-note-del { border: none; background: transparent; color: var(--text-faint); cursor: pointer; font-size: 14px; padding: 0 2px; }
.lead-note-del:hover { color: var(--danger); }
.lead-note-add { display: flex; gap: 8px; }
.lead-note-add input { flex: 1 1 auto; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 10px 12px; }
.lead-note-add input:focus { outline: 2px solid var(--focus-ring); border-color: var(--focus-ring); }
.lead-meta { color: var(--text-muted); font-size: 14px; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 4px; }

/* Stages & statuses config rows */
.cfg-list { display: flex; flex-direction: column; gap: 8px; }
.cfg-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); flex-wrap: wrap; }
.cfg-item input[type="text"] { flex: 1 1 120px; font: inherit; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 8px 10px; background: var(--surface); color: var(--text); }
.cfg-item input[type="color"] { width: 38px; height: 34px; border: 1px solid var(--border-strong); border-radius: var(--radius); padding: 2px; background: var(--surface); cursor: pointer; flex: none; }
.cfg-item .cfg-move { flex: 1 1 160px; min-width: 0; }
.cfg-item .cfg-move .cselect-btn { padding: 8px 10px; }
.cfg-lost { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text); white-space: nowrap; cursor: pointer; }
.cfg-lost input { width: 16px; height: 16px; }
.cfg-arrow { font-size: 12px; padding: 6px 8px; color: var(--text-muted); }
.cfg-arrow:disabled { opacity: 0.3; cursor: default; }

/* Personal follow-up markers on the calendar (outlined, distinct from jobs) */
.fc .fc-event.lead-followup { border: 1px dashed #fff; opacity: 0.96; }

/* ---------- Responsive (phones) ---------- */
@media (max-width: 640px) {
  .app { overflow-x: hidden; }
  .who { display: none; }                 /* hide the Office: name badge on phones */
  .brand-actions { flex-wrap: nowrap; margin-left: auto; }  /* keep New entry + menu together */
  .topbar { padding: 8px 10px; gap: 8px 6px; }
  .topbar .spacer { display: none; }
  .nav-group { flex-wrap: wrap; }
  .topbar .brand { font-size: var(--fs-base); margin-right: 0; }
  .range-label { min-width: 0; font-size: var(--fs-base); }
  .clock { display: none; }
  .who { font-size: 12px; padding: 3px 7px; }
  .btn { padding: 8px 10px; }
  .btn.icon { padding: 8px 10px; }

  /* Calendar: keep columns a usable width and swipe sideways to see more. */
  .calendar-wrap { padding: 8px 8px 4px; overflow: hidden; }
  #calendar { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .fc-dayGridWeek-view .fc-scrollgrid,
  .fc-dayGridMonth-view .fc-scrollgrid { min-width: 680px; }

  .legend { padding: 8px 10px; overflow-x: auto; }
  .legend .legend-item { font-size: 14px; white-space: nowrap; }

  .row { flex-direction: column; }
  .modal-backdrop { padding: 10px; }
  .modal { max-width: 100%; }

  /* View switch: 3 tap boxes instead of a dropdown on phones. */
  .view-menu .view-toggle { display: none; }
  .view-menu .menu-panel {
    display: flex; position: static; flex-direction: row;
    gap: 6px; padding: 0; min-width: 0;
    background: transparent; border: none; box-shadow: none;
  }
  .view-menu .menu-panel .btn {
    flex: 1; justify-content: center; text-align: center;
    border: 1px solid var(--border-strong); border-radius: var(--radius);
    padding: 8px 10px;
  }
  .view-menu .menu-panel .btn:hover { background: var(--surface-2); }
  .view-menu .menu-panel .btn.active,
  .view-menu .menu-panel .btn.active:hover { background: var(--accent); color: #fff; }

  /* No Display Mode on phones. */
  #btn-display { display: none; }
}
