@import url('https://fonts.googleapis.com/css2?family=Fira+Sans:wght@400;500;600;700&family=Fira+Mono:wght@400;500;700&display=swap');

/* ==========================================================================
   Portal La Posta — sistema de diseño
   Estilo: dashboard de datos denso + retícula suiza.
   Reglas: borde antes que sombra, radio chico, tipografía tabular,
   una sola familia, cero degradados decorativos.
   Marca: azul iTrack #201B3A · verde iTrack #44B48F · bordó La Posta #80080A
   ========================================================================== */

:root {
  /* Marca */
  --ink:        #201B3A;
  --ink-alto:   #16122A;
  --ink-suave:  #302949;
  --mint:       #44B48F;
  --mint-osc:   #2F8C6C;
  --posta:      #80080A;

  /* Superficies */
  --fondo:      #F2F3F6;
  --panel:      #FFFFFF;
  --panel-alt:  #F8F9FB;
  --linea:      #D9DCE4;
  --linea-int:  #E9EBF0;

  /* Texto */
  --texto:      #1D1B2B;
  --texto-2:    #5A5F73;
  --texto-3:    #8A8FA3;

  /* Estados */
  --alto:       #B3261E;
  --alto-bg:    #FBECEA;
  --medio:      #9A6206;
  --medio-bg:   #FDF3E2;
  --bajo:       #2C6E4C;
  --bajo-bg:    #EAF4EE;

  /* Métrica */
  --r:          3px;
  --fila:       31px;
  --barra:      54px;
  --nav:        212px;

  --fuente:     'Fira Sans', -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono:       'Fira Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 400 14px/1.5 var(--fuente);
  font-feature-settings: 'tnum' 1, 'cv05' 1;
}

a { color: var(--ink); }

.ico { flex: none; vertical-align: -0.16em; }

/* ------------------------------------------------------------- Estructura */

.marco { display: flex; min-height: 100vh; }

