:root {
  --bg: #f7f8fb;
  --card: #ffffff;
  --text: #1a1f2c;
  --muted: #6b7280;
  --border: #e4e6eb;
  --ok: #0f7a43;
  --warn: #b45309;
  --danger: #b91c1c;
  --accent: #2563eb;
  --kid-reid: #2563eb;
  --kid-evelyn: #db2777;
  --kid-david: #059669;
  --kid-charlie: #d97706;
  --driver-chase: #4338ca;
  --driver-chad: #0d9488;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.site-header {
  padding: 24px 24px 8px;
  max-width: 1024px;
  margin: 0 auto;
}
.site-header h1 { margin: 0; font-size: 22px; }
.tagline { margin: 4px 0 0; color: var(--muted); }

main {
  max-width: 1024px;
  margin: 0 auto;
  padding: 16px 24px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.weekend-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.weekend-header h2 { margin: 0; font-size: 18px; }
.weekend-header .nav { display: flex; gap: 8px; }
.weekend-header button {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.weekend-header button:hover { border-color: var(--accent); color: var(--accent); }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}
.card h3 { margin: 0 0 10px; font-size: 15px; }

/* ETS Options finder */
.ets-card { border-left: 4px solid #f43f5e; }
.ets-sub { margin: -4px 0 12px; font-size: 12px; }
.ets-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.ets-kid { border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.ets-kid-name { margin-bottom: 8px; }
.ets-day { margin-bottom: 6px; font-size: 12px; line-height: 1.8; }
.ets-day-label { color: var(--muted); font-weight: 600; margin-right: 4px; }
.ets-slot { display: inline-block; padding: 2px 7px; margin: 1px 3px 1px 0; border-radius: 6px; background: #dcfce7; color: #166534; font-size: 11px; font-weight: 700; white-space: nowrap; }
.ets-badge { display: inline-block; font-size: 10px; font-weight: 700; color: #7c3aed; background: #ede9fe; padding: 1px 7px; border-radius: 10px; }
.ets-none { font-size: 12px; font-style: italic; }
@media (max-width: 800px) { .ets-grid { grid-template-columns: repeat(2, 1fr); } }

/* "Where this schedule comes from" panel */
.ds-card { border-left: 4px solid var(--accent); }
.ds-details summary {
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  list-style: none;
  user-select: none;
}
.ds-details summary::-webkit-details-marker { display: none; }
.ds-details summary::before { content: "▸ "; color: var(--muted); }
.ds-details[open] summary::before { content: "▾ "; }
.ds-intro { margin: 10px 0 14px; font-size: 13px; }
.ds-group { margin-bottom: 14px; }
.ds-group-title { font-size: 13px; font-weight: 700; margin-bottom: 4px; }
.ds-list { margin: 0; padding-left: 18px; }
.ds-list li { font-size: 13px; line-height: 1.6; color: var(--muted); }
.ds-list li b { color: var(--text, inherit); font-weight: 600; }
.ds-foot { margin: 6px 0 0; font-size: 12px; font-style: italic; }

.day-block { margin-top: 10px; }
.day-block h4 {
  margin: 12px 0 6px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

table.sched {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
table.sched th, table.sched td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.sched th {
  font-weight: 600;
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
table.sched tr:last-child td { border-bottom: none; }

.kid, .driver, .chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: white;
}
.kid-reid { background: var(--kid-reid); }
.kid-evelyn { background: var(--kid-evelyn); }
.kid-david { background: var(--kid-david); }
.kid-charlie { background: var(--kid-charlie); }
.driver-chase { background: var(--driver-chase); }
.driver-chad { background: var(--driver-chad); }

.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 4px;
  vertical-align: middle;
}
.badge-wait { background: #dbeafe; color: #1e3a8a; }
.badge-return { background: #dcfce7; color: #14532d; }
.badge-split { background: #fef3c7; color: #78350f; }
.badge-allday { background: #e0e7ff; color: #3730a3; }
.badge-carpool {
  background: #fb923c;
  color: #fff;
  cursor: help;
  font-weight: 700;
  padding: 2px 8px;
  font-size: 11px;
  box-shadow: 0 0 0 2px rgba(251, 146, 60, 0.25);
}
.badge-colocated { background: #ede9fe; color: #5b21b6; cursor: help; }
.badge-weather { background: #fff7ed; color: #9a3412; cursor: help; font-weight: 600; }
.wx-ok { color: #94a3b8; font-size: 11px; cursor: help; }
.driver-load-row { display: flex; align-items: center; gap: 10px; margin: 6px 0; font-size: 14px; }
.dl-name { flex: 0 0 70px; font-weight: 600; }
.dl-track { flex: 1; height: 16px; background: #f1f5f9; border-radius: 8px; overflow: hidden; }
.dl-fill { display: block; height: 16px; border-radius: 8px; }
.dl-val { flex: 0 0 110px; text-align: right; color: #475569; font-variant-numeric: tabular-nums; }
.badge-external { background: #0d9488; color: #fff; cursor: help; font-weight: 700; padding: 2px 8px; font-size: 11px; }
ul.event-list li.colocated, tr.colocated { opacity: 0.65; }
ul.event-list li.colocated .what { text-decoration: line-through; text-decoration-color: rgba(0,0,0,0.25); }
.stranded-actions { margin-top: 6px; display: flex; gap: 6px; }
.stranded-btn { font-size: 0.85em; padding: 3px 10px; border-radius: 4px; border: 1px solid #d1d5db; background: #fff; cursor: pointer; }
.stranded-btn:hover { background: #f3f4f6; }
.stranded-btn-skip { color: #b45309; border-color: #fcd34d; }
.heatmap-card .heatmap-legend { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; font-size: 0.85em; }
.heatmap-legend .swatch { display: inline-block; width: 12px; height: 12px; border-radius: 2px; vertical-align: middle; }
.heatmap { display: grid; grid-template-columns: repeat(21, 1fr); gap: 4px; margin-top: 8px; }
.heatmap-cell { padding: 8px 4px; border-radius: 6px; border: 1px solid transparent; cursor: pointer; text-align: center; font-family: inherit; }
.heatmap-cell:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.08); }
.heatmap-current { outline: 2px solid #2563eb; outline-offset: 1px; }
.heatmap-dow { font-size: 0.7em; opacity: 0.7; }
.heatmap-day { font-weight: 600; font-size: 0.95em; }
.level-empty { background: #f3f4f6; color: #9ca3af; }
.level-green { background: #d1fae5; color: #065f46; }
.level-yellow { background: #fef3c7; color: #78350f; }
.level-orange { background: #fed7aa; color: #7c2d12; }
.level-red { background: #fecaca; color: #7f1d1d; }
@media (max-width: 700px) {
  .heatmap { grid-template-columns: repeat(7, 1fr); }
}
.map-card .map-container { height: 400px; border-radius: 8px; overflow: hidden; margin-top: 10px; }
.map-legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 0.9em; margin-top: 6px; }
.map-legend-item { display: inline-flex; align-items: center; gap: 4px; }
.map-legend-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; }

.overlap {
  padding: 8px 10px;
  border-left: 3px solid var(--accent);
  background: #eef2ff;
  border-radius: 4px;
  margin-bottom: 6px;
  list-style: none;
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-right: 8px;
}
.view-toggle button {
  background: var(--card);
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}
.view-toggle button.active {
  background: var(--accent);
  color: white;
}

.wait-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
}
.wait-toggle input { margin: 0; }

.summary { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }

.ok { color: var(--ok); margin: 0; }
.muted { color: var(--muted); }

.conflict, .stranded {
  padding: 8px 10px;
  border-left: 3px solid var(--danger);
  background: #fef2f2;
  border-radius: 4px;
  margin-bottom: 6px;
  list-style: none;
}
.stranded { border-left-color: var(--warn); background: #fffbeb; }

ul { padding-left: 18px; margin: 6px 0; }

footer {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
  padding-top: 8px;
}

.sync-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 12px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
}
.unavail-banner {
  margin: 8px 0;
  padding: 10px 14px;
  background: #fff8e1;
  border: 1px solid #f6c244;
  border-left: 4px solid #d18a00;
  border-radius: 8px;
  font-size: 13px;
  color: #6b4500;
  line-height: 1.45;
}
.unavail-banner strong { color: #4a3000; }
.stale-banner {
  margin: 8px 0;
  padding: 10px 14px;
  background: #fee2e2;
  border: 1px solid #ef4444;
  border-left: 4px solid #b91c1c;
  border-radius: 8px;
  font-size: 13px;
  color: #7f1d1d;
  line-height: 1.45;
}
.stale-banner strong { color: #991b1b; }
.refresh-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
}
.refresh-btn:hover { opacity: 0.9; }

.kid-block, .driver-block { margin: 10px 0; }
.kid-block h4, .driver-block h4 {
  margin: 10px 0 6px;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

ul.event-list {
  list-style: none;
  padding-left: 0;
  margin: 4px 0 12px;
  border-left: 2px solid var(--border);
}
ul.event-list li {
  padding: 4px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}
ul.event-list li.riding {
  opacity: 0.55;
  text-decoration: line-through;
}
ul.event-list li.riding .ride-toggle { text-decoration: none; }
.event-list .when { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 180px; }
.event-list .what { flex: 1; min-width: 200px; }

.ride-toggle {
  background: #f1f5f9;
  color: #334155;
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
}
.ride-toggle:hover { border-color: var(--accent); }
li.riding .ride-toggle { background: #dcfce7; color: #14532d; border-color: #86efac; }

/* Suggested rides ("ask another family") */
.suggested-rides-card {
  border: 1px solid #fb923c;
  background: linear-gradient(180deg, #fff7ed 0%, #ffffff 60%);
  box-shadow: 0 1px 4px rgba(251, 146, 60, 0.15);
}
.suggested-rides-card h3 { color: #9a3412; }
.suggested-rides-blurb { margin: 0 0 10px; font-size: 13px; }
.suggested-rides-count { font-size: 12px; font-weight: 500; }
.suggested-rides-kid { margin-top: 8px; }
.suggested-rides-kid h4 { margin: 8px 0 4px; font-size: 13px; }
.suggested-rides-list { list-style: none; padding-left: 0; margin: 0; }
.suggested-ride-row {
  display: grid;
  grid-template-columns: minmax(160px, 200px) 1fr auto;
  grid-template-areas: "when what btn" "hint hint btn";
  gap: 4px 12px;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  align-items: center;
  font-size: 13px;
}
.suggested-ride-row:first-child { border-top: none; }
.suggested-ride-when { grid-area: when; color: var(--muted); font-variant-numeric: tabular-nums; }
.suggested-ride-what { grid-area: what; font-weight: 500; }
.suggested-ride-hint { grid-area: hint; font-size: 12px; color: #7c2d12; }
.suggested-ride-btn { grid-area: btn; align-self: center; white-space: nowrap; }
@media (max-width: 600px) {
  .suggested-ride-row {
    grid-template-columns: 1fr auto;
    grid-template-areas: "when btn" "what btn" "hint hint";
  }
}

/* Weekday routes */
.weekday-routes-card { /* base card styles already apply */ }
.weekday-route-day {
  padding: 10px 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}
.weekday-route-day:first-of-type { border-top: none; }
.weekday-route-day.active {
  background: #eff6ff;
  border-radius: 6px;
  border-top-color: transparent;
  outline: 1px solid #bfdbfe;
}
.weekday-route-day-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.weekday-route-day-header h4 { margin: 0; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--text); }
.weekday-route-count { font-size: 12px; font-weight: 400; }
.show-on-map-btn {
  background: var(--card);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
}
.show-on-map-btn:hover { border-color: var(--accent); color: var(--accent); }
.show-on-map-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.weekday-route-driver {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 4px 0;
  font-size: 13px;
}
.weekday-route-chain {
  flex: 1;
  font-variant-numeric: tabular-nums;
  color: #334155;
  line-height: 1.6;
  word-break: break-word;
}

.map-route-label {
  font-weight: 400;
  font-size: 13px;
  margin-left: 4px;
}

/* Print / export: clean one-page weekly plan. Margins baked into body padding
   (dialog "Margins: None" overrides @page and would clip otherwise). */
@media print {
  @page { margin: 0; }
  body { padding: 12mm 10mm; background: #fff; color: #000; }
  .sync-bar, .nav, .map-card, .heatmap-card, button, .refresh-btn,
  .stale-banner { display: none !important; }
  .card, section { box-shadow: none !important; border: 1px solid #ddd;
                   break-inside: avoid; page-break-inside: avoid; margin: 8px 0; }
  a { color: #000; text-decoration: none; }
  .driver-load-card { break-inside: avoid; }
}
