/* ==========================================================
   Constructa design system
   Built for: gloved thumbs, sunlight, 4G, one-handed use.
   Rules of the house:
   - Tap targets: 48px minimum, 52px for primary actions,
     64px for card summary rows.
   - The status rail (left edge of cards) is the one visual
     signature. Red = needs attention, amber = pending,
     green = confirmed/active, grey = neutral/inactive.
   - System fonts only. No frameworks. No build step.
   ========================================================== */

:root {
  --ink: #171b21;
  --ink-soft: #4d545e;
  --ink-faint: #8a919b;
  --paper: #f3f2ee;
  --card: #ffffff;
  --line: #e2e0da;
  --amber: #f5a800;      /* primary action — hi-vis */
  --amber-press: #dd9700;
  --red: #c23b2e;        /* needs attention / unconfirmed */
  --green: #2e7d43;      /* confirmed / active / working */
  --blue: #2b6cb0;       /* informational */
  --red-soft: #faeae8;
  --green-soft: #e9f3ec;
  --amber-soft: #fdf3d8;
  --blue-soft: #e8f0fa;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(23, 27, 33, 0.1);
  --nav-h: 64px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

/* ---------- Header ---------- */

.app-header {
  background: var(--ink);
  color: #fff;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.app-header .mark {
  width: 10px;
  height: 22px;
  background: var(--amber);
  border-radius: 2px;
}

/* ---------- Navigation ----------
   Desktop: tab strip under the header.
   Mobile (<=680px): fixed bottom bar, thumb territory. */

.nav {
  display: flex;
  background: #232a33;
}
.nav-item {
  flex: 1;
  min-height: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #9aa3ad;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 3px solid transparent;
  -webkit-tap-highlight-color: transparent;
}
.nav-item .nav-icon { font-size: 20px; line-height: 1; }
.nav-item.active { color: #fff; border-bottom-color: var(--amber); }
.nav-item:focus-visible { outline: 2px solid var(--amber); outline-offset: -2px; }

@media (max-width: 680px) {
  .nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    border-top: 1px solid #000;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .nav-item {
    min-height: var(--nav-h);
    font-size: 12px;
    border-bottom: none;
    border-top: 3px solid transparent;
  }
  .nav-item.active { border-top-color: var(--amber); }
  body { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px); }
}

/* ---------- Layout ---------- */

.content {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px;
}
.panel { display: none; }
.panel.active { display: block; }

.panel-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 4px 0 14px;
}
.panel-header h2 { margin: 0; font-size: 20px; font-weight: 700; }
.panel-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ---------- Buttons ---------- */

.btn {
  min-height: 48px;
  padding: 0 20px;
  border: none;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  color: var(--ink);
  background: #e7e5e0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

.btn-primary { background: var(--amber); min-height: 52px; }
.btn-primary:active { background: var(--amber-press); }
.btn-danger-quiet { background: var(--red-soft); color: var(--red); }
.btn-block { width: 100%; }

/* ---------- Search ---------- */

.search {
  width: 100%;
  min-height: 48px;
  padding: 0 16px;
  font-size: 16px;
  font-family: inherit;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  margin-bottom: 12px;
  color: var(--ink);
}
.search:focus { outline: 2px solid var(--blue); border-color: var(--blue); }

/* ---------- Cards + accordion ----------
   .card > .card-head (always visible, whole row tappable)
        > .card-body (accordion detail, hidden until open) */

.card-list { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 5px solid var(--ink-faint); /* status rail */
  overflow: hidden;
}
.card.rail-red   { border-left-color: var(--red); }
.card.rail-amber { border-left-color: var(--amber); }
.card.rail-green { border-left-color: var(--green); }
.card.rail-blue  { border-left-color: var(--blue); }

.card-head {
  width: 100%;
  min-height: 64px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 16px;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  -webkit-tap-highlight-color: transparent;
}
.card-head:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }

.card-title-wrap { flex: 1; min-width: 0; }
.card-title {
  font-weight: 700;
  font-size: 17px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.card-sub {
  margin-top: 3px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.chevron {
  flex: none;
  width: 24px;
  height: 24px;
  color: var(--ink-faint);
  transition: transform 0.18s ease;
}
.card.open .chevron { transform: rotate(180deg); }

.card-body {
  display: none;
  padding: 2px 16px 16px;
  border-top: 1px solid var(--line);
}
.card.open .card-body { display: block; }

.detail-grid { margin: 12px 0; }
.detail-row { padding: 6px 0; }
.detail-label {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-faint);
}
.detail-value { font-size: 16px; color: var(--ink); overflow-wrap: anywhere; }

/* A detail row that drills into another record (client/property, etc).
   Real <button> for keyboard/focus, styled to read as a link. */
button.detail-link {
  background: none; border: none; padding: 0; margin: 0;
  font: inherit; font-size: 16px; font-weight: 700; color: var(--blue);
  cursor: pointer; text-decoration: none; text-align: left;
  -webkit-tap-highlight-color: transparent;
}
button.detail-link:hover, button.detail-link:focus-visible { text-decoration: underline; }
button.detail-link:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
}
.card-actions .btn { flex: 1; }
.card-actions select { flex: 1; min-width: 140px; margin: 0; }

