/* ─────────────────────────────────────────────────────────────────
   Donation Management System — mobile-first PWA styles
   Designed for one meshulach driving and tapping through the day.
   ───────────────────────────────────────────────────────────────── */

:root {
  --bg:           #f5f5f7;
  --surface:      #ffffff;
  --surface-2:    #f4f4f5;
  --border:       #e4e4e7;
  --border-strong:#d4d4d8;

  --fg:           #18181b;
  --fg-muted:     #52525b;
  --fg-subtle:    #a1a1aa;

  --accent:       #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft:  #eef2ff;

  --danger:       #dc2626;
  --danger-soft:  #fef2f2;
  --success:      #059669;
  --warning:      #d97706;

  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-pill:  999px;

  --shadow-sm: 0 1px 3px rgba(24,24,27,0.06), 0 1px 2px rgba(24,24,27,0.04);
  --shadow-md: 0 4px 12px rgba(24,24,27,0.08), 0 2px 4px rgba(24,24,27,0.04);

  --tap:          44px;        /* iOS HIG minimum tap target */
  --topbar-h:     56px;
  --bottomnav-h:  52px;        /* shrunk from 72 — nav is utility, not focus */

  /* Safe-area insets for iPhone notch / Android gesture bar */
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

button { font-family: inherit; }

/* Disable double-tap zoom on interactive elements */
a, button, .icon-btn, .card, nav a {
  touch-action: manipulation;
}

/* ─── App bar (header) — top sticky bar with title + actions ──── */
header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--safe-top) 0 0;
}
header > h1 {
  /* The page-title stays prominent; "Donation Management System"
     becomes a small uppercase label */
  margin: 0;
  padding: 0.625rem 1rem 0;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-subtle);
}
header > nav {
  /* The horizontal nav above main is hidden — bottom tab bar replaces it */
  display: none;
}

/* The actual page-specific app bar lives inside the section as h2 */

/* ─── Main column ─────────────────────────────────────────────── */
main {
  padding: 0 0 calc(var(--bottomnav-h) + var(--safe-bottom) + 1rem);
  min-height: 100vh;
}

section {
  background: transparent;
  padding: 1rem;
  border: none;
  border-radius: 0;
  box-shadow: none;
  margin: 0;
}

h2 {
  font-size: 1.625rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0.5rem 0 1rem;
  color: var(--fg);
}

/* ─── Toolbar above lists ─────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
.toolbar .grow { flex: 1; }

/* ─── Card list (replaces tables) ─────────────────────────────── */
.card-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  list-style: none;
  padding: 0;
  margin: 0;
}

.card {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  text-decoration: none;
  color: inherit;
  min-height: var(--tap);
  transition: background-color 100ms, transform 60ms;
}
.card:active { transform: scale(0.99); background: var(--surface-2); }

.card .avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.95rem;
  flex-shrink: 0;
}

