/* ============================================================
   Flight-deck theme
   palette: night-slate panels, amber "miles", teal "per-dollar"
   type: Space Grotesk (display) / Inter (body) / IBM Plex Mono (data)
   ============================================================ */

:root {
  --bg:      #0c1220;
  --panel:   #141c2c;
  --panel-2: #1a2436;
  --panel-3: #212d43;
  --line:    #2a3852;
  --line-soft: #202b40;
  --ink:     #eef2f8;
  --muted:   #8794ac;
  --faint:   #5c6a84;
  --gold:    #f4b942;
  --gold-dim:#8a6d2c;
  --teal:    #2dd4bf;
  --rose:    #f16d84;
  --blue:    #6ea8fe;
  --radius:  12px;
  --radius-sm: 8px;
  --shadow:  0 8px 28px rgba(0,0,0,.35);
  --sidebar: 400px;

  --gold-rgb: 244,185,66;
  --teal-rgb: 45,212,191;
  --rose-rgb: 241,109,132;
  --blue-rgb: 110,168,254;
  --bg-rgb:   12,18,32;
  --map-bg:   #0a0f1a;
  --btn-color: #241a05;

  --scrollbar-track: #223049;
}

:root.light {
  --bg:      #f5f5f7;
  --panel:   #f8f8fa;
  --panel-2: #f3f3f6;
  --panel-3: #e8e8ed;
  --line:    #d9d9e0;
  --line-soft: #e0e0e8;
  --ink:     #1a1a1a;
  --muted:   #6b7280;
  --faint:   #a0a0a0;
  /* --gold:    #e67e22;
  --gold-dim:#d46a28; */
  --gold:   #648dff;
  --gold-dim:#2753e4;
  --teal:    #0894b7;
  --rose:    #e63946;
  --blue:    #e67e22;
  /* --blue:    #1d4ed8; */
  --radius:  12px;
  --radius-sm: 8px;
  --shadow:  0 8px 28px rgba(0,0,0,.08);
  --sidebar: 400px;

  --blue-rgb: 230,126,34;
  --teal-rgb: 8,148,183;
  --rose-rgb: 230,57,70;
  --gold-rgb: 29,78,216;
  --bg-rgb:   245,245,247;
  --map-bg:   #e4e6ea;
  --btn-color: #251b05;

  --scrollbar-track: #d1d5db;
}

* { box-sizing: border-box; }

.no-select { user-select: none; -webkit-user-select: none; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

.mono {
  font-family: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- shell ---------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar) 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: 100%;
  min-width: 0;
  max-width: 100%;
}

.map-wrap { position: relative; min-width: 0; flex: 1; }
#map { position: relative; width: 100%; height: 100%; background: var(--map-bg); }

/* leaflet chrome, theme-aware */
.leaflet-container { background: var(--map-bg); }
.leaflet-control-attribution {
  background: rgba(var(--bg-rgb),.7) !important;
  color: var(--muted) !important;
}
.leaflet-control-attribution a { color: var(--blue) !important; }
.leaflet-bar a {
  background: var(--panel-2) !important;
  color: var(--ink) !important;
  border-bottom-color: var(--line) !important;
}
.leaflet-bar a:hover { background: var(--panel-3) !important; }
.leaflet-tooltip.ap-label {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--gold);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px; font-weight: 600;
  padding: 1px 6px; box-shadow: none;
}
.leaflet-tooltip.ap-label::before { display: none; }

/* ---------- header ---------- */

.brand {
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
}
.upper-brand {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.upper-brand h1 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 19px;
  letter-spacing: .06em;
  margin: 0;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}
.upper-brand h1 .dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 12px var(--gold);
}
.upper-brand p { margin: 6px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .02em; }

.toggle {
  background: transparent;
  border: none;
  color: var(--faint);
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 15px;
  display: grid; place-items: center;
}

.status-row {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.status-row label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
}
.status-row select {
  flex: 1;
  background: var(--panel-2);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-width: 0;
}

/* ---------- scroll body ---------- */

.trips {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
}
.trips::-webkit-scrollbar { width: 10px; }
.trips::-webkit-scrollbar-thumb { background: var(--scrollbar-track); border-radius: 6px; border: 3px solid var(--panel); }

.trip {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  margin-bottom: 14px;
  overflow: hidden;
}
.trip.active { border-color: var(--gold-dim); }

.trip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 14px;
  cursor: pointer;
}
.trip-head:hover { background: var(--panel-3); }
.trip.active .trip-head { background: linear-gradient(90deg, rgba(var(--gold-rgb),.10), transparent); }

