/* ==========================================================================
   Planibus — sistema visual inspired en Shopify Polaris
   ==========================================================================
   Principios:
   · fondo gris muy claro, superficies blancas (no modo oscuro)
   · gris azulado para texto secundario y bordes, nunca negro puro
   · un solo acento (verde Shopify) para accion primaria
   · radios generosos (8-12px), sombras muy sutiles
   · tipografia densa: 13px base, solo 20px+ para cifras destacadas
   · el color se reserva para el significado: verde ok, ambar aviso, rojo error
   ========================================================================== */

:root {
  /* superficies */
  --bg:            #f1f2f4;
  --surface:       #ffffff;
  --surface-2:     #f7f8f9;
  --surface-3:     #eef0f2;
  --surface-hover: #f6f7f8;

  /* texto */
  --text:          #202223;
  --text-2:        #5c5f62;
  --text-3:        #8c9196;
  --text-inv:      #ffffff;

  /* bordes */
  --line:          #e3e5e8;
  --line-2:        #d3d6da;
  --line-focus:    #2c6ecb;

  /* acento */
  --accent:        #008060;
  --accent-hover:  #006e52;
  --accent-soft:   #e7f4ef;
  --accent-line:   #a8d5c8;

  /* semanticos */
  --ok:            #29845a;
  --ok-soft:       #e6f4ea;
  --warn:          #b98900;
  --warn-soft:     #fff5e0;
  --danger:        #d72c0d;
  --danger-soft:   #fef1f0;
  --info:          #2c6ecb;
  --info-soft:     #eaf1fb;
  --neutral:       #8c9196;
  --neutral-soft:  #f1f2f4;

  /* medidas */
  --r-sm: 6px;
  --r:    8px;
  --r-lg: 12px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.05), 0 0 0 1px rgba(0,0,0,.04);
  --shadow-2: 0 4px 12px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.05);

  --topbar-h: 56px;
  --tabs-h:   44px;

  /* anchos de los paneles redimensionables. Los escribe el usuario al
     arrastrar los tiradores y se guardan en localStorage. Viven en :root y NO
     en .layout: si estuvieran en .layout crearian una sombra local que
     ignoraria el valor que el JS pone en documentElement. */
  --w-left:  320px;
  --w-right: 360px;
  --gutter:  6px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ==========================================================================
   TOPBAR
   ========================================================================== */

.topbar {
  height: var(--topbar-h);
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; flex: 0 0 auto; }

.brand-mark {
  width: 28px; height: 28px;
  border-radius: var(--r-sm);
  background: var(--accent);
  color: var(--text-inv);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; letter-spacing: .02em;
}

.brand-txt h1 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: -.01em;
  line-height: 1.2;
}
.brand-txt span { font-size: 11px; color: var(--text-3); }

.topbar-search {
  flex: 1 1 auto;
  max-width: 380px;
  position: relative;
}
.topbar-search input {
  width: 100%;
  height: 32px;
  padding: 0 10px 0 30px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface-2);
}
.topbar-search input:focus {
  background: var(--surface);
  outline: 0;
  border-color: var(--line-focus);
  box-shadow: 0 0 0 2px rgba(44,110,203,.15);
}
.topbar-search::before {
  content: "";
  position: absolute; left: 10px; top: 50%;
  width: 12px; height: 12px; margin-top: -6px;
  border: 1.5px solid var(--text-3);
  border-radius: 50%;
}
.topbar-search::after {
  content: "";
  position: absolute; left: 21px; top: 50%;
  width: 5px; height: 1.5px; margin-top: 2px;
  background: var(--text-3);
  transform: rotate(45deg);
  transform-origin: left center;
}

.topbar-right {
  margin-left: auto;
  display: flex; align-items: center; gap: 8px;
}

/* ==========================================================================
   TABS
   ========================================================================== */

