/* app.css - shared styles for the GTFS and TXC shells (and the root home page).
 * Landing-only rules (hero, builder cards) live in index.html; each shell's
 * unique rules live in its own inline <style>. */
:root {
  --bg: #0f172a;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --ok: #16a34a;
  --bad: #dc2626;
}

* { box-sizing: border-box; }

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

a { color: var(--brand); }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--bg);
  color: #fff;
  padding: 0 16px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.logo {
  background: var(--brand);
  color: #fff;
  padding: 2px 8px;
  border-radius: 6px;
  letter-spacing: 1px;
  font-size: 14px;
}
.brand-name { color: #e2e8f0; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tab {
  color: #cbd5e1;
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 14px;
}
.tab:hover { background: rgba(255,255,255,.08); color: #fff; }
.tab.active { background: var(--brand); color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.commit-badge {
  font-size: 12px;
  color: #94a3b8;
  background: rgba(255,255,255,.06);
  padding: 3px 8px;
  border-radius: 6px;
  white-space: nowrap;
}

/* ---------- Layout ---------- */
.view { max-width: 1080px; margin: 0 auto; padding: 24px 16px; }
.footer {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 20px;
  border-top: 1px solid var(--line);
}

/* ---------- Cards / panels ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 18px;
  box-shadow: 0 1px 2px rgba(15,23,42,.04);
}
.card h2 { margin: 0 0 12px; font-size: 19px; }
.card h3 { margin: 10px 0 10px; font-size: 16px; }
.section-desc { color: var(--ink-soft); margin: 0 0 16px; }
.operator-block { margin-bottom: 16px; padding-bottom: 5px; border-bottom: 1px solid var(--line); }
.operator-block:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }

/* ---------- Timetable card grouped sections ---------- */
.tt-card-group {
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 12px;
}
.tt-card-group-head {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.tt-card-group .field { margin-bottom: 8px; }
.tt-card-group .field:last-child { margin-bottom: 0; }
.tt-card-group .field label { font-size: 12px; margin-bottom: 2px; }
.tt-card-group .field input,
.tt-card-group .field select {
  padding: 6px 8px;
  font-size: 13px;
}
.tt-inline-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.tt-inline-row:last-child { margin-bottom: 0; }
.tt-inline-row > label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  white-space: nowrap;
  flex-shrink: 0;
}
.tt-inline-row input,
.tt-inline-row select {
  flex: 1;
  padding: 5px 8px;
  font-size: 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  min-width: 0;
}
.tt-inline-row input[type="date"] {
  flex: 0 1 125px;
}
.tt-days-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.tt-days-row label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  color: var(--ink-soft);
  cursor: pointer;
  padding: 3px 6px;
  border-radius: 4px;
  user-select: none;
}
.tt-days-row label:hover { background: rgba(0,0,0,.04); }
.tt-days-row input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
}
.tt-exc-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.tt-exc-form .field { margin-bottom: 0; }
.tt-exc-form .field label { font-size: 11px; margin-bottom: 2px; }
.tt-exc-form input,
.tt-exc-form select {
  padding: 5px 8px;
  font-size: 13px;
}
.tt-exc-form select.exc-type { flex: 0 0 220px; }
.tt-exc-form input.exc-label { flex: 0 0 140px; }
.tt-exc-form input[type="date"] { flex: 0 0 145px; }

/* ---------- Variant table (route detail) ---------- */
.var-table { font-size: 14px; }
.var-table th { font-size: 13px; }
.variant-name-cell { cursor: pointer; }
.variant-name-cell:hover { color: var(--brand); text-decoration: underline; }
.variant-rename-input {
  font-size: 14px; padding: 3px 6px; border: 1px solid var(--brand);
  border-radius: 4px; width: 100%; max-width: 300px;
}

