/* ==========================================================
   Design tokens — modern warm SaaS with Thuniv green as accent.
   The old ledger-cream/paper aesthetic is gone; warmth here
   comes from off-white surfaces + tan-tinted borders + soft
   shadows, not from a beige background. Green is scarce on
   purpose — that's what makes it feel premium.
   ========================================================== */
:root {
  /* Surfaces — warm off-white, not cream. */
  --paper: #FBFAF7;
  --paper-shade: #F4F1EB;
  --paper-line: #E7E2D8;
  --card-bg: #FFFFFF;

  /* Text — near-black with a hint of green, not pure gray. */
  --ink: #17211E;
  --ink-muted: #6B7770;
  --ink-subtle: #96A099;

  /* Accent — Thuniv green. Used deliberately: primary buttons,
     active states, key metrics only. Not on badges or bells. */
  --accent: #1A6B50;
  --accent-dark: #10493A;
  --accent-soft: #E5F1EB;
  --accent-tint: #F3F8F5;

  /* Semantic — muted, not saturated. Used sparingly. */
  --flag: #B45B3E;
  --flag-soft: #FBEDE7;
  --minimal: #928A7A;
  --minimal-soft: #F0EDE6;

  /* Shadow — subtle, warm-tinted, layered. */
  --shadow-xs: 0 1px 2px rgba(23, 33, 30, 0.04);
  --shadow-sm: 0 1px 3px rgba(23, 33, 30, 0.06), 0 1px 2px rgba(23, 33, 30, 0.04);
  --shadow-md: 0 4px 10px rgba(23, 33, 30, 0.06), 0 2px 4px rgba(23, 33, 30, 0.04);
  --shadow-lg: 0 12px 24px rgba(23, 33, 30, 0.08), 0 4px 8px rgba(23, 33, 30, 0.05);
  --shadow-xl: 0 24px 48px rgba(23, 33, 30, 0.12), 0 12px 20px rgba(23, 33, 30, 0.06);
  /* Legacy aliases so existing rules keep working during migration */
  --shadow: var(--shadow-md);
  --shadow-soft: var(--shadow-xs);
  --shadow-lift: var(--shadow-lg);

  --radius-card: 12px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* Type — one family, three sizes. The serif is gone; keeping
     display as a variable in case one-off headings want it. */
  --font-display: "Inter", -apple-system, "SF Pro Display", system-ui, sans-serif;
  --font-body: "Inter", -apple-system, "SF Pro Text", system-ui, sans-serif;
  --font-mono: "JetBrains Mono", "SF Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Safety net: nothing on the page should ever be able to force a
     page-wide horizontal scrollbar, regardless of window width. If
     some element's content genuinely doesn't fit, it should wrap or
     get its own internal scroll (like .quotes-table-wrap already
     does) — never widen the whole document. */
  overflow-x: hidden;
}

/* Old horizontal-lines "notebook paper" background is gone — it's
   the single biggest thing that made the app read as "ledger".
   Deliberately empty to override whatever was here before. */
body { background-image: none; }

::selection { background: var(--accent-soft); color: var(--accent-dark); }

button, select, input, textarea { font-family: inherit; font-size: inherit; }

/* ==========================================================
   Scrollbars — bigger, easier-to-grab thumb everywhere a panel
   actually scrolls (drawer body, sidebars, tables). Default OS
   scrollbars can render very thin with a proportionally tiny thumb,
   which is what made the drawer's tab-row overflow so hard to drag
   before that was fixed at the source (see .drawer-tabs). This is a
   general improvement on top of that fix, not a replacement for it.
   ========================================================== */
* {
  scrollbar-width: auto;
  scrollbar-color: var(--ink-subtle) transparent;
}
*::-webkit-scrollbar {
  width: 14px;
  height: 14px;
}
*::-webkit-scrollbar-track {
  background: transparent;
}
*::-webkit-scrollbar-thumb {
  background-color: var(--ink-subtle);
  border-radius: 999px;
  border: 3px solid var(--paper); /* padding so the thumb reads visibly thick without touching the track edges */
}
*::-webkit-scrollbar-thumb:hover {
  background-color: var(--accent);
}

/* ==========================================================
   Layout shell
   .wrap is customers.html/quotes.html's container — it had no rules
   of its own (a leftover gap from when those pages were added), so
   those two pages rendered with zero page padding/max-width at any
   viewport size. Sharing .ledger's rules fixes that for desktop and
   gives mobile padding overrides below something to actually apply to.
   ========================================================== */
.ledger, .wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 40px 28px 80px;
}

/* ==========================================================
   Header — single row, hairline underline, one primary CTA,
   secondary actions collapsed to compact icon-forward buttons.
   The old thick-black underline is gone.
   ========================================================== */
.ledger-head {
  display: flex;
  flex-wrap: wrap;
  row-gap: 12px;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--paper-line);
  margin-bottom: 32px;
}

.ledger-head-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.stamp-mark {
  color: var(--accent);
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  padding: 6px;
  background: var(--accent-tint);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stamp-mark svg { width: 20px; height: 20px; }

/* The old "FIND YOUR LEADS" all-caps monospace eyebrow above the
   title was the single most "internal admin tool" thing in the
   header — gone entirely. Nothing replaces it. */
.eyebrow { display: none; }

h1 {
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 24px;
  line-height: 1.2;
  margin: 0;
  color: var(--ink);
  letter-spacing: -0.02em;
}
h1 em, h1 .accent-italic {
  font-style: italic;
  font-weight: 500;
  color: var(--accent);
}

.subtitle { display: none; } /* the tagline goes into a proper meta location, not the header */

.ledger-head-right {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ==========================================================
   Header session slot — where session.js inserts the company
   badge + sign-out button. A dedicated container (rather than the
   old ad-hoc DOM insertion) so it's reliably covered by the mobile
   rules below instead of floating independently of them.
   ========================================================== */
.header-session-slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-right: 10px;
  margin-right: 2px;
  border-right: 1px solid var(--paper-line);
}
.header-session-slot:empty { display: none; } /* no border/gap before session.js has loaded */

/* ==========================================================
   Header icon cluster — groups quiet utility icons (notifications,
   import, install) into one visually contained pill instead of each
   floating as its own separate box, so the header reads as
   "one utility group + primary actions" rather than a scattered row
   of same-weight buttons.
   ========================================================== */
.header-icon-cluster {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  background: var(--paper-shade);
  border: 1px solid var(--paper-line);
  border-radius: 10px;
}
.header-icon-cluster .icon-header-btn {
  border: none;
  background: transparent;
  box-shadow: none;
}
.header-icon-cluster .icon-header-btn:hover { background: var(--card-bg); }
.header-icon-cluster:empty { display: none; }

/* ==========================================================
   Buttons — refined, restrained, generous padding.
   ========================================================== */
.btn-ghost, .btn-solid {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
  white-space: nowrap;
  line-height: 1;
}
.btn-ghost:active, .btn-solid:active { transform: translateY(0.5px); }
/* Duplicate/legacy .btn-ghost/.btn-solid block from the previous
   round — the modern versions are defined above. Keep only the
   variants (color, states) here. */

.btn-ghost {
  background: transparent;
  border: 1px solid var(--paper-line);
  color: var(--ink);
}
.btn-ghost:hover {
  background: var(--paper-shade);
  border-color: var(--ink-subtle);
}

.btn-solid {
  background: var(--accent);
  border: 1px solid var(--accent);
  color: #fff;
  box-shadow: var(--shadow-xs);
}
.btn-solid:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  box-shadow: var(--shadow-sm);
}
.btn-solid:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-wide { width: 100%; justify-content: center; margin-top: 4px; }

