:root {
  --ink: #1f2a37;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #f7f8fa;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #b91c1c;
  --good: #047857;
  /* location identity (home / ride start / ride finish) */
  --home-bg: #f1efe8;
  --home-ink: #57564f;
  --start-bg: #e6f1fb;
  --start-ink: #0c447c;
  --finish-bg: #e1f5ee;
  --finish-ink: #0f6e56;
}
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--ink); background: var(--bg);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
header {
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 14px 24px;
}
.brand { font-weight: 700; text-decoration: none; color: var(--ink); font-size: 18px; }
main { max-width: 1000px; margin: 24px auto; padding: 0 20px; }
footer { max-width: 1000px; margin: 40px auto; padding: 0 20px; color: var(--muted); }
h1 { margin: 0 0 4px; }
h2 { margin-top: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.error { color: var(--danger); font-weight: 600; }
.crumb { margin: 0 0 12px; }
.eyebrow {
  margin: 0 0 4px; color: var(--muted); font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.page-hero {
  display: flex; justify-content: space-between; align-items: center; gap: 20px;
  margin: 0 0 20px; padding: 18px 0 8px; border-bottom: 1px solid var(--line);
}
.event-hero { align-items: stretch; }
.route-strip {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px;
}
.route-arrow { color: var(--muted); font-weight: 700; }
.hero-stats { display: grid; grid-template-columns: repeat(3, minmax(84px, 1fr)); gap: 10px; }
.stat.mini { min-width: 84px; padding: 12px 14px; }
.stat.mini b { font-size: 22px; }
.stat.mini span { display: block; }
@media (max-width: 780px) {
  .page-hero, .event-hero { display: block; }
  .hero-stats { margin-top: 14px; }
}
@media (max-width: 520px) { .hero-stats { grid-template-columns: 1fr 1fr; } }

.card {
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 20px; margin: 16px 0; min-width: 0;
}
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.cols > * { min-width: 0; }
@media (max-width: 780px) { .cols { grid-template-columns: 1fr; } }

label { display: block; margin: 10px 0; font-weight: 600; }
label.check { font-weight: 400; display: flex; gap: 8px; align-items: center; }
input, select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; margin-top: 4px;
}
label.check input, .pref-row select { width: auto; margin-top: 0; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 16px 0; padding: 12px 16px; }
legend { font-weight: 700; padding: 0 6px; }
small { font-weight: 400; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

button {
  background: var(--accent); color: #fff; border: 0; border-radius: 8px;
  padding: 10px 16px; font: inherit; font-weight: 600; cursor: pointer;
}
button:hover { background: var(--accent-dark); }
button.link { background: none; color: var(--accent); padding: 0; }
button.link.danger { color: var(--danger); }
button:disabled { cursor: default; opacity: .75; }
.button {
  display: inline-block; text-decoration: none; background: var(--accent);
  color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600;
}
.button.big { font-size: 17px; padding: 12px 22px; }
.primary-action { margin-top: 4px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin: 16px 0 0; }

.share-links { margin-top: 10px; }
.share-row { display: flex; gap: 8px; align-items: center; margin-top: 4px; }
.share-row input { margin-top: 0; min-width: 0; }
.share-row button { flex: 0 0 auto; padding: 8px 12px; }
.share-panel { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 10px; }

.pref-row { display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.pref-row:last-child { border-bottom: 0; }

.roster-wrap { overflow-x: auto; }
table.roster { width: 100%; border-collapse: collapse; }
table.roster th, table.roster td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.roster th:first-child, table.roster td:first-child { padding-left: 0; }
table.roster th {
  color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
}
table.roster td { font-size: 14px; }
.roster-name { display: flex; align-items: flex-start; gap: 9px; min-width: 132px; }
.roster-name .avatar { margin-top: 1px; }
.roster-name small { display: block; margin-top: 1px; }
.role-badge { background: var(--finish-bg); color: var(--finish-ink); }
.roster-actions { width: 1%; padding-right: 0; }
.roster-remove {
  background: none; color: var(--muted); border: 0; border-radius: 6px;
  width: 26px; height: 26px; padding: 0; font-size: 18px; line-height: 1; cursor: pointer;
}
.roster-remove:hover { background: #fef2f2; color: var(--danger); }

.event-list { list-style: none; padding: 0; }
.event-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }

.event-form-card { max-width: 760px; }
.route-picker {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  padding: 14px; border-style: dashed;
}
.route-picker legend { margin-left: -4px; }
.route-choice { position: relative; display: block; margin: 0; font-weight: 400; cursor: pointer; }
.route-choice input {
  position: absolute; width: 1px; height: 1px; inline-size: 1px; block-size: 1px; opacity: 0;
  margin: 0; pointer-events: none;
}
.route-card {
  display: flex; flex-direction: column; gap: 10px; min-height: 132px;
  padding: 14px; border: 1px solid var(--line); border-radius: 8px; background: #fff;
  transition: border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.route-title { font-weight: 700; }
.route-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.route-choice input:checked + .route-card {
  border-color: var(--accent); box-shadow: 0 0 0 3px #dbeafe; background: #fbfdff;
}
.route-choice input:focus-visible + .route-card { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 700px) { .route-picker { grid-template-columns: 1fr; } }

.summary { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 12px; margin: 16px 0 24px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 16px 22px; text-align: center; min-width: 120px; }
.stat b { display: block; font-size: 28px; color: var(--accent); }
.stat span { color: var(--muted); font-size: 13px; }
@media (max-width: 780px) { .summary { grid-template-columns: 1fr 1fr; } }

.plan-section { margin: 26px 0 10px; }
.section-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px;
}
.section-head h2 { margin: 0; }
.section-head.compact { margin-bottom: 14px; }

/* inline icons (SVG sprite) */
.ic {
  width: 1em; height: 1em; vertical-align: -0.14em; flex: 0 0 auto;
  fill: none; stroke: currentColor; stroke-width: 2;
  stroke-linecap: round; stroke-linejoin: round;
}

/* location legend + colour-coded place pills */
.legend { display: flex; flex-wrap: wrap; gap: 16px; margin: 6px 0 0;
  font-size: 13px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 11px; height: 11px; border-radius: 3px; }
.sw-home { background: var(--home-ink); }
.sw-start { background: var(--start-ink); }
.sw-finish { background: var(--finish-ink); }

.loc { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap;
  font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px; }
.loc .ic { font-size: 13px; }
.loc-home { background: var(--home-bg); color: var(--home-ink); }
.loc-start { background: var(--start-bg); color: var(--start-ink); }
.loc-finish { background: var(--finish-bg); color: var(--finish-ink); }
.loc-other { background: var(--bg); color: var(--muted); }

/* people avatars */
.avatar { width: 26px; height: 26px; border-radius: 50%; flex: 0 0 auto;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; background: var(--home-bg); color: var(--home-ink); }
.avatar-driver, .avatar-supporter { background: #eef2ff; color: var(--accent-dark); }
.avatar-rider { background: var(--finish-bg); color: var(--finish-ink); }
.avatar-lg { width: 40px; height: 40px; font-size: 14px; }
.avatars { display: inline-flex; }
.avatars .avatar { border: 2px solid #fff; margin-left: -7px; }
.avatars .avatar:first-child { margin-left: 0; }

/* "day at a glance" timeline */
.glance { display: flex; flex-direction: column; gap: 18px; margin: 14px 0 28px; }
.group-head { display: flex; align-items: center; gap: 7px; margin: 0 0 8px;
  font-size: 13px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); }
.group-head .ic { font-size: 16px; }
.legs { display: flex; flex-direction: column; gap: 10px; }
.leg { background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 12px 14px; }
.leg-main { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.leg-route { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.leg-route .driver-name { font-weight: 600; }
.leg-route > .ic { color: var(--muted); }
.sag-badge { display: inline-flex; align-items: center; gap: 4px;
  background: #faeeda; color: #854f0b; font-size: 12px;
  font-weight: 600; padding: 2px 9px; border-radius: 999px; white-space: nowrap; }
.sag-badge .ic { font-size: 14px; }
.leg-cargo { margin-left: auto; display: flex; gap: 12px;
  color: var(--muted); font-size: 13px; font-weight: 600; }
.leg-cargo span { display: inline-flex; align-items: center; gap: 4px; }
.leg-cargo .ic { font-size: 16px; }
.leg-pax { display: flex; align-items: center; gap: 8px; margin-top: 9px; }
.pax-label { font-size: 12px; color: var(--muted); }
.leg-purpose { margin: 9px 0 0; font-size: 14px; }
.leg-more { margin-top: 9px; border-top: 1px dashed var(--line); padding-top: 6px; }
.leg-more summary { font-size: 13px; font-weight: 600; }
.leg-more p { margin: 8px 0 0; font-size: 14px; }

/* people cards */
.people-plan { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 780px) { .people-plan { grid-template-columns: 1fr; } }
.person { display: flex; flex-direction: column; gap: 12px; }
.person-head { display: flex; align-items: center; gap: 12px; }
.person-id { flex: 1; min-width: 0; }
.person-id h3 { margin: 0; display: flex; align-items: center; gap: 6px; }
.person-id h3 .ic { font-size: 15px; color: var(--muted); }

.journey { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.journey .loc { font-size: 12px; padding: 2px 8px; }
.journey .hop { display: inline-flex; color: var(--muted); }
.journey .hop .ic { font-size: 16px; }

.burden-meta { font-size: 13px; color: var(--muted); margin-bottom: 5px; }
.bar { height: 7px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 999px; }

.person ol { margin: 0; padding-left: 20px; }
.person li { margin: 5px 0; }
.badge { display: inline-block; background: #eef2ff; color: var(--accent-dark);
  border-radius: 999px; padding: 3px 10px; font-size: 13px; font-weight: 600;
  white-space: nowrap; }
.badge.soft { background: var(--home-bg); color: var(--home-ink); }
.notes { list-style: none; padding: 0; margin: 0; font-size: 14px; }
.notes li { display: flex; align-items: flex-start; gap: 8px; margin: 6px 0; }
.notes li .ic { font-size: 15px; color: var(--muted); margin-top: 3px; }

.detail-plan, .car-detail {
  border-top: 1px solid var(--line); padding-top: 10px; color: var(--muted);
}
details summary { color: var(--accent); cursor: pointer; font-weight: 700; }
.detail-plan ol { margin-top: 10px; color: var(--ink); }
.car-detail { margin-top: 18px; }

/* keep the normal arrow (not the text I-beam) over interactive-looking chips */
.loc, .avatar, .leg-cargo span, .journey .hop { cursor: default; }

/* fast custom tooltips (native title= has a fixed ~0.5s browser delay) */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
  background: var(--ink); color: #fff; font-size: 12px; font-weight: 600; line-height: 1.3;
  white-space: nowrap; padding: 4px 8px; border-radius: 6px;
  opacity: 0; pointer-events: none; z-index: 30;
  transition: opacity .08s ease 0s;
}
[data-tip]::before {
  content: ""; position: absolute; bottom: calc(100% + 2px); left: 50%;
  transform: translateX(-50%); border: 5px solid transparent; border-top-color: var(--ink);
  opacity: 0; pointer-events: none; z-index: 30; transition: opacity .08s ease 0s;
}
[data-tip]:hover::after, [data-tip]:hover::before,
[data-tip]:focus-visible::after, [data-tip]:focus-visible::before { opacity: 1; }
/* multi-line, left-aligned tooltip (e.g. the unmet-preferences list) */
.tip-wrap { cursor: help; }
.tip-wrap[data-tip]::after { white-space: pre-line; max-width: 280px; text-align: left; }

/* per-leg cargo ownership inside Details */
.cargo-line { display: flex; align-items: flex-start; gap: 8px;
  margin: 8px 0 0; font-size: 14px; }
.cargo-line .ic { font-size: 15px; color: var(--muted); margin-top: 3px; }

/* structured reference lists (full itinerary, full car movements) */
.detail-steps { list-style: none; padding: 0; margin: 12px 0 0; }
.detail-steps > li { padding: 10px 0; border-bottom: 1px dashed var(--line); }
.detail-steps > li:last-child { border-bottom: 0; }
.detail-steps .istep { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
.detail-steps .istep b { font-size: 15px; }
.phase-label { font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); }
.route-text { color: var(--muted); font-size: 14px; }
.contents { list-style: none; padding: 0; margin: 6px 0 0; }
.contents li { font-size: 13px; color: var(--muted); margin: 3px 0; padding-left: 14px;
  position: relative; }
.contents li::before { content: "·"; position: absolute; left: 4px; }
.note-line { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.note-line .ic { font-size: 15px; color: var(--muted); margin-top: 3px; }
.car-moves { background: #fff; border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 16px; }
.error-card { border-color: #fca5a5; background: #fef2f2; }
