/* Gym System · hoja unica de la aplicacion.

   Todo el look sale de las variables que base.html mete en :root desde la
   configuracion del gimnasio (--accent, --warn). Aqui solo se consume.
*/

:root {
  --bg: #0d1117;
  --bg-2: #131a24;
  --panel: #161f2b;
  --panel-2: #1b2634;
  --line: #24313f;
  --txt: #e6edf3;
  --txt-2: #9fb0c3;
  --accent: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --ok: #22c55e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
}

html[data-tema="light"] {
  --bg: #f4f6f9;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f7f9fc;
  --line: #dde4ec;
  --txt: #101827;
  --txt-2: #5b6b80;
  --shadow: 0 8px 24px rgba(16, 24, 39, .08);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background:
    radial-gradient(1200px 500px at 85% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    var(--bg);
  color: var(--txt);
  font: 15px/1.55 ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0 0 .25rem; letter-spacing: -.02em; }
h2 { font-size: 1.15rem; margin: 0 0 .5rem; }
h3 { font-size: 1rem; margin: 0 0 .4rem; }
p { margin: .35rem 0; }
b { font-weight: 650; }

.dim { color: var(--txt-2); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .92em; }
.right { text-align: right; }
.c { text-align: center; }
.inline { display: inline; }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack.wide { max-width: 980px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }

/* ------------------------------------------------------------------ topbar */
.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 1.25rem;
  padding: .7rem clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: .6rem; color: var(--txt); }
.brand:hover { text-decoration: none; }
.brand img { height: 30px; width: auto; max-width: 130px; object-fit: contain; }
.brand-name { font-weight: 700; letter-spacing: -.02em; }
.brand-tag { display: none; color: var(--txt-2); font-size: .8rem; }

.nav { display: flex; gap: .15rem; flex-wrap: wrap; flex: 1; }
.nav a {
  color: var(--txt-2); padding: .4rem .7rem; border-radius: 999px;
  font-weight: 550; font-size: .92rem;
}
.nav a:hover { color: var(--txt); background: var(--panel); text-decoration: none; }
.nav a.on { color: #06210f; background: var(--accent); }
html[data-tema="light"] .nav a.on { color: #fff; }

.whoami { display: flex; align-items: center; gap: .6rem; }
.who-name { font-weight: 600; font-size: .92rem; max-width: 170px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------- flashes */
.flashes {
  position: fixed; top: 62px; right: clamp(1rem, 3vw, 2rem); z-index: 60;
  display: flex; flex-direction: column; gap: .5rem; max-width: min(92vw, 380px);
}
.flash {
  padding: .7rem .9rem; border-radius: var(--radius-sm);
  background: var(--panel); border: 1px solid var(--line);
  box-shadow: var(--shadow); font-size: .92rem;
  border-left: 4px solid var(--accent);
  animation: entra .25s ease-out;
}
.flash.error { border-left-color: var(--danger); }
.flash.aviso { border-left-color: var(--warn); }
@keyframes entra { from { opacity: 0; transform: translateY(-6px); } }

/* ------------------------------------------------------------------ layout */
.wrap { padding: clamp(1.1rem, 3vw, 2rem); max-width: 1280px; margin: 0 auto; }
.foot {
  padding: 1.5rem 2rem 2.5rem; text-align: center;
  color: var(--txt-2); font-size: .82rem; border-top: 1px solid var(--line);
  margin-top: 2rem;
}

.page-head {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem;
}
.section-title { margin: 1.75rem 0 .75rem; font-size: 1.05rem; color: var(--txt-2);
  text-transform: uppercase; letter-spacing: .08em; font-weight: 650; }

/* ------------------------------------------------------------------ cards */
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 1rem; }

.card {
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
}
.card.stat { display: flex; flex-direction: column; gap: .2rem; }
.stat-n { font-size: 2.1rem; font-weight: 750; letter-spacing: -.04em; }
.stat-t { font-size: 1rem; color: var(--txt-2); font-weight: 500; }
.stat-l { color: var(--txt-2); font-size: .88rem; }
/* Variante para valores largos (nombres de plan, fechas): no desborda la card. */
.stat-n.sm { font-size: 1.15rem; font-weight: 700; letter-spacing: -.02em; word-break: break-word; }
.card.link { display: block; color: var(--txt); transition: transform .15s, border-color .15s; }
.card.link:hover { text-decoration: none; transform: translateY(-3px); border-color: var(--accent); }
.card.note { margin-top: 1.25rem; border-left: 3px solid var(--warn); }
.card.empty { text-align: center; padding: 2.5rem 1rem; display: grid; gap: .8rem; justify-items: center; }

.panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.1rem 1.2rem 1.3rem;
  margin: 0 0 1.1rem;
}
.panel legend {
  padding: 0 .5rem; font-weight: 700; font-size: .95rem; color: var(--accent);
  text-transform: uppercase; letter-spacing: .06em;
}

/* ------------------------------------------------------------------ campos */
.field { display: flex; flex-direction: column; gap: .35rem; font-size: .92rem; }
.field > span { color: var(--txt-2); font-weight: 550; }
.field small { font-size: .8rem; }
.field.check { flex-direction: row; align-items: center; gap: .55rem; font-weight: 550; }
.field.check span { color: var(--txt); }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="time"], input[type="tel"], input[type="url"], input[type="date"],
input[type="search"], input[type="file"], input:not([type]),
select, textarea {
  width: 100%; padding: .6rem .7rem;
  background: var(--bg-2); color: var(--txt);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; font-size: .95rem;
}
input[type="color"] { width: 100%; height: 42px; padding: 3px;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent);
  outline-offset: 1px; border-color: var(--accent);
}
input[type="checkbox"], input[type="radio"] {
  width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer;
}
input[disabled] { opacity: .5; }
textarea { resize: vertical; min-height: 74px; }