.btn-ghost svg, .btn-solid svg { flex-shrink: 0; }
.btn-ghost.is-spinning svg { animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Secondary header icon buttons — compact, quiet, tooltip-only label. */
.icon-header-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  background: var(--card-bg);
  color: var(--ink-muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.icon-header-btn:hover {
  background: var(--paper-shade);
  color: var(--ink);
  border-color: var(--ink-subtle);
}

/* ==========================================================
   Header "more" overflow menu — mobile only (see media query below).
   Holds the secondary labeled actions (Outreach, Add customer, Import)
   so the mobile header isn't a wall of buttons; menu items delegate
   to the real buttons' existing click handlers via data-trigger
   rather than duplicating any logic.
   ========================================================== */
.header-more-wrap { position: relative; display: none; }
.header-more-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 190px;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: 10px;
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(23,33,30,0.16));
  padding: 6px;
  z-index: 70;
}
.header-more-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 10px 10px;
  border: none;
  background: none;
  border-radius: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
}
.header-more-menu button:hover { background: var(--paper-shade); }
.header-more-menu button svg { flex-shrink: 0; color: var(--ink-muted); }

.ledger-head-right { flex-direction: row; }

/* ==========================================================
   Notifications — bell + dropdown panel
   ========================================================== */
.notif-wrap { position: relative; }
#notifBtn { position: relative; padding: 9px 11px; }
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--flag, #b3441e);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  border-radius: 999px;
  padding: 3px 5px;
  min-width: 16px;
  text-align: center;
}
.notif-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 340px;
  max-height: 420px;
  background: var(--card-bg);
  border: 1.5px solid var(--ink);
  border-radius: 10px;
  box-shadow: 0 12px 32px var(--shadow-lift);
  z-index: 60; /* above .bottom-nav (55) in case its max-height ever reaches that far down on a short mobile viewport */
  flex-direction: column;
  overflow: hidden;
}
/* Same bug as .scrim below: an unconditional `display: flex` on this
   class beats the browser's built-in `[hidden] { display: none }` rule
   (author rules win over the user-agent stylesheet), so the panel
   never actually hid no matter what the `hidden` attribute said.
   Scoping display to the un-hidden state only fixes it. */
.notif-panel:not([hidden]) {
  display: flex;
}
.notif-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--paper-line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  text-transform: none;
  letter-spacing: 0;
}
.notif-panel-head-actions { display: flex; gap: 10px; }
.notif-link-btn {
  background: none;
  border: none;
  color: var(--accent-dark);
  font-size: 12px;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
  padding: 0;
}
.notif-link-btn:hover { text-decoration: underline; }
.notif-list { overflow-y: auto; }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--ink-muted); font-size: 12.5px; }
.notif-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--paper-line);
  background: none;
  border-left: none; border-right: none; border-top: none;
  cursor: pointer;
  font-family: inherit;
}
.notif-item:hover { background: var(--paper-shade, rgba(0,0,0,0.03)); }
.notif-item.is-unread { background: var(--accent-soft); }
.notif-item-title { font-size: 12.5px; font-weight: 600; color: var(--ink); }
.notif-item-body { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }
.notif-item-time { font-size: 11px; color: var(--ink-subtle); margin-top: 4px; }

/* ==========================================================
   Stat strip — stamped ledger tiles
   ========================================================== */
/* Stat strip — separate cards with real gaps (not one big block
   with dividers), soft shadows, no dark border cage. */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  margin-bottom: 32px;
}

.stat-tile {
  background: var(--card-bg);
  padding: 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-xs);
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}
.stat-tile:hover { box-shadow: var(--shadow-sm); }

.stat-tile--accent {
  background: var(--accent-tint);
  border-color: var(--accent-soft);
}

.stat-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  letter-spacing: 0;
  text-transform: none;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.stat-tile--accent .stat-value { color: var(--accent-dark); }

.stat-sub {
  font-size: 11.5px;
  color: var(--ink-subtle);
  color: var(--ink-muted);
}

/* ==========================================================
   Pipeline strip — status counts
   ========================================================== */
.pipeline-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 18px;
}

.pipeline-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: 999px;
  padding: 6px 14px 6px 12px;
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.pipeline-chip:hover { border-color: var(--ink-subtle); }
.pipeline-chip.is-active {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 500;
}
.pipeline-chip .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
}
.pipeline-chip b { font-weight: 600; }

/* ==========================================================
   City tabs — card-catalog dividers
   ========================================================== */
/* City tabs — pill-style, subtle, no dark bottom border cage. */
.city-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 20px;
}

.city-tab {
  background: transparent;
  border: 1px solid transparent;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.12s ease;
}
.city-tab:hover { color: var(--ink); background: var(--paper-shade); }
.city-tab.is-active {
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-weight: 600;
}

/* ==========================================================
   Toolbar — search + filters on one clean row.
   ========================================================== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 24px;
}

.search-field {
  flex: 1 1 260px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--ink-muted);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.search-field:hover { border-color: var(--ink-subtle); }
.search-field:focus-within {
  border-color: var(--accent);
  color: var(--ink);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.search-field input {
  border: none;
  outline: none;
  background: transparent;
  font-size: 14px;
  color: var(--ink);
  width: 100%;
}

.toolbar-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.toolbar-filters select {
  min-width: 0;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  padding-right: 28px;
  font-size: 13px;
  color: var(--ink);
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7770' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s ease;
}
.toolbar-filters select:hover { border-color: var(--ink-subtle); }
.toolbar-filters select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* ==========================================================
   Registry body
   ========================================================== */
.registry-count {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 14px;
}

.card-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(320px, 100%), 1fr));
  gap: 14px;
}

/* ==========================================================
   Lead card — modern content card, no perforation, no monospace
   labels, no dashed dividers. Clean, generous, hover-lift.
   ========================================================== */
.lead-card {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-card);
  padding: 18px 20px;
  box-shadow: var(--shadow-xs);
  display: flex;
  flex-direction: column;
  gap: 12px;
  cursor: pointer;
  min-width: 0; /* stop long field values from widening this past its grid
    column in .card-index — see .lead-field dd for the full explanation. */
  transition: transform 0.12s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.lead-card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--ink-subtle);
}

/* Perforation from the old ledger card design — kept as a no-op
   so any lingering HTML template markup doesn't accidentally leak
   through with the old visual. */
.perforation { display: none; }