.card .body {
  flex: 1;
  min-width: 0;
}
.card .title {
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card .subtitle {
  font-size: 0.8125rem;
  color: var(--fg-muted);
  margin-top: 0.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .chevron {
  flex-shrink: 0;
  color: var(--fg-subtle);
  font-size: 1.2rem;
}

.card .trailing {
  flex-shrink: 0;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.card .trailing .amount {
  font-weight: 600;
  font-size: 1rem;
}

.card-actions {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  margin-left: auto;
}

/* ─── Section group (card-list with index header) ─────────────── */
.list-section-header {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  padding: 1rem 0.25rem 0.375rem;
}

/* ─── Buttons ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: var(--tap);
  padding: 0.625rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  text-decoration: none;
  transition: background-color 100ms, transform 60ms;
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }
.btn:hover { background: var(--surface-2); }

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

.btn:disabled,
.btn-primary:disabled {
  background: var(--surface-2);
  border-color: var(--border);
  color: var(--fg-subtle);
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.7;
}
.btn:disabled .spinner { border-top-color: var(--fg-muted); }

.btn-danger {
  color: var(--danger);
  border-color: var(--border);
}
.btn-danger:hover { background: var(--danger-soft); }
.btn-cancel-route {
  color: var(--fg-muted);
  font-size: 0.875rem;
  margin-top: 0.5rem;
}
.btn-cancel-route:hover { color: var(--danger); background: var(--danger-soft); }

.btn-block { width: 100%; }

/* Floating Action Button — primary "+" in lists */
.fab {
  position: fixed;
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 1rem);
  right: 1rem;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--accent);
  color: white;
  border: none;
  box-shadow: var(--shadow-md);
  font-size: 1.6rem;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 40;
  transition: transform 80ms, background-color 100ms;
}
.fab:active { transform: scale(0.92); background: var(--accent-hover); }

/* ─── Icon-only ghost buttons (in card actions) ──────────────── */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--tap);
  height: var(--tap);
  min-width: var(--tap);
  border-radius: var(--radius-pill);
  border: none;
  background: transparent;
  text-decoration: none;
  color: var(--fg-muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: background-color 100ms, color 100ms;
}
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn.icon-money { color: var(--success); }
.icon-btn.icon-money:hover,
.icon-btn.icon-money:active {
  background: rgba(5, 150, 105, 0.1);
  color: #047857;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.icon-btn:active { background: var(--accent-soft); color: var(--accent); transform: scale(0.94); }

/* Card chevron — visual hint that the row is tappable */
.card .chevron svg {
  width: 22px;
  height: 22px;
  display: block;
}

.btn-link {
  background: transparent;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 0.5rem 0.75rem;
  font-size: 0.9375rem;
  font-family: inherit;
  border-radius: var(--radius-sm);
}
.btn-link:active { background: var(--danger-soft); }

/* ─── Inputs ─────────────────────────────────────────────────── */
input[type=search],
input[type=text],
input[type=email],
input[type=tel],
input[type=number],
input[type=date],
input[type=time],
input[type=file],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.625rem 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 16px;  /* >= 16px prevents iOS zoom on focus */
  font-family: inherit;
  background: var(--surface);
  color: var(--fg);
  transition: border-color 100ms, box-shadow 100ms;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type=search] {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><circle cx='11' cy='11' r='7'/><line x1='21' y1='21' x2='16.65' y2='16.65'/></svg>");
  background-repeat: no-repeat;
  background-size: 16px;
  background-position: 0.75rem center;
  padding-left: 2.25rem;
  -webkit-appearance: none;
}
select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-size: 16px;
  background-position: right 0.75rem center;
  padding-right: 2.25rem;
}
.toolbar .org-filter { max-width: 11rem; }
.toolbar.donation-filters {
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
.toolbar.donation-filters select { flex: 1 1 8rem; min-width: 8rem; max-width: 13rem; }

.history-group-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.history-group-toggle button {
  appearance: none;
  background: var(--surface);
  border: none;
  color: var(--fg-muted);
  padding: 0.3rem 0.8rem;
  font-size: 0.8125rem;
  cursor: pointer;
}
.history-group-toggle button:not(:last-child) { border-right: 1px solid var(--border); }
.history-group-toggle button.is-active {
  background: var(--accent);
  color: white;
  font-weight: 600;
}

.history-group {
  list-style: none;
  margin: 0.75rem 0 0.25rem;
  padding: 0.4rem 0.5rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  font-size: 0.8125rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px dashed var(--border);
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.history-group-label { color: var(--fg); text-transform: none; letter-spacing: 0; }
.history-group-meta { color: var(--fg-muted); }

.check-thumb {
  flex-shrink: 0;
  display: block;
  width: 48px;
  height: 48px;
  margin-right: 0.5rem;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}
.check-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Inline-editable cells (kept for desktop; on mobile we go to detail) */
.cell-edit {
  display: inline-block;
  min-width: 60px;
  padding: 0.2rem 0.45rem;
  border-radius: var(--radius-sm);
}

/* Minimal table styling (used by routes.html only — list pages use cards) */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
thead th {
  font-weight: 500;
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  text-align: left;
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
tbody tr:last-child td { border-bottom: none; }

/* ─── Pagination ─────────────────────────────────────────────── */
.pagination {
  display: flex;
  gap: 0.375rem;
  align-items: center;
  justify-content: center;
  margin-top: 1.25rem;
  font-size: 0.875rem;
  color: var(--fg-muted);
  flex-wrap: wrap;
}
.pagination button {
  min-width: var(--tap);
  min-height: var(--tap);
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--fg);
  font-family: inherit;
  font-size: 0.9375rem;
}
.pagination button.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.pagination button:disabled { opacity: 0.4; cursor: default; }
.pagination .meta { width: 100%; text-align: center; order: -1; }

/* ─── Forms ──────────────────────────────────────────────────── */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.form-grid label {
  display: block;
  color: var(--fg-muted);
  font-weight: 500;
  font-size: 0.8125rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.375rem;
}
.form-grid .field {
  display: flex;
  flex-direction: column;
}
.form-grid .full { width: 100%; }
.form-grid .address-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 0.5rem;
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 0.625rem;
  flex-direction: column-reverse;  /* primary at bottom on mobile = thumb zone */
}

/* Spinner */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: dms-spin 0.7s linear infinite;
  vertical-align: -2px;
  margin-right: 0.4rem;
}
@keyframes dms-spin { to { transform: rotate(360deg); } }

.detail-row {
  display: flex;
  flex-direction: column;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--border);
}
.detail-row:last-child { border-bottom: none; }
.detail-row .label {
  color: var(--fg-muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 0.25rem;
}

/* ─── Bottom tab bar ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
  /* Flex (not a fixed N-column grid) so the bar adapts to however many
     tabs pwa.js actually renders. A fixed `repeat(5, 1fr)` left an empty
     5th slot when an older cached pwa.js shipped only 4 tabs. */
  display: flex;
}
.bottom-nav a {
  position: relative;
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  text-decoration: none;
  color: var(--fg-subtle);
  font-size: 0.6875rem;
  font-weight: 500;
  padding: 0.4rem 0.25rem 0.35rem;
  transition: color 120ms;
}
.bottom-nav a .icon-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  max-width: 100%;
  height: 24px;
  border-radius: var(--radius-pill);
  transition: background-color 160ms;
}
.bottom-nav a .icon-wrap svg {
  width: 18px;
  height: 18px;
  display: block;
  transition: transform 160ms;
}
.bottom-nav a:active .icon-wrap svg { transform: scale(0.92); }
.bottom-nav a.active {
  color: var(--accent);
  font-weight: 600;
}
.bottom-nav a.active .icon-wrap {
  background: var(--accent-soft);
}
.bottom-nav a.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 22px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: var(--accent);
}