/* Optional second column in a card's expanded body (renderCard's `side`
   param) — stacked on mobile (one-handed use comes first), side-by-side
   once there's room. Used by the Jobs tab for its activity/status panel;
   every other card list just never passes `side` and is unaffected. */
.card-body-columns { display: flex; flex-direction: column; gap: 14px; }
.card-body-main { flex: 1; min-width: 0; }
.card-body-side {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
@media (min-width: 680px) {
  .card-body-columns { flex-direction: row; }
  .card-body-side {
    flex: 0 0 220px;
    border-top: none;
    border-left: 1px solid var(--line);
    padding-top: 0;
    padding-left: 16px;
  }
}

/* Job card activity panel: milestone icons (done = filled/coloured,
   pending = dimmed — "done steps ticked, future steps dimmed") + a
   short chronological feed. Built from fields already in the job list
   payload, no extra request per card. */
.job-milestones { display: flex; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.job-milestone { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 52px; opacity: 0.4; }
.job-milestone.done { opacity: 1; }
.job-milestone-icon {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper); font-size: 15px; line-height: 1;
}
.job-milestone.done .job-milestone-icon { background: var(--green-soft); }
.job-milestone-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--ink-faint); text-align: center;
}
.job-history-list { display: flex; flex-direction: column; gap: 10px; }
.job-history-item { font-size: 13px; }
.job-history-time { color: var(--ink-faint); font-size: 12px; margin-top: 1px; }

/* Jobs list: thinner collapsed rows than the default card list, so more
   jobs sit above the fold — scoped to #jobCards only, every other tab's
   card list (Dashboard/Contractors/Clients) is untouched. Stays clear of
   the ≥64px tap-target floor (.card-head's min-height) — this only
   trims the padding/gaps around that floor, not the floor itself. */
#jobCards { gap: 6px; }
#jobCards .card-head { padding: 8px 14px; }
#jobCards .card-sub { margin-top: 2px; }

/* Jobs used to go 2-column at >=1000px here — removed: cards (open or
   not) should be full width, same as every other tab's card list. */

/* ---------- Desktop-only density ----------
   The 2-column grid tried here for Contractors/Clients/Properties (same
   treatment as Jobs above) was reverted per feedback, same as Jobs was —
   every tab's card list is single-column, full width, regardless of
   viewport. The hover affordance stays: cards pick up a highlight for
   mouse users, guarded by `hover: hover` + `pointer: fine` so it can
   never get stuck "on" after a tap on a touchscreen laptop. */
@media (hover: hover) and (pointer: fine) {
  .card-head:hover { background: rgba(23, 27, 33, 0.035); }
  .chip-filter:hover { border-color: var(--ink-faint); }
  button.stat-tile:hover { background: rgba(23, 27, 33, 0.02); }
}

/* Registered-contractor engagement snapshot (Contractors tab card's
   side panel) — a job-completed count at three lookback windows, so an
   admin can see at a glance whether a registered contractor is still
   actively taking jobs. */
.engagement-stats { display: flex; gap: 14px; }
.engagement-stat { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.engagement-stat-value {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--green-soft); color: var(--green);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.engagement-stat-label {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--ink-faint);
}

/* ---------- Chips ---------- */

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 1px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: #eceae5;
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip-red   { background: var(--red-soft);   color: var(--red); }
.chip-green { background: var(--green-soft); color: var(--green); }
.chip-amber { background: var(--amber-soft); color: #8a6100; }

/* ---------- Empty state ---------- */

.empty {
  text-align: center;
  color: var(--ink-faint);
  padding: 40px 16px;
  font-size: 16px;
}

/* ---------- Modal / bottom sheet ----------
   Desktop: centered dialog. Mobile: full-height sheet. */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 27, 33, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-overlay.active { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  width: 520px;
  max-width: 94vw;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.3);
}
.modal-title {
  margin: 0;
  padding: 18px 20px 12px;
  font-size: 18px;
  font-weight: 700;
}

/* Modals reachable by drilling down from another one (job/client/
   property detail+edit, reached via map pins, job cards, and each
   other) wrap their title in this row with a Back control ahead of it —
   see modalBack()/pushModalNav() in admin.js. Hidden by default per
   modal instance; JS shows it once there's actually somewhere to go
   back to. Modals that are always a dead end (broadcast, map) keep the
   plain .modal-title above, untouched. */
