/* Route Planner Teams (2026-10-15). Uses the site tokens from global.css, so
   light and dark both follow the header's theme switch. */
.tm-app { max-width: 1240px; margin: 0 auto; padding: 16px; color: var(--text); }
.tm-app [hidden], .tm-dialog [hidden] { display: none !important; }
.tm-loading { padding: 48px 0; text-align: center; color: var(--text-muted); }

.tm-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-xl); padding: 24px; box-shadow: var(--shadow); }
.tm-narrow { max-width: 560px; margin: 24px auto; }
.tm-card h1 { font-size: 1.5rem; margin: 0 0 8px; }
.tm-card p { margin: 0 0 12px; line-height: 1.5; }
.tm-muted { color: var(--text-muted); font-weight: normal; }
.tm-points { margin: 0 0 20px; padding-left: 20px; line-height: 1.6; }

.tm-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 14px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; font-size: 0.92rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.tm-btn:hover { background: var(--hover-bg); }
.tm-btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.tm-btn-primary:hover { background: var(--primary); filter: brightness(1.08); }
.tm-btn-danger { color: var(--danger); }
.tm-btn-small { min-height: 32px; padding: 4px 10px; font-size: 0.85rem; }
.tm-btn:disabled { opacity: 0.55; cursor: default; }

.tm-form { display: flex; flex-direction: column; gap: 6px; }
.tm-form label { font-weight: 600; font-size: 0.9rem; margin-top: 8px; }
.tm-form input[type="text"], .tm-form input[type="email"], .tm-form input[type="tel"], .tm-form input[type="password"],
.tm-form input[type="time"], .tm-form select {
  width: 100%; box-sizing: border-box; min-height: 42px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: var(--radius-md); background: var(--bg); color: var(--text); font: inherit; font-size: 16px; }
.tm-form .tm-btn-primary { margin-top: 14px; }
.tm-check { display: flex; align-items: center; gap: 8px; font-weight: 600; }
.tm-hint { margin: 2px 0 0; font-size: 0.82rem; color: var(--text-muted); }
.tm-error { margin: 8px 0 0; padding: 8px 10px; border-radius: var(--radius-md); background: rgba(239, 68, 68, 0.1); color: var(--danger); font-size: 0.9rem; }
.tm-place { display: flex; gap: 8px; }
.tm-place input { flex: 1; }
.tm-place-result { margin: 2px 0 0; font-size: 0.85rem; color: var(--text-muted); min-height: 1.2em; }
.tm-place-result.is-ok { color: var(--success); }
.tm-place-result.is-bad { color: var(--danger); }
.tm-hours { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tm-hours label { display: block; }
.tm-colours { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tm-colour { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; padding: 0; box-shadow: 0 0 0 1px var(--border); }
.tm-colour[aria-checked="true"] { border-color: var(--text); }

.tm-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 4px 0 12px; }
.tm-kicker { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); }
.tm-title h1 { margin: 2px 0 0; font-size: 1.6rem; }
.tm-tabs { display: flex; gap: 4px; background: var(--bg-secondary); padding: 4px; border-radius: var(--radius-lg); }
.tm-tab { border: 0; background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; padding: 8px 14px; border-radius: var(--radius-md); cursor: pointer; min-height: 40px; }
.tm-tab[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }

.tm-seats { margin: 0 0 12px; }
.tm-seat-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 10px 14px; border-radius: var(--radius-lg);
  border: 1px solid var(--border); background: var(--bg-secondary); font-size: 0.92rem; }
.tm-seat-banner.is-off { border-color: rgba(245, 158, 11, 0.5); background: rgba(245, 158, 11, 0.1); }
/* a failed payment (2026-10-17): red, with the last working day */
.tm-seat-banner.is-failed { border-color: rgba(220, 38, 38, 0.55); background: rgba(220, 38, 38, 0.1); }
.tm-seat-banner strong { font-weight: 700; }