/* ─── Misc ────────────────────────────────────────────────────── */
.empty-state {
  padding: 3rem 1rem;
  text-align: center;
  color: var(--fg-subtle);
  font-size: 0.9375rem;
}
.muted { color: var(--fg-muted); font-size: 0.875rem; }

.status-complete { color: var(--success); font-weight: 500; }
.status-pending  { color: var(--warning); }
.status-comeback { color: var(--danger); }

.pill {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: var(--radius-pill);
  font-size: 0.75rem;
  font-weight: 500;
  background: var(--surface-2);
  color: var(--fg-muted);
}
.pill-cash      { background: #ecfeff; color: #0891b2; }
.pill-credit    { background: #f5f3ff; color: #7c3aed; }
.pill-check     { background: #f0fdf4; color: var(--success); }
.pill-complete  { background: #ecfdf5; color: var(--success); }
.pill-comeback  { background: #fffbeb; color: #b45309; }
.pill-pending   { background: var(--surface-2); color: var(--fg-muted); }

/* ─── Route page: wizard stepper ─────────────────────────────── */
.stepper {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0 1.25rem;
  margin: 0;
  position: relative;
}
.stepper .step {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  color: var(--fg-subtle);
  font-size: 0.8125rem;
  font-weight: 500;
}
.stepper .step + .step::before {
  content: '';
  position: absolute;
  left: -50%;
  right: 50%;
  top: 16px;
  height: 2px;
  background: var(--border);
  z-index: 0;
}
.stepper .step.is-done + .step::before { background: var(--accent); }
.stepper .step-num {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.9375rem;
  position: relative;
  z-index: 1;
}
.stepper .step.is-current .step-num {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}
.stepper .step.is-current { color: var(--fg); font-weight: 600; }
.stepper .step.is-done .step-num {
  background: var(--success);
  border-color: var(--success);
  color: white;
}
.stepper .step.is-done .step-num::before { content: '✓'; }
.stepper .step.is-done .step-num span { display: none; }

/* The HTML `hidden` attribute should win over component display rules
   (otherwise .btn's display:flex keeps the locate-btn visible). */
[hidden] { display: none !important; }

/* "Need to be there by" — inline time picker on a selected donor (step 2)
   and on each stop card (step 3). Compact, optional. */
.donor-pick-time {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  background: var(--accent-soft);
  border-top: 1px solid #c7d2fe;
  font-size: 0.8125rem;
  color: var(--accent);
}
.donor-pick-time input { font-size: 0.875rem; padding: 0.2rem 0.4rem; }
.stop-by {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.4rem;
  font-size: 0.75rem;
  color: var(--fg-muted);
}
.stop-by input { font-size: 0.8125rem; padding: 0.15rem 0.35rem; }
.stop-by-warn { color: var(--warning); font-weight: 600; }

/* Sticky bottom action bar for multi-select on step 2 */
.step2-sticky {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  box-shadow: 0 -2px 12px rgba(24,24,27,0.04);
}
.step2-sticky .btn { min-height: 44px; padding: 0.625rem 1.25rem; }
@media (orientation: landscape) and (min-width: 720px) {
  .step2-sticky {
    max-width: 720px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}
/* When the install banner is visible, lift the sticky bar above it so the
   Continue button is reachable instead of being covered. */
body:has(.install-banner.visible) .step2-sticky {
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 4.5rem);
}

/* Selectable donor cards in step 2 */
.donor-pick {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  color: var(--fg);
  transition: background-color 100ms, border-color 100ms;
}
.donor-pick:hover { background: var(--surface-2); }
.donor-pick.is-selected {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.donor-pick .picker-check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 0.875rem;
}
.donor-pick.is-selected .picker-check {
  background: var(--accent);
  border-color: var(--accent);
}
.donor-pick.is-selected .picker-check::before { content: '✓'; }

.picker-section-header {
  list-style: none;
  margin: 0.75rem 0 0.25rem;
  padding: 0.4rem 0.5rem 0.2rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-subtle);
  border-top: 1px solid var(--border);
}

/* ─── Route page: progress indicator + stop cards ───────────── */
.progress-empty {
  padding: 1rem;
  text-align: center;
  color: var(--fg-subtle);
}
.progress-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}
.progress-row strong { font-size: 1.125rem; }
.progress-bar {
  width: 100%;
  height: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--success);
  transition: width 240ms ease;
}

/* ══ Step-3 stop card — phase-aware redesign ══════════════════════
   Active cards lead with Navigate (the every-stop, while-driving
   action). Completion lives in ✓ Visited / ＋ Log Donation. Delete +
   come-back hide in a ⋯ menu. The note is route intelligence: a quiet
   affordance pre-visit, the hero on a completed card. Fraunces gives
   donor names + AI prompts a warm, hand-made character. */
.stop-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 0.85rem 0.95rem 0.95rem;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.stop-card:hover { box-shadow: var(--shadow-md); }

.stop-name {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 1.12rem;
  line-height: 1.15;
  letter-spacing: -0.005em;
  color: var(--fg);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* header row: drag · name · eta · ⋯ */
.stop-head {
  display: grid;
  grid-template-columns: auto auto 1fr auto auto;
  align-items: center;
  gap: 0.5rem;
}
/* Leading tappable check — tap to mark the stop visited (frees the action row). */
.stop-check {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: #fff;
  cursor: pointer;
  padding: 0;
  display: grid;
  place-items: center;
  transition: border-color 0.12s, background 0.12s, transform 0.1s;
}
.stop-check::before {
  content: '✓';
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--success);
  opacity: 0;
  transition: opacity 0.12s;
}
.stop-check:hover { border-color: var(--success); }
.stop-check:hover::before { opacity: 0.45; }
.stop-check:active { transform: scale(0.9); }
.stop-drag {
  /* 44×44 hit zone (gloved thumb in a parked van) — negative margins eat the
     grid gaps so the ≡ glyph keeps its old compact footprint in the row. */
  width: 44px;
  height: 44px;
  margin: -7px -8px;
  border: none;
  background: none;
  cursor: grab;
  color: var(--fg-subtle);
  font-size: 1.15rem;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
  opacity: 0.55;
  touch-action: none; /* handle only — the card body must keep scrolling the page */
  user-select: none;
  transition: opacity 0.12s, color 0.12s;
}
.stop-drag:hover { color: var(--fg); opacity: 1; }
.stop-drag:active { cursor: grabbing; }

/* Reordering: the lifted card tracks the finger via an inline transform on
   its <li>; every OTHER card transitions its transform, so the gap slides
   open instead of popping. .is-settling keeps the lift's elevation while the
   release animation glides the card into its slot. */
#route-list.is-reordering > li { transition: transform 0.15s ease; will-change: transform; }
#route-list.is-reordering > li.is-dragging { transition: none; }
#route-list.drag-no-anim > li { transition: none !important; }
li.is-dragging,
li.is-settling {
  position: relative;
  z-index: 40; /* above neighbours, below the sticky header (50) */
}
li.is-dragging .stop-card,
li.is-settling .stop-card {
  box-shadow: 0 10px 28px rgba(24, 24, 27, 0.2), 0 2px 6px rgba(24, 24, 27, 0.1);
  background: var(--surface);
}

/* ETA / time chip */
.stop-time {
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.28rem 0.5rem;
  border-radius: var(--radius-sm);
  line-height: 1.15;
  white-space: nowrap;
}
.stop-time--eta {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 0.2rem 0.5rem 0.24rem;
  line-height: 1.1;
}
.stop-time--eta .stop-time-label { font-size: 0.5rem; font-weight: 700; letter-spacing: 0.12em; opacity: 0.85; }
.stop-time--eta .stop-time-value { font-size: 0.84rem; font-weight: 700; }

/* ⋯ overflow menu (native <details>) */
.stop-menu { position: relative; justify-self: end; }
.stop-menu > summary { list-style: none; cursor: pointer; }
.stop-menu > summary::-webkit-details-marker { display: none; }
.stop-more {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  display: grid;
  place-items: center;
  color: var(--fg-subtle);
  font-size: 1.3rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}
.stop-menu[open] .stop-more,
.stop-more:hover { background: var(--surface-2); color: var(--fg); }
.stop-menu-pop {
  position: absolute;
  top: 38px;
  right: 0;
  z-index: 8;
  min-width: 196px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: 0.25rem;
}
.stop-menu-pop button {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  width: 100%;
  text-align: left;
  padding: 0.6rem 0.65rem;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 0.875rem;
  color: var(--fg);
  cursor: pointer;
}
.stop-menu-pop button:hover { background: var(--surface-2); }
.stop-menu-pop button.danger { color: var(--danger); }
.stop-menu-pop button.danger:hover { background: var(--danger-soft); }

/* NAVIGATE — the co-primary hero */
.stop-nav {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-top: 0.75rem;
  padding: 0.7rem 0.8rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  background: linear-gradient(180deg, #f6f7ff 0%, var(--accent-soft) 100%);
  border: 1px solid #c9cdf8;
  transition: border-color 0.18s, box-shadow 0.18s, transform 0.1s;
}
.stop-nav:hover { border-color: var(--accent); box-shadow: 0 4px 14px rgba(79, 70, 229, 0.16); }
.stop-nav:active { transform: scale(0.992); }
.stop-nav-badge {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 1.05rem;
  box-shadow: 0 4px 10px rgba(79, 70, 229, 0.3);
}
.stop-nav-addr {
  flex: 1;
  min-width: 0;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.25;
  color: var(--accent);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stop-nav-go {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--accent);
  white-space: nowrap;
}

/* donor sticky — gold context (kept) */
.donor-sticky {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.7rem;
  padding: 0.45rem 0.65rem;
  background: linear-gradient(180deg, #fffdf7, #fef7e6);
  border: 1px solid #fde68a;
  border-left: 3px solid #e0a008;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  line-height: 1.4;
  color: #6b4d12;
}

/* by-time strip (kept, refined) */
.stop-by {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.6rem;
  font-size: 0.78rem;
  color: var(--fg-muted);
}
.stop-by::before { content: '⏱'; font-size: 0.875rem; opacity: 0.7; }
.stop-by-warn { color: var(--warning); font-weight: 700; }

/* ── Phase 6: scheduling-aware stop surfaces ───────────────────────────────
   Visual layer for route's optimizer flags. Markup hooks (which stop gets each
   class) live in renderStep3 and are wired with route; these styles are inert
   until that markup references them. */

/* Hard appointment time (v.apptHard) — a protected "must be there by" commitment.
   Stronger than the soft ⏱ "By HH:MM": amber + lock so a fixed time reads as fixed. */
.stop-by--hard { color: var(--warning); font-weight: 700; }
.stop-by--hard::before { content: '🔒'; opacity: 0.9; }

/* At-risk / bumped flexible stop (v.bumped) — may be skipped today to protect a
   hard-time appointment. A warning surface, never a silent drop. */
.stop-bump-warn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.55rem;
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
  background: #fff7ed;
  border: 1px solid #fcd9a4;
  color: #92400e;
  font-size: 0.76rem;
  font-weight: 600;
  line-height: 1.3;
}
.stop-bump-warn::before { content: '⚠'; flex: 0 0 auto; }
/* Dim a bumped card slightly so attention goes to stops that WILL happen. */
.stop-card.is-bumped { opacity: 0.82; }

/* The hard-time stop the optimizer is fighting to protect — at risk of being
   missed if the route runs long (v._hardAtRisk). Danger-toned so it stands out. */
.stop-hard-risk {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 0.4rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 700;
}
.stop-hard-risk::before { content: '⚠'; }

/* Pickup / home-base bar at the top of step 3 (route.startLocation) — where the
   route starts, for round-trip timing. "📍 Starting from <addr> · Adjust". */
.pickup-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0.5rem 0 0.75rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.82rem;
  color: var(--fg);
}
.pickup-bar .pickup-icon { flex: 0 0 auto; }
.pickup-bar .pickup-label { color: var(--fg-muted); }
.pickup-bar .pickup-addr { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pickup-adjust {
  flex: 0 0 auto;
  background: none;
  border: none;
  padding: 0.1rem 0.2rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  cursor: pointer;
}
.pickup-adjust:hover { text-decoration: underline; }

/* co-primary actions */
.stop-actions { display: flex; gap: 0.5rem; margin-top: 0.8rem; }
.stop-act {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 46px;
  padding: 0 0.85rem;
  border-radius: var(--radius-md);
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  cursor: pointer;
  text-decoration: none;
  border: 1.5px solid transparent;
  transition: background 0.15s, transform 0.1s, box-shadow 0.2s;
}
.stop-act:active { transform: scale(0.97); }
.stop-act-comeback {
  color: var(--warning);
  background: #fff;
  border-color: #fcd9a4;
}
.stop-act-comeback:hover { background: rgba(217, 119, 6, 0.08); }
.stop-act-donate {
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}
.stop-act-donate:hover { background: var(--accent-hover); }

/* pre-visit note affordance (native <details>) */
.stop-note-wrap { margin-top: 0.7rem; }
.stop-note-wrap > summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0;
  font-size: 0.8rem;
  font-weight: 600;
  color: #92400e;
  opacity: 0.85;
}
.stop-note-wrap > summary::-webkit-details-marker { display: none; }
.stop-note-wrap > summary::before { content: '✨'; font-size: 0.9rem; }
.stop-note-wrap > summary:hover { opacity: 1; }
.stop-note-wrap[open] > summary { margin-bottom: 0.45rem; }

/* ── comeback (heavy) ── */
.stop-card.is-comeback {
  border-color: #fcd9a4;
  overflow: hidden;
  padding-left: calc(0.95rem + 4px);
  background: linear-gradient(95deg, rgba(217, 119, 6, 0.09) 0%, rgba(217, 119, 6, 0.03) 46%, var(--surface) 78%);
}
.stop-card.is-comeback::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 7px;
  background: linear-gradient(180deg, #e8920c, var(--warning));
}
.comeback-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin-bottom: 0.6rem;
  padding: 0.28rem 0.62rem;
  background: var(--warning);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  border-radius: var(--radius-pill);
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.25);
}
/* ═══ COMPLETED — intelligence capture is the hero ═══ */
.stop-card.is-done {
  background: linear-gradient(180deg, #fcfbf8, #f7f5f0);
  border-color: var(--border);
  box-shadow: none;
}
.stop-done-head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 0.65rem;
}
.stop-done-check {
  width: 31px;
  height: 31px;
  border-radius: var(--radius-pill);
  flex-shrink: 0;
  background: var(--success);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.95rem;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(5, 150, 105, 0.3);
}
.stop-done-who { min-width: 0; }
.stop-card.is-done .stop-name {
  text-decoration: line-through;
  text-decoration-color: var(--fg-subtle);
  color: var(--fg-muted);
  white-space: normal;
}
.stop-done-sub { font-size: 0.8rem; color: var(--fg-subtle); margin-top: 0.18rem; }
.stop-done-sub .amt { color: var(--success); font-weight: 700; }

