*, *::before, *::after { box-sizing: border-box; }
html { font-size: 100%; -webkit-text-size-adjust: 100%; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--fuente);
  font-size: 16px;
  line-height: 1.5;
  color: var(--txt);
  background: var(--fondo);
  min-height: 100vh;
}
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--azul); text-underline-offset: 3px; }
a:hover { color: var(--navy-profundo); }
:focus-visible { outline: none; box-shadow: var(--focus); }
::selection { background: #c5dff3; color: var(--ink); }
input, select, textarea { accent-color: var(--azul); caret-color: var(--azul); }
h1, h2, h3, h4 { font-family: var(--fuente-tit); color: var(--tit); margin: 0; letter-spacing: -0.02em; line-height: 1.2; }
h1 { font-size: clamp(1.6rem, 2.4vw, 2.25rem); font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 0.8em; }
p:last-child { margin-bottom: 0; }
ul, ol { margin: 0; }

.sr, .sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
.sr:focus, .sr-only:focus {
  position: fixed; left: 12px; top: 12px; z-index: 200;
  width: auto; height: auto; margin: 0; clip: auto;
  overflow: visible; white-space: normal;
  background: var(--papel); color: var(--ink); padding: 8px 14px;
  border-radius: var(--r-sm); box-shadow: var(--focus);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 18px; border: 1px solid transparent;
  border-radius: 50px; background: var(--azul); color: #fff;
  font-family: var(--fuente-tit); font-weight: 700; font-size: 0.95rem;
  text-decoration: none; line-height: 1; transition: background var(--mov) ease, color var(--mov) ease, border-color var(--mov) ease;
}
.btn:hover { background: var(--azul-hov); color: #fff; }
.btn:disabled, .btn[aria-disabled="true"] {
  background: #c5cdd4; color: #3e4a56; cursor: not-allowed;
}
.btn.sec {
  background: #fff; color: var(--azul); border-color: var(--azul);
}
.btn.sec:hover { background: var(--info-cl); color: var(--navy-profundo); }
.btn.ghost {
  background: transparent; color: var(--azul); border-color: transparent; padding-inline: 12px;
}
.btn.ghost:hover { background: var(--info-cl); color: var(--navy-profundo); }
.btn.mal { background: var(--mal); }
.btn.mal:hover { background: #8f1b12; }
.btn.ok { background: var(--ok); }
.btn.ok:hover { background: #0c574f; }
.btn.full { width: 100%; }
.btn.lg { min-height: 48px; padding-inline: 22px; }
.btn.svg svg { width: 18px; height: 18px; flex: none; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px;
  font-family: var(--fuente-tit); font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.01em; line-height: 1.3;
}
.badge.ok { background: var(--ok-cl); color: var(--ok); }
.badge.amb { background: var(--amb-cl); color: var(--amb); }
.badge.mal { background: var(--mal-cl); color: var(--mal); }
.badge.info { background: var(--info-cl); color: var(--navy); }
.badge.teal { background: var(--teal-cl); color: var(--teal-txt); }
.badge.neutro { background: var(--line-suave); color: var(--mut); }

.fld { margin-bottom: 16px; }
.fld label, .fld .lbl {
  display: block; font-weight: 600; margin-bottom: 6px; color: var(--tit);
}
.fld input[type="radio"], .fld input[type="checkbox"] {
  width: auto; min-height: 1.15em; padding: 0; border: 0; display: inline-block;
}
.radios { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.radios label { display: flex; align-items: center; gap: 10px; font-weight: 600; min-height: 44px; }
.fld input, .fld select, .fld textarea {
  width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid #b7c3ce; border-radius: var(--r-sm); background: #fff;
}
.fld textarea { min-height: 96px; resize: vertical; }
.fld input:hover, .fld select:hover, .fld textarea:hover { border-color: var(--azul-claro); }
.fld input:focus-visible, .fld select:focus-visible, .fld textarea:focus-visible {
  border-color: var(--azul); box-shadow: 0 0 0 3px rgba(18, 89, 161, 0.28);
}
.fld .ayuda { color: var(--mut); font-size: 0.875rem; margin: 6px 0 0; }
.fld .ferr { display: none; color: var(--mal); font-size: 0.875rem; margin: 6px 0 0; font-weight: 600; }
.fld.invalid input, .fld.invalid select, .fld.invalid textarea { border-color: var(--mal); }
.fld.invalid .ferr { display: flex; align-items: flex-start; gap: 6px; }
.pass { position: relative; }
.pass input { padding-right: 52px; }
.eye {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%);
  width: 44px; height: 44px; border: 0; background: transparent; color: var(--mut);
  border-radius: 8px; display: grid; place-items: center;
}
.eye:hover { color: var(--ink); background: var(--fondo); }

.alert {
  padding: 12px 14px; border-radius: var(--r-sm); font-size: 0.95rem;
  display: flex; gap: 10px; align-items: flex-start;
}
.alert.err { background: var(--mal-cl); color: var(--mal); }
.alert.ok { background: var(--ok-cl); color: var(--ok); }
.alert.amb { background: var(--amb-cl); color: var(--amb); }
.alert.info { background: var(--info-cl); color: var(--navy); }
.form-alert:empty { display: none; }

.proto-badge {
  position: fixed; right: 16px; bottom: 16px; z-index: 80;
  background: var(--ink); color: #fff;
  font-family: var(--fuente-tit); font-size: 0.75rem; font-weight: 700;
  padding: 8px 12px; border-radius: 999px; box-shadow: var(--sh-sm);
  pointer-events: none;
}
@media (max-width: 900px) {
  .proto-badge { display: none; }
}

.toast-box {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  z-index: 120; display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100% - 24px));
}
body.es-movil .toast-box { bottom: 84px; }
.toast {
  background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r);
  box-shadow: var(--sh); font-weight: 600;
}
.toast.ok { background: var(--ok); }
.toast.mal { background: var(--mal); }

.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a, .tabs button {
  appearance: none; background: none; border: 0; border-bottom: 3px solid transparent;
  padding: 10px 14px; margin-bottom: -1px; color: var(--mut);
  font-family: var(--fuente-tit); font-weight: 700; font-size: 0.9rem;
  text-decoration: none; border-radius: 8px 8px 0 0;
}
.tabs a:hover, .tabs button:hover { color: var(--navy); background: var(--info-cl); }
.tabs a[aria-current="page"], .tabs a.activo, .tabs button[aria-selected="true"] {
  color: var(--azul); border-bottom-color: var(--azul);
}

.tabla-wrap { overflow: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.925rem; }
table.data th, table.data td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line-suave); vertical-align: top; }
table.data th {
  font-family: var(--fuente-tit); font-size: 0.75rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--mut);
  background: #f7f9fb; white-space: nowrap;
}
table.data tbody tr:hover { background: #f7fbfe; }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .num { font-variant-numeric: tabular-nums; text-align: right; }
.ficha-movil { display: none; }

dialog.dlg { border: 0; border-radius: var(--r-lg); padding: 0; width: min(520px, calc(100% - 24px)); box-shadow: var(--sh); }
dialog.dlg::backdrop { background: rgba(11, 58, 127, 0.45); }
.dlg-in { padding: 24px; }
.dlg h2 { margin-bottom: 8px; }
.dlg-acc { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; flex-wrap: wrap; }

.empty {
  background: #fff; border: 1px dashed var(--line); border-radius: var(--r);
  padding: 32px 20px; text-align: center; color: var(--mut);
}
.empty strong { display: block; color: var(--tit); margin-bottom: 6px; font-family: var(--fuente-tit); }

.kpi-fila { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpi {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 16px 18px;
  container-type: inline-size; min-width: 0;
}
.kpi .v {
  font-family: var(--fuente-tit); font-weight: 800; font-size: clamp(1.05rem, 12cqi, 1.7rem);
  letter-spacing: -0.03em; font-variant-numeric: tabular-nums; color: var(--navy);
  line-height: 1.15; overflow-wrap: anywhere;
}
.kpi .k { color: var(--mut); font-size: 0.85rem; margin-top: 6px; font-weight: 600; }
.kpi .sub { font-size: 0.8rem; color: var(--mut); margin-top: 4px; }
.kpi.destacado { background: var(--navy); color: #fff; border-color: var(--navy); }
.kpi.destacado .v, .kpi.destacado .k, .kpi.destacado .sub { color: #fff; }
.kpi.destacado .sub { color: #d7e4f2; }

.panel {
  background: #fff; border: 1px solid var(--line); border-radius: var(--r); padding: 20px;
}
.panel h2 { margin-bottom: 14px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, 1fr); }

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; width: 100%; }
  table.data tr { padding: 12px 14px; border-bottom: 1px solid var(--line); }
  table.data td { padding: 4px 0; border: 0; text-align: left; }
  table.data td::before {
    content: attr(data-th); display: block;
    font-family: var(--fuente-tit); font-size: 0.72rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.04em; color: var(--mut); margin-bottom: 2px;
  }
  table.data .num { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
