/* Órdenes de servicio. Paleta Seven High: azul noche del sitio, azul de acción y cian del logo. */
:root {
  --tinta: #161f3b;
  --tinta-2: #0e1530;
  --senal: #1fb8d0;
  --accion: #2b6ae6;
  --papel: #f3f5f8;
  --blanco: #ffffff;
  --texto: #1e2a32;
  --suave: #5b6b76;
  --linea: #d5ddd9;
  --ok: #1f7a4d;
  --ok-fondo: #e3f1e9;
  --mal: #b3372b;
  --mal-fondo: #f8e6e3;
  --radio: 4px;
  --titulos: 'Barlow Condensed', 'Arial Narrow', Arial, sans-serif;
  --cuerpo: 'Barlow', 'Segoe UI', Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--papel);
  color: var(--texto);
  font-family: var(--cuerpo);
  font-size: 16px;
  line-height: 1.5;
}
h1, h2, h3 { font-family: var(--titulos); font-weight: 600; line-height: 1.15; margin: 0; color: var(--tinta); }
h1 { font-size: 2rem; letter-spacing: .005em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 .75rem; }
a { color: #1f55c4; }
small, .suave { color: var(--suave); }
img, video { max-width: 100%; }
:focus-visible { outline: 3px solid var(--senal); outline-offset: 2px; }

/* ---------- Barra superior ---------- */
.barra { background: var(--tinta); color: #fff; border-bottom: 4px solid var(--senal); }
.barra-in { max-width: 1120px; margin: 0 auto; padding: 0 16px; display: flex; align-items: center; gap: 20px; min-height: 56px; }
.marca { font-family: var(--titulos); font-weight: 700; font-size: 1.3rem; color: #fff; text-decoration: none; white-space: nowrap; }
.marca img, .pub-cab img { display: block; height: 38px; width: auto; max-width: none; }
.marca.con-logo { max-width: none; overflow: visible; flex: none; }
.nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.nav::-webkit-scrollbar { display: none; }
.nav a { color: #c9d6de; text-decoration: none; padding: 17px 12px 15px; font-weight: 500; white-space: nowrap; border-bottom: 3px solid transparent; }
.nav a:hover { color: #fff; }
.nav a.activo { color: #fff; border-bottom-color: var(--senal); }
.salir button { background: none; border: 1px solid #3b4a7a; color: #c9d6de; padding: 6px 12px; border-radius: var(--radio); font: inherit; font-size: .9rem; cursor: pointer; white-space: nowrap; }
.salir button:hover { color: #fff; border-color: #fff; }

.pagina { max-width: 1120px; margin: 0 auto; padding: 24px 16px 64px; }
.pagina.angosta { max-width: 720px; }
.titulo-pagina { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.titulo-pagina p { margin: 4px 0 0; color: var(--suave); }

/* ---------- Bloques ---------- */
.bloque { background: var(--blanco); border: 1px solid var(--linea); border-radius: var(--radio); padding: 20px; margin-bottom: 16px; }
.bloque > h2 { margin-bottom: 14px; }
.bloque.destacado { border-left: 6px solid var(--senal); }
.bloque.listo { border-left: 6px solid var(--ok); }
.dos { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px 16px; }

.aviso { padding: 12px 16px; border-radius: var(--radio); margin-bottom: 16px; font-weight: 500; }
.aviso.ok { background: var(--ok-fondo); color: #14532f; border: 1px solid #b5d9c4; }
.aviso.error { background: var(--mal-fondo); color: #7c2219; border: 1px solid #e8bdb7; }

/* ---------- Formularios ---------- */
label { display: block; font-weight: 600; font-size: .92rem; margin-bottom: 4px; }
label .suave { font-weight: 400; }
input[type=text], input[type=email], input[type=tel], input[type=password], input[type=number], input[type=datetime-local], input[type=search], input[type=url], select, textarea {
  width: 100%; font: inherit; color: var(--texto); background: #fff;
  border: 1px solid #b4c0bb; border-radius: var(--radio); padding: 9px 11px; min-height: 42px; font-weight: 400;
}
label > input, label > select, label > textarea { display: block; margin-top: 4px; }
.casilla > input { display: inline-block; margin-top: 0; }
textarea { min-height: 96px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid var(--senal); outline-offset: 0; border-color: var(--tinta); }
input[type=file] { font: inherit; max-width: 100%; }
.campo { margin-bottom: 14px; }
.ayuda { font-size: .87rem; color: var(--suave); margin-top: 4px; }
.fila { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.fila.fin { justify-content: flex-end; }
.casilla { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.casilla input { width: 18px; height: 18px; }
.trampa { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  background: var(--tinta); color: #fff; border: 1px solid var(--tinta); border-radius: var(--radio); padding: 9px 16px; min-height: 42px; }
.btn:hover { background: var(--tinta-2); }
.btn.senal { background: var(--accion); border-color: var(--accion); color: #fff; }
.btn.senal:hover { background: #1f55c4; border-color: #1f55c4; }
.btn.linea { background: #fff; color: var(--tinta); border-color: #9fb0ba; }
.btn.linea:hover { background: var(--papel); }
.btn.peligro { background: #fff; color: var(--mal); border-color: #dba9a3; }
.btn.peligro:hover { background: var(--mal-fondo); }
.btn.chico { min-height: 34px; padding: 5px 11px; font-size: .9rem; }
.btn.ancho { width: 100%; }

/* ---------- Tablas ---------- */
.tabla-caja { overflow-x: auto; }
table.tabla { width: 100%; border-collapse: collapse; }
.tabla th { text-align: left; font-size: .85rem; color: var(--suave); font-weight: 600; padding: 8px 10px; border-bottom: 2px solid var(--linea); white-space: nowrap; }
.tabla td { padding: 11px 10px; border-bottom: 1px solid var(--linea); vertical-align: top; }
.tabla tr:last-child td { border-bottom: 0; }
.tabla .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tabla tfoot td { font-weight: 700; border-top: 2px solid var(--tinta); border-bottom: 0; }
.codigo { font-family: var(--titulos); font-weight: 700; font-size: 1.1rem; color: var(--tinta); text-decoration: none; white-space: nowrap; }
a.codigo:hover { text-decoration: underline; }

.estado { display: inline-block; font-size: .85rem; font-weight: 600; padding: 3px 9px; border-radius: 3px; background: #e4eaef; color: var(--tinta); white-space: nowrap; }
.estado.e-asistencia_propuesta, .estado.e-propuesta_enviada, .estado.e-propuesta_aprobada, .estado.pendiente { background: #fdf0c2; color: #6a4f00; }
.estado.e-orden_activa, .estado.e-finalizada, .estado.verificado { background: var(--ok-fondo); color: #14532f; }
.estado.e-cancelada, .estado.rechazado { background: var(--mal-fondo); color: #7c2219; }

/* ---------- Recorrido de la orden (la pieza central) ---------- */
.recorrido { background: var(--tinta); color: #fff; border-radius: var(--radio); padding: 18px 20px 20px; margin-bottom: 16px; }
.recorrido-cab { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 16px; align-items: baseline; margin-bottom: 14px; }
.recorrido-cab strong { font-family: var(--titulos); font-size: 1.5rem; font-weight: 600; line-height: 1.15; }
.recorrido-cab span { color: #b9c8d2; font-size: .95rem; }
.tramos { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; list-style: none; margin: 0; padding: 0; }
.tramos li { font-size: .8rem; color: #8fa5b3; line-height: 1.2; }
.tramos li::before { content: ''; display: block; height: 8px; background: #2a3563; margin-bottom: 7px; }
.tramos li.hecho { color: #dbe5ea; }
.tramos li.hecho::before { background: #7d96d6; }
.tramos li.actual { color: #fff; font-weight: 600; }
.tramos li.actual::before { background: var(--senal); }
.recorrido.cancelada .tramos li::before { background: #2a3563; }

/* ---------- Tablero ---------- */
.conteos { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; margin-bottom: 16px; }
.conteo { background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); padding: 12px 14px; text-decoration: none; color: var(--texto); display: block; border-top: 4px solid #7d96d6; }
.conteo:hover { border-color: var(--tinta); }
.conteo b { display: block; font-family: var(--titulos); font-size: 2rem; line-height: 1; color: var(--tinta); }
.conteo span { font-size: .88rem; color: var(--suave); }
.conteo.atencion { border-top-color: var(--senal); }

.lista { list-style: none; margin: 0; padding: 0; }
.lista li { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 14px; padding: 11px 0; border-bottom: 1px solid var(--linea); align-items: center; }
.lista li:last-child { border-bottom: 0; padding-bottom: 0; }
.lista li:first-child { padding-top: 0; }
.vacio { color: var(--suave); margin: 0; }

/* ---------- Datos ---------- */
dl.datos { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; }
dl.datos dt { color: var(--suave); font-size: .92rem; }
dl.datos dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
.monto { font-family: var(--titulos); font-size: 2.1rem; font-weight: 700; color: var(--tinta); line-height: 1.1; }
.pre { white-space: pre-line; }
.caja-pago { background: var(--papel); border: 1px dashed #9fb0ba; border-radius: var(--radio); padding: 12px 14px; margin: 12px 0; white-space: pre-line; font-weight: 500; }

/* ---------- Registro de fotos y videos ---------- */
.galeria { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.galeria figure { margin: 0; background: #fff; border: 1px solid var(--linea); border-radius: var(--radio); overflow: hidden; }
.galeria a { display: block; }
.galeria img, .galeria video { display: block; width: 100%; height: 130px; object-fit: cover; background: #0e1530; }
.galeria figcaption { font-size: .8rem; color: var(--suave); padding: 6px 8px; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.galeria .doc { height: 130px; display: flex; align-items: center; justify-content: center; background: var(--papel); font-weight: 600; text-decoration: none; }
.galeria form { margin: 0; }
.galeria .quitar { background: none; border: 0; color: var(--mal); font: inherit; font-size: .8rem; cursor: pointer; padding: 0; text-decoration: underline; }
.etapa { font-family: var(--titulos); font-weight: 600; font-size: 1.1rem; color: var(--tinta); margin: 16px 0 8px; }
.etapa:first-of-type { margin-top: 0; }

/* ---------- Historial ---------- */
.historial { list-style: none; margin: 0; padding: 0; }
.historial li { padding: 0 0 14px 18px; border-left: 2px solid var(--linea); position: relative; }
.historial li:last-child { padding-bottom: 0; }
.historial li::before { content: ''; position: absolute; left: -6px; top: 6px; width: 10px; height: 10px; background: var(--tinta); border-radius: 50%; }
.historial li.interno::before { background: #9fb0ba; }
.historial time { display: block; font-size: .82rem; color: var(--suave); }
.historial .envios { font-size: .82rem; color: var(--suave); margin-top: 2px; }
.historial .envios .falla { color: var(--mal); font-weight: 600; }

details.plegable { border-top: 1px solid var(--linea); padding: 10px 0; }
details.plegable:first-of-type { border-top: 0; }
details.plegable summary { cursor: pointer; font-weight: 600; color: var(--tinta); }
details.plegable[open] summary { margin-bottom: 12px; }

.items .item { display: grid; grid-template-columns: minmax(0, 1fr) 84px 140px 36px; gap: 8px; margin-bottom: 8px; align-items: center; }
.items .item button { min-height: 42px; border: 1px solid #dba9a3; background: #fff; color: var(--mal); border-radius: var(--radio); cursor: pointer; font-size: 1.1rem; }
.items-cab { display: grid; grid-template-columns: minmax(0, 1fr) 84px 140px 36px; gap: 8px; font-size: .85rem; color: var(--suave); font-weight: 600; margin-bottom: 4px; }

/* ---------- Páginas públicas ---------- */
.pub-cab { background: var(--tinta); color: #fff; border-bottom: 4px solid var(--senal); }
.pub-cab div { max-width: 720px; margin: 0 auto; padding: 14px 16px; font-family: var(--titulos); font-weight: 700; font-size: 1.35rem; }
.pub-pie { max-width: 720px; margin: 0 auto; padding: 0 16px 40px; color: var(--suave); font-size: .88rem; }
.acceso { max-width: 400px; margin: 9vh auto 0; padding: 0 16px; }

@media (max-width: 820px) {
  .dos { grid-template-columns: 1fr; }
  h1 { font-size: 1.7rem; }
  .tramos { gap: 3px; }
  .tramos li { font-size: 0; }
  .tramos li::before { margin-bottom: 0; }
  .tramos li.actual { font-size: 0; }
  .items .item, .items-cab { grid-template-columns: minmax(0, 1fr) 60px 104px 36px; }
  .bloque { padding: 16px; }
  .barra-in { gap: 10px; }
  .marca { font-size: 1.1rem; max-width: 34vw; overflow: hidden; text-overflow: ellipsis; }
  .marca img, .pub-cab img { height: 30px; }
  .marca.con-logo { max-width: none; }
}
@media print {
  .barra, .pub-pie, .no-imprimir, form { display: none !important; }
  body { background: #fff; }
  .bloque { border: 1px solid #999; break-inside: avoid; }
  .recorrido { background: #fff; color: #000; border: 1px solid #999; }
  .recorrido-cab span { color: #333; }
}