.lead-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.lead-name {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 600;
  margin: 0;
  line-height: 1.3;
  color: var(--ink);
  letter-spacing: -0.005em;
  min-width: 0;
  overflow-wrap: break-word;
}

/* Completeness stamp — subtle dot + short label, not a bordered
   badge. The old bordered pill was reading like a warning label. */
.status-stamp {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-muted);
  text-transform: capitalize;
  padding: 0;
  border: none;
  background: transparent;
  white-space: nowrap;
}
.status-stamp::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--minimal);
}
.status-stamp[data-status="complete"]::before { background: var(--accent); }
.status-stamp[data-status="partial"]::before { background: var(--flag); }
.status-stamp[data-status="minimal"]::before { background: var(--ink-subtle); }

.lead-address {
  margin: -4px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
  min-height: 1px;
  overflow-wrap: break-word;
}

.lead-fields {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.lead-field {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 12px;
  align-items: baseline;
  min-width: 0;
}

.lead-field dt {
  font-size: 11px;
  font-weight: 500;
  color: var(--ink-subtle);
  text-transform: none;
  letter-spacing: 0;
}

.lead-field dd {
  margin: 0;
  font-size: 13px;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0; /* without this, a long unbroken value (email, URL) makes this
    grid track — and everything up to the card and the whole mobile page —
    grow to fit it instead of actually truncating, which is what was
    forcing horizontal scrolling on phones. */
}
.lead-field dd:empty::before { content: "—"; color: var(--ink-subtle); }
.lead-field dd a { color: var(--accent-dark); text-decoration: none; }
.lead-field dd a:hover { text-decoration: underline; }

.mono { font-family: var(--font-mono); font-size: 0.94em; }

/* Card footer — inline meta, no dashed border. */
.lead-card-side {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--paper-line);
  font-size: 11.5px;
  color: var(--ink-subtle);
  flex-wrap: wrap;
}

.lead-city {
  font-weight: 500;
  color: var(--ink-muted);
}

.lead-rating:empty, .lead-source:empty { display: none; }

.lead-city::after { content: "·"; margin-left: 8px; color: var(--ink-subtle); }
.lead-rating:empty + .lead-source::before { content: none; }

.lead-status-select {
  margin-left: auto;
  max-width: 100%;
  min-width: 0;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
  background: var(--paper-shade);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-xs);
  padding: 4px 10px;
  padding-right: 22px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2317211E' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 6px center;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.lead-status-select:hover { border-color: var(--ink-subtle); }

.lead-card .lead-status-select { cursor: pointer; }

/* ==========================================================
   Scrim / modal panel / drawer (shared)
   ========================================================== */
.scrim {
  position: fixed;
  inset: 0;
  background: rgba(23, 33, 30, 0.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  /* Must sit above .bottom-nav (z-index 55) — otherwise the bottom tab
     bar would visually clip over the drawer/modal's bottom edge on
     mobile, and taps there would hit the nav instead of the dialog. */
  z-index: 90;
}

.scrim:not([hidden]) {
  display: flex;
}

.panel {
  margin: auto;
  width: min(480px, 92vw);
  max-height: 88vh;
  overflow-y: auto;
  overflow-x: hidden; /* setting only overflow-y here implicitly makes
    overflow-x compute to "auto" too (per spec), so any child even
    slightly too wide — an unwrapped tab row, a multi-column form —
    was making the ENTIRE modal draggable sideways. Same fix as
    .drawer below; any row that genuinely needs to scroll (like
    .outreach-tabs) scrolls itself instead. */
  background: var(--card-bg);
  border-radius: var(--radius-card);
  border: 1px solid var(--paper-line);
  box-shadow: var(--shadow-xl);
  padding: 28px 30px 32px;
}

.panel-head, .drawer-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}

.panel-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0;
}

.icon-btn {
  background: transparent;
  border: none;
  font-size: 15px;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
}
.icon-btn:hover { background: var(--paper); color: var(--ink); }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  margin: 14px 0 6px;
  letter-spacing: 0;
  text-transform: none;
}
.panel-body .field-label:first-child { margin-top: 0; }

.panel-body select, .panel-body input[type="text"] {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.panel-body select:focus, .panel-body input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.toggle-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 4px;
  font-size: 13px;
  color: var(--ink-muted);
  cursor: pointer;
}
.toggle-row input { margin-top: 3px; accent-color: var(--accent); }

.stage-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 6px 0 4px;
}
.stage-check {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border, #ddd);
  border-radius: 999px;
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
  user-select: none;
}
.stage-check input { accent-color: var(--accent); margin: 0; }
.stage-check:has(input:checked) {
  border-color: var(--accent);
  color: var(--ink);
  background: var(--accent-tint);
}

.panel-note {
  font-size: 12.5px;
  color: var(--ink-muted);
  background: var(--paper-shade);
  border-left: 3px solid var(--accent);
  padding: 11px 14px;
  border-radius: var(--radius-xs);
  margin: 14px 0 0;
  line-height: 1.55;
}

.panel-coverage {
  font-size: 12px;
  color: var(--accent-dark);
  margin: 14px 0 0;
}

.panel-warning {
  font-size: 12.5px;
  color: var(--flag);
  background: var(--flag-soft);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  margin: 0 0 16px;
  line-height: 1.5;
}
.panel-warning code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.05);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 0.9em;
}

.panel-success {
  font-size: 12.5px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  border-radius: var(--radius-xs);
  padding: 10px 12px;
  margin-top: 10px;
}

.panel-wide { width: min(620px, 94vw); }
.panel-xl { width: min(980px, 95vw); max-height: 90vh; }

/* Outreach panel tabs — pill-underline, restrained. */
.outreach-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--paper-line);
  margin-bottom: 22px;
  /* Five tabs don't fit a phone-width panel — scroll the strip itself
     instead of relying on .panel's overflow (now hidden on purpose;
     see .panel above). Same pattern as .drawer-tabs. */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  scrollbar-width: none;
}
.outreach-tabs::-webkit-scrollbar { display: none; }
.outreach-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 4px 12px;
  margin-right: 20px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  margin-bottom: -1px;
  flex-shrink: 0;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.outreach-tab:hover { color: var(--ink); }
.outreach-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

.form-input {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  color: var(--ink);
  font-family: var(--font-body);
  resize: vertical;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea.form-input { font-family: var(--font-body); line-height: 1.55; }

.row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.row .form-input { flex: 1; margin-top: 0; }

.section-subhead {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin: 20px 0 10px;
  letter-spacing: 0;
  text-transform: none;
}

.template-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 6px;
}
.template-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  padding: 9px 11px;
}
.template-row > div:first-child { min-width: 0; } /* the unnamed wrapper
  around name+subject — without this a long subject line can push the
  edit/delete buttons off the row instead of wrapping/truncating */