.stop-intel {
  margin-top: 0.8rem;
  padding: 0.8rem;
  border-radius: var(--radius-md);
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, #fffdf6 0%, #fdedc8 130%);
  border: 1px solid #f3d79b;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
  animation: stop-intel-rise 0.45s cubic-bezier(0.2, 0.7, 0.3, 1) both;
}
.stop-intel::before {
  content: '';
  position: absolute;
  right: -30px;
  top: -30px;
  width: 110px;
  height: 110px;
  background: radial-gradient(circle, rgba(217, 119, 6, 0.12), transparent 70%);
  pointer-events: none;
}
.stop-intel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 0.98rem;
  color: #92400e;
  letter-spacing: -0.005em;
}
.stop-intel-head::before { content: '✨'; font-size: 1rem; }
.stop-intel-egs { margin-top: 0.5rem; font-size: 0.72rem; color: #9a7327; line-height: 1.5; }
.stop-intel-egs b { color: #92400e; }
@keyframes stop-intel-rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ── note field (shared: pre-visit affordance + completed intel) ── */
.stop-notes-row { position: relative; }
.stop-notes {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #fde68a;
  border-radius: var(--radius-sm);
  padding: 0.6rem 2.6rem 0.6rem 0.7rem;
  min-height: 46px;
  line-height: 1.4;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.stop-notes::placeholder { color: #b07d2e; opacity: 0.7; }
.stop-notes:hover { border-color: #fcd34d; }
.stop-notes:focus {
  outline: none;
  border-color: var(--warning);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.16);
  background: #fff;
}
.stop-notes-ai {
  position: absolute;
  top: 8px;
  right: 8px;
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  padding: 0.16rem 0.42rem;
  font-size: 0.625rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #92400e;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #fde68a;
  border-radius: var(--radius-pill);
  pointer-events: none;
}
.stop-notes-ai::before { content: '✨'; font-size: 0.7rem; }
.stop-notes-row.is-extracting .stop-notes-ai { animation: stop-notes-ai-pulse 1.4s ease-in-out infinite; }
@keyframes stop-notes-ai-pulse {
  0%, 100% { background: rgba(255, 255, 255, 0.92); box-shadow: 0 0 0 0 rgba(217, 119, 6, 0); transform: scale(1); }
  50% { background: rgba(253, 237, 200, 0.95); box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.2); transform: scale(1.06); }
}

/* ── Inline "come back later" capture (why + when) ── */
.cb-capture {
  margin-top: 0.75rem;
  padding: 0.8rem;
  border-radius: var(--radius-md);
  background: linear-gradient(180deg, #fffdf6, #fef6e3);
  border: 1px solid #f3d79b;
}
.cb-cap-head {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 600;
  font-size: 0.95rem;
  color: #92400e;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}
.cb-cap-head::before { content: '✨'; }
.cb-cap-head span { font-family: inherit; font-weight: 500; font-size: 0.72rem; color: #9a7327; }
.cb-reasons { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.65rem; }
.cb-chip {
  flex: 1 1 auto;
  padding: 0.5rem 0.7rem;
  border-radius: var(--radius-pill);
  border: 1px solid #f3d79b;
  background: rgba(255, 255, 255, 0.7);
  color: #92400e;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.cb-chip:hover { border-color: #e0a008; }
.cb-chip.on { background: var(--warning); border-color: var(--warning); color: #fff; }
.cb-when-row { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.5rem; }
.cb-when-hint { font-size: 0.72rem; line-height: 1.4; color: #9a7327; margin: 0.1rem 0 0.6rem; }
.cb-when-label {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9a7327;
  margin-bottom: 0.3rem;
}
.cb-date,
.cb-note {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 0.9rem;
  color: var(--fg);
  background: #fff;
  border: 1px solid #f3d79b;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.6rem;
}
.cb-date { margin-bottom: 0.55rem; }
.cb-note { resize: none; min-height: 40px; line-height: 1.4; margin-bottom: 0.65rem; }
.cb-note::placeholder { color: #b07d2e; opacity: 0.7; }
.cb-date:focus,
.cb-note:focus { outline: none; border-color: var(--warning); box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.16); }
.cb-cap-actions { display: flex; gap: 0.5rem; }
.cb-cap-actions .btn { flex: 1; min-height: 42px; }

/* ── Step-4 summary rows (own classes; independent of .stop-card) ── */
.sum-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.6rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.75rem 0.85rem;
}
.sum-main { min-width: 0; }
.sum-name { font-weight: 600; font-size: 0.95rem; color: var(--fg); }
.sum-addr { font-size: 0.8rem; color: var(--fg-muted); margin-top: 0.1rem; }
.sum-note { font-size: 0.8125rem; color: var(--fg); margin-top: 0.25rem; }
.sum-tag { flex-shrink: 0; font-size: 0.8rem; font-weight: 600; white-space: nowrap; }

/* Version chip — top-right, mirrors the net-status pill on the left.
   Background changes with auth state so the 🔒 / ⚠ icon is reinforced. */
.version-chip[data-authed="1"] { background: #0a7a3a; color: white; }
.version-chip[data-authed="0"] { background: #a33; color: white; }
.version-chip {
  position: fixed;
  top: calc(var(--safe-top) + 0.5rem);
  right: 0.75rem;
  z-index: 70;
  padding: 0.2rem 0.625rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  /* pointer-events stays default so chip-tap auth diagnostic works. */
}

/* Online / offline status pill */
.net-status {
  position: fixed;
  top: calc(var(--safe-top) + 0.5rem);
  left: 0.75rem;
  z-index: 70;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.625rem;
  border-radius: var(--radius-pill);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-muted);
  pointer-events: none;
  opacity: 0;
  transition: opacity 200ms;
}
.net-status .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.18);
}
.net-status[data-state="offline"] {
  opacity: 1;
  color: var(--warning);
}
.net-status[data-state="offline"] .dot {
  background: var(--warning);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.18);
}
/* Online state stays subtle — only flash briefly when reconnecting */
.net-status[data-state="online"] {
  opacity: 0;
}

/* Install prompt banner */
.install-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 1rem);
  background: var(--fg);
  color: white;
  padding: 0.875rem 1rem;
  border-radius: var(--radius-md);
  display: none;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-md);
  z-index: 60;
}
.install-banner.visible { display: flex; }
.install-banner span { flex: 1; font-size: 0.875rem; }
.install-banner button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
}
.install-banner .close {
  background: transparent;
  color: var(--fg-subtle);
  padding: 0.25rem 0.5rem;
}

/* Update-available banner — anchored at the top so it doesn't fight the
   install-banner at the bottom. Same color/typography vocabulary as install. */
.update-banner {
  position: fixed;
  left: 1rem;
  right: 1rem;
  top: calc(var(--safe-top, 0px) + 0.75rem);
  background: var(--fg);
  color: white;
  padding: 0.75rem 0.875rem;
  border-radius: var(--radius-md);
  display: none;
  align-items: center;
  gap: 0.75rem;
  box-shadow: var(--shadow-md);
  z-index: 70;
  transform: translateY(-120%);
  transition: transform 200ms ease;
}
.update-banner.visible { display: flex; transform: translateY(0); }
.update-banner span { flex: 1; font-size: 0.875rem; }
.update-banner button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 0.5rem 0.875rem;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
}
.update-banner .close {
  background: transparent;
  color: var(--fg-subtle);
  padding: 0.25rem 0.5rem;
}

/* ─── Tablet portrait (~600-900px) ────────────────────────────── */
@media (min-width: 600px) {
  main {
    max-width: 720px;
    margin: 0 auto;
    padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + 2rem);
  }
  section { padding: 1.25rem 1.5rem; }
  h2 { font-size: 1.875rem; }
  .card { padding: 1rem 1.25rem; }
  .card .avatar { width: 44px; height: 44px; font-size: 1rem; }
}