.tm-split { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 16px; align-items: start; }
.tm-list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.tm-list-head h2 { margin: 0; font-size: 1.1rem; }
.tm-count { color: var(--text-muted); font-weight: 600; }
.tm-driver-list { display: flex; flex-direction: column; gap: 10px; }
.tm-driver { background: var(--card); border: 1px solid var(--border); border-left: 6px solid var(--driver-colour, #999);
  border-radius: var(--radius-lg); padding: 12px 14px; box-shadow: var(--shadow); }
.tm-driver-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tm-driver-name { font-weight: 700; font-size: 1rem; }
.tm-badge { font-size: 0.75rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--bg-secondary); color: var(--text-muted); white-space: nowrap; }
.tm-badge.is-active { background: rgba(16, 185, 129, 0.15); color: #047857; }
.tm-badge.is-invited { background: rgba(245, 158, 11, 0.15); color: #b45309; }
html[data-theme="dark"] .tm-badge.is-active { color: #6ee7b7; }
html[data-theme="dark"] .tm-badge.is-invited { color: #fcd34d; }
.tm-driver-meta { margin: 6px 0 0; font-size: 0.88rem; color: var(--text-muted); line-height: 1.5; }
.tm-driver-meta span { color: var(--text); }
.tm-driver-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tm-empty { padding: 20px; border: 1px dashed var(--border); border-radius: var(--radius-lg); color: var(--text-muted); }
.tm-empty p { margin: 0 0 6px; }

.tm-map-col { position: sticky; top: 12px; }
.tm-map { height: 560px; border-radius: var(--radius-lg); border: 1px solid var(--border); overflow: hidden; background: var(--bg-secondary); }
.tm-map-key { margin: 6px 0 0; font-size: 0.82rem; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }
.tm-key-start { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--text-muted); }
.tm-key-end { display: inline-block; width: 8px; height: 8px; border-radius: 50%; border: 3px solid var(--text-muted); background: var(--card); margin-left: 8px; }

.tm-dialog { border: 0; border-radius: var(--radius-xl); padding: 0; width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 32px);
  background: var(--card); color: var(--text); box-shadow: var(--shadow-lg); }
.tm-dialog::backdrop { background: rgba(15, 23, 42, 0.55); }
.tm-dialog form { padding: 20px; }
.tm-dialog h2 { margin: 0 0 4px; font-size: 1.25rem; }
.tm-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.tm-dialog-actions .tm-btn-primary { margin-top: 0; }

.tm-toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 2000; max-width: calc(100vw - 32px);
  padding: 10px 16px; border-radius: var(--radius-lg); background: #0f172a; color: #fff; box-shadow: var(--shadow-lg); font-size: 0.95rem; }

@media (max-width: 860px) {
  .tm-split { grid-template-columns: 1fr; }
  .tm-map-col { position: static; order: -1; }
  .tm-map { height: 300px; }
  .tm-header { align-items: stretch; }
  .tm-tabs { width: 100%; }
  .tm-tab { flex: 1; }
}

/* ---- Plan the day ---- */
.tm-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tm-plan-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 6px; }
.tm-plan-date { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tm-plan-date label { font-weight: 600; }
.tm-plan-date input[type="date"] { min-height: 40px; padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg); color: var(--text); font: inherit; }
.tm-plan-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tm-plan-status { margin: 0 0 10px; font-size: 0.9rem; color: var(--text-muted); min-height: 1.3em; }
.tm-warn { margin: 0 0 12px; padding: 10px 14px; border-radius: var(--radius-lg); border: 1px solid rgba(245, 158, 11, 0.5); background: rgba(245, 158, 11, 0.1); font-size: 0.92rem; }
.tm-warn ul { margin: 6px 0 0; padding-left: 20px; }
.tm-plan-drivers { display: flex; flex-direction: column; gap: 8px; }
.tm-plan-driver { background: var(--card); border: 1px solid var(--border); border-left: 6px solid var(--driver-colour, #999); border-radius: var(--radius-lg); padding: 10px 12px; }
.tm-late { color: #b45309; font-weight: 600; }
html[data-theme="dark"] .tm-late { color: #fcd34d; }
.tm-link-btn { margin-top: 8px; }
.tm-settings { margin-top: 12px; font-size: 0.9rem; }
.tm-settings summary { cursor: pointer; font-weight: 600; color: var(--text-muted); }
.tm-settings label { display: block; margin: 8px 0 4px; }
.tm-settings input { width: 90px; min-height: 38px; padding: 6px 8px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg); color: var(--text); font: inherit; }
.tm-selbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; margin-bottom: 8px; border-radius: var(--radius-lg); background: var(--primary); color: #fff; }
.tm-selbar select { min-height: 32px; border-radius: var(--radius-sm); border: 0; padding: 4px 8px; font: inherit; }
.tm-selbar .tm-btn { border-color: rgba(255, 255, 255, 0.6); }
.tm-selbar .tm-btn-primary { background: #fff; color: var(--primary); }
.tm-jobs-wrap { margin-top: 18px; }
.tm-jobs-wrap h2 { font-size: 1.1rem; margin: 0 0 8px; }
.tm-table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius-lg); }
.tm-jobs { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tm-jobs th, .tm-jobs td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tm-jobs th { background: var(--bg-secondary); font-weight: 700; position: sticky; top: 0; }
.tm-jobs tr.is-selected td { background: rgba(37, 99, 235, 0.08); }
.tm-jobs tr.is-header td { font-weight: 700; color: var(--text-muted); }
.tm-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 8px; vertical-align: middle; }
.tm-map-table select { min-height: 32px; font: inherit; font-size: 0.85rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg); color: var(--text); }
.tm-job-icon { background: none; border: 0; }
.tm-job-pin { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; box-sizing: border-box;
  border: 2px solid #fff; color: #fff; font-size: 11px; font-weight: 700; font-family: var(--font-sans); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.45); cursor: pointer; }
.tm-job-pin.is-unassigned { border-style: dashed; border-color: #374151; color: #111827; }
.tm-job-pin.is-selected { outline: 3px solid #111827; outline-offset: 1px; transform: scale(1.15); }
html[data-theme="dark"] .tm-job-pin.is-selected { outline-color: #fff; }
.tm-job-pin.is-done { opacity: 0.55; }
.tm-dialog-wide { width: min(860px, calc(100vw - 32px)); }
.tm-dialog textarea { width: 100%; box-sizing: border-box; padding: 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg); color: var(--text); font-family: var(--font-mono); font-size: 14px; }
.tm-dialog input[type="file"] { font: inherit; }
@media (max-width: 860px) {
  .tm-plan-actions { width: 100%; }
  .tm-plan-actions .tm-btn { flex: 1; }
}
.tm-proof-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin: 8px 0 12px; }
.tm-proof-photos figure { margin: 0; }
.tm-proof-photos img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--bg-secondary); }
.tm-my-route { display: inline-block; margin-top: 4px; font-weight: 600; color: var(--primary); text-decoration: none; }
.tm-start h2 { font-size: 1.1rem; margin: 18px 0 8px; }
.tm-steps { margin: 0 0 18px; padding-left: 22px; line-height: 1.6; }
.tm-steps li { margin-bottom: 6px; }
.tm-btn-wide { width: 100%; box-sizing: border-box; min-height: 46px; font-size: 1rem; }
.tm-small { font-size: 0.82rem; }
.tm-seat-banner a { color: var(--primary); font-weight: 600; }
.tm-guide { margin: 0 0 14px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--card); }
.tm-guide summary { cursor: pointer; font-weight: 700; }
.tm-guide .tm-steps { margin: 10px 0 6px; }
.tm-link { border: 0; background: none; padding: 0; font: inherit; font-weight: 700; color: var(--primary); cursor: pointer; text-decoration: underline; }
.tm-driver-actions { display: flex; flex-wrap: wrap; gap: 6px 12px; align-items: center; }
.tm-driver-actions .tm-link-btn { margin-top: 8px; }
.tm-row-edit { margin-left: 6px; border: 0; background: transparent; cursor: pointer; font-size: 0.95rem; color: var(--text-muted); padding: 0 4px; }
.tm-row-edit:hover, .tm-row-edit:focus { color: var(--primary, #2563eb); }

/* Phone tap targets (bug hunt 2026-10-16, fam6-6): the row checkbox and the edit pencil were 13 px and 21 px. */
@media (pointer: coarse) {
  #tm-jobs-table tbody input[type="checkbox"] { width: 22px; height: 22px; margin: 4px; }
  .tm-row-edit { min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center; }
}

.tm-example th, .tm-example td { font-size: 0.8rem; padding: 5px 8px; }
.tm-example th { position: static; }

/* Add jobs: a column nothing is read from reads "Not used" / "Choose…" in grey, never "Ignored" (Dan, 2026-10-16). */
.tm-col-unused { color: var(--text-muted, #6b7280) !important; font-weight: 400 !important; font-style: italic; }

/* Disabled main actions read as disabled: grey, not solid blue (Dan, 2026-10-16). The title says why. */
.tm-btn-primary:disabled, .tm-btn-primary[disabled] { background: var(--bg-secondary, #e5e7eb); border-color: var(--border, #d1d5db);
  color: var(--text-muted, #6b7280); filter: none; opacity: 1; cursor: not-allowed; }
/* Plan the day with no drivers: the next step, as a panel with its button. */
.tm-empty-panel { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px; border: 1px dashed var(--border, #d1d5db); border-radius: 10px; }
.tm-empty-panel p { margin: 0; }
/* After the first driver: add the rest? */
.tm-more-drivers { margin: 0 0 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--primary, #2563eb);
  background: var(--bg-secondary, #eff6ff); }
.tm-more-drivers p { margin: 0 0 8px; }
.tm-more-drivers-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* The browser switched to a driver login under an open manager page. */
.tm-session-banner { position: sticky; top: 0; z-index: 1100; display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px;
  padding: 12px 16px; background: #fef3c7; color: #78350f; border-bottom: 1px solid #f59e0b; }
.tm-session-banner p { margin: 0; flex: 1 1 280px; }

/* Send to drivers when some haven't signed in yet (a dialog built in plan.js, so it has no form padding). */
#tm-notyet-dialog { padding: 20px; }
#tm-notyet-dialog p { margin: 8px 0 16px; }
.tm-dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; }
.tm-badge-small { font-size: 0.72rem; padding: 1px 6px; }

/* in-page confirm (2026-10-17): a destructive OK is red */
.tm-btn-primary.tm-confirm-danger { background: var(--danger); border-color: var(--danger); color: #fff; }

/* import check (2026-10-17): postcodes not found, jobs with no street address */
.tm-importcheck-warn { color: var(--danger); font-weight: 600; }
.tm-importcheck-row { display: grid; grid-template-columns: 1fr 9em auto; gap: 8px; align-items: center; margin: 6px 0; }
.tm-importcheck-row input { min-width: 0; text-transform: uppercase; }
.tm-importcheck-state { font-size: 0.85rem; color: var(--danger); }
.tm-importcheck-row.is-ok .tm-importcheck-state { color: var(--success, #16a34a); }
.tm-import-bare-note { margin: 4px 0 0; font-size: 0.9rem; color: var(--muted, #64748b); }

/* long waits: one-click choices on a driver's card (3b, 2026-10-17) */
.tm-wait-choices { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; }
.tm-wait-choices .tm-btn { white-space: normal; text-align: left; }
.tm-rounds { margin-top: 4px; padding: 6px 8px; border-radius: 8px; background: var(--surface-2, #f1f5f9); font-size: 0.9rem; }
.tm-wait-link { background: none; border-color: transparent; text-decoration: underline; color: var(--primary); }