.actions { display: flex; gap: .7rem; flex-wrap: wrap; align-items: center; }

/* ------------------------------------------------------------------ botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  padding: .58rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--panel-2); color: var(--txt);
  font: inherit; font-weight: 600; font-size: .93rem; cursor: pointer;
  transition: filter .15s, transform .05s; white-space: nowrap;
}
.btn:hover { text-decoration: none; filter: brightness(1.1); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #05240f; }
html[data-tema="light"] .btn.primary { color: #fff; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.sm { padding: .34rem .7rem; font-size: .84rem; }
.btn.danger {
  background: color-mix(in srgb, var(--danger) 20%, var(--panel-2));
  border-color: color-mix(in srgb, var(--danger) 55%, transparent); color: var(--danger);
}

/* ------------------------------------------------------------------ badges */
.badge {
  display: inline-block; padding: .15rem .55rem; border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  color: var(--accent); font-size: .76rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em;
}
.badge.up { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.chip {
  display: inline-block; padding: .2rem .6rem; border-radius: 999px;
  background: var(--panel-2); border: 1px solid var(--line);
  color: var(--txt-2); font-size: .8rem; font-weight: 600;
}
.chip.warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.chip.ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.chip.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 50%, transparent); }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  margin-right: .45rem; background: var(--txt-2); vertical-align: middle; }
.dot.ok { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }
.dot.bad { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 22%, transparent); }
.dot.warn { background: var(--warn); box-shadow: 0 0 0 3px color-mix(in srgb, var(--warn) 22%, transparent); }

/* ------------------------------------------------------- filtros y paginas */
.filters {
  display: grid; grid-template-columns: 2fr 1fr 1fr auto;
  gap: .8rem; align-items: end;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: 1.1rem;
}
.filters .grow { min-width: 0; }
.pager {
  display: flex; align-items: center; justify-content: center;
  gap: .8rem; margin-top: 1rem;
}
/* Atajos de periodo bajo los filtros de /informes. */
.periodos {
  display: flex; gap: .5rem; align-items: center; flex-wrap: wrap;
  margin: -.4rem 0 1.1rem;
}
.periodos a.on { border-color: var(--accent); color: var(--accent); }
/* Listados largos de /informes: plegados, los agregados quedan arriba. */
details.listado > summary.section-title { cursor: pointer; list-style: none; }
details.listado > summary.section-title::-webkit-details-marker { display: none; }
details.listado > summary.section-title::before { content: "▸ "; color: var(--accent); }
details.listado[open] > summary.section-title::before { content: "▾ "; }
details.inline-form {
  border: 1px dashed var(--line); border-radius: var(--radius-sm);
  padding: .55rem .8rem; margin-top: .7rem; background: var(--panel-2);
}
details.inline-form > summary {
  cursor: pointer; color: var(--txt-2); font-weight: 600; font-size: .88rem;
}
details.inline-form[open] > summary { color: var(--txt); margin-bottom: .6rem; }
summary.linkish {
  cursor: pointer; list-style: none; color: var(--accent);
  font-weight: 650; font-size: .88rem;
}
summary.linkish::-webkit-details-marker { display: none; }
summary.linkish:hover { text-decoration: underline; }
/* El fichero del socio: datos a la izquierda, caja de cobro a la derecha. */
.ficha-cols {
  display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 1.1rem; align-items: start;
}
.ficha-cols .panel { margin-bottom: 0; }
@media (max-width: 860px) { .ficha-cols { grid-template-columns: 1fr; } }