/* ─── Tablet landscape / desktop (~900px+) ────────────────────── */
@media (min-width: 900px) {
  main { max-width: 1100px; padding: 0 1rem calc(var(--bottomnav-h) + var(--safe-bottom) + 2rem); }
  header > h1 { padding: 0.875rem 1.5rem 0; font-size: 0.7rem; }
  section { padding: 1.5rem 2rem; }
  h2 { font-size: 2rem; }

  /* Two-column card grid on lists */
  .card-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.625rem 1rem;
  }
  .card { padding: 1.125rem 1.25rem; }
  .card .avatar { width: 48px; height: 48px; font-size: 1.05rem; }
  .card .title { font-size: 1.0625rem; }
  .card .subtitle { font-size: 0.875rem; }

  /* Forms get more comfortable spacing */
  .form-grid { max-width: 720px; }
  .form-actions { flex-direction: row; max-width: 720px; }
  .form-actions .btn-primary { flex: 1; }
}

/* ─── Bottom nav: shape follows orientation, not pixel width.
   Portrait (any device) = full-width like a native tab bar.
   Landscape = floating centered pill (avoids a stretched bar
   across a wide laptop / landscape tablet). ──────────────────── */
@media (orientation: landscape) and (min-width: 720px) {
  .bottom-nav {
    max-width: 540px;
    left: 50%;
    right: auto;
    transform: translateX(-50%);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -2px 12px rgba(24,24,27,0.08);
  }
}

