:root {
  --azul: #2f5597;
  --azul-claro: #4472c4;
  --gris: #f4f6fb;
  --borde: #d8dee9;
  --texto: #1f2937;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", Roboto, system-ui, sans-serif;
  background: var(--gris);
  color: var(--texto);
}
header {
  background: var(--azul);
  color: #fff;
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
header h1 { font-size: 1.2rem; margin: 0; }
header nav a { color: #cfe0ff; text-decoration: none; }
main { max-width: 1100px; margin: 24px auto; padding: 0 16px; }
footer { text-align: center; color: #8893a5; padding: 24px; }

.card {
  background: #fff;
  border: 1px solid var(--borde);
  border-radius: 10px;
  padding: 22px 24px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.card h2 { margin-top: 0; color: var(--azul); }

label { display: block; margin: 12px 0; font-weight: 600; font-size: .92rem; }
label small { font-weight: 400; color: #6b7280; }
input, select {
  width: 100%;
  margin-top: 5px;
  padding: 9px 10px;
  border: 1px solid var(--borde);
  border-radius: 7px;
  font-size: .95rem;
  font-family: inherit;
}
.row { display: flex; gap: 14px; flex-wrap: wrap; }
.row label { flex: 1; min-width: 140px; }

fieldset {
  border: 1px solid var(--borde);
  border-radius: 8px;
  margin: 14px 0;
  padding: 10px 14px;
}
legend { font-weight: 600; padding: 0 6px; }
.chk {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  margin: 6px 14px 6px 0;
  width: auto;
}
.chk input { width: auto; margin: 0; }

details { margin: 14px 0; }
summary { cursor: pointer; font-weight: 600; color: var(--azul); }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
button, .btn {
  background: var(--azul);
  color: #fff;
  border: none;
  padding: 11px 18px;
  border-radius: 7px;
  font-size: .95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.secondary, .btn.secondary { background: #fff; color: var(--azul); border: 1px solid var(--azul); }
button:hover, .btn:hover { opacity: .92; }

.alert {
  background: #fdecea;
  border: 1px solid #f5c6cb;
  color: #842029;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.hidden { display: none; }

.resumen { display: flex; gap: 14px; flex-wrap: wrap; margin: 8px 0 18px; }
.metric {
  background: var(--gris);
  border: 1px solid var(--borde);
  border-radius: 8px;
  padding: 10px 16px;
  text-align: center;
  min-width: 110px;
}
.metric .num { display: block; font-size: 1.5rem; font-weight: 700; color: var(--azul); }
.metric .lbl { font-size: .8rem; color: #6b7280; }

.tabla-wrap { overflow-x: auto; margin-top: 12px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: 8px 10px; border-bottom: 1px solid var(--borde); text-align: left; white-space: nowrap; }
thead th { background: var(--azul); color: #fff; position: sticky; top: 0; }
tbody tr:nth-child(even) { background: #fafbfe; }
tbody tr:hover { background: #eef3fc; }
.vacio { color: #6b7280; padding: 20px 0; }
.chk-detalles { display: flex; align-items: center; gap: 8px; margin: 4px 0 2px; font-weight: 600; color: #374151; cursor: pointer; }
.chk-detalles input { width: 16px; height: 16px; }
.cell-ina { color: #9b1c1c; font-weight: 600; }
tbody tr.row-ina { background: #fdf2f2; }
tbody tr.row-ina:hover { background: #fbe6e6; }
@media print { tbody tr.row-ina { -webkit-print-color-adjust: exact; print-color-adjust: exact; } }

.subtitulo { margin: 2px 0 0; font-size: .85rem; opacity: .85; }
header nav a { margin-left: 14px; }
.brand { display: flex; align-items: center; gap: 14px; }
/* logo sobre chip blanco para que resalte en el encabezado azul */
.header-logo { height: 42px; background: #fff; padding: 5px 9px; border-radius: 8px; display: block; }
.login-logo { display: block; width: 240px; max-width: 85%; margin: 0 auto 6px; }
.ph-logo { height: 60px; display: block; margin-bottom: 8px; }

/* Pantalla de acceso */
.login-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--azul), #1e3a6b); padding: 20px; z-index: 50;
}
.login-screen[hidden] { display: none; }   /* el atributo hidden debe ganar al display:flex */
.login-card {
  background: #fff; border-radius: 14px; padding: 32px 28px; width: 100%; max-width: 380px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3); display: flex; flex-direction: column; gap: 14px;
}
.login-card h1 { margin: 0; font-size: 1.25rem; color: var(--azul); text-align: center; line-height: 1.3; }
.login-sub { margin: 4px 0 0; text-align: center; color: #6b7280; font-size: .85rem; }
.login-card label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; font-weight: 600; color: #374151; }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--borde); border-radius: 8px; font-size: 1rem; font-weight: 400;
}
.login-card input:focus { outline: 2px solid var(--azul); border-color: var(--azul); }
.login-card button {
  margin-top: 6px; padding: 11px; border: 0; border-radius: 8px; background: var(--azul); color: #fff;
  font-size: 1rem; font-weight: 600; cursor: pointer;
}
.login-card button:disabled { opacity: .6; cursor: default; }
.login-error { background: #fde8e8; color: #9b1c1c; padding: 9px 12px; border-radius: 8px; font-size: .85rem; }

/* Encabezado del reporte (solo visible al imprimir / PDF) */
.print-header { display: none; }
.print-header .ph-empresa { font-size: 1.35rem; font-weight: 700; color: var(--azul); }
.print-header .ph-sub { font-size: .95rem; color: #444; margin-top: 2px; }
.print-header .ph-titulo { font-size: 1.05rem; font-weight: 600; margin-top: 10px; }
.print-header .ph-fecha { font-size: .8rem; color: #666; margin-top: 2px; }

/* Impresión / Guardar como PDF */
@media print {
  @page { size: A4 landscape; margin: 14mm; }
  body { background: #fff; }
  header, footer, #form, #estado, .no-print { display: none !important; }
  main { margin: 0; max-width: none; padding: 0; }
  .card.report-card { border: none; box-shadow: none; border-radius: 0; padding: 0; }
  .print-header {
    display: block;
    border-bottom: 2px solid var(--azul);
    padding-bottom: 8px; margin-bottom: 14px;
  }
  .resumen { margin: 10px 0 14px; }
  .tabla-wrap { overflow: visible; }
  table { font-size: .72rem; width: 100%; }
  th, td { white-space: normal; padding: 4px 6px; }
  thead { display: table-header-group; }
  tr { page-break-inside: avoid; }
  thead th { position: static; }
  thead th, .metric, tbody tr:nth-child(even) {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