.trip-drag {
  flex-shrink: 0;
  width: 20px;
  color: var(--faint);
  font-size: 14px;
  line-height: 1;
  letter-spacing: 2px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  display: grid;
  place-items: center;
}
.trip-drag:hover { color: var(--muted); }
.trip-drag:active { cursor: grabbing; }
.trip.dragging {
  opacity: .5;
  cursor: grabbing;
}
.trip.drag-target { box-shadow: 0 -2px 0 0 var(--gold) inset; }

.trip-name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  border: none;
  background: transparent;
  color: var(--ink);
  padding: 2px 4px;
  border-radius: 6px;
  min-width: 0;
}
.trip-name:focus { outline: none; background: var(--bg); box-shadow: inset 0 0 0 1px var(--line); }

.trip-total {
  text-align: right;
  line-height: 1.1;
}
.trip-total .num { color: var(--gold); font-size: 15px; font-weight: 600; }
.trip-total .lbl { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; }

.icon-btn {
  background: transparent;
  border: none;
  color: var(--faint);
  width: 26px; height: 26px;
  border-radius: 6px;
  font-size: 15px;
  display: grid; place-items: center;
}
.icon-btn:hover { background: var(--panel-3); color: var(--rose); }

.trip-body { padding: 4px 12px 12px; }

/* ---------- segment (boarding pass) ---------- */

.seg {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  margin-top: 10px;
}
.seg::before, .seg::after {
  content: "";
  position: absolute;
  width: 12px; height: 12px;
  background: var(--panel-2);
  border: 0px solid var(--line-soft);
  border-radius: 50%;
  top: 50%; transform: translateY(-50%);
}
.seg::before { left: -7px; border-right-color: var(--panel); }
.seg::after  { right: -7px; border-left-color: var(--panel); }

.seg-route {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: "Space Grotesk", sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .04em;
}
.seg-route .arrow { color: var(--gold); font-weight: 400; }
.seg-route .rt { color: var(--muted); font-size: 11px; font-weight: 500; letter-spacing: .1em; }
.seg-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.seg-sub .pill {
  display: inline-block;
  background: var(--panel-3);
  border-radius: 4px;
  padding: 1px 6px;
  margin-right: 5px;
  color: var(--ink);
  letter-spacing: .04em;
}

.seg-foot {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px dashed var(--line);
}
.seg-miles .num {
  font-family: "IBM Plex Mono", monospace;
  font-variant-numeric: tabular-nums;
  color: var(--gold);
  font-size: 20px;
  font-weight: 600;
}
.seg-miles .lbl { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .14em; }
.seg-ppd { text-align: right; color: var(--teal); font-size: 12px; }
.seg-ppd .lbl { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .1em; display: block; }

.seg-actions {
  position: absolute;
  top: 8px; right: 8px;
  display: flex;
  align-items: right;
  gap: 2px;
}
.seg-edit, .seg-x {
  border: none; background: transparent;
  color: var(--faint); font-size: 13px;
  width: 24px; height: 24px;
  border-radius: 5px;
  display: grid; place-items: center;
}
.seg-edit .seg-btn-lbl { display: none; }
.seg-edit:hover { color: var(--gold); background: var(--panel-3); }
.seg-x:hover { color: var(--rose); background: var(--panel-3); }

.breakdown {
  margin-top: 9px;
  font-size: 11px;
  color: var(--muted);
}
.breakdown .row,
.breakdown .row-tab {
  display: flex;
  justify-content: space-between;
  padding: 2px 0;
}
.breakdown .row-tab { 
  margin-left: 12px; 
}
.breakdown .row span:last-child,
.breakdown .row-tab span:last-child { 
  color: var(--ink); 
}

/* ---------- forms ---------- */

.seg-form {
  margin-top: 10px;
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  display: grid;
  gap: 9px;
}
.field { display: grid; gap: 4px; position: relative; }
.field > label {
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em; color: var(--muted);
}
.field input, .field select {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 6px;
  padding: 8px 9px;
  width: 100%;
  min-width: 0;
}
.field input[type="range"] {
  background: var(--line);
  border: 0;
  border-radius: 2px;
  padding: 0;
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--gold-dim); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.check { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.check input { width: 15px; height: 15px; accent-color: var(--gold); }
.slider { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.slider input[type="range"] {
  flex: 1;
  background: var(--line);
  height: 4px;
  border-radius: 2px;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}
.slider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 1px solid var(--gold-dim);
  cursor: pointer;
}
.slider input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--gold);
  border: 1px solid var(--gold-dim);
  cursor: pointer;
}

.form-actions { display: flex; gap: 8px; margin-top: 2px; }

