/* Panel Admin — CSS propio, sin build. Mobile first. */
:root {
  --fondo: #f4f5f7;
  --papel: #ffffff;
  --tinta: #16202c;
  --tenue: #647084;
  --linea: #e1e5ea;
  --marca: #1e3a5f;
  --acento: #e0a100;
  --ok: #17794a;
  --mal: #b3261e;
  --aviso: #9a6200;
  --radio: 10px;
  --lateral: 232px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--tinta);
  background: var(--fondo);
}
a { color: var(--marca); }
h1 { font-size: 1.45rem; margin: 0; letter-spacing: -0.01em; }
h2 { font-size: 1.05rem; margin: 0 0 0.75rem; }
.tenue { color: var(--tenue); }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.positivo { color: var(--ok); }
.negativo { color: var(--mal); }

/* ---- Estructura ---- */
.barra {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.65rem 1rem; background: var(--marca);
}
.marca { color: #fff; font-weight: 700; text-decoration: none; letter-spacing: 0.01em; }
.hamburguesa { color: #fff; font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 0 0.25rem; }
.lateral {
  position: fixed; inset: 0 auto 0 0; z-index: 30; width: var(--lateral);
  display: flex; flex-direction: column;
  padding: 1.1rem 0.75rem; background: var(--marca); color: #d6e0ec;
  transform: translateX(-100%); transition: transform 0.18s ease; overflow-y: auto;
}
.menu-toggle:checked ~ .lateral { transform: none; box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.4); }
.lateral .marca { display: block; padding: 0 0.6rem 0.75rem; font-size: 1.1rem; }
.lateral nav { flex: 1; }
.lateral .grupo {
  margin: 1rem 0.6rem 0.3rem; font-size: 0.7rem; text-transform: uppercase;
  letter-spacing: 0.09em; color: #8fa6c2;
}
.lateral nav a {
  display: block; padding: 0.45rem 0.6rem; border-radius: 7px;
  color: inherit; text-decoration: none;
}
.lateral nav a:hover { background: rgb(255 255 255 / 0.08); }
.lateral nav a.activo { background: rgb(255 255 255 / 0.14); color: #fff; box-shadow: inset 3px 0 var(--acento); }
.salir {
  display: flex; align-items: center; justify-content: space-between; gap: 0.5rem;
  margin-top: 1rem; padding: 0.75rem 0.6rem 0; border-top: 1px solid rgb(255 255 255 / 0.15);
  font-size: 0.85rem;
}
.contenido { padding: 1.1rem 1rem 3rem; max-width: 1180px; }
.centrado { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
@media (min-width: 900px) {
  .barra { display: none; }
  .lateral { transform: none; }
  .contenido { margin-left: var(--lateral); padding: 1.75rem 2rem 3rem; }
}

/* ---- Piezas ---- */
.encabezado {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 0.75rem; margin-bottom: 1.1rem;
}
.tarjeta {
  background: var(--papel); border: 1px solid var(--linea); border-radius: var(--radio);
  padding: 1rem 1.1rem;
}
.grilla { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.dos { display: grid; gap: 0.9rem; margin-top: 0.9rem; }
@media (min-width: 900px) { .dos { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); } }

.emp { display: block; color: inherit; text-decoration: none; border-top: 4px solid var(--c, var(--marca)); }
.emp:hover { border-color: var(--c, var(--marca)); box-shadow: 0 2px 10px rgb(22 32 44 / 0.08); }
.emp h2 { margin: 0; }
.emp .cabeza { display: flex; justify-content: space-between; align-items: center; gap: 0.5rem; margin-bottom: 0.7rem; }
.emp dl { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.75rem; margin: 0; font-size: 0.9rem; }
.emp dt { color: var(--tenue); }
.emp dd { margin: 0; }
.emp .pie { margin: 0.7rem 0 0; font-size: 0.85rem; color: var(--tenue); }

.chip {
  display: inline-block; padding: 0.1rem 0.55rem; border-radius: 99px;
  font-size: 0.75rem; font-weight: 600; background: #e8ecf1; color: var(--tenue); white-space: nowrap;
}
.chip.activo { background: #dff3e8; color: var(--ok); }
.chip.frenado, .chip.aviso { background: #fbefd2; color: var(--aviso); }
.chip.vencido { background: #fbe1df; color: var(--mal); }

.kpis { display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin-bottom: 0.9rem; }
.kpi .etiqueta { font-size: 0.78rem; color: var(--tenue); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi .valor { font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.lista { list-style: none; margin: 0; padding: 0; }
.lista li {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.5rem 0; border-top: 1px solid var(--linea);
}
.lista li:first-child { border-top: 0; }
.lista .cuerpo { flex: 1; min-width: 0; }
.lista small { display: block; color: var(--tenue); }
.tachada { text-decoration: line-through; color: var(--tenue); }
.check {
  width: 1.35rem; height: 1.35rem; flex: none; border-radius: 6px; border: 2px solid #b6bfcb;
  background: #fff; cursor: pointer; padding: 0; line-height: 1; color: #fff; font-size: 0.8rem;
}
.check.hecha { background: var(--ok); border-color: var(--ok); }

/* ---- Tablas ---- */
.tabla-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { padding: 0.55rem 0.7rem; text-align: left; border-bottom: 1px solid var(--linea); vertical-align: middle; }
th { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--tenue); white-space: nowrap; }
tbody tr:hover { background: #fafbfc; }
td.acciones { text-align: right; white-space: nowrap; }
td.acciones form { display: inline; }
.vacio { padding: 2rem 1rem; text-align: center; color: var(--tenue); }

/* ---- Formularios y botones ---- */
.boton {
  display: inline-block; padding: 0.5rem 0.95rem; border-radius: 8px; border: 1px solid var(--marca);
  background: var(--marca); color: #fff; font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
}
.boton:hover { filter: brightness(1.12); }
.boton.secundario { background: var(--papel); color: var(--marca); border-color: var(--linea); }
.boton.peligro { background: var(--mal); border-color: var(--mal); }
.boton.fantasma { background: transparent; border-color: rgb(255 255 255 / 0.3); color: inherit; padding: 0.3rem 0.7rem; }
.boton.chico { padding: 0.25rem 0.6rem; font-size: 0.82rem; }
.formulario { max-width: 620px; }
.formulario p { margin: 0 0 0.9rem; }
.formulario label { display: block; font-weight: 600; font-size: 0.88rem; margin-bottom: 0.25rem; }
input:not([type=checkbox]):not([type=radio]), select, textarea {
  width: 100%; padding: 0.5rem 0.65rem; border: 1px solid #c5ccd6; border-radius: 8px;
  font: inherit; background: #fff; color: var(--tinta);
}
textarea { min-height: 5.5rem; resize: vertical; }
:is(input, select, textarea, button, a):focus-visible { outline: 3px solid var(--acento); outline-offset: 1px; }
.helptext { display: block; font-size: 0.8rem; color: var(--tenue); margin-top: 0.2rem; }
.errorlist { list-style: none; margin: 0 0 0.3rem; padding: 0; color: var(--mal); font-size: 0.85rem; font-weight: 600; }
.botonera { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 1.1rem; }
.filtros-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.6rem 0.75rem; margin-bottom: 0.5rem; }
.filtros-form label { flex: 1 1 150px; max-width: 230px; font-size: 0.78rem; font-weight: 600; color: var(--tenue); }
.filtros-form label.ancho { flex-basis: 220px; max-width: 320px; }
.filtros-form label > :is(input, select) { margin-top: 0.2rem; }
.filtros-form .botonera { margin: 0; }
.conteo { margin: 0 0 0.6rem; font-size: 0.85rem; }
.deuda { margin: 0 0 0.4rem; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.filtros { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.9rem; }
.paginas { display: flex; gap: 0.75rem; align-items: center; margin-top: 0.9rem; font-size: 0.9rem; }

.mensajes { list-style: none; margin: 0 0 1rem; padding: 0; }
.mensajes li { padding: 0.6rem 0.9rem; border-radius: 8px; background: #dff3e8; color: var(--ok); margin-bottom: 0.4rem; font-weight: 600; }
.mensajes li.error { background: #fbe1df; color: var(--mal); }

.login { width: min(380px, 100%); }
.login h1 { margin-bottom: 0.2rem; }
.qr svg { width: 200px; height: 200px; display: block; }
code.clave { word-break: break-all; font-size: 0.8rem; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---- Modal nativo (<dialog id="modal">) ---- */
dialog#modal {
  width: min(560px, calc(100% - 2rem)); max-height: calc(100dvh - 2rem); overflow: auto;
  padding: 1.25rem 1.3rem; border: 1px solid var(--linea); border-radius: var(--radio);
  background: var(--papel); color: var(--tinta); box-shadow: 0 18px 50px rgb(22 32 44 / 0.25);
}
dialog#modal::backdrop { background: rgb(16 24 36 / 0.45); }
dialog#modal h2 { margin-bottom: 0.2rem; }