.template-row-name { font-weight: 600; font-size: 13px; overflow-wrap: break-word; }
.template-row-subject { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; overflow-wrap: break-word; }
.template-row-actions { display: flex; gap: 6px; flex-shrink: 0; }
.template-row-actions button {
  background: transparent;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  font-size: 11px;
  padding: 4px 9px;
  cursor: pointer;
  color: var(--ink-muted);
}
.template-row-actions button:hover { color: var(--ink); border-color: var(--ink-muted); }

.panel-error {
  font-size: 12px;
  color: var(--flag);
  background: var(--flag-soft);
  border-radius: 6px;
  padding: 8px 10px;
  margin-top: 10px;
}

.panel-jobs {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--paper-line);
}
.panel-jobs h3 {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
  margin: 20px 0 10px;
  text-transform: none;
  letter-spacing: 0;
}

.job-list { display: flex; flex-direction: column; gap: 8px; }

.job-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
}
.job-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.job-row-city { font-weight: 500; }
.job-row-meta { font-size: 11.5px; color: var(--ink-muted); overflow-wrap: break-word; }

.job-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  white-space: nowrap;
}
.job-badge[data-status="running"] { background: var(--flag-soft); color: var(--flag); }
.job-badge[data-status="completed"] { background: var(--accent-soft); color: var(--accent-dark); }
.job-badge[data-status="failed"] { background: #f3d2d2; color: #a13a3a; }

/* ==========================================================
   Lead detail drawer
   ========================================================== */
.drawer {
  margin-left: auto;
  width: min(460px, 92vw);
  height: 100%;
  background: var(--card-bg);
  box-shadow: -12px 0 40px rgba(23, 33, 30, 0.10);
  padding: 28px 28px 30px;
  overflow-y: auto;
  overflow-x: hidden; /* the tab row scrolls itself (below) — the drawer
    as a whole should never need to scroll sideways. Without this, an
    overflowing .drawer-tabs row was dragging the entire panel
    horizontally, producing one huge, awkward, hard-to-grab scrollbar
    for the whole drawer instead of a small one on just the tabs. */
}

.drawer-head h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: 0 0 3px;
}
.drawer-city {
  font-size: 13px;
  color: var(--ink-muted);
  margin: 0;
}

.drawer-status-row select {
  width: 100%;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  color: var(--ink);
  font-weight: 500;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  padding-right: 30px;
  font-size: 13.5px;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236B7770' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.drawer-status-row select:hover { border-color: var(--ink-subtle); }
.drawer-status-row select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

.drawer-fields {
  margin: 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.drawer-fields > div {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  font-size: 12.5px;
}
.drawer-fields dt {
  font-size: 12px;
  color: var(--ink-subtle);
  text-transform: none;
  letter-spacing: 0;
}
.drawer-fields dd { margin: 0; word-break: break-word; }
.drawer-fields dd:empty::before { content: "—"; color: var(--ink-subtle); }

.drawer-details-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 18px 0 0;
}
.drawer-details-head .section-subhead { margin: 0; }

.drawer-fields-edit {
  margin: 12px 0 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.drawer-fields-edit .form-input { margin-bottom: 6px; }
.drawer-fields-edit .row { margin-top: 4px; gap: 8px; }

.drawer-notes {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--paper-line);
}
.drawer-notes h3 {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ink);
  margin: 0 0 12px;
  text-transform: none;
  letter-spacing: 0;
}

.note-composer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}
.note-composer textarea {
  width: 100%;
  resize: vertical;
  background: var(--paper);
  border: 1.5px solid var(--paper-line);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--ink);
}

.note-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.note-item {
  background: var(--paper);
  border-radius: 8px;
  padding: 9px 11px;
  font-size: 12.5px;
}
.note-item[data-type="system"], .note-item[data-type="status_change"], .note-item[data-type="audit"] {
  background: transparent;
  border: 1px dashed var(--paper-line);
  color: var(--ink-muted);
  font-style: italic;
}
.note-time {
  display: block;
  font-size: 11px;
  color: var(--ink-subtle);
  margin-top: 4px;
}

/* ==========================================================
   Empty state
   ========================================================== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  border: 1.5px dashed var(--paper-line);
  border-radius: 10px;
  background: var(--card-bg);
}
.empty-title {
  font-family: var(--font-display);
  font-size: 18px;
  margin: 0 0 6px;
  color: var(--ink);
}
.empty-sub {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
}

/* ==========================================================
   Responsive
   ========================================================== */
@media (max-width: 860px) {
  .stat-strip { grid-template-columns: repeat(2, 1fr); }
  .ledger-head { flex-direction: column; }
  .ledger-head-right { align-items: flex-start; }
}

@media (max-width: 480px) {
  .stat-strip { grid-template-columns: 1fr; }
  .card-index { grid-template-columns: 1fr; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .lead-card, .btn-ghost, .city-tab { transition: none; }
  .btn-ghost.is-spinning svg { animation: none; }
}

/* Focus visibility */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ==========================================================
   Drawer tabs — Details / Conversations
   ========================================================== */
.drawer-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1.5px solid var(--paper-line);
  padding: 0 24px;
  margin: 0 -24px;
  flex-shrink: 0;
  /* Scrolls on its own when tabs don't fit, instead of forcing the
     whole drawer to scroll sideways (see .drawer overflow-x above). */
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  /* A tab strip reads better as swipeable than as a document with a
     scrollbar — hide the native bar but keep it fully draggable via
     touch, trackpad, or a horizontal mouse-wheel/shift-scroll. */
  scrollbar-width: none;
}
.drawer-tabs::-webkit-scrollbar { display: none; }
.drawer-tab {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 14px 4px;
  margin-right: 22px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: -1px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: color 0.15s var(--ease), border-color 0.15s var(--ease);
}
.drawer-tab:hover { color: var(--ink); }
.drawer-tab.is-active {
  color: var(--ink);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.drawer-tab-badge {
  font-size: 11px;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border-radius: 999px;
  padding: 2px 7px;
  min-width: 18px;
  text-align: center;
}

.drawer-body {
  padding-top: 20px;
}

/* ==========================================================
   Conversations — thread list
   ========================================================== */
.conv-thread-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
  min-width: 0;
}

.conv-thread-row {
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  cursor: pointer;
  min-width: 0; /* same fix as .lead-card — see .lead-field dd for why */
  transition: transform 0.12s var(--ease), box-shadow 0.12s var(--ease), border-color 0.12s var(--ease);
}
.conv-thread-row:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px var(--shadow-soft);
  border-color: var(--accent);
}
.conv-thread-row-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.conv-thread-subject {
  font-weight: 600;
  font-size: 13.5px;
  color: var(--ink);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.conv-thread-time {
  font-size: 11.5px;
  color: var(--ink-subtle);
  white-space: nowrap;
  flex-shrink: 0;
}
.conv-thread-preview {
  font-size: 12px;
  color: var(--ink-muted);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.conv-thread-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--ink-muted);
  font-size: 13px;
}

/* ==========================================================
   Conversations — compose / active thread shared bits
   ========================================================== */
.conv-back {
  background: transparent;
  border: none;
  color: var(--accent-dark);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 0 0 14px;
  display: block;
}
.conv-back:hover { text-decoration: underline; }