/* ------------------------------------------------------------------ tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--panel); }
.table { width: 100%; border-collapse: collapse; font-size: .93rem; }
.table th, .table td { padding: .7rem .85rem; text-align: left; border-bottom: 1px solid var(--line); }
.table thead th {
  background: var(--panel-2); color: var(--txt-2);
  font-size: .76rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: color-mix(in srgb, var(--accent) 5%, transparent); }
.table tr.off td { opacity: .55; }
.table td.right, .table th.right { text-align: right; }
.table td.d { text-transform: capitalize; font-weight: 600; }
.table .right form { display: inline-block; margin-left: .35rem; }
/* El desplegable de anular/cancelar vive dentro de la celda. */
.table details.inline-form { display: inline-block; margin-top: 0; border: 0; padding: 0;
  background: transparent; vertical-align: middle; }
.table details.inline-form[open] { display: block; padding: .5rem 0 0; }

/* ------------------------------------------------------------------ tabs */
.tabs { display: flex; gap: .3rem; flex-wrap: wrap; border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem; }
.tabs a {
  padding: .55rem .95rem; color: var(--txt-2); font-weight: 600; font-size: .92rem;
  border-bottom: 2px solid transparent;
}
.tabs a:hover { color: var(--txt); text-decoration: none; }
.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); }

/* ------------------------------------------------------------------ login */
.login-card {
  max-width: 400px; margin: clamp(2rem, 10vh, 7rem) auto;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 2rem 1.75rem; box-shadow: var(--shadow);
}
.login-head { text-align: center; margin-bottom: 1.4rem; }
.login-head h1 { font-size: 1.3rem; margin-top: .6rem; }
.login-logo { height: 52px; max-width: 180px; object-fit: contain; }
.login-card .btn { margin-top: .4rem; }

.center-box { text-align: center; padding: 4rem 1rem; }

/* ------------------------------------------------------------------ upload */
.upload-row { display: flex; align-items: center; gap: .8rem; }
.upload-row input[type="file"] { font-size: .86rem; color: var(--txt-2); }
.preview { display: inline-flex; align-items: center; }
.preview img { height: 38px; max-width: 130px; object-fit: contain;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px; }

/* ---------------------------------------------------------- acceso facial */
/* Kiosco a pantalla completa (body.kiosco-mode, bloque body_class de
   base.html): barra de estado arriba, escena con el video a fondo
   completo y pie con el CTA. Se ocultan el topbar y el pie genericos. */
body.kiosco-mode .topbar,
body.kiosco-mode .foot { display: none; }
body.kiosco-mode .wrap { max-width: none; padding: 0; margin: 0; }

.kiosco {
  display: grid;
  grid-template-rows: auto 1fr auto;
  min-height: 100vh;
  min-height: 100dvh;
}
.kiosco-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0;
}