/* ---------- Help box ---------- */
.help {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-left: 4px solid var(--brand);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 16px;
  color: #1e3a8a;
  font-size: 14px;
}
.help h4 { margin: 0 0 6px; font-size: 14px; }
.help p { margin: 0; }
.help ul { margin: 6px 0 0; padding-left: 18px; }
.help li { margin: 2px 0; }
/* Collapsible hint cards (details.help): heading + right-aligned chevron. */
summary.help-summary {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  cursor: pointer; list-style: none;
}
summary.help-summary::-webkit-details-marker { display: none; }
summary.help-summary h4 { margin: 0; }
.help-chev { transition: transform .12s ease; font-size: 16px; line-height: 1; color: currentColor; }
details.help[open] .help-chev { transform: rotate(180deg); }
.help-body { margin-top: 6px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 4px;
  color: var(--ink);
}
.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.field input, .field select, .field textarea {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(37,99,235,.15);
}
.field-row .field { flex: 1; min-width: 200px; }
.field-row .field-sm { flex: 0 0 140px; min-width: unset; }
textarea { min-height: 120px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--brand);
  color: #fff;
  border: none;
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  cursor: pointer;
}
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: #e2e8f0;
  border: 1px solid rgba(255,255,255,.2);
}
.btn-ghost:hover { background: rgba(255,255,255,.1); }
.btn-secondary { background: #475569; }
.btn-secondary:hover { background: #334155; }
.btn-success { background: var(--ok); }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--bad); }
.btn-danger:hover { background: #b91c1c; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

/* ---------- Tables ---------- */
table.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.grid th, table.grid td {
  border: 1px solid var(--line);
  padding: 6px 8px;
  text-align: left;
}
table.grid th { background: var(--panel-soft); font-weight: 600; }
table.grid input, table.grid select {
  width: 100%;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 13px;
}
table.grid tr:nth-child(even) td { background: #fcfdff; }
table.grid input.input-error { border: 2px solid var(--bad); }
input.input-error { border: 2px solid var(--bad); }

/* Stop library: fixed column widths (ATCO/code narrow, coordinates wide) */
table.grid.stops-grid { table-layout: fixed; }

/* ---------- Home step cards / routes route list ---------- */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.step {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
}
.step .num {
  width: 28px; height: 28px;
  background: var(--brand); color: #fff;
  border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; margin-bottom: 8px;
}
.step h3 { margin: 4px 0 6px; font-size: 15px; }
.step p { margin: 0; color: var(--ink-soft); font-size: 13px; }

/* ---------- Misc ---------- */
.muted { color: var(--muted); }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.route-row { align-items: flex-start; flex-wrap: nowrap; }
.route-row > .route-name { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.route-row > .route-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.route-badges { display: inline-flex; flex-wrap: wrap; gap: 6px; margin-left: 8px; vertical-align: middle; }
.empty {
  text-align: center; color: var(--muted);
  padding: 30px; border: 1px dashed var(--line); border-radius: 10px; margin: 6px 0;
}
.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px,1fr)); gap: 12px; }
.summary-tile {
  background: var(--panel-soft); border: 1px solid var(--line);
  border-radius: 10px; padding: 14px; text-align: center;
}
.summary-tile .n { font-size: 26px; font-weight: 700; color: var(--brand); }
.summary-tile .l { font-size: 13px; color: var(--ink-soft); }
.issue { padding: 8px 10px; border-radius: 8px; margin-bottom: 6px; font-size: 14px; }
.issue-bad { background: #fee2e2; color: #991b1b; }
.issue-warn { background: #fef3c7; color: #92400e; }
.issue-ok { background: #dcfce7; color: #166534; }
.issue-link { cursor: pointer; }
.issue-link:hover { filter: brightness(0.96); box-shadow: 0 0 0 2px rgba(37,99,235,.35); }
.hidden { display: none !important; }

/* Review: grouped validation issues */
.issue-group { margin-bottom: 8px; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.issue-group-head {
  padding: 8px 10px; cursor: pointer; display: flex; align-items: center; gap: 8px;
  background: var(--panel-soft); font-weight: 600; font-size: 14px; user-select: none;
}
.issue-group-head:hover { background: #eef2f7; }
.issue-group-head .chev { transition: transform .12s ease; color: var(--ink-soft); }
.issue-group-head.open .chev { transform: rotate(90deg); }
.issue-group-head .ph { margin-left: 10px; font-weight: 400; }
.issue-list { padding: 6px; }
.issue-subgroup { margin: 4px 0 6px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.issue-subgroup .issue-group-head { background: transparent; font-size: 13px; padding: 6px 8px; }
.issue-list .issue { margin-bottom: 4px; }
.issue-list .issue:last-child { margin-bottom: 0; }

/* ---------- Modal overlay ---------- */
.modal-bg {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-y: auto;
  padding: 16px 0;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  max-width: 420px;
  width: 90%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,.2);
}
.modal h3 { margin: 0 0 10px; }
.modal .confirm-msg { margin: 0 0 14px; font-size: 15px; }
.modal .btn-row { margin-top: 16px; }
.tag-manual { background:#fef3c7; color:#92400e; font-size:11px; padding:1px 6px; border-radius:4px; }
.tag-custom { background:#dbeafe; color:#1e40af; font-size:11px; padding:1px 6px; border-radius:4px; }

/* ---------- Stop list (direction editor) ---------- */
.stop-list-header { display:flex; gap:8px; align-items:center; margin-bottom:8px; }
.stop-list-header input { width:200px; flex:none; padding:7px 10px; border:1px solid var(--line); border-radius:8px; font-size:14px; }
.stop-list-header input:focus { outline:none; border-color:var(--brand); box-shadow:0 0 0 3px rgba(37,99,235,.15); }
.stop-list-add-btn { padding:7px 12px; background:var(--brand); color:#fff; border:none; border-radius:8px; font-size:13px; font-weight:600; cursor:pointer; white-space:nowrap; }
.stop-list-add-btn:hover { background:var(--brand-dark); }
.stop-list-msg { font-size:12px; color:var(--muted); white-space:nowrap; }

.stop-list-table { width:100%; border-collapse:collapse; font-size:13px; }
.stop-list-table th,.stop-list-table td { border:1px solid var(--line); padding:5px 6px; text-align:left; }
.stop-list-table th { background:var(--panel-soft); font-weight:600; }
.stop-list-table tr:nth-child(even) td { background:#fcfdff; }

.stop-code-cell { white-space:nowrap; }
.stop-code-text { color:var(--ink); }
.stop-edit-btn { background:none; border:none; color:var(--muted); cursor:pointer; font-size:13px; margin-left:4px; padding:0; vertical-align:middle; }
.stop-edit-btn:hover { color:var(--brand); }
.stop-list-table .stop-edit-input { width:110px; padding:3px 4px; font-size:13px; font-weight:600; }

.stop-drag-handle { cursor:grab; color:var(--muted); user-select:none; font-size:16px; letter-spacing:1px; font-weight:600; }
.stop-drag-handle:active { cursor:grabbing; }
.stop-list-table tr.dragging { opacity:0.4; }
.stop-list-table tr.drag-over td { border-top:2px solid var(--brand); }
.stop-list-table tr.drop-bottom td { border-top:1px dashed var(--line); color:var(--muted); }
.stop-list-table tr.drop-bottom td.drop-bottom-cell { padding:4px 6px; text-align:center; font-size:12px; }
.stop-list-table tr.drop-bottom.drag-over td { border-top:2px solid var(--brand); border-bottom:none; background:var(--panel-soft); }
.stop-code-muted { font-size:11px; color:var(--muted); margin-left:4px; }

.sel-restrict { font-size:12px; padding:1px 2px; }

/* ---------- Map pick modal (variant builder: add stops from map) ---------- */
.modal-map { max-width: 1100px; width: 94%; }
.map-pick-layout { display: flex; gap: 14px; align-items: stretch; }
.map-pick-left { flex: 0 0 360px; min-width: 0; display: flex; flex-direction: column; max-height: 62vh; overflow-y: auto; }
.map-pick-right { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; }
.map-pick-count { font-size: 13px; font-weight: 700; margin-bottom: 6px; }
.map-pick-tools { display: flex; gap: 8px; margin-bottom: 8px; }
.map-pick-tools input { flex: 1 1 auto; min-width: 0; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 13px; }
.map-pick-tools input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.map-pick-map-wrap { position: relative; }
.map-pick-map { height: 55vh; min-height: 380px; width: 100%; border: 1px solid var(--line); border-radius: 8px; z-index: 0; }
.map-pick-map.pick-mode { cursor: crosshair; }
.map-pick-results { position: absolute; top: 8px; left: 8px; width: 270px; max-height: 300px; overflow-y: auto; background: #fff; border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,.2); z-index: 500; }
.map-pick-results .stop-result { padding: 8px 10px; border-bottom: 1px solid var(--line); cursor: pointer; font-size: 13px; }
.map-pick-results .stop-result:hover { background: var(--panel-soft); }
.map-pick-results .stop-result .atco { font-weight: 700; color: var(--brand); }
.map-pick-msg { font-size: 12px; margin-top: 6px; min-height: 16px; }
.map-pick-tip { font-size: 12px; margin-top: 2px; color: #92400e; }
.map-pick-under { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 8px; font-size: 12px; }
.map-pick-legend { display: inline-flex; align-items: center; gap: 10px; flex-wrap: wrap; color: var(--muted); }
.map-pick-legend .mpk { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.map-pick-legend .mpk-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
/* "Show other mode stops" toggle: muted outline when off, filled brand + colour when on. */
.map-pick-other {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 11px; font-size: 12px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px;
  background: var(--panel); color: var(--ink-soft); cursor: pointer;
}
.map-pick-other:hover { border-color: var(--brand); color: var(--ink); }
.map-pick-other .mpk-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; opacity: .35; }
.map-pick-other.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.map-pick-other.on .mpk-dot { opacity: 1; box-shadow: 0 0 0 1px rgba(255,255,255,.7); }
.map-pick-other[disabled] { opacity: .5; cursor: not-allowed; }
.map-pick-create { margin-top: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel-soft); }
.map-pick-create input { width: 100%; padding: 6px 8px; font-size: 13px; border: 1px solid var(--line); border-radius: 6px; margin-top: 6px; }
@media (max-width: 820px) {
  .map-pick-layout { flex-direction: column; }
  .map-pick-left { flex: none; max-height: 30vh; }
  .map-pick-map { height: 44vh; min-height: 300px; }
}

/* ---------- Trip grid (sticky columns, horizontal scroll) ---------- */
.grid-wrap {
  overflow-x: auto;
  margin: 8px 0;
  border: 1px solid var(--line);
  border-radius: 8px;
}
table.grid.trip-grid {
  width: max-content;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
}
table.grid.trip-grid th, table.grid.trip-grid td {
  border: none;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 4px 6px;
  white-space: nowrap;
  vertical-align: middle;
}
table.grid.trip-grid th:first-child,
table.grid.trip-grid td:first-child {
  border-left: 1px solid var(--line);
}
table.grid.trip-grid thead tr:first-child th {
  border-top: 1px solid var(--line);
}
table.grid.trip-grid thead th {
  background: var(--panel-soft);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
}
.sticky-col {
  position: sticky;
  left: 0;
  z-index: 1;
  background: var(--panel);
}
table.grid.trip-grid thead .sticky-col {
  z-index: 3;
}
.col-num { left: 0; width: 30px; text-align: center; }
.col-stop { left: 30px; width: 260px; }
.stop-cell { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stop-meta { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.trip-col { width: 75px; }
.trip-col--ad { width: 85px; }
table.grid.trip-grid .trip-col { padding: 3px 4px; }
table.grid.trip-grid thead .trip-col { text-align: center; }
table.grid.trip-grid thead .trip-header { justify-content: center; }
.col-add { width: 40px; text-align: center; }
.trip-header {
  display: flex;
  align-items: center;
  gap: 4px;
  position: relative;
}
.trip-num-btn {
  background: none;
  border: none;
  color: inherit;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 13px;
  line-height: 1.4;
  padding: 2px 3px;
  text-decoration: underline;
  text-decoration-color: #94a3b8;
  text-underline-offset: 2px;
}
.trip-num-btn:hover { color: var(--brand); text-decoration-color: var(--brand); }
.trip-num-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; border-radius: 4px; }
.trip-ov-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #db2777;
  flex-shrink: 0;
}
.trip-ov-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.trip-ov-adcol {
  width: 110px;
  white-space: nowrap;
}
.btn-link {
  background: none;
  border: none;
  color: var(--brand);
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  text-decoration: underline;
  font-family: inherit;
}
.btn-link:hover { color: var(--brand-dark); }
.inline-name { display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.inline-name .inline-name-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inline-name .name-edit { background:none; border:none; color:#94a3b8; cursor:pointer; font-size:14px; line-height:1; padding:0 2px; }
.inline-name .name-edit:hover { color:#475569; }
.inline-name-input { border:1px solid var(--brand); border-radius:6px; font:inherit; font-weight:600; padding:3px 7px; }
.inline-name .inline-ok { background:none; border:none; color:var(--ok); cursor:pointer; font-size:16px; font-weight:700; line-height:1; padding:0 2px; }
.inline-name .inline-cancel { background:none; border:none; color:var(--bad); cursor:pointer; font-size:16px; font-weight:700; line-height:1; padding:0 2px; }
.cell-time.cell-error,.cell-arr.cell-error,.cell-dep.cell-error{ border:2px solid var(--bad); background:#fee2e2; }
table.grid.trip-grid tfoot td { background: var(--panel-soft); }
table.grid.trip-grid tfoot .trip-col { text-align: center; }
.trip-del-row .sticky-col { background: var(--panel-soft); }
.trip-del { color: var(--bad); text-decoration: underline; cursor: pointer; font-size: 12px; font-family: inherit; }
.trip-del:hover { opacity: 0.8; }
.row-expand { text-decoration: none; color: var(--ink); }
.row-expand.active { font-weight: bold; color: var(--brand-dark); }
.cell-single, .cell-arr-row, .cell-dep-row {
  display: flex;
  align-items: center;
  gap: 2px;
}
.cell-arrdep {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.cell-label {
  font-size: 10px;
  color: var(--muted);
  font-weight: 600;
  text-align: right;
  flex-shrink: 0;
  user-select: none;
}
.cell-time, .cell-arr, .cell-dep {
  width: 55px;
  padding: 3px 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  font-size: 12px;
  text-align: center;
  font-family: ui-monospace, monospace;
}
.cell-time:hover, .cell-arr:hover, .cell-dep:hover {
  border-color: var(--line);
}
.cell-time:focus, .cell-arr:focus, .cell-dep:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(37,99,235,.15);
}

.dup-form { margin-top: 8px; padding: 8px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; }
.dup-title { font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }

.stop-name {
  display: block;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Timetable preview ---------- */
.tp-only-toggle {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-soft);
  cursor: pointer; white-space: nowrap;
}
.tt-prev-legend { font-size: 12px; color: var(--muted); margin: 2px 0 8px; }
.tt-group-head {
  display: flex; align-items: baseline; flex-wrap: wrap;
  gap: 4px 14px; margin: 6px 0 2px;
}
.tt-group-days { font-weight: 700; font-size: 15px; }

.tt-group-names { font-size: 12px; color: var(--muted); }
.tt-group-exc {
  font-size: 12px; color: #92400e; background: #fef3c7;
  padding: 1px 7px; border-radius: 5px;
}
table.grid.tt-prev {
  width: max-content;
  border-collapse: separate;
  border-spacing: 0;
}
table.grid.tt-prev th,
table.grid.tt-prev td {
  text-align: center; padding: 4px 9px; font-size: 13px;
  white-space: nowrap; border-bottom: 1px solid var(--line);
}
table.grid.tt-prev thead th { background: var(--panel-soft); font-weight: 600; }
table.grid.tt-prev th.trip-off { color: var(--muted); }
table.grid.tt-prev .stop-col {
  position: sticky; left: 0; z-index: 1;
  background: var(--panel);
  text-align: left; min-width: 190px; max-width: 260px;
  overflow: hidden; text-overflow: ellipsis;
  border-right: 1px solid var(--line);
}
table.grid.tt-prev thead .stop-col { background: var(--panel-soft); z-index: 2; }
table.grid.tt-prev tbody tr:nth-child(even) td { background: #fcfdff; }
.tt-prev .st-row {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.tt-prev .st-name {
  flex: 1;
  font-weight: 500;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tt-prev .stop-dual {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tt-prev .ad-lines {
  display: flex;
  flex-direction: column;
  line-height: 15px;
}
.tt-prev .tp-mark { color: #2563eb; font-size: 9px; flex-shrink: 0; }
.tt-prev .ad-tag { display: inline-block; min-width: 22px; font-size: 10px; color: var(--muted); text-align: left; }
table.grid.tt-prev td { font-variant-numeric: tabular-nums; }
.tt-prev .dual-cell .cv { line-height: 15px; min-height: 15px; }
.tt-prev .tt-est { font-style: italic; opacity: .72; }

/* ---------- Timetable preview: mini date calendar ---------- */
.tt-cal { width: 246px; margin: 2px 0 10px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel); }
.tt-cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.tt-cal-title { font-weight: 700; font-size: 13px; }
.tt-cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.tt-cal-dow { font-size: 10px; font-weight: 700; color: var(--muted); padding: 1px 0; }
.tt-cal-pad { min-height: 24px; }
.tt-cal-day { min-height: 24px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; color: var(--muted); border-radius: 5px; border: 1px solid transparent; background: none; font-family: inherit; }
.tt-cal-day.is-active { color: var(--ink); cursor: pointer; border-color: var(--line); background: var(--panel-soft); font-weight: 600; }
.tt-cal-day.is-active:hover { border-color: var(--brand); }
.tt-cal-day.is-sel { background: var(--brand); border-color: var(--brand); color: #fff; }

/* date bar + popover (calendar floats above the tables) */
.tt-date-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 2px 0 10px; }
.tt-cal-wrap { position: relative; display: inline-block; }
.tt-cal-pop { display: none; position: absolute; top: calc(100% + 4px); left: 0; z-index: 30; }
.tt-cal-pop.open { display: block; }
.tt-cal-pop .tt-cal { margin: 0; box-shadow: 0 10px 28px rgba(15,23,42,.18); }
.tt-dir { margin-bottom: 18px; }
.tt-dir:last-child { margin-bottom: 0; }

/* ---------- Route map ---------- */
.route-map .leaflet-container {
  height: 420px;
  border-radius: 8px;
  border: 1px solid var(--line);
  z-index: 1;
}
.map-legend { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 10px; }
.map-legend-item {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 4px 12px 4px 9px; cursor: pointer;
  background: var(--panel); user-select: none;
}
.map-legend-item:hover { border-color: var(--brand); }
.map-legend-item input { margin: 0; cursor: pointer; }
.map-swatch {
  width: 14px; height: 5px; border-radius: 3px; display: inline-block; flex-shrink: 0;
}
.map-num {
  width: 20px; height: 20px; border-radius: 50%;
  background: #fff; border: 3px solid #2563eb;
  color: #0f172a; font-size: 10px; font-weight: 700; line-height: 14px;
  text-align: center; font-family: inherit;
}
.map-legend-note { font-size: 12px; color: var(--muted); margin: 4px 0 10px; }
.map-route-row { display: inline-flex; align-items: center; gap: 8px; flex-basis: 100%; flex-wrap: wrap; }
.map-route-name { font-size: 12px; font-weight: 600; color: var(--ink-soft); min-width: 140px; }
.map-dot { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px rgba(15,23,42,.3); }
  