/* Panel de Prevención — estilo "bitácora de terreno": azul petróleo, papel cálido y ámbar de alerta. */
:root {
  --fuente: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --fondo: #f4f1ea;
  --papel: #fffdf8;
  --tinta: #13262f;
  --texto: #1f2d33;
  --texto-suave: #5b6b72;
  --linea: #e2dccf;
  --petroleo: #0f3d4c;
  --petroleo-2: #165568;
  --azul-suave: #8fb3c0;
  --ambar: #e09b2d;
  --ambar-suave: #fbead0;
  --rojo: #c2413a;
  --naranja: #e0702d;
  --amarillo: #e3b52b;
  --verde: #2f8a5b;
  --verde-suave: rgba(47, 138, 91, .15);
  --vip: #7a4fb5;
  --radio: 10px;
  --sombra: 0 1px 0 rgba(19, 38, 47, .04), 0 6px 18px -10px rgba(19, 38, 47, .25);
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--fuente); color: var(--texto); background: var(--fondo); }
a { color: var(--petroleo-2); }
h1, h2 { color: var(--tinta); line-height: 1.2; }
h1 { font-size: clamp(1.4rem, 1.1rem + 1.2vw, 2rem); margin: 0 0 .25rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h2 small { color: var(--texto-suave); font-weight: 400; }
small { color: var(--texto-suave); }
.oculto { display: none !important; }

/* barra superior */
.barra { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: .6rem clamp(1rem, 3vw, 2rem); background: var(--petroleo); color: #eaf2f4;
  border-bottom: 3px solid var(--ambar); }
.marca { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; }
.marca b { display: block; font-size: 1rem; letter-spacing: .02em; }
.marca small { display: block; color: #a9c3cb; font-size: .72rem; }
.marca-sello { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 8px; background: var(--ambar);
  color: var(--petroleo); font-weight: 800; font-size: 1.1rem; transform: rotate(-4deg); box-shadow: 2px 2px 0 #0a2a35; }
.marca-sello.grande { width: 52px; height: 52px; font-size: 1.6rem; }
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a { color: #d4e3e8; text-decoration: none; padding: .4rem .7rem; border-radius: 999px; font-size: .92rem; }
.nav a:hover { background: rgba(255, 255, 255, .08); }
.nav a.activo { background: var(--papel); color: var(--petroleo); font-weight: 600; }
.quien { display: flex; align-items: center; gap: .6rem; font-size: .85rem; color: #a9c3cb; }
.salir { color: #fff; border: 1px solid rgba(255, 255, 255, .35); padding: .25rem .6rem; border-radius: 6px; text-decoration: none; }
.salir:hover { background: var(--ambar); color: var(--petroleo); border-color: var(--ambar); }

.contenido { max-width: 1200px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.encabezado { margin: .5rem 0 1.25rem; }
.encabezado p { margin: .25rem 0; color: var(--texto-suave); max-width: 70ch; }
.bloque { margin-bottom: 1.5rem; }
.pie { text-align: center; color: var(--texto-suave); font-size: .78rem; padding: 2rem 1rem 3rem; }

/* tarjetas y KPI */
.tarjeta { background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio); padding: 1rem 1.1rem;
  box-shadow: var(--sombra); margin: 0 0 1rem; }
.tarjetas { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.tarjetas.pequenas { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); margin-bottom: 1rem; }
.kpi { background: var(--papel); border: 1px solid var(--linea); border-left: 4px solid var(--azul-suave);
  border-radius: var(--radio); padding: .7rem .9rem; box-shadow: var(--sombra); }
.kpi span { display: block; font-size: .8rem; color: var(--texto-suave); }
.kpi b { display: block; font-size: 1.7rem; color: var(--tinta); font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.kpi.acento { border-left-color: var(--ambar); background: linear-gradient(180deg, var(--ambar-suave), var(--papel) 70%); }
.kpi.ok { border-left-color: var(--verde); }
.kpi.vip { border-left-color: var(--vip); }

/* semáforo */
.semaforo { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; }
.luz { display: block; text-decoration: none; color: #fff; border-radius: var(--radio); padding: .8rem 1rem; box-shadow: var(--sombra);
  transition: transform .15s ease; }
.luz:hover { transform: translateY(-2px); }
.luz b { display: block; font-size: 2rem; line-height: 1; font-variant-numeric: tabular-nums; }
.luz span { font-size: .82rem; opacity: .95; }
.luz.rojo { background: var(--rojo); }
.luz.naranja { background: var(--naranja); }
.luz.amarillo { background: var(--amarillo); color: #3b2c00; }
.luz.verde { background: var(--verde); }
.luz.neutro { background: var(--petroleo-2); }

/* gráficos */
.grilla-graficos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.grafico { margin: 0; }
.grafico.ancho { grid-column: 1 / -1; }
.grafico figcaption { font-weight: 600; color: var(--tinta); margin-bottom: .5rem; }
.dos-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }

/* listas, chips y estados */
.lista-simple { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .5rem; }
.lista-simple li { background: var(--papel); border: 1px dashed var(--linea); border-radius: 8px; padding: .5rem .75rem;
  display: flex; justify-content: space-between; gap: .5rem; }
.chip { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 999px; background: #e8eef0; color: var(--petroleo);
  margin-right: .25rem; }
.chip.vip { background: #efe6fa; color: var(--vip); font-weight: 600; }
.estado { display: inline-block; font-size: .75rem; padding: .1rem .5rem; border-radius: 6px; background: #eceae4; text-transform: capitalize; }
.e-enviado, .e-aprobado { background: #dcefe3; color: #1d6a43; }
.e-alertado { background: var(--ambar-suave); color: #8a5a10; }
.e-borrador, .e-correccion { background: #fff1d6; color: #8a5a10; }
.e-ignorado { background: #f3dcda; color: #8f2e28; }
.e-sin_gatillo, .e-nuevo { color: var(--texto-suave); }
.punto { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: #bbb; }
.s-vencido { background: var(--rojo); } .s-vence_hoy { background: var(--naranja); }
.s-por_vencer { background: var(--amarillo); } .s-ok { background: var(--verde); }

/* tablas (se convierten en fichas en el celular) */
.tabla-wrap { overflow-x: auto; padding: 0; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--texto-suave);
  background: #f7f3ea; padding: .6rem .75rem; border-bottom: 1px solid var(--linea); }
td { padding: .6rem .75rem; border-bottom: 1px solid var(--linea); vertical-align: top; }
tbody tr:hover { background: #fbf7ee; }
.vacio { color: var(--texto-suave); text-align: center; padding: 1.5rem; }
.contador { color: var(--texto-suave); margin: 0 0 .5rem; }

/* filtros */
.filtros { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.filtros label { display: flex; flex-direction: column; font-size: .78rem; color: var(--texto-suave); gap: .2rem; }
.filtros label.check { flex-direction: row; align-items: center; gap: .4rem; font-size: .9rem; color: var(--texto); padding-bottom: .5rem; }
input, select { font: inherit; padding: .45rem .6rem; border: 1px solid #cfc7b6; border-radius: 8px; background: #fff; color: var(--texto); }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid var(--ambar); outline-offset: 1px; }
button { font: inherit; font-weight: 600; padding: .5rem 1.1rem; border: 0; border-radius: 8px; background: var(--petroleo);
  color: #fff; cursor: pointer; transition: background .15s ease; }
button:hover { background: var(--petroleo-2); }
button:active { transform: translateY(1px); }

/* detalle de correo / chat */
.texto { white-space: pre-wrap; margin: 0; }
.borrador { white-space: pre-wrap; font: .88rem/1.55 var(--mono); background: #faf6ec; border: 1px solid var(--linea);
  border-radius: 8px; padding: .8rem; margin: 0; max-height: 420px; overflow: auto; }
.historial { margin: 0; padding-left: 1.2rem; }
.historial li { margin: .4rem 0; }
.volver { text-decoration: none; font-size: .9rem; }
.chat { display: flex; flex-direction: column; gap: 1rem; }
.burbuja-grupo { display: flex; flex-direction: column; gap: .35rem; }
.burbuja { max-width: min(680px, 92%); padding: .6rem .8rem; border-radius: 12px; box-shadow: var(--sombra); }
.burbuja p { margin: .2rem 0 0; white-space: pre-wrap; }
.burbuja.usuario { align-self: flex-end; background: var(--petroleo); color: #f0f6f8; border-bottom-right-radius: 4px; }
.burbuja.usuario small { color: #a9c3cb; }
.burbuja.usuario .chip { background: rgba(255, 255, 255, .15); color: #fff; }
.burbuja.bot { align-self: flex-start; background: var(--papel); border: 1px solid var(--linea); border-bottom-left-radius: 4px; }
.nota { color: var(--texto-suave); font-size: .82rem; }

/* login */
.login-fondo { min-height: 100vh; display: grid; place-items: center;
  background: radial-gradient(circle at 20% 10%, #1b5a6e 0, transparent 40%), var(--petroleo); }
.login { width: min(400px, 92vw); color: #eaf2f4; }
.login-marca { display: flex; gap: .9rem; align-items: center; margin-bottom: 1.2rem; }
.login-marca h1 { color: #fff; margin: 0; }
.login-marca p { margin: 0; color: #a9c3cb; }
.login-form { display: grid; gap: .9rem; color: var(--texto); }
.login-form label { display: grid; gap: .3rem; font-size: .85rem; color: var(--texto-suave); }
.login .nota { color: #a9c3cb; text-align: center; }
.alerta { background: #f3dcda; color: #8f2e28; padding: .6rem .8rem; border-radius: 8px; margin: 0; }

@media (max-width: 760px) {
  .grilla-graficos, .dos-col { grid-template-columns: 1fr; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; }
  .quien span { display: none; }
  table thead { display: none; }
  table, tbody, tr, td { display: block; width: 100%; }
  tbody tr { border-bottom: 1px solid var(--linea); padding: .5rem 0; }
  td { border: 0; padding: .2rem .9rem; }
  td[data-l]:not([data-l=""])::before { content: attr(data-l) ": "; font-weight: 600; color: var(--texto-suave); font-size: .78rem; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