.conv-compose-view .field-label:first-of-type { margin-top: 4px; }

.conv-active-subject {
  font-family: var(--font-display);
  font-size: 16.5px;
  font-weight: 600;
  margin: 0 0 14px;
  padding-bottom: 12px;
  border-bottom: 1px dashed var(--paper-line);
}

/* ==========================================================
   Conversations — chat bubbles
   ========================================================== */
.conv-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  max-height: 44vh;
  overflow-y: auto;
  padding-right: 2px;
}

.conv-bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.conv-bubble.is-outbound {
  align-self: flex-end;
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.conv-bubble.is-inbound {
  align-self: flex-start;
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.conv-bubble-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  margin-top: 6px;
  flex-wrap: wrap;
}
.conv-bubble.is-outbound .conv-bubble-meta { justify-content: flex-end; }
.conv-bubble-time {
  font-size: 11px;
  opacity: 0.7;
}
.conv-bubble-badge {
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.25);
}
.conv-bubble.is-inbound .conv-bubble-badge { background: var(--accent-soft); color: var(--accent-dark); }

.conv-reply {
  border-top: 1px solid var(--paper-line);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-sm { padding: 6px 11px; font-size: 12px; }

/* --------------------------------------------------------------
   WhatsApp — availability pill + drawer chat
   -------------------------------------------------------------- */
.wa-status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.wa-status-pill {
  font-size: 11px;
  font-weight: 500;
  border-radius: 999px;
  padding: 3px 10px;
  text-transform: none;
  letter-spacing: 0;
  flex-shrink: 0;
}
.wa-status-pill[data-state="unknown"] { background: var(--minimal-soft); color: var(--minimal); }
.wa-status-pill[data-state="yes"] { background: var(--accent-soft); color: var(--accent-dark); }
.wa-status-pill[data-state="no"] { background: var(--flag-soft); color: var(--flag); }
.wa-window-note { font-size: 12px; color: var(--ink-muted); }
#drawerPanelWhatsapp .conv-reply { gap: 10px; }
#drawerPanelWhatsapp .conv-reply .field-label:not(:first-child) { margin-top: 4px; }
.wa-template-vars { display: flex; flex-direction: column; gap: 8px; margin: 4px 0; }
.wa-template-vars .field-label { margin-top: 0; font-size: 12px; }
.wa-preview-box {
  background: var(--paper-shade);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 4px 0;
}
.wa-preview-label {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink-muted);
  margin-bottom: 6px;
  text-transform: none;
  letter-spacing: 0;
}
.wa-preview-box p {
  margin: 0;
  font-size: 13px;
  white-space: pre-wrap;
  color: var(--ink);
}
.conv-bubble-approx {
  font-size: 10.5px;
  font-style: italic;
  opacity: 0.75;
  margin-top: 4px;
}

/* --------------------------------------------------------------
   Quotes — real table (not CSS grid), built for the wide .panel-xl
   modal, not the narrow drawer. See panel-xl above.
   -------------------------------------------------------------- */
.quote-line-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 8px;
}
.quote-line-table {
  width: 100%;
  min-width: 560px; /* below this the columns become unreadably cramped — the wrapper above scrolls instead of squeezing them */
  border-collapse: collapse;
}
.quote-line-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-muted);
  padding: 8px;
  border-bottom: 1px solid var(--paper-line);
  text-transform: none;
  letter-spacing: 0;
}
.quote-line-table td {
  padding: 6px 8px;
  vertical-align: middle;
  border-bottom: 1px solid var(--paper-line);
}
.quote-line-table th:nth-child(2), .quote-line-table td:nth-child(2),
.quote-line-table th:nth-child(5), .quote-line-table td:nth-child(5) { width: 70px; }
.quote-line-table th:nth-child(3), .quote-line-table td:nth-child(3) { width: 110px; }
.quote-line-table th:nth-child(4), .quote-line-table td:nth-child(4) { width: 100px; }
.quote-line-table th:nth-child(6), .quote-line-table td:nth-child(6) { width: 120px; text-align: right; }
.quote-line-table th:last-child, .quote-line-table td:last-child { width: 32px; }
.quote-line-table input {
  width: 100%;
  font-size: 13px;
  padding: 7px 8px;
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--ink);
}
.quote-line-table .quote-line-total {
  display: block;
  text-align: right;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--ink);
}
.quote-line-remove {
  background: none;
  border: none;
  color: var(--flag);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
}
.quote-line-table--readonly td { font-size: 13.5px; }
.quote-line-table--readonly td:nth-child(2) { text-align: right; }
.quote-line-table--readonly td:nth-child(3) { text-align: right; }
.quote-line-table--readonly td:nth-child(5) { text-align: right; }
.quote-line-table--readonly td:nth-child(6) { text-align: right; font-family: var(--font-mono); }

.quote-form-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 6px;
}

.status-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 500;
  text-transform: capitalize;
  letter-spacing: 0;
  border-radius: 999px;
  padding: 3px 10px;
}
.status-badge[data-status="draft"] { background: var(--minimal-soft); color: var(--minimal); }
.status-badge[data-status="sent"] { background: var(--accent-soft); color: var(--accent-dark); }
.status-badge[data-status="viewed"] { background: var(--accent-soft); color: var(--accent-dark); }
.status-badge[data-status="accepted"] { background: var(--accent); color: #fff; }
.status-badge[data-status="rejected"] { background: var(--flag-soft); color: var(--flag); }
.status-badge[data-status="expired"] { background: var(--minimal-soft); color: var(--minimal); }
.status-badge[data-status="unpaid"] { background: var(--flag-soft); color: var(--flag); }
.status-badge[data-status="partially_paid"] { background: var(--accent-soft); color: var(--accent-dark); }
.status-badge[data-status="paid"] { background: var(--accent); color: #fff; }
.status-badge[data-status="overdue"] { background: var(--flag); color: #fff; }

.quote-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: 12px;
  margin-top: 16px;
}
.quote-list-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 18px;
  border: 1.5px solid var(--paper-line);
  border-radius: 12px;
  cursor: pointer;
  background: var(--card-bg);
  transition: border-color 0.15s ease, transform 0.1s ease;
}
.quote-list-row:hover { border-color: var(--accent); transform: translateY(-1px); }
.quote-list-row-main { display: flex; flex-direction: column; gap: 4px; }
.quote-list-row-number { font-family: var(--font-mono); font-size: 14px; font-weight: 700; }
.quote-list-row-meta { font-size: 12px; color: var(--ink-muted); display: flex; align-items: center; gap: 8px; }
.quote-list-row-total { font-family: var(--font-mono); font-size: 20px; font-weight: 700; color: var(--accent-dark); }

.quote-detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1.5px solid var(--paper-line);
}
.quote-detail-head h3 { margin: 0 0 6px; font-family: var(--font-display); font-size: 24px; }
.quote-detail-totals {
  margin: 16px 0;
  margin-left: auto;
  width: min(300px, 100%);
  padding: 14px 16px;
  background: var(--paper);
  border-radius: 10px;
  font-size: 13.5px;
}
.quote-detail-totals-row { display: flex; justify-content: space-between; padding: 3px 0; }
.quote-detail-totals-row.grand { font-weight: 700; font-size: 17px; border-top: 1px solid var(--paper-line); padding-top: 8px; margin-top: 6px; }

