/* Informe Abastecimiento Granipack — estilo general
   Paleta basada en el sistema de visualización validado (superficie clara). */
:root {
  --pagina: #f9f9f7;
  --superficie: #fcfcfb;
  --tinta: #0b0b0b;
  --tinta-2: #52514e;
  --tinta-suave: #898781;
  --linea: #e1e0d9;
  --borde: rgba(11, 11, 11, 0.10);
  --azul: #2a78d6;
  --azul-osc: #1c5cab;
  --azul-claro: #cde2fb;
  --naranja: #eb6834;
  --aqua: #1baf7a;
  --ok: #0ca30c;
  --alerta: #fab219;
  --serio: #ec835a;
  --critico: #d03b3b;
  --radio: 10px;
  --sombra: 0 1px 3px rgba(11,11,11,.06), 0 4px 14px rgba(11,11,11,.05);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--pagina);
  color: var(--tinta);
  font-size: 14px;
  display: flex;
  min-height: 100vh;
}

/* ---------- barra lateral ---------- */
.sidebar {
  width: 232px; min-width: 232px;
  background: #10233c;
  color: #dbe4ef;
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.marca { display: flex; align-items: center; gap: 10px; padding: 18px 16px 14px; }
.marca-logo {
  width: 38px; height: 38px; border-radius: 9px;
  background: linear-gradient(135deg, var(--azul), var(--azul-osc));
  color: #fff; font-weight: 800; font-size: 20px;
  display: flex; align-items: center; justify-content: center;
}
.marca-nombre { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .2px; }
.marca-sub { font-size: 11.5px; color: #93a5bd; }
nav { padding: 6px 10px; flex: 1; overflow-y: auto; }
nav a {
  display: flex; align-items: center; gap: 10px;
  color: #c2cfdf; text-decoration: none;
  padding: 9px 12px; border-radius: 8px; margin: 2px 0;
  font-weight: 500;
}
nav a:hover { background: rgba(255,255,255,.07); color: #fff; }
nav a.activo { background: var(--azul); color: #fff; }
nav .icono { font-size: 15px; width: 18px; text-align: center; opacity: .9; }
.nav-sep {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.1px;
  color: #7b8da6; padding: 14px 12px 4px;
}
.sidebar-pie { padding: 12px; border-top: 1px solid rgba(255,255,255,.08); }
.enlace-recarga {
  display: block; text-align: center; margin-top: 7px;
  font-size: 11.5px; color: #93a5bd; text-decoration: underline;
}
.enlace-recarga:hover { color: #fff; }
.sync-estado { font-size: 11.5px; color: #93a5bd; margin-top: 8px; line-height: 1.5; }
.sync-estado b { color: #dbe4ef; }
.sync-estado.error { color: #ff9d9d; }

/* ---------- contenido ---------- */
main { flex: 1; padding: 24px 28px 60px; min-width: 0; }
.encabezado { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
h1 { font-size: 22px; margin: 0; font-weight: 700; }
.sub { color: var(--tinta-2); margin-top: 3px; font-size: 13px; }

/* ---------- botones y filtros ---------- */
.btn {
  border: 1px solid var(--borde); border-radius: 8px;
  background: var(--superficie); color: var(--tinta);
  padding: 8px 14px; font-size: 13.5px; font-weight: 600;
  cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; gap: 7px;
}
.btn:hover { border-color: var(--azul); color: var(--azul-osc); }
.btn-primario { background: var(--azul); border-color: var(--azul); color: #fff; width: 100%; justify-content: center; }
.btn-primario:hover { background: var(--azul-osc); color: #fff; }
.btn-primario:disabled { opacity: .6; cursor: wait; }
.filtros {
  display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 10px 12px; margin-bottom: 14px;
}
.filtros label { font-size: 12.5px; color: var(--tinta-2); font-weight: 600; }
.filtros select, .filtros input[type="text"], .filtros input[type="date"] {
  border: 1px solid var(--linea); border-radius: 7px; padding: 7px 9px;
  font-size: 13.5px; background: #fff; color: var(--tinta); font-family: inherit;
}
.filtros input[type="text"] { min-width: 230px; }

/* ---------- tarjetas KPI ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 14px 16px; box-shadow: var(--sombra);
}
.kpi .etiqueta { font-size: 12px; color: var(--tinta-2); font-weight: 600; text-transform: uppercase; letter-spacing: .4px; }
.kpi .valor { font-size: 24px; font-weight: 750; margin-top: 4px; }
.kpi .detalle { font-size: 12px; color: var(--tinta-suave); margin-top: 3px; }

/* ---------- paneles y gráficos ---------- */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 14px; }
.grid-2b { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .grid-2, .grid-2b { grid-template-columns: 1fr; } }
.panel {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); padding: 16px; box-shadow: var(--sombra);
  margin-bottom: 14px; min-width: 0;
}
.panel h2 { font-size: 14.5px; margin: 0 0 12px; font-weight: 700; }
.panel .lienzo { position: relative; height: 260px; }

/* ---------- tablas ---------- */
.tabla-contenedor {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra);
  overflow: auto; max-height: calc(100vh - 210px);
}
table.datos { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 12.8px; }
table.datos th {
  position: sticky; top: 0; z-index: 3;
  background: #f2f1ed; color: var(--tinta-2);
  font-size: 11.3px; text-transform: uppercase; letter-spacing: .4px;
  padding: 9px 10px; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--linea); cursor: pointer; user-select: none;
}
table.datos th.txt, table.datos td.txt { text-align: left; }
table.datos td {
  padding: 7px 10px; border-bottom: 1px solid var(--linea);
  text-align: right; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.datos tbody tr:hover td { background: #f2f6fc; }
table.datos td.txt { max-width: 340px; overflow: hidden; text-overflow: ellipsis; }
table.datos .fijo-1, table.datos th.fijo-1 { position: sticky; left: 0; background: var(--superficie); z-index: 2; }
table.datos th.fijo-1 { z-index: 4; background: #f2f1ed; }
table.datos .fijo-2, table.datos th.fijo-2 { position: sticky; left: 96px; background: var(--superficie); z-index: 2; box-shadow: 2px 0 0 var(--linea); }
table.datos th.fijo-2 { z-index: 4; background: #f2f1ed; }
table.datos tbody tr:hover .fijo-1, table.datos tbody tr:hover .fijo-2 { background: #f2f6fc; }
.col-num { color: var(--tinta); }
.col-calc { background: #fbfaf6; }
.negativo { color: var(--critico); font-weight: 650; }

/* ---------- semáforo ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  border-radius: 999px; padding: 2.5px 9px 2.5px 7px;
  font-size: 11.5px; font-weight: 700; white-space: nowrap;
}
.badge::before { content: ""; width: 8px; height: 8px; border-radius: 50%; }
.badge.OK { background: #e7f6e7; color: #085c08; } .badge.OK::before { background: var(--ok); }
.badge.ALERTA { background: #fdf3d7; color: #7a5200; } .badge.ALERTA::before { background: var(--alerta); }
.badge.CRITICO { background: #fbe3e3; color: #8f1f1f; } .badge.CRITICO::before { background: var(--critico); }
.chips { display: flex; gap: 10px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: 999px; padding: 6px 13px; font-weight: 700; font-size: 13px;
}
.chip .punto { width: 10px; height: 10px; border-radius: 50%; }
.punto.ok { background: var(--ok); } .punto.alerta { background: var(--alerta); } .punto.critico { background: var(--critico); }

/* ---------- listas del dashboard ---------- */
.lista-barras { display: flex; flex-direction: column; gap: 8px; }
.fila-barra { display: grid; grid-template-columns: 200px 1fr 90px; gap: 10px; align-items: center; font-size: 12.6px; }
.fila-barra .nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tinta-2); }
.fila-barra .pista { background: #efeeea; border-radius: 5px; height: 14px; overflow: hidden; }
.fila-barra .relleno { height: 100%; background: var(--azul); border-radius: 5px 4px 4px 5px; min-width: 2px; }
.fila-barra .cifra { text-align: right; font-variant-numeric: tabular-nums; font-weight: 650; }

/* ---------- programación ---------- */
table.datos input.prog {
  width: 62px; border: 1px solid transparent; background: transparent;
  text-align: right; font: inherit; padding: 3px 4px; border-radius: 5px;
}
table.datos input.prog:hover { border-color: var(--linea); background: #fff; }
table.datos input.prog:focus { border-color: var(--azul); background: #fff; outline: 2px solid var(--azul-claro); }
table.datos input.prog.guardado { background: #e7f6e7; transition: background .2s; }
th.finde, td.finde { background: #faf6ec !important; }
td.sugerido {
  background: #e3eefb !important;
  box-shadow: inset 0 0 0 2px var(--azul);
  border-radius: 2px;
}
td.sugerido input.prog::placeholder { color: var(--azul-osc); font-weight: 650; opacity: .85; }
th.col-sugerencia, td.col-sugerencia { min-width: 540px; }
.sugerencia {
  display: flex; align-items: center; flex-wrap: nowrap;
  gap: 10px;
  font-weight: 650; color: var(--azul-osc); white-space: nowrap;
}
.sugerencia b { min-width: 78px; text-align: right; }
.sugerencia .sug-fecha {
  border: 1px solid var(--linea); border-radius: 6px; padding: 4px 6px;
  font: inherit; font-size: 12.5px; color: var(--tinta); background: #fff; width: 130px;
}
.sugerencia .sug-fecha:focus { border-color: var(--azul); outline: 2px solid var(--azul-claro); }
.sugerencia .btn-mini { padding: 4px 12px; }
.aplicada { color: #085c08; font-weight: 700; font-size: 12px; white-space: nowrap; }
.nota-plan { color: var(--tinta-suave); font-weight: 500; font-size: 11.5px; }
.plan-ok { color: #085c08; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.plan-exceso { color: #7a5200; font-weight: 700; font-size: 12.5px; white-space: nowrap; }
.sin-sugerencia { color: var(--tinta-suave); font-size: 12px; }
.btn-mini {
  border: 1px solid var(--azul); background: #fff; color: var(--azul-osc);
  border-radius: 6px; padding: 2px 8px; font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.btn-mini:hover { background: var(--azul); color: #fff; }
.muestra-sugerido {
  background: #e3eefb; box-shadow: inset 0 0 0 2px var(--azul);
  border-radius: 3px; padding: 0 5px; font-weight: 650; color: var(--azul-osc);
}

/* ---------- cronograma (calendario) ---------- */
.calendario {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra); overflow: hidden;
}
.cal-cabecera, .cal-semana { display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-cabecera div {
  padding: 9px 10px; font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .5px; color: var(--tinta-2); background: #f2f1ed;
  border-bottom: 1px solid var(--linea); text-align: center;
}
.cal-dia {
  min-height: 108px; padding: 6px; border-bottom: 1px solid var(--linea);
  border-right: 1px solid var(--linea); background: var(--superficie);
  display: flex; flex-direction: column; gap: 4px; min-width: 0;
}
.cal-semana .cal-dia:last-child { border-right: none; }
.calendario .cal-semana:last-child .cal-dia { border-bottom: none; }
.cal-dia.fuera-mes { background: #f6f5f2; }
.cal-dia.fuera-mes .cal-num { color: #c3c2b7; }
.cal-dia.hoy { background: #f2f6fc; box-shadow: inset 0 0 0 2px var(--azul); }
.cal-num { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 6px; }
.hoy-marca {
  font-size: 9.5px; background: var(--azul); color: #fff;
  border-radius: 4px; padding: 1px 5px; letter-spacing: .5px;
}
.partida {
  display: flex; align-items: center; gap: 5px;
  background: #f1f0ec; border: 1px solid var(--linea); border-radius: 7px;
  padding: 3px 6px; font-size: 11.5px; min-width: 0;
}
.partida-texto { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--tinta-2); font-weight: 550; }
.partida-cant { font-weight: 750; font-variant-numeric: tabular-nums; }
.partida.fabricada { background: #e7f6e7; border-color: #b5dfb5; }
.partida.fabricada .partida-texto { color: #085c08; }
.partida.vencida { background: #fbe3e3; border-color: #efb9b9; }
.partida.vencida .partida-texto { color: #8f1f1f; }
.partida.vencida .partida-cant { color: #8f1f1f; }
.chulito {
  width: 20px; height: 20px; min-width: 20px; border-radius: 6px;
  border: 1.5px solid #b9b7ae; background: #fff; color: transparent;
  font-size: 12px; font-weight: 900; line-height: 1; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.chulito:hover { border-color: var(--ok); color: #b5dfb5; }
.chulito.activo { background: var(--ok); border-color: var(--ok); color: #fff; }
.leyenda { font-weight: 650; padding: 0 4px; border-radius: 4px; }
.leyenda.verde { background: #e7f6e7; color: #085c08; }
.leyenda.roja { background: #fbe3e3; color: #8f1f1f; }
.leyenda.neutra { background: #f1f0ec; color: var(--tinta-2); }

/* ---------- avisos y estados ---------- */
.aviso {
  position: fixed; bottom: 18px; right: 18px; z-index: 50;
  background: var(--tinta); color: #fff; border-radius: 9px;
  padding: 11px 16px; font-size: 13.5px; box-shadow: var(--sombra);
  max-width: 420px;
}
.aviso.error { background: var(--critico); }
.oculto { display: none; }
.vacio { padding: 40px; text-align: center; color: var(--tinta-suave); }

.centro-inicial { max-width: 520px; margin: 10vh auto; text-align: center; }
.centro-inicial .icono-grande { font-size: 46px; }
.centro-inicial h1 { margin: 12px 0 6px; }
.centro-inicial p { color: var(--tinta-2); line-height: 1.55; }
.progreso { margin-top: 18px; font-size: 13.5px; color: var(--tinta-2); min-height: 22px; }
.spinner {
  display: inline-block; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid var(--azul-claro); border-top-color: var(--azul);
  animation: girar .8s linear infinite; vertical-align: -3px; margin-right: 7px;
}
@keyframes girar { to { transform: rotate(360deg); } }

/* ---------- necesidades de materia prima ---------- */
.nota-aviso {
  background: #fdf3d7; border: 1px solid #f0dca8; color: #6b4a00;
  border-radius: var(--radio); padding: 11px 15px; margin-bottom: 14px;
  font-size: 13px; line-height: 1.5;
}
.nota-aviso code {
  background: #fff8e6; border: 1px solid #efdcae; border-radius: 4px;
  padding: 1px 5px; font-size: 12.2px;
}
.pie-tabla {
  margin-top: 10px; font-size: 13px; color: var(--tinta-2);
  font-variant-numeric: tabular-nums;
}
.panel-suelto { margin-top: 18px; }
.panel-suelto .sub { margin-bottom: 10px; }
table.tabla-simple { font-size: 12.5px; }
table.tabla-simple th { position: static; }

/* ---------- mapa de bodegas ---------- */
select.rol-bodega {
  font: inherit; font-size: 12.3px; padding: 3px 6px;
  border: 1px solid var(--linea); border-radius: 6px; background: #fff; cursor: pointer;
}
select.rol-bodega:focus { border-color: var(--azul); outline: 2px solid var(--azul-claro); }
select.rol-bodega.rol-produccion { background: #e7f6e7; color: #085c08; font-weight: 650; }
select.rol-bodega.rol-traslado { background: #fdf3d7; color: #7a5200; }
select.rol-bodega.rol-no { background: #f4f3f0; color: var(--tinta-suave); }
.marca-origen { color: var(--tinta-suave); font-size: 12px; }
.titulo-seccion { font-size: 15px; margin: 4px 0 4px; font-weight: 750; }
.sub-seccion { margin-bottom: 12px; max-width: 900px; line-height: 1.5; }
.chips-bodegas { margin-bottom: 12px; }
.grid-rutas {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 14px; margin-bottom: 22px;
}
.ruta h2 { margin-bottom: 10px; }
.lista-ruta { list-style: none; margin: 0; padding: 0; }
.lista-ruta li {
  display: grid; grid-template-columns: 26px 1fr auto 56px;
  gap: 8px; align-items: center;
  padding: 5px 6px; border-radius: 7px; font-size: 12.8px;
  border: 1px solid transparent;
}
.lista-ruta li + li { margin-top: 2px; }
.lista-ruta li:hover { background: #f2f6fc; }
.lista-ruta li.propia { background: #e7f6e7; border-color: #c6e8c6; }
.lista-ruta li.sin-stock .nombre, .lista-ruta li.sin-stock .stock { color: var(--tinta-suave); }
.lista-ruta li.movida { background: #e3eefb; border-color: var(--azul); }
.lista-ruta .pos {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--superficie); border: 1px solid var(--linea);
  font-size: 11.5px; font-weight: 700; color: var(--tinta-2);
}
.lista-ruta li.propia .pos { background: var(--ok); border-color: var(--ok); color: #fff; }
.lista-ruta .nombre { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lista-ruta .etiqueta-propia {
  font-size: 11px; font-weight: 700; color: #085c08; background: #d6efd6;
  border-radius: 999px; padding: 1px 7px; margin-left: 4px;
}
.lista-ruta .stock { font-variant-numeric: tabular-nums; color: var(--tinta-2); }
.lista-ruta .mover { display: flex; gap: 3px; justify-content: flex-end; }
.lista-ruta .mover .btn-mini { padding: 1px 6px; line-height: 1.3; }
.pie-ruta { margin-top: 9px; font-size: 12px; color: var(--tinta-suave); }

/* ---------- acceso y usuarios ---------- */
body.fondo-acceso {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--fondo); margin: 0;
}
.tarjeta-acceso {
  background: var(--superficie); border: 1px solid var(--borde);
  border-radius: var(--radio); box-shadow: var(--sombra);
  padding: 30px 30px 26px; width: 100%; max-width: 380px; text-align: left;
}
.tarjeta-acceso h1 { font-size: 19px; margin: 14px 0 2px; }
.tarjeta-acceso .sub { margin-bottom: 18px; line-height: 1.5; }
.tarjeta-acceso label {
  display: block; font-size: 12.5px; font-weight: 650;
  color: var(--tinta-2); margin: 12px 0 5px;
}
.tarjeta-acceso input {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 14px;
  border: 1px solid var(--linea); border-radius: 8px; padding: 9px 11px;
}
.tarjeta-acceso input:focus { border-color: var(--azul); outline: 2px solid var(--azul-claro); }
.marca-logo.grande { width: 40px; height: 40px; font-size: 20px; border-radius: 10px; }
.btn.ancho { width: 100%; margin-top: 20px; justify-content: center; text-align: center; }
.error-acceso {
  background: #fbe3e3; color: #8f1f1f; border: 1px solid #f0c6c6;
  border-radius: 8px; padding: 9px 12px; font-size: 13px; margin-bottom: 4px;
}
.nota-ok, .nota-error {
  border-radius: var(--radio); padding: 11px 15px; margin-bottom: 14px; font-size: 13px;
}
.nota-ok { background: #e7f6e7; border: 1px solid #c6e8c6; color: #085c08; }
.nota-error { background: #fbe3e3; border: 1px solid #f0c6c6; color: #8f1f1f; }
.pie-usuario {
  margin-top: 12px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,.12);
  font-size: 12.5px; color: rgba(255,255,255,.75); display: flex;
  flex-wrap: wrap; gap: 4px 10px; align-items: baseline;
}
.pie-usuario a { color: #fff; text-decoration: none; font-weight: 650; }
.pie-usuario a:hover { text-decoration: underline; }
.rol-usuario { font-size: 11.5px; opacity: .8; width: 100%; }
.enlace-salir { margin-left: auto; opacity: .85; }
.linea { display: flex; gap: 6px; align-items: center; }
.linea select, .linea input { font: inherit; font-size: 12.3px; padding: 3px 6px;
  border: 1px solid var(--linea); border-radius: 6px; }
.formulario-vertical label { display: block; font-size: 12.5px; font-weight: 650;
  color: var(--tinta-2); margin: 12px 0 5px; }
.formulario-vertical input { width: 100%; box-sizing: border-box; font: inherit;
  border: 1px solid var(--linea); border-radius: 8px; padding: 8px 10px; }
.formulario-vertical .btn { margin-top: 16px; }
.nota-menor { font-size: 12px; opacity: .85; }
td.fecha-necesaria { font-weight: 700; white-space: nowrap; }
td.fecha-necesaria .urgente { color: var(--critico); }
td.dia-critico {
  background: #fbe3e3 !important;
  box-shadow: inset 0 0 0 2px var(--critico); border-radius: 2px; font-weight: 700;
}
/* ---------- matriz de roles ---------- */
th.col-rol { text-align: left; min-width: 165px; position: relative; }
.rol-sub { font-weight: 500; font-size: 11px; color: var(--tinta-suave); text-transform: none; letter-spacing: 0; }
.borrar-rol { position: absolute; top: 6px; right: 8px; padding: 0 5px; line-height: 1.4; }
select.permiso {
  font: inherit; font-size: 12.3px; padding: 3px 6px; width: 100%;
  border: 1px solid var(--linea); border-radius: 6px; cursor: pointer;
}
select.permiso:focus { border-color: var(--azul); outline: 2px solid var(--azul-claro); }
select.permiso.nivel-editar { background: #e7f6e7; color: #085c08; font-weight: 650; }
select.permiso.nivel-ver { background: #fdf3d7; color: #7a5200; }
select.permiso.nivel-no { background: #f4f3f0; color: var(--tinta-suave); }
select.permiso:disabled { opacity: .75; cursor: default; }
