:root {
  --navy: #16263f; --navy-2: #2a4466; --navy-3: #13304f; --amber: #f2b000;
  --bg: #f1f4f8; --card: #ffffff; --line: #e2e7ef; --line-2: #eef1f5;
  --text: #16263f; --muted: #55617a; --soft: #3c4760;
  --ok-bg: #dcefe3; --ok: #1e6140; --warn-bg: #fdf1cc; --warn: #7a5200;
  --bad-bg: #f8dcd6; --bad: #8f2a1a; --info-bg: #dbe7fb; --info: #1f4b8f; --gray-bg: #e6ebf2;
  --display: 'Lexend', 'Poppins', system-ui, sans-serif;
  --body: 'Source Sans 3', 'Segoe UI', system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--body); font-size: 15px; color: var(--text); background: var(--bg); }
a { color: var(--info); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--display); margin: 0; }
h1 { font-size: 30px; font-weight: 600; }
h2 { font-size: 18px; font-weight: 600; }

/* ---------- Login ---------- */
.login { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; }
.login-lado { background: var(--navy); color: #fff; padding: 56px; display: flex; flex-direction: column; justify-content: space-between; }
.logo-completo { background: #fff; border-radius: 16px; padding: 18px 22px; align-self: flex-start; }
.logo-completo img { display: block; width: 260px; max-width: 100%; height: auto; }
.login-lado p { color: #c9d2e3; max-width: 40ch; line-height: 1.5; }
.login-form { display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-form form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px; }
.login-aviso { font-size: 13px; color: var(--muted); line-height: 1.45; }

/* ---------- Estructura ---------- */
.shell { display: flex; min-height: 100vh; }
.lateral { width: 270px; flex-shrink: 0; background: var(--navy); color: #fff; display: flex; flex-direction: column; padding: 20px 14px 14px; gap: 10px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.marca { display: flex; align-items: center; gap: 12px; padding: 0 6px 8px; }
.marca-logo { width: 60px; height: 48px; border-radius: 10px; background: #fff; padding: 3px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.marca-logo img { max-width: 100%; max-height: 100%; }
.marca b { font-family: var(--display); font-size: 17px; line-height: 1.15; display: block; }
.marca small { color: #b5c2d6; }
.grupo { font-size: 11px; font-weight: 700; letter-spacing: .8px; color: #8b9ab3; padding: 10px 12px 3px; }
.lateral a { display: flex; align-items: center; gap: 10px; min-height: 36px; padding: 0 12px; border-radius: 8px; color: #d3dbe8; text-decoration: none; font-weight: 500; }
.lateral a:hover { background: #22375a; color: #fff; }
.lateral a.activo { background: var(--navy-2); color: #fff; font-weight: 700; }
.yo { margin-top: auto; border-top: 1px solid #2c3f5c; padding: 12px 6px 0; display: flex; align-items: center; gap: 10px; }
.yo .ini { width: 40px; height: 40px; border-radius: 50%; background: var(--navy-2); display: flex; align-items: center; justify-content: center; font-weight: 700; flex-shrink: 0; }
.yo small { color: #b5c2d6; display: block; }
.contenido { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; }
.barra { height: 68px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; padding: 0 32px; position: sticky; top: 0; z-index: 5; }
.barra-titulo { font-family: var(--display); font-weight: 500; }
.btn.menu-btn { display: none; }
main { padding: 26px 32px 40px; display: flex; flex-direction: column; gap: 18px; }
.encabezado { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.encabezado p { margin: 4px 0 0; color: var(--muted); }
.acciones { display: flex; gap: 10px; flex-wrap: wrap; }

/* ---------- Componentes ---------- */
.btn { height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid #d6dde8; background: #fff; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.btn:hover { border-color: #9aa6bb; }
.btn.primario { background: var(--navy); color: #fff; border-color: var(--navy); }
.btn.primario:hover { background: var(--navy-3); }
.btn.peligro { color: var(--bad); }
.btn.chico { height: 34px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .55; cursor: wait; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.kpi span { font-size: 14px; font-weight: 600; color: var(--soft); }
.kpi b { font-family: var(--display); font-size: clamp(19px, 1.7vw, 26px); font-weight: 600; white-space: nowrap; }
.kpi small { color: var(--muted); font-size: 14px; }
.tarjeta { background: var(--card); border: 1px solid var(--line); border-radius: 14px; }
.tarjeta-cab { padding: 14px 20px; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; border-bottom: 1px solid var(--line-2); }
.tarjeta-cuerpo { padding: 18px 20px; }
.tabla-envoltura { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; background: #f6f8fb; font-size: 13px; color: var(--soft); font-weight: 700; padding: 11px 14px; white-space: nowrap; }
td { padding: 11px 14px; border-top: 1px solid var(--line-2); vertical-align: middle; }
td.num, th.num { text-align: right; white-space: nowrap; }
td .fila-acciones { display: flex; gap: 6px; justify-content: flex-end; }
.vacio { padding: 36px 20px; text-align: center; color: var(--muted); }
.etiqueta { display: inline-block; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 99px; background: var(--gray-bg); color: var(--soft); white-space: nowrap; }
.etiqueta.ok { background: var(--ok-bg); color: var(--ok); }
.etiqueta.warn { background: var(--warn-bg); color: var(--warn); }
.etiqueta.bad { background: var(--bad-bg); color: var(--bad); }
.etiqueta.info { background: var(--info-bg); color: var(--info); }
.filtros { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.filtros input, .filtros select { height: 40px; border: 1px solid #d6dde8; border-radius: 8px; padding: 0 10px; background: #fff; }

a.kpi-link { text-decoration: none; color: inherit; }
a.kpi-link:hover { border-color: #9aa6bb; }
.dos { display: grid; grid-template-columns: 1.5fr 1fr; gap: 16px; align-items: start; }
.lista { display: flex; flex-direction: column; padding-top: 6px; padding-bottom: 6px; }
.fila-lista { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); }
.fila-lista:last-child { border-bottom: none; }
.fila-lista small { display: block; color: var(--muted); font-size: 13px; }
.barras { display: flex; flex-direction: column; gap: 10px; }
.barra { display: grid; grid-template-columns: 200px 1fr 120px; gap: 14px; align-items: center; font-size: 14px; }
.barra b { text-align: right; }
.barra-fondo { height: 10px; border-radius: 99px; background: var(--gray-bg); overflow: hidden; }
.barra-fondo div { height: 100%; border-radius: 99px; background: var(--navy-3); }
.ayuda { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.45; align-self: center; }
.ayuda.ancho { grid-column: 1 / -1; }
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.check input { width: 18px; height: 18px; }

/* ---------- Formularios ---------- */
.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.campo { display: flex; flex-direction: column; gap: 6px; }
.campo.ancho, .form > .ancho { grid-column: 1 / -1; }
.campo label { font-size: 14px; font-weight: 600; }
.campo input, .campo select, .campo textarea { height: 44px; border: 1px solid #c9d2df; border-radius: 10px; padding: 0 12px; background: #fff; width: 100%; }
.campo textarea { height: 90px; padding: 10px 12px; resize: vertical; }
.nota { padding: 12px 14px; border-radius: 10px; background: var(--warn-bg); color: #6b3a0e; font-size: 14px; grid-column: 1 / -1; }
.tipo-opciones { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; grid-column: 1 / -1; }
.tipo-opcion { text-align: left; padding: 14px 16px; border-radius: 10px; border: 2px solid var(--line); background: #fff; cursor: pointer; display: flex; flex-direction: column; gap: 4px; }
.tipo-opcion.sel { border-color: var(--navy); background: #e8eef6; }
.tipo-opcion small { color: var(--soft); line-height: 1.4; }
.adjunto { grid-column: 1 / -1; border: 2px dashed #c9d2df; border-radius: 10px; padding: 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.adjunto img { max-height: 90px; border-radius: 6px; }

/* ---------- Ventana modal ---------- */
.modal-fondo { position: fixed; inset: 0; background: rgba(15, 25, 45, .5); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 20; }
.modal { background: #fff; border-radius: 16px; width: 100%; max-width: 760px; }
.modal .tarjeta-cab { border-bottom: 1px solid var(--line); }
.modal-pie { padding: 14px 20px; display: flex; justify-content: flex-end; gap: 10px; border-top: 1px solid var(--line-2); }

/* ---------- Imprimir y escanear ---------- */
.tres { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.accion-grande { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.accion-grande.destacada { border: 3px solid var(--amber); }
.accion-grande p { margin: 0; color: var(--muted); }

#aviso { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 10px; font-weight: 600; display: none; z-index: 30; max-width: 90vw; }
#aviso.error { background: var(--bad); }
#aviso.visible { display: block; }

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

/* ---------- Celular ---------- */
@media (max-width: 900px) {
  .login { grid-template-columns: 1fr; }
  .login-lado { padding: 32px 24px; }
  .lateral { position: fixed; left: -290px; z-index: 15; transition: left .2s; }
  .lateral.abierto { left: 0; }
  .btn.menu-btn { display: inline-flex; }
  .barra, main { padding-left: 16px; padding-right: 16px; }
  .form, .tres, .tipo-opciones, .dos { grid-template-columns: 1fr; }
  .barra { grid-template-columns: 1fr; gap: 4px; }
  .barra b { text-align: left; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- Al imprimir una pantalla ---------- */
@media print {
  .lateral, .barra, .acciones, .filtros, .fila-acciones, .no-imprimir { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
  .tarjeta, .kpi { border-color: #999; }
}
