:root {
  --azul: #003366;
  --azul-claro: #eaf3fb;
  --verde: #1e7a3c;
  --gris: #6b7280;
  --borde: #e2e8f0;
  --fondo: #f5f7fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--fondo);
  color: #1f2937;
  font-size: 16px;
  line-height: 1.5;
}

/* ─── Barra superior ─────────────────────────────────────────── */
.topbar {
  background: var(--azul);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  flex-wrap: wrap;
}
.marca {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  text-decoration: none;
}
.marca-logo {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: #fff;
  color: var(--azul);
  font-weight: bold;
  display: flex; align-items: center; justify-content: center;
}
.marca strong { display: block; font-size: 16px; }
.marca small { display: block; font-size: 11px; opacity: .8; }

.nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.nav a {
  color: #dbe7f3;
  text-decoration: none;
  padding: 7px 12px;
  border-radius: 7px;
  font-size: 14px;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.salir { color: #ffd7d7; }

/* ─── Estructura ─────────────────────────────────────────────── */
.contenedor {
  max-width: 1080px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}
h1 { font-size: 22px; margin: 4px 0 6px; color: var(--azul); }
h2 { font-size: 18px; margin: 0 0 10px; color: var(--azul); }
.sub { color: var(--gris); font-size: 14px; margin-bottom: 18px; }

.tarjeta {
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }

.reporte-card h3 { margin: 0 0 6px; font-size: 17px; color: var(--azul); }
.reporte-card p { margin: 0 0 12px; font-size: 14px; color: var(--gris); }
.meta { font-size: 12px; color: var(--gris); margin-bottom: 12px; }

.botones { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  display: inline-block;
  background: var(--azul);
  color: #fff;
  text-decoration: none;
  border: 0;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 15px;
  cursor: pointer;
}
.btn:hover { background: #004b8f; }
.btn-sec { background: #fff; color: var(--azul); border: 1px solid var(--azul); }
.btn-sec:hover { background: var(--azul-claro); }
.btn-chico { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .6; cursor: not-allowed; }

/* ─── Avisos ─────────────────────────────────────────────────── */
.aviso { padding: 10px 14px; border-radius: 8px; margin-bottom: 16px; font-size: 14px; }
.aviso-ok { background: #e8f7ee; border: 1px solid #a9dcbd; color: #1e7a3c; }
.aviso-alerta { background: #fff4d6; border: 1px solid #e6c766; color: #6b5310; }
.aviso-error { background: #fdeeee; border: 1px solid #f2c3c3; color: #a93226; }
pre.salida {
  background: #0f172a; color: #d7e3f4; padding: 12px; border-radius: 8px;
  font-size: 12px; overflow-x: auto; max-height: 280px;
}

/* ─── Login ──────────────────────────────────────────────────── */
.login-wrap { max-width: 420px; margin: 8vh auto; text-align: center; }
.login-wrap .tarjeta { padding: 28px 22px; }
.btn-ms {
  display: inline-flex; align-items: center; gap: 10px; justify-content: center;
  background: #fff; color: #2f2f2f; border: 1px solid #d0d0d0; border-radius: 8px;
  padding: 12px 18px; font-size: 16px; text-decoration: none; width: 100%;
}
.btn-ms:hover { background: #f3f3f3; }
.chico { font-size: 12px; color: var(--gris); }

/* ─── Reporte ────────────────────────────────────────────────── */
.reporte-frame {
  width: 100%; height: 78vh; min-height: 520px;
  border: 1px solid var(--borde); border-radius: 12px; background: #fff;
}

/* ─── Chat ───────────────────────────────────────────────────── */
.chat-caja {
  background: #fff; border: 1px solid var(--borde); border-radius: 12px;
  display: flex; flex-direction: column; height: 66vh; min-height: 420px;
}
.chat-hilo { flex: 1; overflow-y: auto; padding: 16px; }
.msg { max-width: 88%; margin-bottom: 12px; padding: 10px 14px; border-radius: 12px; font-size: 15px; white-space: pre-wrap; }
.msg-usuario { background: var(--azul); color: #fff; margin-left: auto; border-bottom-right-radius: 4px; }
.msg-agente { background: #f1f5f9; color: #1f2937; border-bottom-left-radius: 4px; }
.msg-hora { font-size: 11px; color: var(--gris); margin-top: 4px; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--borde); }
.chat-form textarea {
  flex: 1; resize: none; border: 1px solid var(--borde); border-radius: 8px;
  padding: 10px; font-size: 15px; font-family: inherit; height: 52px;
}
.sugerencias { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.sugerencias button {
  background: #fff; border: 1px solid var(--borde); border-radius: 20px;
  padding: 6px 12px; font-size: 13px; cursor: pointer; color: var(--azul);
}
.cargando { color: var(--gris); font-size: 14px; font-style: italic; }

/* ─── Tablas ─────────────────────────────────────────────────── */
table.tabla { width: 100%; border-collapse: collapse; background: #fff; font-size: 14px; }
table.tabla th, table.tabla td { padding: 8px 10px; border-bottom: 1px solid var(--borde); text-align: left; }
table.tabla th { background: var(--azul-claro); color: var(--azul); font-size: 13px; }
table.tabla td.der { text-align: right; }

/* ─── Pie ────────────────────────────────────────────────────── */
.pie {
  text-align: center; color: var(--gris); font-size: 12px;
  padding: 24px 16px; border-top: 1px solid var(--borde);
}

@media (max-width: 600px) {
  .contenedor { padding: 14px 12px 30px; }
  .reporte-frame { height: 70vh; }
  .nav a { padding: 6px 9px; font-size: 13px; }
}

/* ─── Frescura de datos / estado ─────────────────────────────── */
.fila-flex { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.tarjeta-ok { border-left: 4px solid var(--verde); }
.tarjeta-alerta { border-left: 4px solid #e6a300; background: #fffdf5; }
.chip {
  display: inline-block; font-size: 11px; padding: 2px 9px; border-radius: 20px;
  vertical-align: middle; font-weight: 600;
}
.chip-ok { background: #e8f7ee; color: #1e7a3c; }
.chip-alerta { background: #fff4d6; color: #8a6d00; }
.chip-info { background: var(--azul-claro); color: var(--azul); }

@media (max-width: 600px) {
  .fila-flex { align-items: flex-start; }
}

/* ─── Leyenda de chequeos en el header ─────────────────────────────────── */
.leyenda {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 6px 18px; font-size: 12.5px; border-bottom: 1px solid var(--borde);
}
.leyenda-ok { background: #eefaf1; color: #1e7a3c; }
.leyenda-alerta { background: #fff6e0; color: #8a6d00; border-bottom-color: #e6c766; }
.leyenda-estado { font-weight: 700; white-space: nowrap; }
.leyenda-item { white-space: nowrap; }
.leyenda-item b { color: #4b5563; font-weight: 600; }

/* ─── Bloqueo por actualización automática ─────────────────────────────── */
body.sin-scroll { overflow: hidden; }
.bloqueo {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(15, 23, 42, .82);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.bloqueo-caja {
  background: #fff; border-radius: 14px; padding: 26px 22px; max-width: 520px; width: 100%;
  text-align: center; box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.bloqueo-caja h2 { font-size: 19px; margin: 0 0 10px; color: var(--azul); }
.bloqueo-caja .sub { font-size: 14px; }
.bloqueo-estado { margin: 16px 0; font-size: 15px; font-weight: 600; color: #334155; }
.bloqueo-caja .botones { margin-top: 6px; }

.spinner {
  display: inline-block; width: 16px; height: 16px; vertical-align: -3px;
  border: 2.5px solid #cbd5e1; border-top-color: var(--azul);
  border-radius: 50%; animation: giro .8s linear infinite;
}
@keyframes giro { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  .leyenda { gap: 10px; font-size: 11.5px; padding: 6px 12px; }
}

/* ─── Badge de solicitudes en el menú ──────────────────────────────────── */
.badge {
  display: inline-block; background: #e6a300; color: #3a2c00; font-size: 11px;
  font-weight: 700; border-radius: 10px; padding: 1px 6px; vertical-align: 1px;
}