/* ─── Wide tablet / desktop (~1200px+) — more columns ────────── */
@media (min-width: 1200px) {
  main { max-width: 1280px; }
  .card-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* Route page lists always go top-to-bottom (single column on every size). */
#route-list, #donor-search-results {
  display: flex !important;
  flex-direction: column;
  gap: 0.625rem;
}

/* ── Dashboard / landing page ─────────────────────────────────── */
.dashboard {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  padding-top: 0.5rem;
}
.dash-date {
  font-size: 0.8125rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.dash-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem 1.25rem;
  box-shadow: var(--shadow-sm);
}
.dash-eyebrow {
  margin: 0 0 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.dash-headline {
  margin: 0 0 0.25rem;
  font-size: 1.375rem;
  font-weight: 700;
  color: var(--fg);
}
.dash-sub {
  margin: 0 0 0.25rem;
  font-size: 0.9375rem;
  color: var(--fg-muted);
}
.dash-card .progress-bar { margin: 0.75rem 0 1.25rem; }
.dash-card .btn-block { margin-top: 0.25rem; }
.dash-empty, .dash-progress { text-align: left; }
.dash-done { text-align: center; }
.dash-check {
  width: 64px;
  height: 64px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: var(--success);
  color: #fff;
  font-size: 2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dash-done .dash-sub { text-align: center; }
.dash-done .dash-headline { text-align: center; margin-bottom: 0.5rem; }

.dash-totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.75rem 0 1rem;
  padding: 0.75rem 0.5rem;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.dash-totals > div {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.dash-total-num {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--fg);
}
.dash-total-lbl {
  font-size: 0.7rem;
  color: var(--fg-subtle);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.125rem;
}

.dash-comebacks-card {
  margin-top: 0.75rem;
  padding: 0.75rem 1rem;
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
}
.dash-comebacks-card .dash-eyebrow {
  color: #713f12;
  font-weight: 600;
  margin: 0 0 0.5rem;
}
.cb-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cb-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.25rem 0;
  font-size: 0.875rem;
  color: #713f12;
}
.cb-name { font-weight: 500; }
.cb-orig { font-size: 0.75rem; color: #92400e; font-style: italic; }

.cb-banner {
  margin: 0 0 0.875rem;
  padding: 0.75rem 0.875rem;
  background: #fef9c3;
  border: 1px solid #fde68a;
  border-radius: var(--radius-md);
}
.cb-banner-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 600;
  color: #713f12;
  margin-bottom: 0.5rem;
}
.cb-banner .btn-sm { padding: 0.25rem 0.6rem; font-size: 0.8125rem; }
.cb-banner .cb-list li { color: #713f12; }

/* ─── Force-portrait fallback overlay ───────────────────────────
   The real lock is screen.orientation.lock('portrait') in pwa.js, which
   works once the app owns orientation (installed PWA / standalone). This
   overlay only appears in the one gap that can't cover: a plain browser
   tab held landscape on a touch device. Hidden everywhere else. */
.rotate-overlay { display: none; }
@media (pointer: coarse) and (orientation: landscape) {
  html.dms-force-portrait .rotate-overlay {
    display: flex;
    position: fixed;
    inset: 0;
    z-index: 10000;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--bg, #f5f5f7);
    color: var(--text, #18181b);
    text-align: center;
  }
  html.dms-force-portrait .rotate-overlay svg { width: 64px; height: 64px; opacity: 0.7; }
  html.dms-force-portrait .rotate-overlay p { font-size: 1.0625rem; font-weight: 600; margin: 0; }
}

/* ─── Visible enrollment button (replaces the hidden version-chip tap) ───
   Sits just above the bottom nav, right side. Owner = "Enroll a device",
   un-enrolled device = "Enter access PIN". Built in pwa.js / buildEnrollUI. */
.enroll-fab {
  position: fixed;
  right: 0.75rem;
  bottom: calc(var(--bottomnav-h, 64px) + var(--safe-bottom, 0px) + 0.6rem);
  z-index: 75;
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--fg);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(24,24,27,0.12);
  cursor: pointer;
}
.enroll-fab:active { transform: scale(0.97); }
/* Owner: subtle. Un-enrolled device: loud, since enrolling is the whole task. */
.enroll-fab[data-role="guest"] {
  background: var(--warning, #a33);
  color: #fff;
  border-color: transparent;
}

/* ─── Home-screen enrollment gate (auto-shown when signed out) ───
   Full-screen overlay built in pwa.js / buildEnrollGate. The FAB stays as the
   re-entry point if the gate is dismissed with "Not now". */
.enroll-gate {
  position: fixed;
  inset: 0;
  z-index: 300;                /* above the FAB, install banner and bottom nav */
  background: rgba(24, 24, 27, 0.55);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}
.enroll-gate-card {
  background: var(--surface, #fff);
  color: var(--fg);
  border-radius: var(--radius-lg, 0.75rem);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  padding: 1.5rem 1.25rem;
  width: 100%;
  max-width: 22rem;
  text-align: center;
}
.enroll-gate-icon { font-size: 2rem; }
.enroll-gate-card h2 { margin: 0.5rem 0 0.35rem; }
.enroll-gate-card p { color: var(--fg-muted); font-size: 0.875rem; margin: 0 0 1rem; }
.enroll-gate-card input {
  width: 100%;
  text-align: center;
  font-size: 1.4rem;
  letter-spacing: 0.35em;
  padding: 0.6rem 0.5rem;
  margin-bottom: 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 0.5rem);
  background: var(--bg);
  color: var(--fg);
}
.enroll-gate-status {
  min-height: 1.25rem;
  font-size: 0.8125rem;
  margin-top: 0.6rem;
  white-space: pre-line;
}
.enroll-gate-dismiss {
  margin-top: 0.75rem;
  background: none;
  border: none;
  color: var(--fg-muted);
  font-size: 0.8125rem;
  text-decoration: underline;
  cursor: pointer;
}
