:root {
  --azul: #1f3a5f; --azul-claro: #eef4fa; --texto: #1d2733; --suave: #5b6675; --borde: #d7dee7;
  --verde: #1e7b34; --rojo: #b42318; --ambar: #9a6700; --fondo: #f6f8fb; --blanco: #fff;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--texto);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--fondo); }
button, .boton { font: inherit; background: var(--azul); color: #fff; border: 1px solid var(--azul); border-radius: 6px; padding: .5rem .9rem; cursor: pointer; display: inline-block; }
button.sec, .boton { background: var(--blanco); color: var(--azul); }
button:focus-visible, input:focus-visible, select:focus-visible, tr:focus-visible { outline: 3px solid #7aa7d8; outline-offset: 1px; }
input, select, textarea { font: inherit; padding: .45rem .5rem; border: 1px solid var(--borde); border-radius: 6px; width: 100%; background: var(--blanco); color: var(--texto); }
label { display: flex; flex-direction: column; gap: .25rem; font-size: .85rem; color: var(--suave); }
.error { color: var(--rojo); }
.aviso { color: var(--verde); }
.aviso:empty, .error:empty { display: none; }
button.enlace { background: none; border: none; color: var(--azul); text-decoration: underline; padding: .6rem 0; min-height: 44px; justify-self: start; }
.nota { color: var(--suave); font-size: .85rem; }

#entrar { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.tarjeta { background: var(--blanco); border: 1px solid var(--borde); border-radius: 10px; padding: 2rem; width: min(380px, 100%); display: grid; gap: 1rem; }
.tarjeta h1 { margin: 0; color: var(--azul); }
.logo { height: 34px; }

.barra { display: flex; align-items: center; gap: 1rem; padding: .75rem 16px; background: var(--blanco); border-bottom: 1px solid var(--borde); flex-wrap: wrap; }
.barra .usuario { margin-left: auto; color: var(--suave); }
.pestanas { display: flex; gap: .25rem; padding: .75rem 16px 0; flex-wrap: wrap; }
.pestanas button { background: transparent; color: var(--suave); border: none; border-bottom: 3px solid transparent; border-radius: 0; }
.pestanas button.activa { color: var(--azul); border-bottom-color: var(--azul); font-weight: 600; }
#vista-ranking, #vista-cargas { padding: 1rem 16px 2rem; }
.filtros { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .75rem; }
.rango { display: flex; gap: .3rem; }
.acciones { display: flex; flex-wrap: wrap; gap: .5rem; margin: 1rem 0 .5rem; align-items: center; }
.acciones span { display: contents; }
body.lector .solo-admin { display: none; }

.tabla-envoltura { overflow-x: auto; background: var(--blanco); border: 1px solid var(--borde); border-radius: 8px; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { padding: .5rem .6rem; border-bottom: 1px solid var(--borde); text-align: left; vertical-align: top; }
th { background: var(--azul); color: #fff; font-weight: 600; white-space: nowrap; position: sticky; top: 0; }
#tabla tbody tr { cursor: pointer; }
#tabla tbody tr:hover { background: var(--azul-claro); }
td.met, th.met { text-align: right; font-weight: 700; }
td.chico { font-size: .8rem; color: var(--suave); max-width: 280px; }
.etiqueta { font-size: .7rem; background: var(--azul-claro); color: var(--azul); padding: .1rem .4rem; border-radius: 99px; margin-left: .3rem; }
.disp { font-weight: 600; color: var(--ambar); }
.disp[data-d="Libre"] { color: var(--verde); }
.disp[data-d="No disponible"] { color: var(--rojo); }

dialog { border: 1px solid var(--borde); border-radius: 10px; padding: 1.25rem; width: min(860px, calc(100% - 32px)); max-height: 90vh; }
dialog::backdrop { background: rgba(20, 30, 45, .45); }
dialog h2 small { font-size: .8rem; color: var(--suave); font-weight: 400; }
.rejilla { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.rejilla.metricas { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
#f-ficha > label { margin-bottom: .75rem; }
.historial { padding-left: 1.2rem; font-size: .85rem; }
.pie { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

#informe { display: none; }
@media print {
  @page { size: letter; margin: 14mm; }
  body { background: #fff; }
  body > :not(#informe) { display: none !important; }
  #informe { display: block; font-size: 10pt; }
  #informe header { display: flex; gap: 1rem; align-items: center; border-bottom: 2px solid var(--azul); padding-bottom: .5rem; margin-bottom: 1rem; }
  #informe header img { height: 36px; }
  #informe h1 { font-size: 15pt; margin: 0; color: var(--azul); }
  #informe header p { margin: .15rem 0; color: var(--suave); }
  #informe th { position: static; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  #informe table { margin-bottom: 1.2rem; font-size: 9pt; }
  #informe article { break-inside: avoid; border-top: 1px solid var(--borde); padding-top: .4rem; }
  #informe article h2 { font-size: 11pt; margin: .2rem 0; color: var(--azul); }
  #informe .linea { color: var(--suave); margin: .1rem 0; font-size: 9pt; }
}