.ap-label .link {
  color: inherit;
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  text-decoration: none;
}

.ap-label .link:hover { color: var(--gold-dim); }

/* buttons */
.btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn:hover { background: var(--panel-3); }
.btn.gold { background: var(--gold); color: var(--btn-color); border-color: var(--gold); font-weight: 600; }
.btn.gold:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: 7px 10px; font-size: 12px; }

.add-seg {
  width: 100%;
  margin-top: 10px;
  border: 1px dashed var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: var(--radius-sm);
  padding: 9px;
  font-size: 12.5px;
}
.add-seg:hover { color: var(--gold); border-color: var(--gold-dim); }

.sidebar-foot {
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 10px;
  align-items: center;
}
.grand {
  flex: 1;
  line-height: 1.1;
}
.grand .num { font-family: "IBM Plex Mono", monospace; color: var(--gold); font-size: 18px; font-weight: 600; }
.grand .lbl { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .12em; }

.empty {
  color: var(--muted);
  text-align: center;
  padding: 30px 16px;
  font-size: 13px;
  line-height: 1.6;
}

/* ---------- autocomplete ---------- */
.ac {
  position: absolute;
  top: calc(100% + 3px);
  left: 0; right: 0;
  z-index: 40;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  max-height: 220px;
  overflow-y: auto;
}
.ac-item { padding: 8px 10px; cursor: pointer; border-bottom: 1px solid var(--line-soft); }
.ac-item:last-child { border-bottom: none; }
.ac-item:hover, .ac-item.hl { background: var(--panel-3); }
.ac-item .code { font-family: "IBM Plex Mono", monospace; color: var(--gold); font-weight: 600; margin-right: 8px; }
.ac-item .nm { color: var(--ink); }
.ac-item .cc { color: var(--muted); font-size: 11px; float: right; }

/* ---------- comparison modal ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(6,10,18,.72);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-center; justify-content: flex-center;
  z-index: 100;
  padding: 24px;
}
.overlay.open { display: flex; }
.modal {
  width: min(calc(var(--sidebar) - 48px), 100%);
  max-height: calc(100vh - 48px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.modal-head {
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
}
.modal-head h2 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 18px; margin: 0; letter-spacing: .04em; text-transform: uppercase;
}
.modal-body { padding: 20px 22px; overflow-y: auto; }

.cmp-section { margin-bottom: 18px; }
.cmp-section-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.cmp-section-head h3 {
  font-family: "Space Grotesk", sans-serif;
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--muted); margin: 0; font-weight: 600;
}
.cmp-section-tools { display: flex; align-items: center; gap: 14px; margin-left: 12px; }

.cmp-legs { display: grid; gap: 8px; }
.cmp-leg {
  display: grid;
  grid-template-columns: 22px 1fr auto 1fr auto;
  gap: 8px; align-items: center;
}
.cmp-leg .leg-idx {
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--panel-3); color: var(--muted);
  font-family: "IBM Plex Mono", monospace; font-size: 11px;
}
.cmp-leg .arrow { color: var(--gold); }
.cmp-leg .field { position: relative; }
.cmp-leg input {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 8px 9px; width: 100%;
  text-transform: uppercase;
}
.cmp-leg input:focus { outline: none; border-color: var(--gold-dim); }

.cmp-carriers { display: grid; gap: 10px; }
.cmp-carrier {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
}
.carrier-top {
  display: grid;
  grid-template-columns: 1fr 130px auto;
  gap: 8px; align-items: center;
}
.carrier-top select, .carrier-top input {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 8px 9px; width: 100%;
  min-width: 0px;
}
.carrier-legs {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--line);
}
.carrier-leg { display: grid; gap: 3px; }
.carrier-leg span {
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px; color: var(--muted); letter-spacing: .02em;
}
.carrier-leg select {
  background: var(--bg); border: 1px solid var(--line); color: var(--ink);
  border-radius: 6px; padding: 6px 8px; min-width: 78px;
}
.carrier-note {
  margin-top: 9px; padding-top: 9px;
  border-top: 1px dashed var(--line);
  color: var(--muted); font-size: 11.5px;
}

.cmp-route-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 8px; gap: 12px; flex-wrap: wrap;
}
.cmp-route-head .route-str {
  font-family: "Space Grotesk", sans-serif;
  font-size: 14px; letter-spacing: .03em;
}

.cmp-results { margin-top: 18px; }
table.cmp {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
table.cmp th {
  text-align: right;
  font-size: 10px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); font-weight: 500;
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
table.cmp th:first-child, table.cmp td:first-child { text-align: left; }
table.cmp td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line-soft);
  text-align: right;
}
table.cmp tr:last-child td { border-bottom: none; }
table.cmp .al { font-weight: 600; }
table.cmp .al small { display: block; color: var(--muted); font-weight: 400; font-size: 11px; }
table.cmp .miles { font-family: "IBM Plex Mono", monospace; color: var(--gold); font-weight: 600; font-size: 15px; }
table.cmp .ppd   { font-family: "IBM Plex Mono", monospace; color: var(--teal); }
table.cmp .bar-cell { width: 34%; }
.bar {
  height: 8px; border-radius: 4px;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  min-width: 2px;
}
table.cmp tr.best td { background: rgba(var(--gold-rgb),.06); }
.tag {
  display: inline-block; font-size: 9px; text-transform: uppercase; letter-spacing: .08em;
  padding: 1px 6px; border-radius: 4px; margin-left: 6px; vertical-align: middle;
}
.tag.gold { background: rgba(var(--gold-rgb),.15); color: var(--gold); }
.tag.teal { background: rgba(var(--teal-rgb),.15); color: var(--teal); }
.tag.err  { background: rgba(var(--rose-rgb),.15); color: var(--rose); }

.hint { color: var(--muted); font-size: 12px; line-height: 1.6; }
.error-line { color: var(--rose); font-size: 12px; margin-top: 4px; }

/* ---------- multi-trip comparison ---------- */
.mt-picker {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 2px 12px;
}
.mt-pick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink);
  font-size: 13px;
}
.mt-pick-row:last-child { border-bottom: none; }
.mt-pick-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--gold); flex-shrink: 0; }
.mt-pick-row input:disabled ~ span { color: var(--faint); }
.mt-pick-name { display: flex; align-items: center; gap: 9px; min-width: 0; }
.mt-pick-name span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mt-pick-pts {
  color: var(--muted);
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
  flex-shrink: 0;
}

