:root {
  --bg: #0e1116;
  --panel: #171c23;
  --panel-2: #1e252e;
  --line: #303a46;
  --text: #f4f7fa;
  --muted: #aab5c1;
  --orange: #f58220;
  --orange-2: #ff9e45;
  --green: #4bd091;
  --red: #ff6b6b;
  --yellow: #ffcb66;
  --shadow: 0 18px 50px rgba(0, 0, 0, .26);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 15% 0%, rgba(245,130,32,.12), transparent 28rem),
    linear-gradient(180deg, #11151b, var(--bg) 28rem);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.site-header {
  position: sticky;
  z-index: 1000;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem max(1rem, calc((100vw - 1400px) / 2));
  background: rgba(14,17,22,.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-wrap { display: flex; align-items: center; gap: .9rem; }
.brand-mark {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--orange), #bc4800);
  color: white;
  font-size: 1.55rem;
  font-weight: 900;
  box-shadow: 0 8px 24px rgba(245,130,32,.28);
}
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.2rem, 2vw, 1.55rem); }
h2 { margin-bottom: .6rem; font-size: clamp(1.3rem, 2.3vw, 2rem); line-height: 1.15; }
.eyebrow { margin-bottom: .35rem; color: var(--orange-2); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.status-pill, .badge {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .45rem .75rem;
  background: var(--panel);
  color: var(--muted);
  font-size: .82rem;
  font-weight: 700;
}
.status-pill span { width: .55rem; height: .55rem; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 5px rgba(75,208,145,.12); }

.page-shell { width: min(1400px, calc(100% - 2rem)); margin: 2rem auto 4rem; }
.card {
  border: 1px solid rgba(255,255,255,.09);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(30,37,46,.96), rgba(23,28,35,.96));
  box-shadow: var(--shadow);
}
.hero { display: grid; grid-template-columns: 1.3fr .7fr; gap: 2rem; align-items: center; padding: clamp(1.5rem, 4vw, 3rem); overflow: hidden; }
.hero h2 { max-width: 20ch; font-size: clamp(2rem, 4vw, 4rem); letter-spacing: -.035em; }
.hero-copy > p:last-child { max-width: 72ch; color: var(--muted); line-height: 1.65; }
.hero-flow { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .55rem; padding: 2rem 1rem; }
.hero-flow span { padding: .65rem .85rem; border-radius: 10px; background: #252e39; border: 1px solid #3b4654; font-weight: 800; }
.hero-flow i { color: var(--orange); font-style: normal; font-weight: 900; }

.input-card, .ride-card, .route-card, .export-card, .map-card { margin-top: 1.2rem; padding: clamp(1.2rem, 3vw, 2rem); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.section-heading h2 { margin-bottom: 0; }
label { display: grid; gap: .5rem; color: #dfe6ed; font-size: .9rem; font-weight: 700; }
textarea, input, select {
  width: 100%;
  border: 1px solid #3a4653;
  border-radius: 11px;
  outline: none;
  background: #10151b;
  color: var(--text);
  padding: .78rem .9rem;
  transition: border-color .18s, box-shadow .18s;
}
textarea { resize: vertical; line-height: 1.5; }
textarea:focus, input:focus, select:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(245,130,32,.13); }
.input-footer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-top: 1rem; }
.help-text, .fine-print, .provider-note { color: var(--muted); line-height: 1.5; }
.help-text { margin: 0; font-size: .88rem; }
.fine-print { margin: 1rem 0 0; font-size: .76rem; }
.provider-note { font-size: .75rem; }

.button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: .72rem 1rem;
  color: white;
  font-weight: 800;
  transition: transform .15s, background .15s, border-color .15s;
}
.button:hover { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.button-primary { background: linear-gradient(135deg, var(--orange), #d65d00); box-shadow: 0 8px 24px rgba(245,130,32,.2); }
.button-primary:hover { background: linear-gradient(135deg, var(--orange-2), var(--orange)); }
.button-secondary { background: #2a3440; border-color: #455260; }
.button-ghost { background: transparent; border-color: #3c4855; color: #dce4eb; }
.button-wide { width: 100%; margin-top: 1rem; }
.split-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: .55rem; margin-top: .7rem; }

.workspace.hidden, .hidden { display: none !important; }
.form-grid { display: grid; grid-template-columns: 2fr 1fr 1.2fr .8fr; gap: 1rem; }
.timing-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: .75rem; margin-top: 1.2rem; }
.timing-strip > div { display: grid; gap: .18rem; padding: 1rem; border: 1px solid var(--line); border-radius: 12px; background: rgba(10,14,18,.45); }
.timing-strip span, .metric span { color: var(--muted); font-size: .77rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.timing-strip strong { font-size: 1.3rem; }
.timing-strip small, .metric small { color: #788594; }

.metrics-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-top: 1.2rem; }
.metric { display: grid; gap: .3rem; padding: 1.25rem; }
.metric strong { font-size: clamp(1.45rem, 3vw, 2.25rem); }
.content-grid { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1.2rem; align-items: start; }
.export-card { position: sticky; top: 92px; }
.check-row { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: .65rem; margin: .65rem 0; font-weight: 600; }
.check-row input { width: 1.05rem; height: 1.05rem; accent-color: var(--orange); }

.leg-panel { margin: 1rem 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: rgba(12,16,21,.45); }
.leg-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem; background: #222a34; border-bottom: 1px solid var(--line); }
.leg-header h3 { margin: 0; font-size: 1rem; }
.leg-stats { display: flex; gap: .55rem; flex-wrap: wrap; }
.leg-stats span { border-radius: 999px; padding: .35rem .6rem; background: #151b22; color: var(--muted); font-size: .75rem; font-weight: 700; }
.source-link { display: block; max-width: 100%; padding: .8rem 1rem 0; color: #8fbdf8; font-size: .74rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.waypoint-list { padding: .85rem; }
.waypoint-row { display: grid; grid-template-columns: 70px minmax(180px, 1fr) 120px 120px auto; gap: .6rem; align-items: end; margin-bottom: .65rem; }
.waypoint-row label { font-size: .72rem; color: var(--muted); }
.waypoint-row input, .waypoint-row select { padding: .62rem .68rem; font-size: .83rem; }
.icon-buttons { display: flex; gap: .35rem; padding-bottom: .05rem; }
.icon-button { width: 36px; height: 36px; border: 1px solid #3d4956; border-radius: 9px; background: #202832; color: #d9e1e8; font-weight: 900; }
.icon-button.danger { color: #ff9c9c; }
.leg-actions { display: flex; justify-content: space-between; gap: .7rem; padding: 0 .85rem .85rem; }
.add-waypoint { border: 1px dashed #44515e; border-radius: 10px; background: transparent; color: var(--muted); padding: .55rem .75rem; }

.message-stack { display: grid; gap: .55rem; margin-top: .8rem; }
.message { border-radius: 10px; padding: .75rem .9rem; border: 1px solid; font-size: .84rem; line-height: 1.45; }
.message.error { border-color: rgba(255,107,107,.5); background: rgba(255,107,107,.1); color: #ffc2c2; }
.message.warning { border-color: rgba(255,203,102,.4); background: rgba(255,203,102,.08); color: #ffe0a3; }
.message.success { border-color: rgba(75,208,145,.4); background: rgba(75,208,145,.08); color: #b8f5d5; }

#map { height: min(62vh, 650px); min-height: 430px; border-radius: 13px; background: #10151b; }
.leaflet-container { font-family: inherit; }
.route-label { display: grid; place-items: center; width: 26px !important; height: 26px !important; margin-left: -13px !important; margin-top: -13px !important; border: 2px solid white; border-radius: 50%; background: var(--orange); color: white; box-shadow: 0 4px 12px rgba(0,0,0,.35); font-size: .7rem; font-weight: 900; }

.busy-overlay { position: fixed; z-index: 5000; inset: 0; display: grid; place-content: center; justify-items: center; gap: .8rem; background: rgba(7,9,12,.84); backdrop-filter: blur(8px); text-align: center; }
.busy-overlay span { color: var(--muted); }
.spinner { width: 48px; height: 48px; border: 4px solid rgba(255,255,255,.14); border-top-color: var(--orange); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
footer { padding: 1rem 1rem 3rem; text-align: center; color: #788594; font-size: .8rem; }

@media (max-width: 1050px) {
  .hero { grid-template-columns: 1fr; }
  .form-grid, .timing-strip, .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .content-grid { grid-template-columns: 1fr; }
  .export-card { position: static; }
}
@media (max-width: 720px) {
  .site-header { align-items: flex-start; }
  .status-pill { display: none; }
  .page-shell { width: min(100% - 1rem, 1400px); margin-top: .75rem; }
  .hero { padding: 1.35rem; }
  .hero h2 { font-size: 2.25rem; }
  .input-footer, .section-heading { align-items: stretch; flex-direction: column; }
  .form-grid, .timing-strip, .metrics-grid { grid-template-columns: 1fr; }
  .waypoint-row { grid-template-columns: 78px 1fr; }
  .waypoint-row .coordinate-field { grid-column: span 1; }
  .waypoint-row .icon-buttons { grid-column: 1 / -1; }
  .split-buttons { grid-template-columns: 1fr; }
  #map { min-height: 360px; }
}
