/* Paginas de las VTC. Las variables, los botones, las tarjetas y las tablas son
   las de la cuenta (account.css, que se carga antes): aca solo lo propio.
   --vtc es el color de la empresa; lo pone vtc.js en la pagina de cada una. */
:root { --vtc: var(--accent); }
[hidden] { display: none !important; }

.vtc-nav { display: flex; gap: 1.1rem; margin-left: 0.6rem; margin-right: auto; font-size: 0.92rem; }
.vtc-nav a { color: var(--muted); text-decoration: none; }
.vtc-nav a:hover, .vtc-nav a[aria-current] { color: var(--text); }
.vtc-pie { max-width: 1120px; margin: 2rem auto 0; }
.betaTag { display: inline-block; font-size: 0.68rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; background: #ffb020; color: #1a1002; border-radius: 4px; padding: 1px 6px; vertical-align: 0.1em; }
.beta-aviso { max-width: 1120px; margin: 0.8rem auto 0; padding: 0.55rem 0.8rem; border: 1px solid #5a4410; border-radius: 8px; background: #2a2210; font-size: 0.9rem; line-height: 1.45; }
.beta-aviso a { color: #ffcf6b; white-space: nowrap; }
.vtc-pie a { color: var(--muted); }
#unitSelect, #langSelect { max-width: 9rem; }

select, textarea, input[type="text"], input[type="search"], input[type="number"], input[type="url"] {
  background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: 0.5rem 0.65rem; font: inherit; font-size: 0.95rem;
}
textarea { width: 100%; resize: vertical; min-height: 5.5rem; }
:is(select, textarea, input):focus-visible, .btn:focus-visible, a:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.btn { text-decoration: none; }
.btn.vtc { background: var(--vtc); border-color: var(--vtc); color: var(--vtc-tinta, #06121f); font-weight: 600; }
.btn.vtc:hover:not(:disabled) { background: var(--vtc); filter: brightness(1.1); }
.btn.chico { padding: 0.3rem 0.7rem; font-size: 0.85rem; border-radius: 6px; }
.botones { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.sin-banderas .bandera { font-family: 'Banderas', system-ui, sans-serif; }
.vacio { color: var(--muted); margin: 0.4rem 0; }

/* ------------------------------------------------- escudo de la empresa */
.escudo {
  flex: none; display: grid; place-items: center; width: 3rem; height: 3rem; border-radius: 12px;
  background: var(--e, var(--accent)); color: var(--e-tinta, #06121f); overflow: hidden;
  font-weight: 800; font-size: 0.85rem; letter-spacing: 0.02em; line-height: 1;
}
.escudo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.escudo.grande { width: 5.5rem; height: 5.5rem; border-radius: 20px; font-size: 1.5rem; }
.escudo.mini { width: 1.6rem; height: 1.6rem; border-radius: 6px; font-size: 0.5rem; }
.tag-vtc {
  font-weight: 700; font-size: 0.85em; color: var(--e, var(--vtc)); white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* -------------------------------------------------------- directorio */
.portada { margin: 1.8rem 0 1.2rem; display: grid; gap: 0.5rem; max-width: 62ch; }
.portada h1 { font-size: 1.7rem; line-height: 1.15; margin: 0; text-wrap: balance; }
.portada p { margin: 0; color: var(--muted); }
.portada .botones { margin-top: 0.6rem; }
.empresas { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr)); gap: 0.8rem; }
.empresa {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 0.2rem 0.8rem; padding: 0.9rem;
  background: var(--panel); border: 1px solid var(--line); border-left: 3px solid var(--e, var(--accent));
  border-radius: 10px; color: var(--text); text-decoration: none; transition: border-color 0.15s;
}
.empresa:hover { border-color: var(--e, var(--accent)); }
.empresa .escudo { grid-row: span 2; }
.empresa .nombre { display: flex; gap: 0.45rem; align-items: baseline; min-width: 0; }
.empresa .nombre b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empresa .slogan { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empresa .datos { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.15rem 0.9rem; font-size: 0.82rem; color: var(--muted); margin-top: 0.5rem; }
.empresa .datos b { color: var(--text); font-variant-numeric: tabular-nums; }
.empresa .chips { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.4rem; align-items: center; }
.chip {
  font-size: 0.72rem; border: 1px solid var(--line); border-radius: 999px; padding: 0.05rem 0.55rem;
  color: var(--muted); white-space: nowrap;
}
.chip.ok { color: var(--ok); border-color: var(--ok); }
.chip.warn { color: var(--warn); border-color: var(--warn); }
.chip.bad { color: var(--danger); border-color: var(--danger); }
.chip-juego { font-weight: 700; letter-spacing: 0.04em; }
/* La hoja de la cuenta estira los campos de texto a todo el ancho; en una fila
   de filtros van al lado de su boton. */
.filtros input[type="text"], .filtros input[type="search"] { width: auto; flex: 0 1 22rem; min-width: 0; padding: 0.35rem 0.6rem; font-size: 0.88rem; }
.filtros .btn { align-self: center; }
.peligro .botones { margin-top: 0.8rem; }
.una-columna { grid-template-columns: minmax(0, 1fr); }
.con-unidad { display: flex; align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.85rem; }
.paginas { display: flex; gap: 0.6rem; justify-content: center; margin-top: 1rem; }

/* ------------------------------------------------- cabeza de la empresa */
.cabeza-vtc {
  margin: 1.2rem 0 0; border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background:
    radial-gradient(120% 160% at 0% 0%, color-mix(in srgb, var(--vtc) 26%, transparent), transparent 62%),
    var(--panel);
}
.cabeza-vtc .arriba { display: flex; gap: 1.1rem; align-items: center; padding: 1.2rem 1.2rem 0.9rem; flex-wrap: wrap; }
.cabeza-vtc .quien { min-width: 0; flex: 1 1 16rem; }
.cabeza-vtc h1 { margin: 0; font-size: 1.6rem; line-height: 1.15; overflow-wrap: anywhere; }
.cabeza-vtc .slogan { margin: 0.2rem 0 0; color: var(--muted); }
.cabeza-vtc .chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.55rem; align-items: center; }
.cabeza-vtc .chips a { color: var(--accent); text-decoration: none; }
.cabeza-vtc .acciones-vtc { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cinta-vtc { display: grid; grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr)); border-top: 1px solid var(--line); background: rgba(0, 0, 0, 0.18); }
.cinta-vtc > div { padding: 0.75rem 0.9rem; border-right: 1px solid var(--line); min-width: 0; }
.cinta-vtc > div:last-child { border-right: none; }
.cinta-vtc b { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cinta-vtc span { font-size: 0.72rem; color: var(--muted); }

.modo-vtc {
  display: flex; flex-wrap: wrap; gap: 0.6rem 0.9rem; align-items: center; margin: 0.8rem 0 0;
  padding: 0.65rem 0.9rem; border: 1px solid var(--line); border-radius: 10px; background: var(--panel);
}
.modo-vtc .que { color: var(--muted); font-size: 0.88rem; }
.interruptor { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.interruptor button {
  border: none; background: none; color: var(--muted); font: inherit; font-size: 0.88rem; padding: 0.35rem 0.9rem; cursor: pointer;
}
.interruptor button[aria-pressed="true"] { background: var(--vtc); color: var(--vtc-tinta, #06121f); font-weight: 600; }
.interruptor button.personal[aria-pressed="true"] { background: #39414c; color: var(--text); }
.modo-vtc .rango { margin-left: auto; min-width: 12rem; flex: 0 1 18rem; }
.barra-rango { height: 6px; border-radius: 3px; background: #2a2f37; overflow: hidden; margin-top: 0.25rem; }
.barra-rango i { display: block; height: 100%; background: var(--vtc); }

.pestanas-vtc { display: flex; gap: 0.2rem; overflow-x: auto; margin: 1rem 0 0; border-bottom: 1px solid var(--line); scrollbar-width: none; }
.pestanas-vtc::-webkit-scrollbar { display: none; }
.pestanas-vtc a {
  padding: 0.6rem 0.85rem; color: var(--muted); text-decoration: none; white-space: nowrap; font-size: 0.93rem;
  border-bottom: 2px solid transparent; display: inline-flex; gap: 0.4rem; align-items: center;
}
.pestanas-vtc a:hover { color: var(--text); }
.pestanas-vtc a[aria-current="page"] { color: var(--text); border-bottom-color: var(--vtc); }
.numerito { background: var(--vtc); color: var(--vtc-tinta, #06121f); border-radius: 999px; font-size: 0.7rem; font-weight: 700; padding: 0 0.4rem; min-width: 1.2rem; text-align: center; }

.dos { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.dos > div { min-width: 0; }
.texto-largo { white-space: pre-line; overflow-wrap: anywhere; margin: 0 0 1rem; }
.texto-largo:last-child { margin-bottom: 0; }
.card h3 { font-size: 0.95rem; margin: 1rem 0 0.4rem; color: var(--muted); font-weight: 600; }
.card > h3:first-child { margin-top: 0; }

/* ------------------------------------------------------------- personas */
.persona { display: inline-flex; gap: 0.5rem; align-items: center; color: var(--text); text-decoration: none; min-width: 0; }
.persona:hover span { text-decoration: underline; }
.persona img, .persona .inicial { width: 1.7rem; height: 1.7rem; border-radius: 50%; flex: none; background: #2a2f37; object-fit: cover; }
.persona .inicial { display: grid; place-items: center; font-size: 0.75rem; font-weight: 700; color: var(--muted); }
.persona span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.persona.oculta span { color: var(--muted); font-style: italic; }

/* ------------------------------------------------------------ organigrama */
/* El arbol de puestos: un nivel por fila, unidos por una linea al medio. */
.arbol { display: grid; gap: 1.5rem; justify-items: center; }
.nivel { position: relative; width: 100%; display: grid; justify-items: center; gap: 0.5rem; }
.nivel + .nivel::before { content: ''; position: absolute; top: -1.5rem; left: 50%; width: 2px; height: 1.5rem; background: var(--line); }
.nivel .puesto {
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--p, var(--muted));
  border: 1px solid var(--p, var(--line)); border-radius: 999px; padding: 0.1rem 0.8rem; background: var(--panel); position: relative;
}
.nivel .gente { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; }
.ficha { display: flex; gap: 0.55rem; align-items: center; padding: 0.4rem 0.7rem 0.4rem 0.45rem; border: 1px solid var(--line); border-radius: 999px; background: var(--bg); max-width: 100%; }
.ficha small { display: block; color: var(--r, var(--muted)); font-size: 0.7rem; line-height: 1.1; }
.nivel .vacante { color: var(--muted); font-size: 0.85rem; }

/* ----------------------------------------------------------------- listas */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { padding: 0.6rem 0; border-bottom: 1px solid var(--line); display: flex; gap: 0.7rem; align-items: center; flex-wrap: wrap; }
.lista > li:last-child { border-bottom: none; }
.lista .crece { flex: 1 1 12rem; min-width: 0; }
.lista .cuando { color: var(--muted); font-size: 0.8rem; white-space: nowrap; }
.puesto-num { width: 1.8rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.lista li.yo { background: color-mix(in srgb, var(--vtc) 10%, transparent); margin: 0 -0.6rem; padding-left: 0.6rem; padding-right: 0.6rem; border-radius: 6px; }
.lista .valor { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; margin-left: auto; }
.barra-valor { height: 4px; border-radius: 2px; background: #2a2f37; overflow: hidden; margin-top: 0.3rem; }
.barra-valor i { display: block; height: 100%; background: var(--vtc); }
.en-ruta .punto { width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--ok); flex: none; }
.en-ruta .punto.personal { background: var(--muted); }

/* ----------------------------------------------------------------- tablas */
.tabla-caja { overflow-x: auto; }
table.vtc { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
table.vtc th { text-align: left; font-weight: 600; font-size: 0.78rem; color: var(--muted); padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.vtc td { padding: 0.5rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.vtc .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.vtc th button { background: none; border: none; color: inherit; font: inherit; cursor: pointer; padding: 0; }
table.vtc th button[aria-sort] { color: var(--text); }
table.vtc tr.fila { cursor: pointer; }
table.vtc tr.fila:hover td { background: #1b1f25; }
table.vtc td.panel { background: #1d232b; padding: 0.8rem; }
.puesto-chip { display: inline-flex; align-items: center; gap: 0.35rem; white-space: nowrap; }
.puesto-chip::before { content: ''; width: 0.6rem; height: 0.6rem; border-radius: 50%; background: var(--p, var(--muted)); }

/* ------------------------------------------------------------ formularios */
.campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: 0.9rem; }
.campos .ancho { grid-column: 1 / -1; }
.campo label, .campo legend { display: block; font-size: 0.85rem; color: var(--muted); margin-bottom: 0.3rem; padding: 0; }
.campo { border: none; margin: 0; padding: 0; min-width: 0; }
.campo :is(input[type="text"], input[type="url"], input[type="number"], select) { width: 100%; }
.campo input[type="color"] { width: 3.4rem; height: 2.4rem; padding: 0.15rem; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; }
.campo .check-linea { display: inline-flex; color: var(--text); font-size: 0.92rem; margin: 0; }
.campo .opciones label { display: inline-flex; color: var(--text); font-size: 0.92rem; margin: 0; }
.campo .pista { font-size: 0.8rem; color: var(--muted); margin: 0.3rem 0 0; min-height: 1.2em; }
.campo .pista.mal { color: var(--danger); }
.campo .pista.bien { color: var(--ok); }
.opciones { display: flex; flex-wrap: wrap; gap: 0.3rem 1rem; }
.opciones label, .check-linea { display: inline-flex; align-items: center; gap: 0.45rem; color: var(--text); font-size: 0.92rem; margin: 0; }
.opciones input, .check-linea input { accent-color: var(--vtc); width: 1.05em; height: 1.05em; }
.consentimiento { border: 1px solid var(--warn); border-radius: 8px; padding: 0.8rem 0.9rem; background: rgba(255, 178, 59, 0.08); }
.consentimiento p { margin: 0 0 0.6rem; font-size: 0.92rem; }
.peligro { border-color: rgba(255, 77, 77, 0.5); }

/* ------------------------------------------------------ puestos y permisos */
.permisos { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 13rem), 1fr)); gap: 0.4rem 0.9rem; margin: 0.6rem 0; }
.permisos label { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin: 0; color: var(--text); font-size: 0.88rem; }
.permisos select { padding: 0.2rem 0.4rem; font-size: 0.82rem; }
.fila-rango { display: grid; grid-template-columns: auto minmax(0, 1fr) 9.5rem 2.2rem; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.fila-rango input[type="color"] { width: 2.4rem; height: 2.2rem; padding: 0.1rem; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
.fila-rango input { width: 100%; min-width: 0; }
.mover { display: inline-flex; gap: 0.15rem; }
.mover button { background: none; border: 1px solid var(--line); color: var(--muted); border-radius: 6px; width: 1.9rem; height: 1.9rem; cursor: pointer; }
.mover button:disabled { opacity: 0.35; cursor: default; }

/* ----------------------------------------------------------------- dialogo */
dialog.vtc-dialogo {
  background: var(--panel); color: var(--text); border: 1px solid var(--line); border-radius: 14px; padding: 1.2rem;
  width: min(34rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto;
}
dialog.vtc-dialogo::backdrop { background: rgba(0, 0, 0, 0.65); }
dialog.vtc-dialogo h2 { color: var(--text); font-size: 1.1rem; margin: 0 0 0.8rem; }
dialog.vtc-dialogo .botones { margin-top: 1rem; justify-content: flex-end; }
.vista-tarjeta { background: #0b0d10; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: grid; place-items: center; padding: 0.6rem; margin: 0.8rem 0; }
.vista-tarjeta canvas { max-width: 100%; max-height: 46vh; width: auto; height: auto; display: block; }

.grafico-vtc svg { display: block; width: 100%; height: auto; }
.grafico-vtc .barra { fill: var(--vtc); }
.grafico-vtc .barra.vacia { fill: var(--line); }
.grafico-vtc text { fill: var(--muted); font-size: 11px; font-family: system-ui, sans-serif; }
.grafico-vtc .tope { fill: var(--text); font-weight: 600; }
.logro-vtc { display: grid; gap: 0.2rem; padding: 0.5rem 0; border-bottom: 1px solid var(--line); font-size: 0.9rem; }
.logro-vtc:last-child { border-bottom: none; }
.logro-vtc.listo b { color: var(--warn); }
.logro-vtc .linea { display: flex; justify-content: space-between; gap: 0.8rem; }
.logro-vtc .linea span { color: var(--muted); font-size: 0.82rem; font-variant-numeric: tabular-nums; }

/* Mapa de viajes de la empresa (mapa.js) */
.mapa-caja-vtc { position: relative; height: min(62vh, 560px); min-height: 300px; margin: 0.6rem 0 0.4rem;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #1b1e23; }
/* Mas especifico que .maplibregl-map (position: relative), que se carga despues */
.mapa-caja-vtc > .mapa-vtc { position: absolute; inset: 0; }
.mapa-aviso-vtc { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; margin: 0;
  padding: 1rem; text-align: center; color: var(--muted); background: rgba(13, 15, 18, 0.55); pointer-events: none; }
.leyenda-vtc { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.4rem 0; }
.chofer-mapa { display: inline-flex; align-items: center; gap: 0.4rem; min-height: 32px; padding: 0.25rem 0.65rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--bg); color: var(--text); font: inherit; font-size: 0.86rem; cursor: pointer; }
.chofer-mapa:hover { border-color: var(--muted); }
.chofer-mapa[aria-pressed="true"] { border-color: var(--c, var(--vtc)); background: var(--panel); }
.chofer-mapa:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.chofer-mapa .muestra { width: 0.9rem; height: 0.3rem; border-radius: 2px; background: var(--c); flex: none; }
.chofer-mapa .muted { font-size: 0.8rem; }

@media (max-width: 820px) { .dos { grid-template-columns: minmax(0, 1fr); gap: 0; } }
@media (max-width: 640px) {
  .top { flex-wrap: wrap; gap: 0.5rem 1rem; }
  .vtc-nav { order: 3; width: 100%; margin: 0; }
  .cabeza-vtc .arriba { padding: 1rem; }
  .cabeza-vtc h1 { font-size: 1.3rem; }
  .escudo.grande { width: 4rem; height: 4rem; border-radius: 16px; font-size: 1.1rem; }
  .cinta-vtc { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cinta-vtc > div { border-bottom: 1px solid var(--line); }
  .cinta-vtc > div:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .cinta-vtc > div:last-child { border-bottom: none; }
  .cabeza-vtc .quien { flex-basis: 11rem; }
  /* Puesto y rango estan en el panel de cada miembro: en el celular la tabla
     arranca por la distancia, que es lo que se viene a mirar. */
  table.vtc .ancho-solo { display: none; }
  /* Quien y cuando arriba, que paso abajo. */
  .lista.renglones > li { gap: 0.2rem 0.7rem; }
  .lista.renglones .crece { order: 3; flex-basis: 100%; }
  .lista.renglones .cuando { margin-left: auto; }
  .lista.renglones .valor + .cuando { margin-left: 0; }
  .lista.renglones .abajo-todo { order: 4; }
  .lista.renglones .persona { flex: 1 1 4rem; }
  .lista.puestos .crece { flex-basis: 7rem; }
  .modo-vtc .rango { margin-left: 0; flex: 1 1 100%; }
  .fila-rango { grid-template-columns: auto minmax(0, 1fr) 7.5rem 2.2rem; }
}
@media (prefers-reduced-motion: reduce) { .empresa { transition: none; } }