.tabs {
  height: var(--tabs-h);
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 2px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.tab {
  height: 100%;
  padding: 0 14px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  display: flex; align-items: center;
}
.tab:hover { color: var(--text); background: var(--surface-2); }
.tab[aria-selected="true"] {
  color: var(--accent);
  border-bottom-color: var(--accent);
  font-weight: 650;
}

.tab-panel { display: none; }
.tab-panel.activa { display: contents; }

/* ==========================================================================
   LAYOUT RESPONSIVE
   ==========================================================================
   Tres zonas (rail izq / mapa / rail der) sobre un grid de areas. Los anchos
   los fija el usuario arrastrando los tiradores, y se guardan en localStorage,
   asi que cada pantalla conserva su propia disposicion.

   Breakpoints:
     >= 1200px  las tres columnas a la vista
     < 1200px   dos columnas: mapa + un rail (el otro se abre en cajon)
     < 820px    una columna con pestanas (el mapa se abre a pantalla completa)
   ========================================================================== */

.layout {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  gap: 0;
  grid-template-columns: var(--w-left) var(--gutter) minmax(0, 1fr) var(--gutter) var(--w-right);
  grid-template-areas: "left lg map gr right";
}

.pane { min-width: 0; min-height: 0; position: relative; }
/* separacion visual entre panel y gutter */
.pane-left  { border-right: 0; }
.pane-right { border-left: 0; }
.pane-left  { grid-area: left;  overflow: hidden; }
.pane-map   { grid-area: map;   overflow: hidden; }
.pane-right { grid-area: right; overflow: hidden; }

/* El mapa necesita ser posicionado por dentro del grid */
.pane-map > .mapwrap { position: absolute; inset: 0; }

/* --- rail: columna con scroll propio --- */
.rail {
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 12px;
  scrollbar-width: thin;
}

/* --- tiradores redimensionables --- */
.gutter {
  grid-area: lg;
  position: relative;
  cursor: col-resize;
  background: transparent;
  touch-action: none;
}
.gutter::after {
  content: "";
  position: absolute;
  /* zona de agarre amplia: 14px reales, aunque la columna sea de 6px */
  inset: 0 -4px;
  background: transparent;
  transition: background .12s;
}
.gutter:hover::after,
.gutter.dragging::after { background: var(--accent); opacity: .35; }
.gutter.gr { grid-area: gr; }

/* punto de agarre */
.gutter::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 3px; height: 28px;
  margin: -14px 0 0 -1.5px;
  border-radius: 2px;
  background: var(--line-2);
  opacity: 0;
  transition: opacity .12s;
}
.gutter:hover::before { opacity: 1; }

/* --- barra de vista movil --- */
.viewbar { display: none; }

/* ==========================================================================
   RESPONSIVE: 2 columnas (tablet / portatil pequeno)
   ========================================================================== */

@media (max-width: 1199px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-areas: "main";
  }
  .pane-left, .pane-right, .gutter { display: none; }
  .pane-map { display: block; }

  /* el rail visible se mete dentro del area unica */
  .pane-map { grid-area: main; }

  .viewbar {
    display: flex;
    gap: 4px;
    padding: 8px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    flex: 0 0 auto;
  }
  .viewbar button {
    flex: 1 1 0;
    height: 34px;
    border: 1px solid var(--line-2);
    border-radius: var(--r-sm);
    background: var(--surface);
    font-size: 12.5px;
    font-weight: 550;
    color: var(--text-2);
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  }
  .viewbar button[aria-pressed="true"] {
    background: var(--accent-soft);
    border-color: var(--accent-line);
    color: var(--accent);
  }

  /* cuando se elige un rail, el mapa se oculta */
  body.view-rail .pane-map { display: none; }
  body.view-rail .pane-left,
  body.view-rail .pane-right {
    display: block;
    grid-area: main;
  }
  body.view-rail .gutter { display: none; }
}