.mt-trips { display: grid; gap: 14px; }
.mt-trip-card {
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  overflow: hidden;
}
.mt-trip-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 12px 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}
.mt-trip-info { flex: 1; min-width: 0; }
.mt-trip-name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 15px;
}
.mt-trip-route {
  color: var(--muted);
  font-size: 11px;
  margin-top: 3px;
  line-height: 1.5;
}
.mt-trip-checkbox {
  margin-top: 7px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11.5px;
}
.mt-trip-checkbox input { width: 13px; height: 13px; accent-color: var(--gold); }
.mt-trip-body { padding: 12px; display: grid; gap: 10px; }
.mt-trip-body .cmp-carriers { display: grid; gap: 10px; }

.mt-breakdown { margin-bottom: 20px; }
.mt-breakdown-name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 8px;
  color: var(--ink);
}
.mt-breakdown-name .hint { display: inline; font-size: 11.5px; }

.tag.muted { background: var(--panel-3); color: var(--muted); }

/* ---------- loyalty timeline ---------- */
.tl-track {
  display: grid;
  gap: 9px;
  margin-top: 4px;
  position: relative;
  padding-left: 26px;
}
.tl-track::before {
  content: "";
  position: absolute;
  left: 10px;
  top: 4px;
  bottom: 4px;
  border-left: 2px dashed var(--line);
}

.tl-step {
  position: relative;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  box-shadow: inset 3px 0 0 0 var(--gold-dim);  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.tl-step.return { box-shadow: inset 3px 0 0 0 var(--blue); }
.tl-step.no-points { opacity: .72; }
.tl-step::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold-dim);
  border: 2px solid var(--bg);
}
.tl-step.return::before { background: var(--blue); }
.tl-step-main { min-width: 0; }
.tl-step-route {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 600;
  font-size: 13.5px;
  letter-spacing: .01em;
}
.tl-step-route .dir { color: var(--gold); margin-right: 5px; }
.tl-step.return .tl-step-route .dir { color: var(--blue); }
.tl-step-sub { color: var(--muted); font-size: 11px; margin-top: 3px; }
.tl-step-trip { color: var(--faint); }
.tl-step-pts { text-align: right; flex-shrink: 0; }
.tl-step-pts .pts { color: var(--gold); font-weight: 600; font-size: 14px; }
.tl-step.no-points .tl-step-pts .pts { color: var(--muted); font-weight: 500; }
.tl-step-pts .bal { color: var(--muted); font-size: 10.5px; margin-top: 2px; }