.lateral {
  width: var(--nav);
  flex: none;
  background: var(--ink);
  color: #C9CBD8;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.lateral__marca {
  height: var(--barra);
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.lateral__marca img { height: 19px; width: auto; display: block; }

.lateral__grupo {
  padding: 18px 16px 7px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .11em;
  text-transform: uppercase;
  color: #7B7F98;
}

.lateral nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: #C9CBD8;
  text-decoration: none;
  font-size: 13.5px;
  border-left: 2px solid transparent;
  transition: background .16s ease, color .16s ease;
}
.lateral nav a:hover { background: rgba(255,255,255,.055); color: #fff; }
.lateral nav a.activo {
  background: rgba(68,180,143,.13);
  border-left-color: var(--mint);
  color: #fff;
  font-weight: 500;
}
.lateral nav a.activo .ico { color: var(--mint); }

.lateral__pie {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.09);
  font-size: 11.5px;
  color: #7B7F98;
}
.lateral__pie a { color: #C9CBD8; text-decoration: none; display: inline-flex; align-items: center; gap: 7px; }
.lateral__pie a:hover { color: #fff; text-decoration: underline; }

.principal { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* Barra superior: acá convive el logo del cliente */
.barra {
  height: var(--barra);
  background: var(--panel);
  border-bottom: 1px solid var(--linea);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.barra h1 { margin: 0; font-size: 16px; font-weight: 600; letter-spacing: -.01em; }
.barra__sub { color: var(--texto-3); font-size: 12.5px; margin-left: 2px; }
.barra__cliente { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.barra__cliente img { height: 34px; width: 34px; border-radius: 50%; border: 1px solid var(--linea); }
.barra__cliente b { font-size: 13px; font-weight: 600; color: var(--posta); display: block; line-height: 1.25; }
.barra__cliente span { font-size: 11px; color: var(--texto-3); }

.lienzo { padding: 20px 22px 44px; flex: 1; }

/* ---------------------------------------------------------------- Paneles */

.panel {
  background: var(--panel);
  border: 1px solid var(--linea);
  border-radius: var(--r);
}
.panel__cab {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--linea);
  background: var(--panel-alt);
}
.panel__cab h2 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--texto-2);
}
.panel__cab .der { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.panel__cuerpo { padding: 14px; }

.rejilla { display: grid; gap: 16px; }
@media (min-width: 1080px) { .rejilla--2 { grid-template-columns: 340px 1fr; align-items: start; } }

/* ----------------------------------------------------------------- Filtros */

.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: 10px 12px; }
.filtros--acciones { display: flex; gap: 8px; align-items: flex-end; padding-top: 2px; }

.campo { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.campo > label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--texto-2);
}
.campo__ayuda { font-size: 11.5px; color: var(--texto-3); }
.campo__error { font-size: 12px; color: var(--alto); }

input[type=text], input[type=date], input[type=number], input[type=password], select, textarea {
  font: 400 13.5px/1.4 var(--fuente);
  color: var(--texto);
  background: #fff;
  border: 1px solid var(--linea);
  border-radius: var(--r);
  padding: 6px 9px;
  height: 32px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea { height: auto; min-height: 62px; resize: vertical; }
select { appearance: none; padding-right: 26px;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235A5F73' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 8px center;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(32,27,58,.13);
}
input[disabled], select[disabled] { background: var(--panel-alt); color: var(--texto-3); }

/* ----------------------------------------------------------------- Botones */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 32px;
  padding: 0 13px;
  font: 500 13px/1 var(--fuente);
  border: 1px solid var(--linea);
  border-radius: var(--r);
  background: #fff;
  color: var(--texto);
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.btn:hover { background: var(--panel-alt); border-color: #C2C6D2; }
.btn:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.btn--primario { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn--primario:hover { background: var(--ink-alto); border-color: var(--ink-alto); }

.btn--verde { background: var(--mint-osc); border-color: var(--mint-osc); color: #fff; }
.btn--verde:hover { background: #27775b; border-color: #27775b; }

.btn--peligro { color: var(--alto); }
.btn--peligro:hover { background: var(--alto-bg); border-color: #E6B5AF; }

.btn--chico { height: 26px; padding: 0 9px; font-size: 12px; gap: 5px; }
.btn--icono { width: 26px; padding: 0; }

/* ------------------------------------------------------------------ Tablas */

.tabla-caja { overflow-x: auto; border-top: 1px solid var(--linea); }

table.datos { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.5px; }

table.datos th, table.datos td {
  padding: 0 9px;
  height: var(--fila);
  border-bottom: 1px solid var(--linea-int);
  text-align: left;
  white-space: nowrap;
}
table.datos thead th {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--panel-alt);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--texto-2);
  border-bottom: 1px solid var(--linea);
}
/* Fila 1 del encabezado: los cinco bloques del informe */
table.datos thead tr.bloques th {
  top: 0;
  height: 27px;
  font-size: 10px;
  letter-spacing: .12em;
  color: #fff;
  text-align: center;
  border-left: 1px solid rgba(255,255,255,.24);
}
table.datos thead tr.bloques th:first-child,
table.datos thead tr.bloques th.fija-bloque + th { border-left: 0; }
table.datos thead tr.campos th { top: 27px; }

/* Los colores van con la misma especificidad que la regla de thead th,
   si no la ganaría el gris genérico del encabezado. */
table.datos thead tr.bloques th.b1 { background: #201B3A; }
table.datos thead tr.bloques th.b2 { background: #2F6D5B; }
table.datos thead tr.bloques th.b3 { background: #80080A; }
table.datos thead tr.bloques th.b4 { background: #7A5A16; }
table.datos thead tr.bloques th.b5 { background: #35406B; }

table.datos tbody tr:hover td { background: #FAFBFD; }
table.datos tbody tr.par td { background: #FCFCFE; }
table.datos tbody tr.par:hover td { background: #F6F8FC; }

td.num, th.num { text-align: right; font-family: var(--mono); font-size: 12px; }
td.mono { font-family: var(--mono); font-size: 12px; }
td.tenue, .tenue { color: var(--texto-3); }
.recorte { max-width: 190px; overflow: hidden; text-overflow: ellipsis; }

/* Columnas fijas al hacer scroll horizontal: dominio y fecha.
   El desplazamiento de .fija2 lo calcula app.js según el ancho real de .fija1,
   así no depende de que el texto mida lo que uno supone. */
table.datos .fija1, table.datos .fija2 { position: sticky; z-index: 4; background: #fff; }
table.datos .fija1 { left: 0; }
table.datos .fija2 { left: 116px; box-shadow: 1px 0 0 var(--linea); }
table.datos thead .fija1, table.datos thead .fija2 { z-index: 7; background: var(--panel-alt); }
/* En la fila de bloques solo se fija el tramo que cubre esas dos columnas */
table.datos thead tr.bloques .fija-bloque { position: sticky; left: 0; z-index: 8; }
table.datos tbody tr.par .fija1, table.datos tbody tr.par .fija2 { background: #FCFCFE; }
table.datos tbody tr:hover .fija1, table.datos tbody tr:hover .fija2 { background: #FAFBFD; }

.dominio { font-family: var(--mono); font-weight: 700; font-size: 12.5px; letter-spacing: .02em; }

/* Fila desplegable con el detalle de eventos del día */
tr.detalle > td { padding: 0; background: #FBFBFD !important; }
.detalle__caja { padding: 11px 14px 13px; border-bottom: 1px solid var(--linea); }
.detalle__titulo {
  font-size: 10.5px; font-weight: 600; letter-spacing: .09em;
  text-transform: uppercase; color: var(--texto-2); margin: 0 0 7px;
}
table.mini { border-collapse: collapse; font-size: 12px; }
table.mini th, table.mini td { padding: 3px 14px 3px 0; text-align: left; white-space: nowrap; }
table.mini th { font-weight: 600; color: var(--texto-2); font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; }
table.mini td { border-top: 1px solid var(--linea-int); }

.expandir {
  border: 0; background: none; padding: 0; cursor: pointer; color: var(--texto-2);
  display: inline-flex; align-items: center;
}
.expandir .ico { transition: transform .18s ease; }
.expandir[aria-expanded=true] .ico { transform: rotate(90deg); }

/* ----------------------------------------------------------- Indicadores */

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(132px, 1fr)); border-top: 1px solid var(--linea); }
.kpi { padding: 10px 14px; border-right: 1px solid var(--linea-int); }
.kpi:last-child { border-right: 0; }
.kpi dt {
  font-size: 10.5px; font-weight: 600; letter-spacing: .07em;
  text-transform: uppercase; color: var(--texto-2); margin: 0 0 3px;
}
.kpi dd { margin: 0; font: 600 20px/1.15 var(--mono); letter-spacing: -.02em; }
.kpi dd small { font: 400 11.5px var(--fuente); color: var(--texto-3); margin-left: 3px; }
.kpi__nota { font-size: 11px; color: var(--texto-3); margin-top: 2px; }

/* --------------------------------------------------------------- Etiquetas */

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 2px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  border: 1px solid transparent;
}
.pill--alto  { background: var(--alto-bg);  color: var(--alto);  border-color: #EBC3BE; }
.pill--medio { background: var(--medio-bg); color: var(--medio); border-color: #EDD6AA; }
.pill--bajo  { background: var(--bajo-bg);  color: var(--bajo);  border-color: #C3DDCE; }
.pill--gris  { background: #EEF0F4; color: var(--texto-2); border-color: #DDE0E8; }
.pill--tipo  { background: #fff; color: var(--ink); border-color: var(--linea); }

.marca-siniestro { display: inline-flex; align-items: center; gap: 5px; color: var(--posta); font-weight: 500; }

/* ----------------------------------------------------------------- Avisos */

.aviso {
  display: flex; align-items: flex-start; gap: 9px;
  padding: 9px 12px; border-radius: var(--r); font-size: 13px;
  border: 1px solid; margin-bottom: 14px;
}
.aviso--ok    { background: var(--bajo-bg);  border-color: #C3DDCE; color: #21563B; }
.aviso--error { background: var(--alto-bg);  border-color: #EBC3BE; color: #8C1D17; }
.aviso--info  { background: #EEF1F8; border-color: #D3D9E8; color: #333C5C; }

.vacio { padding: 46px 20px; text-align: center; color: var(--texto-2); }
.vacio h3 { margin: 0 0 5px; font-size: 15px; font-weight: 600; color: var(--texto); }
.vacio p { margin: 0 0 14px; font-size: 13px; }

/* ------------------------------------------------------------------- Notas */

.nota-bloque {
  font-size: 11.5px; color: var(--texto-2); background: var(--panel-alt);
  border-left: 2px solid var(--mint); padding: 7px 11px; margin: 0 0 12px;
}

.leyenda { display: flex; flex-wrap: wrap; gap: 4px 16px; padding: 9px 14px; font-size: 11.5px; color: var(--texto-2); border-top: 1px solid var(--linea); }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 9px; height: 9px; border-radius: 1px; display: inline-block; }

/* ------------------------------------------------------------------ Login */

.acceso { min-height: 100vh; display: grid; grid-template-columns: 1fr; background: var(--fondo); }
@media (min-width: 900px) { .acceso { grid-template-columns: 1.05fr .95fr; } }

.acceso__lado {
  background: var(--ink);
  color: #fff;
  padding: 44px 46px;
  display: none;
  flex-direction: column;
}
@media (min-width: 900px) { .acceso__lado { display: flex; } }
.acceso__lado img.logo { height: 26px; width: auto; align-self: flex-start; }
.acceso__lado h2 {
  margin: auto 0 0; font-size: 30px; font-weight: 600; line-height: 1.18;
  letter-spacing: -.02em; max-width: 15ch;
}
.acceso__lado h2 em { font-style: normal; color: var(--mint); }
.acceso__lado p { margin: 14px 0 0; color: #A8ACC0; font-size: 14px; max-width: 42ch; }
.acceso__lista { margin: 26px 0 0; padding: 0; list-style: none; border-top: 1px solid rgba(255,255,255,.11); }
.acceso__lista li {
  padding: 9px 0; border-bottom: 1px solid rgba(255,255,255,.11);
  font-size: 13px; color: #C9CBD8; display: flex; gap: 10px;
}
.acceso__lista b { color: #fff; font-weight: 600; min-width: 24px; font-family: var(--mono); }

.acceso__form { display: flex; align-items: center; justify-content: center; padding: 34px 24px; }
.acceso__caja { width: 100%; max-width: 348px; }
.acceso__sello { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.acceso__sello img { width: 54px; height: 54px; border-radius: 50%; border: 1px solid var(--linea); }
.acceso__sello b { display: block; font-size: 15px; color: var(--posta); }
.acceso__sello span { font-size: 12.5px; color: var(--texto-3); }
.acceso__caja h1 { margin: 0 0 3px; font-size: 20px; font-weight: 600; letter-spacing: -.01em; }
.acceso__caja > p { margin: 0 0 20px; color: var(--texto-2); font-size: 13.5px; }
.acceso__campos { display: grid; gap: 13px; }
.acceso__pie { margin-top: 22px; padding-top: 15px; border-top: 1px solid var(--linea); font-size: 11.5px; color: var(--texto-3); }
.acceso__logo-movil { display: block; height: 20px; margin: 0 0 24px; }
@media (min-width: 900px) { .acceso__logo-movil { display: none; } }

/* ------------------------------------------------------------- Formularios */

.form-linea { display: grid; gap: 11px; }
@media (min-width: 620px) { .form-linea--2 { grid-template-columns: 1fr 1fr; } }
.form-acciones { display: flex; gap: 8px; margin-top: 14px; padding-top: 13px; border-top: 1px solid var(--linea-int); }

table.abm { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.abm th, table.abm td {
  padding: 0 12px; height: 34px; text-align: left;
  border-bottom: 1px solid var(--linea-int); white-space: nowrap;
}
table.abm thead th {
  background: var(--panel-alt); font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--texto-2);
  border-bottom: 1px solid var(--linea);
}
table.abm tbody tr:hover td { background: var(--panel-alt); }
table.abm td.acciones { text-align: right; white-space: nowrap; }

.arbol { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.arbol > li { border-bottom: 1px solid var(--linea-int); padding: 9px 0; }
.arbol > li:last-child { border-bottom: 0; }
.arbol__region { display: flex; align-items: center; gap: 9px; font-weight: 600; }
.arbol__region .ico { color: var(--ink); }
.arbol ul { list-style: none; margin: 6px 0 0; padding: 0 0 0 22px; border-left: 1px solid var(--linea); }
.arbol ul li { padding: 4px 0; display: flex; align-items: center; gap: 8px; }
.arbol__div { font-weight: 500; }
.arbol__sub { color: var(--texto-2); }
.arbol .acciones { margin-left: auto; display: flex; gap: 4px; opacity: 0; transition: opacity .15s ease; }
.arbol li:hover > .acciones, .arbol li:focus-within > .acciones { opacity: 1; }

/* -------------------------------------------------------------- Impresión */

@media print {
  .lateral, .barra__cliente ~ *, .no-imprimir { display: none !important; }
  .marco { display: block; }
  .barra { position: static; border-bottom: 2px solid var(--ink); }
  .lienzo { padding: 0; }
  .panel { border: 0; }
  .tabla-caja { overflow: visible; }
  table.datos { font-size: 8.5px; }
  table.datos th, table.datos td { height: auto; padding: 2px 4px; }
  table.datos .fija1, table.datos .fija2 { position: static; }
  body { background: #fff; }
  @page { size: A3 landscape; margin: 10mm; }
}

/* ------------------------------------------------------ Accesibilidad/Mov. */

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

/* Menú lateral colapsado en pantallas chicas */
@media (max-width: 860px) {
  .marco { flex-direction: column; }
  .lateral {
    width: 100%; height: auto; position: static;
    flex-direction: row; flex-wrap: nowrap; align-items: center;
    overflow-x: auto;
  }
  .lateral__grupo, .lateral__pie { display: none; }
  .lateral__marca { border-bottom: 0; flex: none; }
  .lateral nav { display: flex; flex: none; }
  .lateral nav a {
    border-left: 0; border-bottom: 2px solid transparent;
    padding: 13px; white-space: nowrap;
  }
  .lateral nav a.activo { border-left: 0; border-bottom-color: var(--mint); }

  .barra {
    height: auto; min-height: var(--barra);
    padding: 9px 14px; gap: 10px; flex-wrap: wrap;
  }
  .barra h1 { font-size: 15px; }
  .barra__sub { display: none; }
  .barra__cliente > div { display: none; }
  .barra__cliente img { height: 30px; width: 30px; }

  .panel__cab { flex-wrap: wrap; }
  .panel__cab .der { margin-left: 0; flex-wrap: wrap; }
  .form-acciones { flex-wrap: wrap; }
  .form-acciones > span[style] { margin-left: 0 !important; width: 100%; }

  .lienzo { padding: 14px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi { border-bottom: 1px solid var(--linea-int); }
}

/* La barra de sesión del pie del menú vuelve arriba a la derecha en móvil */
@media (max-width: 860px) {
  .lateral__pie { display: flex; margin-left: auto; padding: 0 14px; border: 0; }
  .lateral__pie > div:first-child { display: none; }
}