/* ==========================================================================
   RESPONSIVE: movil
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* foco visible para navegacion por teclado */
.gutter:focus-visible { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ==========================================================================
   CARD
   ========================================================================== */

.card {
  background: var(--surface);
  border-radius: var(--r);
  box-shadow: var(--shadow-1);
  overflow: hidden;
  flex: 0 0 auto;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.card-head h2 {
  margin: 0;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -.005em;
}

.card-head .sub {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 400;
}

.card-body { padding: 14px; }
.card-body.tight { padding: 10px 12px; }

.card-foot {
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

/* ==========================================================================
   CONTROLES
   ========================================================================== */

.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.field > label,
.field-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-2);
  letter-spacing: .01em;
}

.field-hint { font-size: 11px; color: var(--text-3); }
.field-error { font-size: 11px; color: var(--danger); font-weight: 550; }

.input, .select {
  height: 32px;
  width: 100%;
  padding: 0 10px;
  background: var(--surface);
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  color: var(--text);
  transition: border-color .12s, box-shadow .12s;
  min-width: 0;
}
.select {
  padding-right: 26px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='none' stroke='%235c5f62' stroke-width='1.5' d='M1 1l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  cursor: pointer;
}
.input:focus, .select:focus {
  outline: 0;
  border-color: var(--line-focus);
  box-shadow: 0 0 0 2px rgba(44,110,203,.15);
}
.input::placeholder { color: var(--text-3); }

.input-sm { height: 28px; font-size: 12px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.form-grid { display: grid; gap: 10px; }

/* botones */
.btn {
  height: 32px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--line-2);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
.btn:hover:not(:disabled) { background: var(--surface-2); }
.btn:active:not(:disabled) { background: var(--surface-3); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 2px rgba(44,110,203,.35);
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inv);
}
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-primary:active:not(:disabled) { background: var(--accent-hover); }

.btn-sm { height: 26px; padding: 0 9px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-quiet { border-color: transparent; background: transparent; }
.btn-quiet:hover:not(:disabled) { background: var(--surface-3); }

/* segmented control */
.segmented {
  display: inline-flex;
  background: var(--surface-3);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.segmented button {
  border: none;
  background: none;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: 550;
  color: var(--text-2);
  cursor: pointer;
}
.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}

/* ==========================================================================
   BANNER / ALERT
   ========================================================================== */

.alert {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}
.alert[hidden] { display: none; }
.alert-ok      { background: var(--ok-soft);      color: #1a5c3e; }
.alert-warn    { background: var(--warn-soft);    color: #7a5c00; }
.alert-danger  { background: var(--danger-soft);  color: #9c1d08; }
.alert-info    { background: var(--info-soft);    color: #1c4f96; }
.alert-close {
  margin-left: auto;
  border: none; background: none; cursor: pointer;
  color: inherit; opacity: .6; font-size: 15px; line-height: 1;
  padding: 0 2px;
}
.alert-close:hover { opacity: 1; }

/* ==========================================================================
   BADGES / PILLS
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 20px;
  padding: 0 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: .005em;
  white-space: nowrap;
  background: var(--neutral-soft);
  color: var(--text-2);
}
.badge-ok      { background: var(--ok-soft);      color: var(--ok); }
.badge-warn    { background: var(--warn-soft);    color: var(--warn); }
.badge-danger  { background: var(--danger-soft);  color: var(--danger); }
.badge-info    { background: var(--info-soft);    color: var(--info); }
.badge-accent  { background: var(--accent-soft);  color: var(--accent); }

.dot { width: 7px; height: 7px; border-radius: 50%; flex: 0 0 auto; }
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-danger { background: var(--danger); }
.dot-neutral { background: var(--neutral); }

/* ==========================================================================
   STATS
   ========================================================================== */

.stats { display: grid; gap: 1px; background: var(--line); }
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stats-2 { grid-template-columns: repeat(2, 1fr); }

.stat {
  background: var(--surface);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.stat-label {
  font-size: 11px;
  color: var(--text-2);
  font-weight: 550;
  display: flex; align-items: center; gap: 4px;
}
.stat-value {
  font-size: 19px;
  font-weight: 650;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}
.stat-value.sm { font-size: 15px; }
.stat-sub { font-size: 11px; color: var(--text-3); }
.stat-value.ok { color: var(--ok); }
.stat-value.warn { color: var(--warn); }
.stat-value.danger { color: var(--danger); }

/* ==========================================================================
   MAPA
   ========================================================================== */

.mapwrap {
  position: relative;
  border-radius: var(--r);
  overflow: hidden;
  box-shadow: var(--shadow-1);
  min-height: 0;
  background: var(--surface-3);
}
#mapa { position: absolute; inset: 0; }

.map-legend {
  position: absolute; left: 12px; bottom: 12px;
  display: flex; gap: 14px;
  padding: 7px 11px;
  background: rgba(255,255,255,.94);
  backdrop-filter: blur(6px);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-1);
  font-size: 11px;
  color: var(--text-2);
}
.map-legend span { display: flex; align-items: center; gap: 5px; }

.map-panel {
  position: absolute; right: 12px; top: 12px;
  min-width: 180px;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(6px);
  border-radius: var(--r-sm);
  box-shadow: var(--shadow-1);
  overflow: hidden;
}
.map-panel-head {
  padding: 8px 11px;
  font-size: 11px; font-weight: 650;
  border-bottom: 1px solid var(--line);
  display: flex; justify-content: space-between;
}
.map-panel-row {
  padding: 6px 11px;
  font-size: 11px;
  color: var(--text-2);
  display: flex; justify-content: space-between; gap: 12px;
}
.map-panel-row b { color: var(--text); font-variant-numeric: tabular-nums; }

/* ==========================================================================
   LISTAS
   ========================================================================== */

.list { display: flex; flex-direction: column; }

.row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  text-align: left;
  border-left: 3px solid transparent;
  width: 100%;
}
.row:last-child { border-bottom: none; }
.row:hover { background: var(--surface-hover); }
.row.sel { background: var(--info-soft); border-left-color: var(--info); }
.row.sel:hover { background: var(--info-soft); }
.row.no-cursor { cursor: default; }
.row.no-cursor:hover { background: var(--surface); }

.row-main { flex: 1 1 auto; min-width: 0; }
.row-title {
  font-size: 13px; font-weight: 550;
  display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.row-sub {
  font-size: 11px; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 1px;
}
.row-right { flex: 0 0 auto; text-align: right; }
.row-num {
  font-size: 13px; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.row-num.ok { color: var(--ok); }
.row-num.danger { color: var(--danger); }
.row-cap { font-size: 10px; color: var(--text-3); }

.scroll-y { overflow-y: auto; }

.empty {
  padding: 28px 16px;
  text-align: center;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.5;
}
.empty b { color: var(--text-2); }

/* ==========================================================================
   CHIPS
   ========================================================================== */

.chips { display: flex; flex-wrap: wrap; gap: 5px; }

.chip {
  height: 24px;
  padding: 0 9px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: var(--surface);
  font-size: 11px;
  font-weight: 550;
  color: var(--text-2);
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.chip:hover { background: var(--surface-2); border-color: var(--text-3); color: var(--text); }
.chip.accent { background: var(--accent-soft); border-color: var(--accent-line); color: var(--accent); }

/* ==========================================================================
   PARADAS (editor)
   ========================================================================== */

.stop {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.stop-n {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
}
.stop-n.first { background: var(--accent); color: var(--text-inv); }
.stop-n.last  { background: var(--text-2); color: var(--text-inv); }
.stop-name { font-size: 12px; font-weight: 550; }
.stop-meta { font-size: 11px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.icon-btn {
  width: 24px; height: 24px;
  border: none; background: none;
  border-radius: var(--r-sm);
  color: var(--text-3);
  cursor: pointer;
  display: grid; place-items: center;
  font-size: 15px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-3); color: var(--danger); }

/* ==========================================================================
   TIMELINE DEL CONDUCTOR  (lo nuevo)
   ========================================================================== */

.tl { display: flex; flex-direction: column; }

.tl-head {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.tl-head .who { font-size: 13px; font-weight: 650; }
.tl-head .when {
  margin-left: auto; font-size: 11px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.tl-numbers {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}
.tl-numbers .stat { padding: 9px 12px; }
.tl-numbers .stat-value { font-size: 15px; }

/* barra de tiempo */
.tl-bar {
  position: relative;
  height: 30px;
  background: var(--surface-3);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}
.tl-seg {
  position: absolute;
  top: 6px;
  height: 18px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-inv);
  overflow: hidden;
  white-space: nowrap;
}
.tl-seg.carga { background: var(--accent); }
.tl-seg.vacio { background: var(--neutral); }
.tl-seg.pausa { background: var(--warn); }

.tl-hours {
  position: relative;
  height: 16px;
  font-size: 9px;
  color: var(--text-3);
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.tl-hour {
  position: absolute;
  top: 2px;
  transform: translateX(-50%);
  font-variant-numeric: tabular-nums;
}

/* lista de viajes */
.tl-viajes { padding: 4px 0; }

.tl-viaje {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 10px;
  padding: 7px 14px;
  position: relative;
}
/* linea vertical que conecta los viajes */
.tl-viaje::before {
  content: "";
  position: absolute;
  left: 20px; top: 0; bottom: 0;
  width: 2px;
  background: var(--line);
}
.tl-viaje:first-child::before { top: 16px; }
.tl-viaje:last-child::before  { bottom: calc(100% - 16px); }

.tl-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  margin-top: 4px;
  margin-left: 2px;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1.5px var(--line-2);
  position: relative;
  z-index: 1;
}
.tl-dot.v0 { background: var(--accent); box-shadow: 0 0 0 1.5px var(--accent); }
.tl-dot.v1 { background: var(--info);    box-shadow: 0 0 0 1.5px var(--info); }
.tl-dot.v2 { background: #8b5cf6;        box-shadow: 0 0 0 1.5px #8b5cf6; }
.tl-dot.v3 { background: var(--warn);    box-shadow: 0 0 0 1.5px var(--warn); }

.tl-cuerpo { min-width: 0; padding-bottom: 2px; }

.tl-vhead {
  display: flex; align-items: center; gap: 7px; flex-wrap: wrap;
}
.tl-mat {
  font-size: 12px; font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.tl-tiempo {
  font-size: 11px; color: var(--text-2);
  font-variant-numeric: tabular-nums;
}
.tl-cambio {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 10px; font-weight: 600;
  color: var(--warn);
  background: var(--warn-soft);
  padding: 1px 6px;
  border-radius: 9px;
}
.tl-cambio.sin-espacio { color: var(--danger); background: var(--danger-soft); }

.tl-servicios { margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px; }
.tl-srv {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-3);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  border: none;
}
.tl-srv:hover { background: var(--accent-soft); color: var(--accent); }

/* ==========================================================================
   SUGERENCIAS (modo asistido)
   ========================================================================== */

.sug {
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}
.sug:last-child { border-bottom: none; }
.sug:hover { background: var(--surface-hover); }
.sug.top { background: var(--accent-soft); }
.sug.top:hover { background: var(--accent-soft); }

.sug-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sug-rank {
  display: grid; place-items: center;
  width: 18px; height: 18px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text-2);
  font-size: 10px; font-weight: 700;
  flex: 0 0 auto;
}
.sug.top .sug-rank { background: var(--accent); color: var(--text-inv); }

.sug-code { font-size: 13px; font-weight: 600; }
.sug-client { font-size: 11px; color: var(--text-3); }

.sug-figures {
  display: flex;
  gap: 16px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
}
.fig { display: flex; flex-direction: column; gap: 1px; }
.fig-lbl { font-size: 10px; color: var(--text-3); }
.fig-val {
  font-size: 14px; font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
.fig-val.ok { color: var(--ok); }
.fig-val.warn { color: var(--warn); }
.fig-val.muted { color: var(--text-3); font-size: 12px; }

.sug-actions { display: flex; gap: 6px; margin-top: 10px; }

.sug-notes { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.note {
  font-size: 11px;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  line-height: 1.4;
  display: flex; gap: 6px;
}
.note-warn { background: var(--warn-soft); color: #7a5c00; }
.note-danger { background: var(--danger-soft); color: #9c1d08; }

/* ==========================================================================
   ECONOMIA
   ========================================================================== */

.eco-hero {
  padding: 18px 14px;
  text-align: center;
  background: linear-gradient(180deg, var(--accent-soft), var(--surface));
  border-bottom: 1px solid var(--line);
}
.eco-hero .lbl {
  font-size: 11px; font-weight: 600; color: var(--text-2);
  text-transform: uppercase; letter-spacing: .05em;
}
.eco-hero .val {
  font-size: 30px; font-weight: 700; letter-spacing: -.03em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin: 3px 0;
}
.eco-hero .val.ok { color: var(--ok); }
.eco-hero .val.danger { color: var(--danger); }
.eco-hero .sub { font-size: 12px; color: var(--text-2); }

.eco-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
}
.eco-row:last-child { border-bottom: none; }
.eco-code { font-size: 12px; font-weight: 550; }
.eco-meta { font-size: 11px; color: var(--text-3); margin-top: 1px; }
.eco-fig { text-align: right; }
.eco-margen {
  font-size: 13px; font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.eco-margen.ok { color: var(--ok); }
.eco-margen.danger { color: var(--danger); }
.eco-ph { font-size: 10px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.meter {
  height: 3px;
  background: var(--surface-3);
  border-radius: 2px;
  margin-top: 4px;
  overflow: hidden;
  width: 70px;
}
.meter > i { display: block; height: 100%; border-radius: 2px; }

.table-strip {
  display: flex;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1500px) {
  .layout { grid-template-columns: 310px minmax(0,1fr) 340px; }
}
@media (max-width: 1280px) {
  .layout { grid-template-columns: 280px minmax(0,1fr) 300px; gap: 10px; padding: 10px; }
  .topbar-search { max-width: 240px; }
}
/* spinner */
.spin {
  width: 13px; height: 13px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  flex: 0 0 auto;
}
.spin[hidden] { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 819px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px; padding: 8px 12px; }
  .topbar-search { max-width: none; order: 3; flex-basis: 100%; }
  .topbar-right { gap: 6px; }

  .layout { padding: 0; }

  .rail { padding: 10px; gap: 10px; }

  /* tarjetas sin sombra dura, mas aire y tipografia comoda */
  .card-head { padding: 12px 13px; }
  .card-body { padding: 13px; }

  /* stats en 2 columnas en lugar de 4 */
  .stats-4 { grid-template-columns: repeat(2, 1fr); }
  .stats-2 { grid-template-columns: repeat(2, 1fr); }

  /* botones y selects a ancho completo, comodos de tocar */
  .btn { height: 38px; padding: 0 14px; }
  .input, .select { height: 38px; font-size: 16px; }  /* >=16px evita el zoom en iOS */
  .input-sm { height: 34px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .grid-3 { gap: 8px; }

  .tab { padding: 0 10px; font-size: 12.5px; }
  .tabs { padding: 0 6px; }

  .row { padding: 11px 13px; }
  .sug { padding: 13px; }
  .sug-figures { gap: 12px; flex-wrap: wrap; }

  .map-legend {
    left: 8px; bottom: 8px; right: 8px;
    justify-content: space-between; gap: 8px;
    font-size: 10.5px; padding: 6px 9px;
  }
  .map-panel { right: 8px; top: 8px; min-width: 140px; }

  .timeline-numbers, .tl-numbers { grid-template-columns: repeat(2, 1fr); }
  .tl-bar { height: 26px; }
  .tl-seg { top: 5px; height: 16px; }
}

/* ==========================================================================
   PANTALLA ESTRECHA EN MOVIL: la vista de mapa necesita los bordes
   ========================================================================== */

@media (max-width: 480px) {
  .brand-txt span { display: none; }
  .stats-4 { grid-template-columns: repeat(2, 1fr); }
  .viewbar button { font-size: 11.5px; padding: 0 6px; }
  .tab { padding: 0 8px; font-size: 12px; }
}

/* ==========================================================================
   ACCESIBILIDAD: respeta movimiento reducido
   ========================================================================== */