.catalog-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 1px solid var(--paper-line);
  border-radius: 10px;
  margin-bottom: 8px;
}
.catalog-row-main { display: flex; flex-direction: column; gap: 2px; }
.catalog-row-name { font-weight: 600; font-size: 13px; }
.catalog-row-meta { font-family: var(--font-mono); font-size: 11px; color: var(--ink-muted); }
.catalog-row-actions { display: flex; gap: 6px; }

/* --------------------------------------------------------------
   Customer History — purchase summary + activity timeline
   -------------------------------------------------------------- */
.history-stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.history-stat {
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.history-stat-label { font-size: 11.5px; color: var(--ink-muted); margin-bottom: 4px; }
.history-stat-value { font-family: var(--font-display); font-size: 20px; font-weight: 650; color: var(--ink); letter-spacing: -0.01em; }
.history-stat-value.warn { color: var(--flag); }
.history-stat-sub { font-size: 11px; color: var(--ink-subtle); margin-top: 2px; }

.history-product-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid var(--paper-line);
  font-size: 12.5px;
}
.history-product-row:last-child { border-bottom: none; }
.history-product-name { font-weight: 500; color: var(--ink); }
.history-product-meta { color: var(--ink-subtle); font-size: 11.5px; }

.history-empty { padding: 24px 0; text-align: center; color: var(--ink-muted); font-size: 12.5px; }

.timeline-item {
  display: flex;
  gap: 12px;
  padding-bottom: 18px;
  position: relative;
}
.timeline-item::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 16px;
  bottom: 0;
  width: 1px;
  background: var(--paper-line);
}
.timeline-item:last-child::before { display: none; }
.timeline-dot {
  flex-shrink: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  margin-top: 3px;
  background: var(--minimal);
  border: 2px solid var(--card-bg);
  box-shadow: 0 0 0 1px var(--paper-line);
}
.timeline-item[data-kind="status"] .timeline-dot { background: var(--ink-subtle); }
.timeline-item[data-kind="email"] .timeline-dot,
.timeline-item[data-kind="whatsapp"] .timeline-dot { background: var(--accent); }
.timeline-item[data-kind="quote"] .timeline-dot { background: #C99A3E; }
.timeline-item[data-kind="payment"] .timeline-dot { background: var(--accent-dark); }
.timeline-content { flex: 1; min-width: 0; }
.timeline-title { font-size: 13px; font-weight: 500; color: var(--ink); }
.timeline-body { font-size: 12.5px; color: var(--ink-muted); margin-top: 2px; white-space: pre-wrap; word-break: break-word; }
.timeline-time { font-size: 11px; color: var(--ink-subtle); margin-top: 3px; }
.timeline-more {
  display: block;
  margin: 10px auto 0;
  padding: 6px 16px;
}

/* --------------------------------------------------------------
   Top nav — Leads / Customers / Analytics
   -------------------------------------------------------------- */
.top-nav {
  display: flex;
  gap: 2px;
  margin-left: 20px;
}
.top-nav-link {
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-muted);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.top-nav-link:hover { background: var(--paper-shade); color: var(--ink); }

/* ==========================================================
   Account menu — avatar with initials, opens a proper dropdown with
   full identity (name, username, company) and a real sign-out menu
   item, instead of a bare text label + lone icon button.
   ========================================================== */
.account-menu-wrap { position: relative; }

.account-avatar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px 3px 3px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.account-avatar-btn:hover { background: var(--paper-shade); border-color: var(--paper-line); }
.account-avatar-btn .chevron { color: var(--ink-subtle); transition: transform 0.15s ease; }
.account-avatar-btn[aria-expanded="true"] .chevron { transform: rotate(180deg); }

.account-avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: #fff;
  font-family: var(--font-display);
  font-weight: 650;
  font-size: 12px;
  letter-spacing: 0.02em;
}
.account-avatar-lg { width: 40px; height: 40px; font-size: 15px; }

.account-name-inline {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-dropdown {
  /* position: fixed + top/left are set in JS at open time (session.js),
     based on the avatar button's actual on-screen position — it moves
     around too much (mid-header on desktop, wraps to the far left on
     mobile) for a static CSS anchor to stay correct everywhere. */
  width: 240px;
  max-width: calc(100vw - 16px);
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: 12px;
  box-shadow: var(--shadow-lg, 0 12px 32px rgba(23,33,30,0.16));
  padding: 14px;
  z-index: 80;
}
.account-dropdown-header {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.account-dropdown-header > div {
  min-width: 0; /* the unnamed wrapper div around name+username — without
    this, a long name/username forces the row (and the fixed-width
    dropdown box) wider than the screen instead of wrapping/truncating */
}
.account-dropdown-name {
  font-size: 14px;
  font-weight: 650;
  color: var(--ink);
  line-height: 1.3;
  overflow-wrap: break-word;
}
.account-dropdown-username {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--ink-subtle);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.account-dropdown-divider {
  height: 1px;
  background: var(--paper-line);
  margin: 12px 0;
}
.account-dropdown-company {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--ink-muted);
  min-width: 0;
}
.account-dropdown-company svg { flex-shrink: 0; color: var(--ink-subtle); }
.account-dropdown-company-name {
  font-weight: 600;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0; /* same fix as .lead-field dd — see that comment for why
    this is needed for the ellipsis to actually take effect */
}
.account-dropdown-signout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 12px;
  padding: 9px 10px;
  border: 1px solid var(--paper-line);
  border-radius: 8px;
  background: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.account-dropdown-signout:hover {
  background: var(--flag-soft, #fbede7);
  color: var(--flag, #b45b3e);
  border-color: var(--flag, #b45b3e);
}

.top-nav-link.is-active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }

/* --------------------------------------------------------------
   Customers page — list-left / record-right layout
   -------------------------------------------------------------- */
.cust-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 20px;
  align-items: start;
}
@media (max-width: 860px) { .cust-layout { grid-template-columns: 1fr; } }

/* ---- Quotes tab ---- */
.quotes-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.quotes-toolbar .search-field { flex: 1; min-width: 240px; max-width: 420px; }
.quotes-table-wrap {
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-card);
  overflow-x: auto;
  margin-top: 12px;
}
.quotes-table { width: 100%; border-collapse: collapse; }
.quotes-table th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--ink-subtle);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--paper-line);
  white-space: nowrap;
}
.quotes-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--paper-line);
  font-size: 13px;
  vertical-align: middle;
  white-space: nowrap;
}
.quotes-table tr:last-child td { border-bottom: none; }
.quotes-table-link { color: var(--ink); font-weight: 500; text-decoration: none; min-width: 0; }
.quotes-table-link:hover { color: var(--accent-dark); text-decoration: underline; }
.quotes-table-actions { display: flex; gap: 6px; justify-content: flex-end; }
#quotesEmpty { padding: 32px 16px; text-align: center; }