/* Barra de estado: marca, sede, camara y reloj. */
.kiosco-barra {
  display: flex; align-items: center; justify-content: space-between;
  gap: .8rem 1.2rem; flex-wrap: wrap;
  padding: .65rem clamp(1rem, 3vw, 2rem);
  background: color-mix(in srgb, var(--bg-2) 90%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  position: relative; z-index: 4;
}
.kiosco-marca { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.kiosco-marca img { height: 26px; max-width: 120px; object-fit: contain; }
.kiosco-nombre {
  font-weight: 750; letter-spacing: -.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kiosco-sede {
  color: var(--txt-2); font-size: .88rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kiosco-estado { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.kiosco-est {
  display: inline-flex; align-items: center;
  color: var(--txt-2); font-size: .84rem; text-transform: uppercase;
  letter-spacing: .05em; font-weight: 650;
}
.kiosco-reloj {
  font-variant-numeric: tabular-nums; font-weight: 750; font-size: 1.1rem;
  letter-spacing: .02em; color: var(--txt);
}

/* Escena: el video ocupa todo; encima el velo de legibilidad, el marco
   oval (guia de "pon la cara aqui") y el subtitulo abajo. */
.kiosco-escena {
  position: relative; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  text-align: center;
  background: radial-gradient(120% 90% at 50% 0%,
    color-mix(in srgb, var(--accent) 16%, var(--bg-2)), var(--bg));
}
#kiosco-video { display: none; }
#kiosco-video.on {
  display: block; position: absolute; inset: 0; z-index: 1;
  width: 100%; height: 100%; object-fit: cover;
  transform: scaleX(-1); /* espejo: la captura del canvas no se ve afectada */
}
.kiosco-velo {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--bg) 55%, transparent), transparent 24%),
    linear-gradient(0deg, color-mix(in srgb, var(--bg) 60%, transparent), transparent 30%);
}
.kiosco-marco {
  position: relative; z-index: 3;
  height: clamp(230px, 44vh, 430px); aspect-ratio: 3 / 4;
  border: 3px solid color-mix(in srgb, var(--accent) 55%, transparent);
  border-radius: 50%;
  box-shadow:
    0 0 46px color-mix(in srgb, var(--accent) 26%, transparent),
    inset 0 0 34px color-mix(in srgb, var(--accent) 12%, transparent);
  animation: respira 3.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes respira { 50% { opacity: .5; transform: scale(1.025); } }
.kiosco-centro {
  position: absolute; left: 0; right: 0;
  bottom: clamp(.9rem, 3.5vh, 2rem);
  z-index: 4; padding: 0 1.2rem; pointer-events: none;
}
.kiosco-sub {
  margin: 0; color: #fff; font-weight: 700;
  font-size: clamp(1.05rem, 2.6vw, 1.45rem);
  text-shadow: 0 2px 14px rgba(0, 0, 0, .7);
}

/* Pie: CTA gigante centrado + avisos. */
.kiosco-pie {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: center;
  gap: .7rem; padding: clamp(.9rem, 3vh, 1.6rem) 1.2rem;
  background: color-mix(in srgb, var(--bg-2) 92%, transparent);
  border-top: 1px solid var(--line);
  position: relative; z-index: 5;
}
.kiosco-cta {
  flex: 1 1 240px; max-width: 420px;
  padding: .95rem 1.6rem; border-radius: 999px;
  font-size: 1.06rem; font-weight: 750;
}
.kiosco-cta:disabled { opacity: .55; cursor: not-allowed; }
.kiosco-aviso {
  flex: 1 1 100%; margin: 0; text-align: center;
  color: var(--warn); font-size: .92rem; min-height: 1.2em;
}

/* Resultado: flash a pantalla completa con icono gigante. */
.kiosco-resultado {
  position: fixed; inset: 0; z-index: 60;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .4rem; text-align: center; padding: 2rem;
  animation: flash-entra .18s ease-out;
}
@keyframes flash-entra { from { opacity: 0; transform: scale(1.03); } }
.kiosco-resultado[hidden] { display: none; }
.kiosco-resultado.bien { background: color-mix(in srgb, var(--ok) 90%, #000); }
.kiosco-resultado.mal { background: color-mix(in srgb, var(--danger) 90%, #000); }
.kiosco-resultado::before {
  color: #fff; font-weight: 800; line-height: 1;
  font-size: clamp(3.4rem, 14vh, 6.5rem);
}
.kiosco-resultado.bien::before { content: "\2713"; }
.kiosco-resultado.mal::before { content: "\2715"; }
.kiosco-msg {
  margin: 0; color: #fff; font-weight: 800;
  font-size: clamp(1.7rem, 6vw, 3rem); letter-spacing: -.02em;
}
.kiosco-det {
  margin: 0; color: rgba(255, 255, 255, .94); font-weight: 650;
  font-size: clamp(1rem, 2.6vw, 1.3rem);
}

@media (prefers-reduced-motion: reduce) {
  .kiosco-marco, .kiosco-resultado { animation: none; }
}

/* ---------------------------------------------------- camara de la ficha */
.camara-caja { display: grid; gap: .6rem; justify-items: start; }
.camara-video {
  display: none; width: 100%; max-height: 260px; background: #000;
  border-radius: var(--radius-sm); border: 1px solid var(--line);
}
.camara-video.on { display: block; }
.dims-list { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .45rem; font-size: .92rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .45rem 1rem; margin: .4rem 0 0; font-size: .92rem; }
.kv dt { color: var(--txt-2); }
.kv dd { margin: 0; font-weight: 600; }

/* --------------------------------------------------------------- responsive */
@media (max-width: 860px) {
  .kiosco-sede { display: none; }
  .kiosco-cta { max-width: none; }
  .filters { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 720px) {
  .topbar { flex-wrap: wrap; gap: .6rem; padding: .6rem 1rem; }
  .nav { order: 3; width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: .2rem; }
  .whoami { margin-left: auto; }
  .brand-tag { display: none; }
  .who-name { max-width: 110px; }
  .flashes { top: 104px; right: .75rem; left: .75rem; max-width: none; }
  .table th, .table td { padding: .6rem .6rem; }
}

@media (max-width: 520px) {
  .stat-n { font-size: 1.7rem; }
  .page-head { align-items: flex-start; }
  .filters { grid-template-columns: 1fr; }
}