.modal-title-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 20px 12px;
}
.modal-title-row .modal-title { padding: 0; }
.modal-back-btn {
  flex: none;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--ink-soft);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.modal-back-btn:hover { background: rgba(23, 27, 33, 0.06); }
.modal-back-btn:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.modal-scroll { overflow-y: auto; padding: 0 20px; flex: 1; }
.modal-actions {
  display: flex;
  gap: 10px;
  padding: 14px 20px calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
}
.modal-actions .btn { flex: 1; }

@media (max-width: 680px) {
  .modal-overlay.active { align-items: stretch; }
  .modal {
    width: 100%;
    max-width: none;
    max-height: none;
    border-radius: 0;
  }
}

/* ---------- Forms ---------- */

.form-group { margin-bottom: 16px; }
.form-group > label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
input[type="text"], input[type="date"], input[type="time"], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 16px; /* prevents iOS zoom-on-focus */
  font-family: inherit;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
}
textarea { min-height: 72px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--blue);
  border-color: var(--blue);
}

/* Checkbox groups: each option is a full-width 44px+ tap row */
.checkbox-group {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  max-height: 220px;
  overflow-y: auto;
}
.checkbox-group label,
.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 4px 12px;
  font-size: 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.checkbox-group label:last-child { border-bottom: none; }

/* Broadcast candidate rows: company name + (for 'individuals' mode)
   the active employees a tick would actually text, so it's obvious up
   front who a checked company reaches, not just its name. */
.broadcast-candidate-info { display: flex; flex-direction: column; gap: 2px; padding: 6px 0; min-width: 0; }
.broadcast-candidate-name { overflow-wrap: anywhere; }
.broadcast-candidate-employees { font-size: 13px; }
.checkbox-group input[type="checkbox"],
.check-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: none;
  accent-color: var(--green);
}

.hint { font-size: 13px; color: var(--ink-faint); }

/* ---------- Filter chips (quick status filters above a card list) ---------- */

.filter-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.chip-filter {
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip-filter.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip-filter:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

.warning-box {
  background: var(--amber-soft);
  border: 1px solid var(--amber);
  color: #6b4c00;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin: 10px 0;
  font-size: 15px;
}

.report-box {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  margin-top: 14px;
  font-size: 15px;
  display: none;
}
.report-box ul { margin: 8px 0 0; padding-left: 20px; }

/* ---------- Info box (draft/explainer banners) ---------- */

.info-box {
  background: var(--blue-soft);
  border: 1px solid var(--blue);
  color: #1d4c7a;
  padding: 12px 14px;
  border-radius: var(--radius);
  margin: 0 0 14px;
  font-size: 14px;
}

/* ---------- Stat tiles (Analytics) ---------- */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.stat-tile {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-left: 5px solid var(--ink-faint);
  padding: 14px 16px;
}
.stat-tile.rail-red   { border-left-color: var(--red); }
.stat-tile.rail-amber { border-left-color: var(--amber); }
.stat-tile.rail-green { border-left-color: var(--green); }
.stat-tile.rail-blue  { border-left-color: var(--blue); }
button.stat-tile {
  border: none; border-left: 5px solid var(--ink-faint);
  text-align: left; font: inherit; color: inherit;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
button.stat-tile.rail-red   { border-left-color: var(--red); }
button.stat-tile.rail-amber { border-left-color: var(--amber); }
button.stat-tile.rail-green { border-left-color: var(--green); }
button.stat-tile.rail-blue  { border-left-color: var(--blue); }
button.stat-tile:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.stat-tile.active { box-shadow: 0 0 0 2px var(--ink) inset, var(--shadow); }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1.1; }
.stat-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--ink-faint); margin-top: 4px;
}
.stat-delta { font-size: 13px; font-weight: 600; margin-top: 2px; }
.stat-delta.up { color: var(--green); }
.stat-delta.down { color: var(--red); }

/* ---------- Map (Jobs tab → Map button) ----------
   Real Leaflet/OSM map — see openMapOverlay()/renderMapMarkers() in
   jobs.js. Status is never colour-only on the map: every pin carries a
   distinct glyph (see JOB_STATUS_ICON) in addition to its rail colour,
   and the legend spells out colour + glyph + label together. */

.modal-map { width: 920px; }

.map-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  margin-bottom: 14px;
}
.map-filter-group { flex: 1; min-width: 220px; }
.map-filter-group select { min-height: 44px; }
.map-custom-range { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.map-custom-range input[type="date"] { min-height: 44px; }

#map-canvas {
  height: 420px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--paper); /* visible while tiles are still loading */
}
@media (max-width: 680px) {
  #map-canvas { height: 320px; }
}

/* Custom divIcon markers — a coloured circle (status rail colour) with
   a status-specific glyph inside, so shape/symbol carries the meaning
   too, not just hue. */