.cust-sidebar {
  position: sticky;
  top: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cust-filters { display: flex; flex-wrap: wrap; gap: 6px; }
.cust-filter {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--paper-line);
  background: var(--card-bg);
  font-size: 12.5px;
  color: var(--ink-muted);
  cursor: pointer;
  transition: all 0.12s ease;
}
.cust-filter:hover { border-color: var(--ink-subtle); color: var(--ink); }
.cust-filter.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-dark); font-weight: 600; }
.cust-count { font-size: 12px; color: var(--ink-muted); margin: 0; }

.cust-list { display: flex; flex-direction: column; gap: 6px; max-height: calc(100vh - 220px); overflow-y: auto; }
.cust-list-empty { font-size: 13px; color: var(--ink-muted); text-align: center; padding: 24px 12px; }

.cust-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  text-align: left;
  padding: 12px 14px;
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-sm);
  background: var(--card-bg);
  cursor: pointer;
  transition: border-color 0.12s ease, background 0.12s ease;
}
.cust-row:hover { border-color: var(--ink-subtle); }
.cust-row.is-selected { border-color: var(--accent); background: var(--accent-tint); }
.cust-row-main { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cust-row-name { font-weight: 600; font-size: 13.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-row-sub { font-size: 11.5px; color: var(--ink-muted); }
.cust-row-figures { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex-shrink: 0; }
.cust-row-ltv { font-family: var(--font-mono); font-size: 13px; font-weight: 600; color: var(--accent-dark); }
.cust-row-dues { font-size: 11px; color: var(--flag); font-weight: 500; }
.cust-row-orders { font-size: 11px; color: var(--ink-subtle); }

.cust-detail {
  background: var(--card-bg);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-card);
  min-height: 400px;
  padding: 24px 26px;
}
/* Same [hidden]-vs-`display:flex` bug as .notif-panel above — an
   unconditional `display: flex` here beats the browser's built-in
   `[hidden] { display: none }` rule, so setting custEmpty.hidden = true
   in JS never actually hid it. That's why the "Select a customer…"
   placeholder (with its 360px min-height) kept rendering above the
   real record instead of being replaced by it. */
.cust-empty {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  min-height: 360px;
  color: var(--ink-muted);
  text-align: center;
}
.cust-empty:not([hidden]) {
  display: flex;
}
.cust-empty p { font-size: 13.5px; max-width: 240px; }

.cust-record-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 12px; }
.cust-record-head > div:first-child { min-width: 0; } /* the unnamed wrapper
  around name+sub — without this, a long business name refuses to wrap and
  forces this row (and the whole page's layout width) wider than the
  screen instead of dropping the actions to their own line below */
.cust-record-name { font-family: var(--font-display); font-size: 24px; font-weight: 650; margin: 0 0 4px; letter-spacing: -0.01em; overflow-wrap: break-word; }
.cust-record-sub { font-size: 13px; color: var(--ink-muted); margin: 0; overflow-wrap: break-word; }
.cust-record-actions { flex-shrink: 0; display: flex; flex-wrap: wrap; gap: 8px; }

.cust-edit-panel {
  padding: 14px 0 18px;
  border-bottom: 1px solid var(--paper-line);
  margin-bottom: 18px;
}

.cust-contact-row { display: flex; flex-wrap: wrap; gap: 18px; padding: 12px 0 18px; border-bottom: 1px solid var(--paper-line); margin-bottom: 18px; }
.cust-contact { font-size: 13px; color: var(--ink); }
.cust-contact b { font-weight: 500; color: var(--ink-subtle); font-size: 11px; display: block; margin-bottom: 1px; }

.cust-stat-grid { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 640px) { .cust-stat-grid { grid-template-columns: 1fr 1fr; } }

.cust-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 24px; }
@media (max-width: 720px) { .cust-cols { grid-template-columns: 1fr; } }
.cust-col { min-width: 0; }