.tl-banner {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(90deg, rgba(var(--gold-rgb),.16), rgba(var(--gold-rgb),.03));
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.tl-banner::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--gold);
  border: 2px solid var(--bg);
  box-shadow: 0 0 6px var(--gold);
}
.tl-banner-icon { font-size: 17px; flex-shrink: 0; }
.tl-banner-text { flex: 1; font-size: 12.5px; }
.tl-banner-bal { color: var(--gold); font-size: 12px; font-family: "IBM Plex Mono", monospace; flex-shrink: 0; }

.tl-summary {
  margin-top: 18px;
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: grid; gap: 8px;
}
.tl-summary-row { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); }
.tl-summary-row span:last-child { color: var(--ink); font-weight: 600; font-family: "IBM Plex Mono", monospace; }
.tl-summary-row.final { font-size: 14px; padding-top: 8px; border-top: 1px dashed var(--line); }
.tl-summary-row.final span:last-child { color: var(--gold); font-size: 18px; }
.tl-summary-row .status-val { font-family: "Space Grotesk", sans-serif; }
.tl-downloads { display: flex; gap: 8px; margin-top: 12px; }
.tl-downloads .btn { flex: 1; }

/* ---------- responsive: mobile/narrow ---------- */
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 48vh 52vh; }
  .sidebar { border-right: none; border-bottom: 1px solid var(--line); order: 2; }
  .map-wrap { order: 1; }
  .cmp-leg { grid-template-columns: 20px 1fr auto 1fr auto; }
  .carrier-top { grid-template-columns: 1fr 100px auto; }
  .modal { width: min(560px, 100%); }

  html, body { font-size: 13px; }

  .app { grid-template-rows: 38vh 62vh; }

  .brand { padding: 14px 14px 12px; }
  .brand h1 { font-size: 16px; letter-spacing: .04em; }
  .brand p { font-size: 11.5px; }
  .status-row { margin-top: 12px; }

  .trips { padding: 10px; }

  .trip-head { padding: 11px 10px 11px 12px; }
  .trip-name { font-size: 14px; }
  .icon-btn { width: 32px; height: 32px; font-size: 16px; }

  /* segment cards: bigger tap targets, room for two stacked action buttons */
  .seg { padding: 11px 12px; }
  .seg-route { font-size: 15.5px; flex-wrap: wrap; }
  .seg-actions { flex-direction: row; top: 6px; right: 6px; gap: 4px; }
  .seg-edit, .seg-x { width: 30px; height: 30px; font-size: 16px; }
  .seg-miles .num { font-size: 18px; }

  /* add/edit segment form: single-column, larger inputs for touch */
  .seg-form { padding: 12px 12px 14px; gap: 10px; }
  .grid-2 { grid-template-columns: 1fr; gap: 10px; }
  .field input, .field select { padding: 10px 10px; font-size: 14px; }
  .form-actions { flex-direction: column-reverse; }
  .form-actions .btn { width: 100%; }

  .sidebar-foot { flex-wrap: wrap; padding: 12px; }
  .sidebar-foot .grand { flex-basis: 100%; order: -1; margin-bottom: 4px; text-align: center; }
  .sidebar-foot .btn { flex: 1; }

  /* comparison + multi-trip modals go full-screen on phones */
  .overlay { padding: 0; z-index: 1000; }
  .modal { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
  .modal-head { padding: 14px 16px; }
  .modal-head h2 { font-size: 15px; }
  .modal-body { padding: 14px 14px 28px; }

  .cmp-legs {display: flex; flex-direction: column; gap: 6px; }
  .cmp-leg {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 10px 0;
    border-bottom: 1px dashed var(--line-soft);
    display: flex;
    flex-wrap: nowrap;
  }
  .cmp-leg .field { flex: 1; min-width: 0; }
  .cmp-leg:last-child { border-bottom: none; }
  .cmp-leg .leg-idx { justify-self: start; }
  .cmp-leg .arrow { justify-self: center; }
  .cmp-leg .l-del { justify-self: end; }

  .carrier-top { display: flex; gap: 8px; }
  .carrier-legs { gap: 10px; }
  .carrier-leg select { min-width: 0; width: 100%; }

  .ap-label .link {
    font-size: 10.5px;
    font-weight: 500;
  }

  table.cmp { font-size: 12px; }
  table.cmp th, table.cmp td { padding: 8px 6px; }
  .cmp-results { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  table.cmp .bar-cell { display: none; }

  .mt-trip-head { padding: 11px 10px 11px 12px; }
  .mt-pick-row { padding: 10px 0; }

  .trip-drag { width: 26px; font-size: 16px; }

  .tl-step { flex-wrap: wrap; }
  .tl-step-pts { text-align: left; }
  .tl-banner { flex-wrap: wrap; }
}