.map-pin-icon {
  width: 30px; height: 30px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.35);
  background: var(--ink-faint);
}
.map-pin-icon span { transform: rotate(45deg); font-size: 14px; line-height: 1; }
.map-pin-icon.rail-red   { background: var(--red); }
.map-pin-icon.rail-amber { background: var(--amber); }
.map-pin-icon.rail-blue  { background: var(--blue); }
.map-pin-icon.rail-green { background: var(--green); }

.map-popup { font-size: 14px; min-width: 180px; }
.map-popup .map-popup-title { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.map-popup .map-popup-row { color: var(--ink-soft); margin-bottom: 2px; }
.map-popup .btn { min-height: 36px; padding: 0 12px; font-size: 13px; margin-top: 8px; width: 100%; }

.map-legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 14px 0; }
.map-legend-item { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-soft); }
.map-legend-dot {
  width: 20px; height: 20px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center; font-size: 11px;
}
.map-legend-dot.rail-red   { background: var(--red); }
.map-legend-dot.rail-amber { background: var(--amber); }
.map-legend-dot.rail-blue  { background: var(--blue); }
.map-legend-dot.rail-green { background: var(--green); }
.map-legend-dot.rail-grey  { background: var(--ink-faint); }

/* ---------- Calendar grid (Calendar tab) ---------- */

.cal-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.cal-month-label { font-size: 17px; font-weight: 700; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-headcell {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--ink-faint); text-align: center; padding: 4px 0 8px;
}
.cal-day {
  display: block;
  width: 100%;
  margin: 0;
  min-height: 60px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 5px;
  font-size: 12px;
  font-family: inherit;
  text-align: left;
  color: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cal-day:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.cal-day.other-month { background: transparent; border-color: transparent; pointer-events: none; }
.cal-day.today { border: 2px solid var(--blue); }
.cal-daynum { font-weight: 700; font-size: 12px; color: var(--ink-soft); }
.cal-dots { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 3px; }

/* Numbered event badges — a coloured circle per event type present that
   day (New/Assigned/Scheduled, not the full 7-status palette — see the
   Calendar section comment in jobs.js), each carrying its own count
   rather than a plain dot. */
.cal-badge {
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 3px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
}
.cal-badge.amber { background: var(--amber); color: var(--ink); } /* amber is light — dark text reads better here, same as .btn-primary */
.cal-badge.blue  { background: var(--blue);  color: #fff; }
.cal-badge.green { background: var(--green); color: #fff; }

/* ---------- Phone-frame preview (Field app tab) ---------- */

.phone-frame {
  width: 260px;
  max-width: 100%;
  margin: 0 auto;
  border: 8px solid var(--ink);
  border-radius: 28px;
  background: var(--paper);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.phone-screen { padding: 16px 14px 20px; }
.phone-step {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; color: var(--ink-faint); margin-bottom: 4px;
}
.phone-step.done { color: var(--green); }
.phone-step.done::before { content: "✓"; font-weight: 700; }
.phone-step.current { color: var(--ink); font-weight: 700; }
.phone-big-btn {
  width: 100%; min-height: 96px; margin: 14px 0;
  background: var(--amber); border: none; border-radius: var(--radius);
  font-size: 18px; font-weight: 800; color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
}
.phone-big-btn .icon { font-size: 28px; }
.phone-guide { font-size: 13px; color: var(--ink-soft); background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }

/* ---------- Motion discipline ---------- */

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ---------- Desktop: left sidebar nav ----------
   Header spans the full top; nav becomes a fixed-width column on the
   left below it; content fills the rest. CSS grid on <body> — header,
   nav and content are already siblings, so this needs no wrapper.
   Placed at the END of the file on purpose: at equal specificity the
   later rule wins regardless of media match, so this has to come after
   the base .content/.nav/.app-header rules above or they'd clobber it
   (this exact bug shipped once already — .content's base `margin: 0
   auto` was winning and grid's auto-margin behavior shrink-fit +
   centered the content column instead of stretching it). */

@media (min-width: 681px) {
  body {
    display: grid;
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas: "header header" "nav content";
    min-height: 100vh;
  }
  .app-header { grid-area: header; }
  .nav {
    grid-area: nav;
    flex-direction: column;
    align-items: stretch;
    border-right: 1px solid #000;
    overflow-y: auto;
    padding: 10px 0;
  }
  .nav-item {
    flex: none;
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 0 22px;
    min-height: 48px;
    border-bottom: none;
    border-left: 3px solid transparent;
  }
  .nav-item .nav-icon { font-size: 17px; width: 20px; text-align: center; }
  .nav-item.active { border-left-color: var(--amber); border-bottom-color: transparent; background: rgba(255, 255, 255, 0.06); }
  .content {
    grid-area: content;
    max-width: none;
    margin: 0;
    padding: 24px 32px;
  }
}
