  :root, :root[data-theme="dark"] {
    --bg: #0c0f0d;
    --panel: #12160f;
    --panel-2: #171c14;
    --line: rgba(242, 241, 234, 0.09);
    --ink: #f2f1ea;
    --ink-2: #a8aa9e;
    --ink-3: #6d7066;
    --amber: #e8a13c;       /* relleno: botones, badges, marcadores */
    --accent: #e8a13c;      /* ámbar como texto (legible según el tema) */
    --amber-ink: #1a1206;
    --map-bg: #0e0e0e;
    --glow-1: rgba(232, 161, 60, 0.09);
    --glow-2: rgba(57, 135, 229, 0.05);
    --error-text: #f3b8b8;
    color-scheme: dark;
  }
  :root[data-theme="light"] {
    --bg: #f6f5f0;
    --panel: #ffffff;
    --panel-2: #f1efe8;
    --line: rgba(20, 20, 16, 0.12);
    --ink: #1b1b17;
    --ink-2: #55534b;
    --ink-3: #8a887e;
    --amber: #e8a13c;
    --accent: #a8620a;      /* ámbar más oscuro para texto sobre blanco */
    --amber-ink: #1a1206;
    --map-bg: #e8e6df;
    --glow-1: rgba(232, 161, 60, 0.10);
    --glow-2: rgba(57, 135, 229, 0.06);
    --error-text: #c0392b;
    color-scheme: light;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body {
    background: var(--bg);
    color: var(--ink);
    font-family: "Instrument Sans", system-ui, sans-serif;
    font-size: 14px;
    overflow: hidden;
  }
  body::before {
    content: "";
    position: fixed; inset: 0; pointer-events: none; z-index: 0;
    background:
      radial-gradient(900px 500px at -5% -10%, var(--glow-1), transparent 60%),
      radial-gradient(700px 600px at 105% 110%, var(--glow-2), transparent 60%);
  }

  /* minmax(0, 1fr) en la fila + min-height:0 en main: sin eso, una tabla larga
     agranda la fila del grid más allá del viewport y el mapa se traga la página */
  .app { display: grid; grid-template-columns: 316px 1fr; grid-template-rows: minmax(0, 1fr); height: 100vh; position: relative; z-index: 1; }

  /* ---------- Sidebar ---------- */
  aside {
    background: var(--panel);
    border-right: 1px solid var(--line);
    padding: 26px 22px;
    display: flex; flex-direction: column; gap: 22px;
    overflow-y: auto;
  }
  .reveal { opacity: 0; transform: translateY(8px); animation: rise .5s ease forwards; }
  @keyframes rise { to { opacity: 1; transform: none; } }

  .brand h1 {
    font-family: "Bricolage Grotesque", sans-serif;
    font-weight: 700; font-size: 21px; letter-spacing: 0.2px;
    margin: 0; line-height: 1.15;
  }
  .brand h1 .moon { color: var(--accent); }
  .brand p { margin: 6px 0 0; color: var(--ink-3); font-size: 12px; letter-spacing: 0.4px; text-transform: uppercase; }
  .brand-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
  .icon-btn {
    background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line);
    width: 30px; height: 30px; min-width: 30px; padding: 0; border-radius: 8px;
    font-size: 15px; line-height: 1; flex: none; display: flex; align-items: center; justify-content: center;
  }
  .icon-btn:hover { color: var(--accent); filter: none; transform: none; border-color: var(--accent); }

  form { display: flex; flex-direction: column; gap: 12px; animation-delay: .06s; }
  /* Encabezados de grupo en el sidebar: label + línea divisoria */
  .group-head {
    display: flex; align-items: center; gap: 10px; margin: 8px 0 -2px;
    font: 700 10px "Instrument Sans", sans-serif; text-transform: uppercase;
    letter-spacing: 1.1px; color: var(--ink-3);
  }
  .group-head::after { content: ""; flex: 1; height: 1px; background: var(--line); }
  .group-head:first-child { margin-top: 0; }
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
  .note { font-size: 11px; color: var(--ink-3); line-height: 1.45; margin-top: -4px; }
  input[type="number"], select {
    background: var(--panel-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 11px; font: 500 14px "Spline Sans Mono", monospace;
    outline: none; transition: border-color .15s;
  }
  select { font-family: "Instrument Sans", sans-serif; cursor: pointer; }
  label { display: flex; flex-direction: column; gap: 5px; font-size: 11px; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.6px; }
  input[type="text"], input[type="date"], input[type="email"], input[type="password"] {
    background: var(--panel-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 11px; font: 500 14px "Spline Sans Mono", monospace;
    outline: none; transition: border-color .15s;
  }
  input:focus { border-color: var(--amber); }
  .check { flex-direction: row; align-items: center; gap: 8px; text-transform: none; letter-spacing: 0; font-size: 12px; cursor: pointer; }
  .check input { accent-color: var(--amber); width: 14px; height: 14px; }

  /* ---------- Selector de drivers ---------- */
  .drivers-box {
    max-height: 150px; overflow: auto; background: var(--panel-2);
    border: 1px solid var(--line); border-radius: 8px; padding: 5px;
    display: flex; flex-direction: column; gap: 1px;
  }
  .drivers-box .empty-note { font-size: 11.5px; color: var(--ink-3); padding: 6px 7px; }
  .driver-row {
    display: flex; align-items: center; gap: 8px; padding: 5px 7px;
    border-radius: 6px; cursor: pointer; font-size: 12.5px; color: var(--ink);
    text-transform: none; letter-spacing: 0; flex-direction: row;
  }
  .driver-row:hover { background: var(--panel); }
  .driver-row input { accent-color: var(--amber); width: 13px; height: 13px; flex: none; }
  .driver-row .st { width: 8px; height: 8px; border-radius: 50%; flex: none; }
  .driver-row .st.on { background: #199e70; }
  .driver-row .st.off { background: var(--amber); }
  .driver-row .st.nopos { background: transparent; border: 1.5px solid var(--ink-3); }
  .driver-row .dname { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .driver-row .dseen { font: 500 10.5px "Spline Sans Mono", monospace; color: var(--ink-3); flex: none; }

  /* ---------- Ubicaciones a excluir (buscar + chips) ---------- */
  .excl-loc-results {
    max-height: 190px; overflow: auto; background: var(--panel-2);
    border: 1px solid var(--line); border-radius: 8px; padding: 4px;
    margin-top: -4px; display: flex; flex-direction: column; gap: 1px;
  }
  .excl-loc-results[hidden] { display: none; }
  .excl-loc-results .empty-note { font-size: 11.5px; color: var(--ink-3); padding: 6px 7px; }
  .excl-loc-opt {
    text-align: left; background: none; border: 0; border-radius: 6px;
    padding: 6px 8px; cursor: pointer; color: var(--ink); font-size: 12.5px;
    display: flex; flex-direction: column; gap: 1px; align-items: stretch;
  }
  .excl-loc-opt:hover { background: var(--panel); filter: none; }
  .excl-loc-opt .code { font: 500 11px "Spline Sans Mono", monospace; color: var(--ink-3); }
  .excl-loc-opt .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  /* Marca "winery" (tipo 1) para distinguir bodegas de viñedos en la lista/chips */
  .kind {
    display: inline-block; margin-left: 6px; padding: 0 5px; border-radius: 4px;
    font: 600 9.5px "Instrument Sans", sans-serif; text-transform: uppercase;
    letter-spacing: 0.4px; vertical-align: 1px;
    background: rgba(57, 135, 229, 0.16); color: #3987e5;
  }
  .excl-loc-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -2px; }
  .excl-loc-chips[hidden] { display: none; }
  .excl-loc-chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 6px; padding: 4px 6px 4px 8px; font-size: 11.5px;
  }
  .excl-loc-chip .lbl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .excl-loc-chip .code { font: 500 10.5px "Spline Sans Mono", monospace; color: var(--ink-3); }
  .excl-loc-chip button {
    flex: none; background: none; border: 0; padding: 0 2px; margin: 0;
    color: var(--ink-3); font-size: 14px; line-height: 1; cursor: pointer;
  }
  .excl-loc-chip button:hover { color: var(--error-text); filter: none; }
  button {
    background: var(--amber); color: var(--amber-ink);
    font: 600 14px "Instrument Sans", sans-serif;
    border: 0; border-radius: 8px; padding: 11px;
    cursor: pointer; transition: transform .12s, filter .15s;
    display: flex; align-items: center; justify-content: center; gap: 8px;
  }
  button:hover { filter: brightness(1.08); transform: translateY(-1px); }
  button:disabled { filter: saturate(0.4) brightness(0.8); cursor: default; transform: none; }
  .spinner { width: 13px; height: 13px; border: 2px solid var(--amber-ink); border-top-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; display: none; }
  button:disabled .spinner { display: inline-block; }
  @keyframes spin { to { transform: rotate(360deg); } }

  #error {
    display: none; background: rgba(230, 103, 103, 0.12); border: 1px solid rgba(230, 103, 103, 0.4);
    color: var(--error-text); border-radius: 8px; padding: 10px 12px; font-size: 12.5px; line-height: 1.45;
    overflow-wrap: break-word;
  }
  #login-error { color: var(--error-text); }
  /* label es display:flex — sin esto, hidden no lo esconde (mismo caso que
     #login-overlay[hidden]) */
  #login-env-row[hidden] { display: none; }
  /* Filtro de tipo: se esconde cuando la flota de trabajo tiene un solo tipo
     (hoy Gondola por el matching) — display:flex le ganaría a hidden. */
  #trailer-type-row[hidden] { display: none; }
  #radius-km-row[hidden] { display: none; }  /* label = display:flex, gana a hidden */

  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; animation-delay: .12s; }
  .stat {
    background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
    padding: 12px 12px 10px;
  }
  .stat b {
    display: block; font: 700 26px/1 "Spline Sans Mono", monospace;
    font-variant-numeric: tabular-nums;
  }
  .stat.amber b { color: var(--accent); }
  .stat span { display: block; margin-top: 5px; font-size: 10.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: 0.6px; }

  .legend { display: flex; flex-direction: column; gap: 7px; animation-delay: .18s; }
  .legend h2, .section-title {
    font-family: "Bricolage Grotesque", sans-serif; font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1.2px; color: var(--ink-2); margin: 0 0 2px;
  }
  .legend .row { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--ink-2); }
  .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
  .dot.ringed { background: transparent; box-shadow: 0 0 0 2px var(--ink); }
  .dash { width: 16px; border-top: 2px dashed var(--amber); flex: none; }
  .legend .n { margin-left: auto; font: 500 11.5px "Spline Sans Mono", monospace; color: var(--ink-3); }

  .foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; animation-delay: .24s; }
  .foot-note { color: var(--ink-3); font-size: 11px; line-height: 1.6; }
  /* Herramientas secundarias (p.ej. el chequeo de viñedos superpuestos):
     un link discreto — el flujo principal del dashboard no cambia. */
  .tool-link { color: var(--ink-2); font-size: 12px; text-decoration: none; }
  .tool-link:hover { color: var(--accent); }
  .logout-btn {
    background: var(--panel-2); color: var(--ink-2); border: 1px solid var(--line);
    border-radius: 8px; padding: 9px 12px; font: 600 12.5px "Instrument Sans", sans-serif;
    display: flex; align-items: center; gap: 7px; justify-content: flex-start;
  }
  .logout-btn:hover { color: #e06666; border-color: rgba(224, 102, 102, 0.5); filter: none; transform: none; }
  .logout-btn .who { margin-left: auto; color: var(--ink-3); font-weight: 500; font-size: 11px;
    max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* ---------- Main ---------- */
  main { display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden; }
  .mainbar {
    display: flex; align-items: baseline; gap: 14px;
    padding: 14px 20px 12px; border-bottom: 1px solid var(--line);
  }
  .mainbar h2 { font-family: "Bricolage Grotesque", sans-serif; font-size: 17px; font-weight: 600; margin: 0; }
  .mainbar .sub { color: var(--ink-3); font-size: 12px; }
  /* Ambiente de la sesión, siempre a la vista: PROD discreto; TESTING
     (api-dev) bien fuerte para no confundir datos de prueba con la operación
     real */
  #env-badge {
    align-self: center; border-radius: 999px; padding: 2px 10px;
    font: 700 10px "Instrument Sans", sans-serif; letter-spacing: 1.2px; cursor: default;
  }
  #env-badge.dev { background: rgba(232, 161, 60, 0.14); color: var(--amber); border: 1px solid var(--amber); }
  #env-badge.prod { background: transparent; color: var(--ink-3); border: 1px solid var(--line); }

  #map { flex: 1.5; min-height: 0; background: var(--map-bg); }
  .leaflet-container { background: var(--map-bg); font: inherit; }

  .tabs {
    display: flex; gap: 2px; padding: 0 14px; border-top: 1px solid var(--line);
    background: var(--panel);
  }
  .tab {
    background: none; color: var(--ink-3); border: 0; border-bottom: 2px solid transparent;
    border-radius: 0; padding: 10px 14px 8px; font: 600 12px "Instrument Sans", sans-serif;
    text-transform: uppercase; letter-spacing: 0.8px; cursor: pointer; transition: color .15s;
  }
  .tab:hover { color: var(--ink-2); filter: none; transform: none; }
  .tab.active { color: var(--accent); border-bottom-color: var(--amber); }
  .map-toggle {
    margin-left: auto; align-self: center;
    background: none; color: var(--ink-3); border: 0; border-radius: 6px;
    padding: 6px 8px; font: 600 11px "Instrument Sans", sans-serif;
    text-transform: uppercase; letter-spacing: 0.7px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px; transition: color .15s;
  }
  .map-toggle:hover { color: var(--ink); }
  .map-toggle .chev { display: inline-block; font-size: 9px; transition: transform .15s; }
  main.map-collapsed #map { display: none; }
  .tablewrap { flex: 1; min-height: 0; overflow: auto; border-top: 1px solid var(--line); }
  /* Filtro por texto arriba de la tabla (Vineyards / Reposition shipments):
     barra sticky, y el thead de esos tabs se pega justo debajo (top: 46px) */
  .tab-filter {
    position: sticky; top: 0; z-index: 3; height: 46px; box-sizing: border-box;
    display: flex; align-items: center; gap: 10px; padding: 0 14px;
    background: var(--panel); border-bottom: 1px solid var(--line);
  }
  /* 460px = el placeholder más largo entra completo (mono 12.5px) */
  .tab-filter .filter-box { position: relative; display: flex; flex: 0 1 460px; }
  .tab-filter input {
    width: 100%; height: 30px; box-sizing: border-box; padding: 0 28px 0 10px;
    font: 500 12.5px "Spline Sans Mono", monospace;
  }
  .filter-clear {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    width: 22px; height: 22px; border: 0; border-radius: 50%;
    background: none; color: var(--ink-3); font-size: 15px; line-height: 1;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    padding: 0;
  }
  .filter-clear:hover { color: var(--ink); background: var(--panel-2); }
  .filter-clear[hidden] { display: none; }  /* display:flex le ganaría a hidden */
  .tab-filter[hidden] { display: none; }  /* display:flex le ganaría a hidden */
  .tab-filter .count { color: var(--ink-3); font-size: 11.5px; white-space: nowrap; }
  .has-filter thead th { top: 46px; }
  /* Primera fila de una ruta mostrada solo como contexto (el match fue otro
     move de la misma ruta): atenuada para que no parezca un match propio */
  tr.filter-context td { opacity: 0.4; }

  /* ---------- Edición en las tablas (targets / prioridades) ---------- */
  /* input.<clase> para ganarle en cascada a input[type=number] de arriba */
  input.target-input, input.prio-input {
    width: 58px; text-align: right; padding: 3px 6px;
    font: 500 13px "Spline Sans Mono", monospace;
    background: var(--panel-2); color: var(--ink);
    border: 1px solid var(--line); border-radius: 6px;
  }
  input.prio-input { width: 52px; font-weight: 700; color: var(--accent); }
  input.target-input.overridden { border-color: var(--amber); color: var(--accent); font-weight: 700; }
  .row-del {
    background: none; border: 0; color: var(--ink-3); font-size: 15px;
    line-height: 1; cursor: pointer; padding: 2px 7px; border-radius: 6px;
    display: inline-flex; transition: color .12s, background .12s;
  }
  .row-del:hover { color: #e06666; background: rgba(224, 102, 102, 0.12); filter: none; transform: none; }
  /* Tab Trailers: sacar un trailer de la corrida / devolverlo (tab Excluded) */
  .remove-trailer {
    background: none; border: 0; color: var(--ink-3); font-size: 15px;
    line-height: 1; cursor: pointer; padding: 2px 7px; border-radius: 6px;
    display: inline-flex; transition: color .12s, background .12s;
  }
  .remove-trailer:hover { color: #e06666; background: rgba(224, 102, 102, 0.12); filter: none; transform: none; }
  .restore-trailer {
    background: none; border: 1px solid var(--line); color: var(--ink-2);
    font: 600 11px "Instrument Sans", sans-serif; cursor: pointer;
    padding: 3px 8px; border-radius: 6px; white-space: nowrap;
  }
  .restore-trailer:hover { color: var(--accent); border-color: var(--amber); filter: none; transform: none; }

  /* ---------- Routes: el ruteo es un paso explícito ---------- */
  .route-cta {
    display: flex; flex-direction: column; align-items: center; gap: 14px;
    padding: 52px 20px; text-align: center;
  }
  .route-cta[hidden] { display: none; }
  .route-cta p { margin: 0; max-width: 540px; color: var(--ink-2); font-size: 13px; line-height: 1.55; }
  .route-cta .note { color: var(--ink-3); font-size: 11.5px; }
  #route-go { min-width: 260px; padding: 12px 22px; }
  #route-stale-note { color: var(--amber); font-weight: 600; }
  .prio { display: inline-flex; align-items: center; gap: 8px; }
  .prio b { color: var(--accent); font: 700 15px "Spline Sans Mono", monospace; min-width: 3ch; text-align: right; }
  .prio-bar { display: inline-block; width: 64px; height: 5px; border-radius: 3px; background: var(--panel-2); overflow: hidden; vertical-align: middle; }
  .prio-bar i { display: block; height: 100%; background: var(--amber); border-radius: 3px; }
  table { width: 100%; border-collapse: collapse; font-size: 13px; }
  thead th {
    position: sticky; top: 0; background: var(--panel);
    text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.8px;
    color: var(--ink-3); font-weight: 600; padding: 10px 14px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
  }
  tbody td { padding: 9px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
  tbody tr { cursor: pointer; transition: background .12s; }
  tbody tr:hover { background: rgba(232, 161, 60, 0.07); }
  td.num, td.mono { font: 500 13px "Spline Sans Mono", monospace; font-variant-numeric: tabular-nums; }
  td.num { text-align: right; }
  th.num { text-align: right; }
  td .muted { color: var(--ink-3); }
  /* Nombre legible del campo bajo su código (origen/destino), letra chica */
  .subname {
    display: block; margin-top: 2px; max-width: 34ch;
    font: 400 11px "Instrument Sans", sans-serif; color: var(--ink-3);
    letter-spacing: 0; text-transform: none; white-space: normal; line-height: 1.3;
  }
  .chip {
    display: inline-block; background: var(--panel-2); border: 1px solid var(--line);
    border-radius: 6px; padding: 1px 7px; margin: 1px 3px 1px 0;
    font: 500 11px "Spline Sans Mono", monospace; color: var(--ink-2); white-space: nowrap;
  }
  .chip b { color: var(--accent); font-weight: 700; }
  .empty { padding: 26px; color: var(--ink-3); text-align: center; }

  /* ---------- Leaflet dark chrome ---------- */
  .leaflet-popup-content-wrapper, .leaflet-popup-tip {
    background: var(--panel-2); color: var(--ink);
    box-shadow: 0 4px 18px rgba(0,0,0,0.5); border: 1px solid var(--line);
  }
  .leaflet-popup-content { font: 13px "Instrument Sans", sans-serif; margin: 12px 14px; }
  .leaflet-popup-content .muted { color: var(--ink-2); }
  .leaflet-popup-content table { margin-top: 6px; }
  .leaflet-popup-content td, .leaflet-popup-content th { padding: 1px 8px 1px 0; text-align: left; }
  .leaflet-popup-content th { color: var(--ink-3); font-weight: 600; }
  .leaflet-container a.leaflet-popup-close-button { color: var(--ink-3); }
  .leaflet-tooltip {
    background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
    box-shadow: none; font: 600 12px "Instrument Sans", sans-serif;
  }
  .leaflet-tooltip-top:before { border-top-color: var(--panel-2); }
  .leaflet-bar a { background: var(--panel-2); color: var(--ink); border-color: var(--line); }
  .leaflet-bar a:hover { background: var(--panel); }
  .leaflet-control-attribution { background: rgba(12, 15, 13, 0.75); color: var(--ink-3); }
  .leaflet-control-attribution a { color: var(--ink-2); }
  .vineyard-badge .badge {
    background: var(--amber); color: var(--amber-ink); border: 2px solid var(--bg); border-radius: 10px;
    padding: 1px 7px; font: 700 12px "Spline Sans Mono", monospace; white-space: nowrap;
    box-shadow: 0 1px 6px rgba(0,0,0,0.55); transform: translate(-50%, -50%); display: inline-block;
  }
  .truck-badge .badge {
    background: var(--ink); color: var(--bg); border: 2px solid var(--amber); border-radius: 10px;
    padding: 1px 8px; font: 700 12px "Spline Sans Mono", monospace; white-space: nowrap;
    box-shadow: 0 1px 6px rgba(0,0,0,0.55); transform: translate(-50%, -50%); display: inline-block;
  }
  .driver-badge .badge {
    background: var(--ink); color: var(--bg); border: 2px solid #199e70; border-radius: 10px;
    padding: 1px 8px; font: 700 11px "Spline Sans Mono", monospace; white-space: nowrap;
    box-shadow: 0 1px 6px rgba(0,0,0,0.55); transform: translate(-50%, -50%); display: inline-block;
  }
  .driver-badge .badge.noloc { border-color: var(--ink-3); border-style: dashed; opacity: .85; }
  .legline { display: inline-block; width: 18px; height: 0; vertical-align: middle; }
  .legline.dashed { border-top: 2px dashed var(--ink-2); }
  .legline.solid { border-top: 3px solid var(--ink-2); }
  .route-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 7px; vertical-align: baseline; }
  #route-focus, #origin-focus {
    position: absolute; top: 12px; right: 12px; z-index: 1100;
    background: var(--panel); border: 1px solid var(--amber); border-radius: 999px;
    padding: 7px 14px; font-size: 12.5px; color: var(--ink); cursor: pointer;
    box-shadow: 0 2px 12px rgba(0,0,0,0.45); white-space: nowrap;
  }
  #route-focus:hover, #origin-focus:hover { filter: brightness(1.1); }
  #route-focus span, #origin-focus span { color: var(--accent); font-weight: 600; margin-left: 4px; }
  #route-rows tr[data-route] { cursor: pointer; }
  #route-rows tr[data-route]:hover { background: rgba(232, 161, 60, 0.05); }
  #route-rows tr.focused, #rows tr.focused { background: rgba(232, 161, 60, 0.12); }
  /* Leyenda del margen del fence: aro punteado ámbar + banda de la zona */
  .dot.margin-ringed { background: transparent; border: 2px dashed var(--amber); box-sizing: border-box; }
  .halo-swatch { display: inline-block; width: 16px; height: 8px; border-radius: 4px; background: rgba(232, 161, 60, 0.30); flex: none; }

  /* ---------- Login ---------- */
  #login-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(12, 15, 13, 0.92); backdrop-filter: blur(6px);
    display: flex; align-items: center; justify-content: center;
  }
  #login-overlay[hidden] { display: none; }
  .login-card {
    background: var(--panel); border: 1px solid var(--line); border-radius: 14px;
    padding: 34px 32px; width: 360px; display: flex; flex-direction: column; gap: 14px;
    box-shadow: 0 12px 48px rgba(0,0,0,0.6);
  }
  .login-card h2 {
    font-family: "Bricolage Grotesque", sans-serif; font-size: 19px; font-weight: 700; margin: 0;
  }
  .login-card p { margin: -6px 0 4px; color: var(--ink-3); font-size: 12.5px; }
  .signout { background: none; border: 0; color: var(--ink-3); font-size: 11px; cursor: pointer;
    padding: 0; text-decoration: underline; text-align: left; }
  .signout:hover { color: var(--accent); filter: none; transform: none; }

  @media (max-width: 900px) {
    body { overflow: auto; }
    .app { grid-template-columns: 1fr; height: auto; }
    aside { border-right: 0; border-bottom: 1px solid var(--line); }
    #map { height: 55vh; flex: none; }
    .tablewrap { max-height: none; }
  }
