/* ============================================================
   Dashboard Zona Franca de Rionegro
   Paleta de marca (zfr.ageinformatica.com) + paleta de datos validada
   ============================================================ */

:root {
  /* marca */
  --gold: #FDEE20;
  --orange: #FBB03F;
  --ink: #0a0a05;
  --brand-gray: #929496;
  --sand: #f5f4ef;

  /* superficies e ink */
  --surface: #ffffff;
  --plane: #f7f7f4;
  --text-1: #0b0b0b;
  --text-2: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);

  /* series categoricas (orden fijo, validado) */
  --s1: #2a78d6; --s2: #eb6834; --s3: #1baf7a; --s4: #eda100;
  --s5: #e87ba4; --s6: #008300; --s7: #4a3aa7; --s8: #e34948;

  /* estado */
  --good: #006300;
  --good-mark: #0ca30c;
  --critical: #d03b3b;
  --warning: #fab219;

  --radio: 10px;
  --sombra: 0 1px 2px rgba(11, 11, 11, .05), 0 8px 24px rgba(11, 11, 11, .04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Barlow', system-ui, -apple-system, 'Segoe UI', sans-serif;
  background: var(--plane);
  color: var(--text-1);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: 'Barlow Condensed', 'Barlow', sans-serif; font-weight: 700; line-height: 1.1; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.oculto { display: none !important; }
.tabular { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ ACCESO */

.acceso {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  background: var(--ink);
}

.acceso-marca {
  position: relative;
  padding: 56px 60px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
}

.acceso-marca::after {
  content: '';
  position: absolute;
  right: -18%; top: -25%;
  width: 90%; height: 150%;
  background: linear-gradient(115deg, transparent 42%, rgba(251, 176, 63, .22) 42%, rgba(251, 176, 63, .22) 52%, transparent 52%, transparent 60%, rgba(253, 238, 32, .16) 60%, rgba(253, 238, 32, .16) 68%, transparent 68%);
  pointer-events: none;
}

.acceso-marca .logo-caja { position: relative; z-index: 1; }
.acceso-marca .logo-caja svg { height: 78px; width: auto; display: block; }

.acceso-lema { position: relative; z-index: 1; max-width: 460px; }
.acceso-lema .kicker {
  display: flex; align-items: center; gap: 10px;
  color: var(--gold); font-size: 11px; font-weight: 800;
  letter-spacing: .18em; text-transform: uppercase; margin-bottom: 18px;
}
.acceso-lema .kicker::before { content: ''; width: 28px; height: 2px; background: var(--gold); }
.acceso-lema h1 { font-size: clamp(34px, 4vw, 52px); color: #fff; margin-bottom: 14px; }
.acceso-lema h1 em { font-style: normal; color: var(--gold); }
.acceso-lema p { color: rgba(255, 255, 255, .55); font-size: 15px; line-height: 1.7; }

.acceso-pie { position: relative; z-index: 1; color: rgba(255, 255, 255, .35); font-size: 12px; }

.acceso-form {
  background: #fff;
  display: flex; align-items: center; justify-content: center;
  padding: 40px;
}
.acceso-form form { width: 100%; max-width: 340px; }
.acceso-form h2 { font-size: 30px; margin-bottom: 4px; }
.acceso-form .sub { color: var(--text-2); font-size: 14px; margin-bottom: 28px; }

.campo { margin-bottom: 16px; }
.campo label {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; color: var(--text-2); margin-bottom: 6px;
}
.campo input, .campo select {
  width: 100%; padding: 11px 12px;
  border: 1px solid var(--grid); border-radius: 8px;
  background: #fff; transition: border-color .15s, box-shadow .15s;
}
.campo input:focus, .campo select:focus {
  outline: none; border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(253, 238, 32, .45);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 18px; border: 1px solid transparent; border-radius: 8px;
  font-size: 13px; font-weight: 700; letter-spacing: .03em;
  background: var(--ink); color: var(--gold);
  transition: background .15s, opacity .15s;
}
.btn:hover { background: #24241a; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-bloque { width: 100%; padding: 13px; }
.btn-sec { background: #fff; color: var(--text-1); border-color: var(--grid); }
.btn-sec:hover { background: var(--sand); }
.btn-peligro { background: #fff; color: var(--critical); border-color: rgba(208, 59, 59, .35); }
.btn-peligro:hover { background: rgba(208, 59, 59, .06); }
.btn-mini { padding: 6px 10px; font-size: 12px; }

.aviso {
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 16px;
  border: 1px solid; display: flex; gap: 8px; align-items: flex-start;
}
.aviso-error { background: rgba(208, 59, 59, .07); border-color: rgba(208, 59, 59, .3); color: #8c2020; }
.aviso-ok { background: rgba(12, 163, 12, .07); border-color: rgba(12, 163, 12, .3); color: var(--good); }

/* ------------------------------------------------------------ APP */

.cabecera {
  position: sticky; top: 0; z-index: 50;
  background: #fff; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 18px;
  padding: 0 24px; height: 62px;
}
.cabecera .logo-caja svg { height: 34px; width: auto; display: block; }
.cabecera .titulo { line-height: 1.15; }
.cabecera .titulo strong {
  display: block; font-family: 'Barlow Condensed', sans-serif;
  font-size: 19px; font-weight: 700; letter-spacing: .01em;
}
.cabecera .titulo span { font-size: 11px; color: var(--text-muted); letter-spacing: .05em; text-transform: uppercase; }
.cabecera .separador { width: 1px; height: 26px; background: var(--grid); }
.cabecera .espacio { flex: 1; }
.cabecera .quien { text-align: right; line-height: 1.2; }
.cabecera .quien strong { font-size: 13px; }
.cabecera .quien span { display: block; font-size: 11px; color: var(--text-muted); }

.pestanas {
  display: flex; gap: 2px; padding: 0 24px;
  background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 62px; z-index: 49; overflow-x: auto;
}
.pestanas button {
  background: none; border: none; padding: 13px 16px;
  font-size: 13px; font-weight: 600; color: var(--text-2);
  border-bottom: 3px solid transparent; white-space: nowrap;
}
.pestanas button:hover { color: var(--text-1); }
.pestanas button.activa { color: var(--text-1); border-bottom-color: var(--gold); }

.filtros {
  display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
  padding: 14px 24px; background: #fff; border-bottom: 1px solid var(--border);
  position: sticky; top: 108px; z-index: 48;
}
.filtros .campo { margin: 0; min-width: 130px; }
.filtros .campo select, .filtros .campo input { padding: 7px 10px; font-size: 13px; }
.filtros .acciones { margin-left: auto; display: flex; gap: 8px; }

.contenido { padding: 22px 24px 60px; max-width: 1500px; margin: 0 auto; }
.vista { display: none; }
.vista.activa { display: block; }

.seccion-titulo {
  display: flex; align-items: baseline; gap: 12px; margin: 26px 0 12px;
}
.seccion-titulo:first-child { margin-top: 0; }
.seccion-titulo h2 { font-size: 22px; }
.seccion-titulo .nota { font-size: 12.5px; color: var(--text-muted); }

.tarjeta {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radio); box-shadow: var(--sombra); padding: 18px;
}

.rejilla { display: grid; gap: 14px; }
.rejilla-3 { grid-template-columns: repeat(3, 1fr); }
.rejilla-2 { grid-template-columns: repeat(2, 1fr); }
/* paneles de indicadores en paralelo: cada uno conserva su propia escala */
.rejilla-paneles { grid-template-columns: repeat(auto-fit, minmax(430px, 1fr)); }

/* chips de seleccion de indicadores */
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  padding: 7px 13px; border-radius: 20px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--grid); background: #fff; color: var(--text-2);
  transition: background .15s, border-color .15s, color .15s;
}
.chip:hover { border-color: var(--brand-gray); color: var(--text-1); }
.chip.activa {
  background: var(--ink); color: var(--gold); border-color: var(--ink);
}
.pista-campo { font-weight: 500; text-transform: none; letter-spacing: 0; color: var(--text-muted); }

/* KPI */
.kpi { display: flex; gap: 16px; align-items: flex-start; }
.kpi-icono {
  width: 46px; height: 46px; border-radius: 50%; flex: 0 0 46px;
  display: grid; place-items: center; background: var(--ink); color: var(--gold);
}
.kpi-icono svg { width: 22px; height: 22px; }
.kpi-cuerpo { flex: 1; min-width: 0; }
.kpi-nombre {
  font-size: 11px; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: 8px;
}
.kpi-valor { font-size: 32px; font-weight: 700; line-height: 1; letter-spacing: -.01em; }
.kpi-unidad { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-left: 4px; }
.kpi-pie { margin-top: 10px; display: flex; align-items: center; gap: 12px; font-size: 13px; color: var(--text-2); }

.delta { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; }
.delta-sube { color: var(--good); }
.delta-baja { color: var(--critical); }
.delta-neutro { color: var(--text-muted); }

.chip-comp { font-size: 12px; color: var(--text-muted); }

/* analisis */
.analisis { display: grid; gap: 10px; }
.alerta {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); font-size: 14px;
}
.alerta .marca { flex: 0 0 auto; font-size: 16px; line-height: 1.3; }
.alerta strong { font-weight: 700; }
.alerta.pos { border-left: 3px solid var(--good-mark); }
.alerta.neg { border-left: 3px solid var(--critical); }
.alerta.info { border-left: 3px solid var(--s1); }
.alerta.hito { border-left: 3px solid var(--gold); }

/* graficos */
.lienzo { position: relative; height: 340px; }
.lienzo-alto { height: 420px; }
.lienzo-bajo { height: 260px; }

.leyenda { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--text-2); }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.leyenda i { width: 11px; height: 11px; border-radius: 3px; display: inline-block; }

/* tablas */
.tabla-envoltura { overflow-x: auto; }
table.datos { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
table.datos th, table.datos td { padding: 8px 10px; text-align: right; white-space: nowrap; }
table.datos th:first-child, table.datos td:first-child { text-align: left; }
table.datos thead th {
  background: var(--ink); color: #fff; font-size: 11px; font-weight: 700;
  letter-spacing: .06em; text-transform: uppercase;
}
table.datos thead tr.grupos th { background: #17170f; }
table.datos thead tr.grupos th.a { background: #1b3a5c; }
table.datos thead tr.grupos th.b { background: #15613f; }
table.datos tbody tr:nth-child(even) { background: var(--sand); }
table.datos tbody tr:hover { background: rgba(253, 238, 32, .14); }
table.datos tfoot td {
  background: var(--ink); color: #fff; font-weight: 700; border-top: 2px solid var(--gold);
}
table.datos tfoot td .delta-sube { color: #5ee45e; }
table.datos tfoot td .delta-baja { color: #ff8a8a; }
table.datos td.sep { border-left: 1px solid var(--grid); }

/* mapa de calor */
table.calor td.celda { color: var(--text-1); font-weight: 600; border-radius: 3px; }

.pie-nota { font-size: 12px; color: var(--text-muted); margin-top: 10px; }

/* usuarios */
.form-linea { display: grid; grid-template-columns: repeat(5, 1fr) auto; gap: 10px; align-items: end; }
.etiqueta {
  display: inline-block; padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .04em;
}
.etiqueta-admin { background: var(--ink); color: var(--gold); }
.etiqueta-dir { background: var(--sand); color: var(--text-2); border: 1px solid var(--grid); }
.etiqueta-off { background: rgba(208, 59, 59, .1); color: var(--critical); }
.etiqueta-on { background: rgba(12, 163, 12, .1); color: var(--good); }

/* modal */
.velo {
  position: fixed; inset: 0; background: rgba(10, 10, 5, .55);
  display: grid; place-items: center; z-index: 100; padding: 20px;
}
.modal { background: #fff; border-radius: 12px; padding: 26px; width: 100%; max-width: 420px; }
.modal h3 { font-size: 22px; margin-bottom: 6px; }
.modal .sub { font-size: 13.5px; color: var(--text-2); margin-bottom: 18px; }
.modal-acciones { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.modal-ancho { max-width: 620px; max-height: 92vh; overflow-y: auto; }

/* ---- envio por WhatsApp ---- */
.btn-wp { background: #128C4A; color: #fff; }
.btn-wp:hover { background: #0f7a40; }

.wp-opciones { display: grid; gap: 8px; margin-bottom: 18px; }
.opcion {
  display: flex; gap: 11px; align-items: flex-start;
  padding: 11px 13px; border: 1px solid var(--grid); border-radius: 9px;
  cursor: pointer; transition: border-color .15s, background .15s;
}
.opcion:hover { border-color: var(--brand-gray); background: var(--sand); }
.opcion input { margin-top: 3px; flex: 0 0 auto; width: 16px; height: 16px; accent-color: #128C4A; }
.opcion span { display: block; line-height: 1.35; }
.opcion strong { display: block; font-size: 14px; }
.opcion small { color: var(--text-muted); font-size: 12.5px; }
.opcion-todo { border-style: dashed; }

.wp-previa {
  border: 1px solid var(--grid); border-radius: 8px; background: var(--sand);
  max-height: 340px; overflow-y: auto; padding: 10px;
}
.wp-previa img { display: block; width: 100%; height: auto; box-shadow: var(--sombra); }

.cargando { padding: 60px; text-align: center; color: var(--text-muted); }

@media (max-width: 1100px) {
  .rejilla-3, .rejilla-2 { grid-template-columns: 1fr; }
  .acceso { grid-template-columns: 1fr; }
  .acceso-marca { display: none; }
  .form-linea { grid-template-columns: 1fr 1fr; }
}

@media print {
  .cabecera, .pestanas, .filtros, .acciones, .btn { display: none !important; }
  body { background: #fff; }
  .contenido { padding: 0; }
  .tarjeta { box-shadow: none; break-inside: avoid; }
  .vista { display: none !important; }
  .vista.activa { display: block !important; }
}