.cust-invoice-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--paper-line);
  flex-wrap: wrap;
}
.cust-invoice-main { display: flex; flex-direction: column; gap: 2px; }
.cust-invoice-number { font-family: var(--font-mono); font-size: 13px; font-weight: 600; }
.cust-invoice-meta { font-size: 11.5px; color: var(--ink-muted); }
.cust-invoice-right { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.btn-sm { padding: 4px 10px; font-size: 12px; }

.send-quote-menu {
  display: flex;
  flex-direction: column;
  min-width: 130px;
  background: var(--paper, #fff);
  border: 1px solid var(--paper-line, #ddd);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.14);
  overflow: hidden;
}
.send-quote-menu button {
  all: unset;
  cursor: pointer;
  padding: 8px 12px;
  font-size: 13px;
  color: inherit;
}
.send-quote-menu button:hover { background: var(--paper-hover, rgba(0,0,0,0.05)); }
.send-quote-menu button + button { border-top: 1px solid var(--paper-line, #eee); }

/* ==========================================================
   Bottom nav (mobile) — replaces .top-nav below 768px. Hidden by
   default; the media query near the end of this file switches it on
   and hides the desktop nav. Safe-area padding so it clears the home
   indicator / gesture bar on notched phones.
   ========================================================== */
.bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 55;
  background: var(--card-bg);
  border-top: 1px solid var(--paper-line);
  box-shadow: 0 -4px 16px rgba(23, 33, 30, 0.06);
  padding: 4px 4px calc(4px + env(safe-area-inset-bottom));
}
.bottom-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 52px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  color: var(--ink-subtle);
  text-decoration: none;
  font-size: 10.5px;
  font-weight: 500;
  transition: color 0.15s ease, background 0.15s ease;
}
.bottom-nav-link:active { background: var(--paper-shade); }
.bottom-nav-link.is-active { color: var(--accent-dark); }

/* ==========================================================
   PWA update banner — injected by pwa.js when a new service worker
   is waiting to activate.
   ========================================================== */
.pwa-update-banner {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ink);
  color: #fff;
  padding: 10px 12px 10px 16px;
  border-radius: 999px;
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  max-width: calc(100vw - 32px);
}
.pwa-update-banner button {
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 12px;
}
.pwa-update-banner #pwaUpdateBtn { background: var(--accent); color: #fff; }
.pwa-update-banner #pwaUpdateDismiss { background: transparent; color: rgba(255,255,255,0.6); padding: 6px 4px; font-weight: 400; }

/* ==========================================================
   Install-app button — shown in the header once the browser fires
   beforeinstallprompt (pwa.js). Hidden by default and on platforms
   that never fire it (iOS Safari, already-installed contexts).
   ========================================================== */
#pwaInstallBtn { display: inline-flex; }

/* ==========================================================
   Header decluttering — a WIDER, separate breakpoint from the main
   mobile pass below. The header has enough content (nav, company
   badge, icon cluster, 3 action buttons) that it stops fitting on one
   row well before phone widths — common laptop screens (1280–1440px)
   hit this too. Without this, .ledger-head's flex-wrap fallback above
   would still kick in, but as an ugly uncontrolled 2-row wrap instead
   of the deliberate "fold into a menu" treatment mobile already gets.
   This applies that same treatment earlier, so it stays a clean single
   row at laptop widths and only true phones get the bottom nav /
   touch-target rules in the block below.
   ========================================================== */
@media (max-width: 1180px) {
  #outreachBtn, #addCustomerBtn[class~="btn-ghost"], .header-icon-cluster #importBtn {
    display: none;
  }
  .header-more-wrap { display: block; }
  .account-name-inline { max-width: 80px; }
}

/* ==========================================================
   Mobile responsive pass — one consolidated breakpoint set rather
   than scattering media queries next to each component, so the whole
   picture at each width is easy to see in one place.
   ========================================================== */
@media (max-width: 768px) {
  /* Bottom tab bar takes over primary navigation; free up the header
     for just branding + page-specific actions. */
  .top-nav { display: none; }
  .bottom-nav { display: flex; }
  .ledger, .wrap { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }

  .ledger, .wrap { padding-left: 16px; padding-right: 16px; padding-top: 20px; }

  .ledger-head {
    padding-bottom: 16px;
    margin-bottom: 20px;
  }
  .ledger-head-left { flex-wrap: wrap; row-gap: 8px; }
  .ledger-head-right {
    flex-wrap: wrap;
    width: 100%;
    justify-content: flex-start;
  }
  h1 { font-size: 20px; }

  /* Secondary labeled actions (Outreach, Add customer, Import) and the
     more-menu that replaces them are already handled by the wider
     1180px breakpoint above — nothing further needed here. */

  .header-session-slot { border-right: none; padding-right: 0; margin-right: 0; }
  /* Avatar alone is enough on a phone-width header — full name and
     the chevron are reachable by tapping it open, same pattern as
     Gmail/most mobile apps' account avatar. */
  .account-name-inline, .account-avatar-btn .chevron { display: none; }
  .account-avatar-btn { padding: 3px; }

  /* Same idea as the old analytics-shortcut icon — redundant now that
     the bottom nav covers primary navigation on mobile. */
  #dashboardBackBtn { display: none; }

  /* Touch target sizing — inputs/selects/buttons get comfortably
     tappable, per standard ~44px mobile guidance. */
  .btn-ghost, .btn-solid, .icon-header-btn, .toolbar-filters select,
  .search-field, .drawer-status-row select, .panel-body select,
  .panel-body input[type="text"] {
    min-height: 44px;
  }

  .toolbar-filters { width: 100%; }
  .toolbar-filters select { flex: 1 1 45%; }

  /* Notifications panel — fixed 340px overflowed narrow phones. */
  .notif-panel {
    position: fixed;
    top: 64px;
    left: 12px;
    right: 12px;
    width: auto;
    max-height: 70vh;
  }

  /* Modals/panels — a little less side padding so content has more
     breathing room at ~90vw. */
  .panel { padding: 22px 18px 24px; }
  .panel-xl { width: 95vw; max-height: 92vh; }

  /* Drawer already sits at 92vw — just trim its own padding to match. */
  .drawer { padding: 20px 18px 24px; }

  /* Two-column layouts collapse everywhere. */
  .dash-grid { grid-template-columns: 1fr; }
  .cust-cols { grid-template-columns: 1fr; }

  /* Lead cards — guarantee exactly one full-width card per row instead
     of leaving it to auto-fill/minmax, and trim the padding a bit so
     cards read as phone-sized rather than a shrunk desktop card. The
     min-width:0 fixes above (see .lead-card, .lead-field dd, etc.)
     stop long values from forcing any of this wider than the screen. */
  .card-index { grid-template-columns: 1fr; gap: 10px; }
  .lead-card { padding: 14px 16px; gap: 10px; }
  .lead-card-side { row-gap: 6px; }

  /* Toolbar stacks so the search field gets full width instead of
     being squeezed next to the status filter chips. */
  .quotes-toolbar { flex-direction: column; align-items: stretch; }
  .quotes-toolbar .search-field { max-width: none; }

  /* Quotes table — a wide data table forces horizontal scrolling to
     see every column, which is exactly the "too much scrolling" problem
     on a phone even though the scroll itself was technically contained.
     Below 768px, turn each row into a stacked card instead: hide the
     header row, and let each cell show its own label (from data-label,
     added in quotes.js) above its value. */
  .quotes-table-wrap { overflow-x: visible; background: transparent; border: none; }
  .quotes-table { min-width: 0; }
  .quotes-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
  .quotes-table, .quotes-table tbody, .quotes-table tr, .quotes-table td { display: block; width: 100%; }
  .quotes-table tr {
    background: var(--card-bg);
    border: 1px solid var(--paper-line);
    border-radius: var(--radius-card);
    padding: 6px 14px;
    margin-bottom: 10px;
  }
  .quotes-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px dashed var(--paper-line);
    white-space: normal;
    min-width: 0;
  }
  .quotes-table tr:last-child { margin-bottom: 0; }
  .quotes-table td:last-child { border-bottom: none; }
  .quotes-table td[data-label]::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-subtle);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
  }
  .quotes-table td[data-label=""]::before { display: none; }
  .quotes-table td[data-label=""] { justify-content: flex-end; flex-wrap: wrap; }
  .quotes-table-actions { justify-content: flex-end; }

  /* Quote builder / customer-record-edit form rows — 3 columns of
     inputs side by side was unusably cramped on a phone (each input
     ending up ~90px wide). One column, stacked. */
  .quote-form-row { grid-template-columns: 1fr; }

  /* Customers page — show one pane at a time instead of stacking the
     full list above the full record (which used to mean scrolling
     past everyone just to see the customer you tapped). JS toggles
     .is-showing-detail on selection; see customers.js. */
  .cust-layout.is-showing-detail .cust-sidebar { display: none; }
  .cust-layout:not(.is-showing-detail) .cust-detail { display: none; }
  .cust-layout.is-showing-detail #custBackBtn { display: inline-flex; }

  /* Customer record header — let the Edit details / New quote buttons
     drop to their own full-width row below the name on a phone, rather
     than squeezing next to it (see .cust-record-head above for the fix
     that stops this row forcing the whole page wider). */
  .cust-record-actions { width: 100%; }
  .cust-record-actions .btn-ghost, .cust-record-actions .btn-solid { flex: 1; justify-content: center; }
}

#custBackBtn {
  display: none; /* mobile-only — see .cust-layout.is-showing-detail above */
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--ink-muted);
  font-size: 13.5px;
  font-weight: 500;
  padding: 4px 0 16px;
  cursor: pointer;
}
.cust-back-btn:hover { color: var(--ink); }

@media (max-width: 420px) {
  .stat-strip { grid-template-columns: 1fr 1fr; }
  .cust-stat-grid { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 18px; }
  .bottom-nav-link span { font-size: 10px; }
}