:root {
  --ink: #18202b;
  --ink-soft: #5b6573;
  --panel: #f3f5f2;
  --line: #d5dbd3;
  --precise: #0f8b7a;
  --imprecise: #c2860f;
  --route: #2443c9;
  --danger: #b4312a;
  --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --body: "Barlow", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.45 var(--body); color: var(--ink); background: var(--panel); }

h1, h2 { font-family: var(--display); font-weight: 700; letter-spacing: .01em; margin: 0; }
h1 { font-size: 34px; line-height: 1.05; }
h2 { font-size: 19px; text-transform: uppercase; }
.muted { color: var(--ink-soft); margin: 0; }
.small { font-size: 13px; }
.error { color: var(--danger); min-height: 1.2em; margin: 0; font-size: 14px; }
.hint { margin: 0; padding: 8px 10px; border-left: 3px solid var(--route); background: #fff; }
.brand { font: 700 15px var(--display); letter-spacing: .14em; margin: 0; }
.brand span { color: var(--route); }

button { font: 600 15px var(--body); cursor: pointer; border-radius: 6px; border: 1px solid transparent; padding: 10px 14px; }
button:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--route); outline-offset: 2px; }
.primary { background: var(--route); color: #fff; }
.primary:not(:disabled):hover { background: #1b35a6; }
.secondary { background: #fff; color: var(--ink); border-color: var(--line); }
.secondary:not(:disabled):hover { border-color: var(--ink-soft); }
.link { background: none; padding: 0; color: var(--route); font-weight: 500; }

/* --- login ------------------------------------------------------------------------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px;
  background: repeating-linear-gradient(135deg, #e7ebe5 0 22px, var(--panel) 22px 44px); }
.login-card { width: min(380px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 28px; display: grid; gap: 14px; }
.login-card label { display: grid; gap: 4px; font-weight: 500; }
.login-card input { font: 16px var(--body); padding: 10px 12px; border: 1px solid var(--line); border-radius: 6px; }

/* --- app --------------------------------------------------------------------------- */
.app { display: grid; grid-template-columns: 380px 1fr; height: 100%; }
.map { height: 100%; min-height: 360px; }
.panel { overflow-y: auto; border-right: 1px solid var(--line); background: var(--panel); }
.panel-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; padding: 14px 18px; background: var(--ink); color: #fff; }
.panel-head .brand span { color: #9fb2ff; }
.panel-head .link { color: #fff; text-decoration: underline; }
.who { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.tag { font: 500 11px var(--mono); padding: 2px 6px; border-radius: 4px; background: rgba(255,255,255,.14); }
.block { padding: 16px 18px; border-bottom: 1px solid var(--line); display: grid; gap: 10px; }

.legend { display: grid; gap: 4px; font-size: 14px; color: var(--ink-soft); }
.legend span, .legend label { display: flex; align-items: center; gap: 8px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; flex: none; }
.dot.precise { background: var(--precise); }
.dot.imprecise { border: 2px solid var(--imprecise); background: #fff; }

.range { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 8px; font-weight: 500; }
.range input { grid-column: 1 / -1; accent-color: var(--route); }
.range output { font: 500 15px var(--mono); }
.toggle { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.toggle input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--route); flex: none; }
.toggle > span { display: grid; gap: 2px; }
.toggle strong { font-weight: 600; }

.route-head { display: flex; justify-content: space-between; align-items: baseline; }
.route-head .muted { font: 500 13px var(--body); text-transform: none; }
.figures { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 0; }
.figures div { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; }
.figures dt { font-size: 12px; color: var(--ink-soft); }
.figures dd { margin: 0; font: 700 22px var(--display); }

/* Paradas como franja de señalética: número en placa, hora en mono. */
.stops { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; position: relative; }
.stops::before { content: ""; position: absolute; left: 15px; top: 14px; bottom: 14px; width: 3px; background: var(--route); }
.stops li { position: relative; display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: start;
  padding: 7px 6px 7px 0; border-radius: 6px; cursor: pointer; }
.stops li:hover, .stops li.active { background: #fff; }
.plate { position: relative; z-index: 1; width: 32px; height: 28px; display: grid; place-items: center; border-radius: 5px;
  background: var(--route); color: #fff; font: 700 16px var(--display); box-shadow: 0 0 0 3px var(--panel); }
.stops li.origin .plate { background: var(--ink); }
.stop-name { font-weight: 600; line-height: 1.2; }
.stop-address { font-size: 13px; color: var(--ink-soft); }
.eta { font: 500 13px var(--mono); padding-top: 4px; }

.history { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.history li button { width: 100%; text-align: left; background: #fff; border-color: var(--line); font-weight: 500;
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; }
.history li button.active { border-color: var(--route); }
.history .mono { font: 500 12px var(--mono); color: var(--ink-soft); }

/* --- marcadores -------------------------------------------------------------------- */
.stop-marker { display: grid; place-items: center; width: 26px; height: 22px; border-radius: 4px; background: var(--route);
  color: #fff; font: 700 14px var(--display); border: 2px solid #fff; box-shadow: 0 1px 3px rgba(0,0,0,.35); }
.stop-marker.active { background: var(--ink); transform: scale(1.25); }
.start-marker { width: 22px; height: 22px; border-radius: 50%; background: var(--ink); border: 4px solid #fff;
  box-shadow: 0 0 0 2px var(--ink), 0 2px 6px rgba(0,0,0,.4); }

/* --- ficha del punto (popup) ------------------------------------------------------- */
.leaflet-popup-content { margin: 12px 14px; font: 13px/1.4 var(--body); color: var(--ink); }
.pp { display: grid; gap: 6px; min-width: 250px; }
.pp p { margin: 0; }
.pp .mono { font: 500 12px var(--mono); }
.pp-name { font: 700 18px/1.15 var(--display); }
.pp-stop { display: flex; align-items: center; gap: 8px; font: 500 12px var(--mono); color: var(--ink-soft); }
.pp-stop .plate { width: 26px; height: 22px; font-size: 14px; box-shadow: none; }
.pp table { border-collapse: collapse; width: 100%; }
.pp-fields th { text-align: left; vertical-align: top; font-weight: 500; color: var(--ink-soft); padding: 1px 10px 1px 0; white-space: nowrap; }
.pp-fields td { padding: 1px 0; overflow-wrap: anywhere; }
.pp a { color: var(--route); }
.pp-section { font: 700 13px var(--display); text-transform: uppercase; letter-spacing: .04em; margin-top: 2px !important; }
.pp-items { border: 1px solid var(--line); }
.pp-items th { text-align: left; font-weight: 500; color: var(--ink-soft); background: var(--panel); padding: 3px 6px; }
.pp-items td { padding: 3px 6px; border-top: 1px solid var(--line); }
.pp-meta { font-size: 12px; color: var(--ink-soft); border-top: 1px solid var(--line); padding-top: 6px; }
.stop-address .directions { color: var(--route); text-decoration: underline; text-underline-offset: 2px; }
.pp .directions { font-weight: 600; }

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; grid-template-rows: 55vh auto; height: auto; }
  .map { order: -1; height: 55vh; }
  .panel { overflow: visible; border-right: 0; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
