:root {
  --fondo: #f5f4f1;
  --tarjeta: #ffffff;
  --texto: #1f2328;
  --suave: #6b6f76;
  --borde: #e4e2dc;
  --acento: #0f766e;
  --acento-2: #ccfbf1;
  --peligro: #b42318;
  --peligro-2: #fee4e2;
  --aviso: #b54708;
  --aviso-2: #fef0c7;
  --ok: #067647;
  --ok-2: #dcfae6;
  --sombra: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.04);
  --radio: 14px;
  --barra: 64px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #121416; --tarjeta: #1b1e21; --texto: #e9eaec; --suave: #9aa0a6; --borde: #2c3035;
    --acento: #2dd4bf; --acento-2: #134e4a; --peligro: #f97066; --peligro-2: #3d1a17;
    --aviso: #fdb022; --aviso-2: #3b2a0a; --ok: #47cd89; --ok-2: #0f2e1f;
    --sombra: 0 1px 2px rgba(0,0,0,.4); color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo); color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--barra) + env(safe-area-inset-bottom));
}
body.sin-barra { padding-bottom: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--acento); }
.oculto { display: none !important; }

/* Cabecera */
.cabecera {
  position: sticky; top: 0; z-index: 20; background: var(--tarjeta); border-bottom: 1px solid var(--borde);
  display: flex; align-items: center; gap: 10px; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
}
.cabecera h1 { font-size: 17px; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cabecera .gym { font-size: 12px; color: var(--suave); font-weight: 500; display: block; }
.marca { width: 30px; height: 30px; border-radius: 9px; background: var(--acento); color: #fff; display: grid; place-items: center; font-weight: 800; flex: none; }

main { max-width: 1100px; margin: 0 auto; padding: 14px 16px 24px; }

/* Barra inferior (móvil) y lateral (escritorio) */
.barra {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--tarjeta);
  border-top: 1px solid var(--borde); padding-bottom: env(safe-area-inset-bottom);
}
.barra a {
  flex: 1; height: var(--barra); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--suave); text-decoration: none; font-size: 11px; font-weight: 600; position: relative;
}
.barra a svg { width: 24px; height: 24px; }
.barra a.activo { color: var(--acento); }
.barra .globo { position: absolute; top: 8px; left: calc(50% + 6px); background: var(--peligro); color: #fff; border-radius: 99px; font-size: 10px; padding: 0 5px; min-width: 16px; text-align: center; }
@media (min-width: 900px) {
  body { padding-bottom: 0; padding-left: 92px; }
  .barra { top: 0; right: auto; width: 92px; flex-direction: column; border-top: 0; border-right: 1px solid var(--borde); padding-top: 70px; }
  .barra a { flex: none; height: 72px; }
  .cabecera { margin-left: 0; }
}

/* Elementos */
.tarjeta { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); box-shadow: var(--sombra); padding: 14px; }
.tarjeta + .tarjeta { margin-top: 10px; }
.titulo-sec { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--suave); font-weight: 700; margin: 18px 2px 8px; display: flex; align-items: center; gap: 8px; }
.titulo-sec:first-child { margin-top: 4px; }
.titulo-sec .der { margin-left: auto; text-transform: none; letter-spacing: 0; }
.fila { display: flex; align-items: center; gap: 10px; }
.fila.envolver { flex-wrap: wrap; }
.crece { flex: 1; min-width: 0; }
.suave { color: var(--suave); }
.peq { font-size: 13px; }
.mini { font-size: 12px; }
.negrita { font-weight: 700; }
.centro { text-align: center; }
.vacio { text-align: center; color: var(--suave); padding: 32px 12px; }
.rejilla { display: grid; gap: 10px; }
@media (min-width: 700px) { .rejilla.dos { grid-template-columns: 1fr 1fr; } .rejilla.tres { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1000px) { .rejilla.tres { grid-template-columns: repeat(3, 1fr); } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid var(--borde); background: var(--tarjeta);
  border-radius: 10px; padding: 9px 14px; min-height: 42px; cursor: pointer; font-weight: 600; text-decoration: none; color: var(--texto);
}
.btn:active { transform: scale(.98); }
.btn.prim { background: var(--acento); border-color: var(--acento); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.prim { color: #042f2e; } }
.btn.peligro { color: var(--peligro); border-color: var(--peligro-2); background: var(--peligro-2); }
.btn.plano { border-color: transparent; background: transparent; }
.btn.peq { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.btn.ancho { width: 100%; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icono-btn { border: 0; background: transparent; width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; color: var(--texto); }
.icono-btn:hover { background: var(--fondo); }
.icono-btn svg { width: 22px; height: 22px; }

label.campo { display: block; margin-bottom: 12px; }
label.campo > span { display: block; font-size: 13px; color: var(--suave); font-weight: 600; margin-bottom: 4px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=time], input[type=tel], input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--borde); background: var(--fondo); border-radius: 10px; padding: 10px 12px; min-height: 44px;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--acento); outline-offset: -1px; }
.check { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--acento); }

/* Chips de clasificación y estado */
.chip { display: inline-flex; align-items: center; gap: 5px; border-radius: 99px; padding: 2px 9px; font-size: 12px; font-weight: 600; background: var(--fondo); border: 1px solid var(--borde); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chips { display: flex; flex-wrap: wrap; gap: 5px; }
.chip.sel { background: var(--acento-2); border-color: var(--acento); }
button.chip { cursor: pointer; min-height: 32px; padding: 4px 12px; }
.etq { font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 6px; background: var(--fondo); color: var(--suave); }
.etq.ok { background: var(--ok-2); color: var(--ok); }
.etq.mal { background: var(--peligro-2); color: var(--peligro); }
.etq.av { background: var(--aviso-2); color: var(--aviso); }
.etq.ac { background: var(--acento-2); color: var(--acento); }

/* Selector de días */
.semana { display: flex; align-items: center; gap: 6px; margin-bottom: 10px; }
.semana .rango { flex: 1; text-align: center; font-weight: 700; }
.dias { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 12px; scrollbar-width: none; }
.dias button {
  flex: 1; min-width: 62px; border: 1px solid var(--borde); background: var(--tarjeta); border-radius: 12px; padding: 8px 4px; cursor: pointer; text-align: center;
}
.dias button b { display: block; font-size: 18px; }
.dias button small { display: block; font-size: 11px; color: var(--suave); }
.dias button.activo { background: var(--acento); color: #fff; border-color: var(--acento); }
.dias button.activo small { color: inherit; opacity: .85; }
.dias button.hoy:not(.activo) { border-color: var(--acento); }
.dias button.cerrado { opacity: .45; }

/* Tarjeta de sesión */
.sesion { cursor: pointer; display: block; }
.sesion .hora { font-size: 20px; font-weight: 800; letter-spacing: -.01em; }
.sesion.cancelada { opacity: .6; }
.sesion.cancelada .hora { text-decoration: line-through; }
.ocup { height: 6px; border-radius: 99px; background: var(--fondo); overflow: hidden; margin: 8px 0 6px; }
.ocup > i { display: block; height: 100%; background: var(--acento); border-radius: 99px; }
.ocup.llena > i { background: var(--aviso); }
.ocup.pasada > i { background: var(--peligro); }
.nombres { font-size: 13px; color: var(--suave); }
.plazas { font-weight: 800; font-size: 15px; }
.plazas.llena { color: var(--aviso); }
.plazas.pasada { color: var(--peligro); }

/* Listas */
.lista { background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio); overflow: hidden; }
.lista > .item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-top: 1px solid var(--borde); min-height: 56px; }
.lista > .item:first-child { border-top: 0; }
.lista > .item.toque { cursor: pointer; }
.lista > .item.toque:active { background: var(--fondo); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--acento-2); color: var(--acento); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.item.anulado .crece { opacity: .5; text-decoration: line-through; }

/* Hoja / modal */
.velo { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; animation: aparecer .15s; }
.hoja {
  background: var(--tarjeta); width: 100%; max-width: 640px; max-height: 92vh; max-height: 92dvh; border-radius: 18px 18px 0 0; display: flex; flex-direction: column;
  animation: subir .2s ease-out; padding-bottom: env(safe-area-inset-bottom);
}
.hoja > header { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--borde); }
.hoja > header h2 { font-size: 17px; margin: 0; flex: 1; min-width: 0; }
.hoja > header h2 small { display: block; font-size: 12px; color: var(--suave); font-weight: 500; }
.hoja > .cuerpo { overflow-y: auto; padding: 14px 16px 18px; -webkit-overflow-scrolling: touch; }
.hoja > footer { padding: 10px 16px; border-top: 1px solid var(--borde); display: flex; gap: 8px; }
.hoja > footer .btn { flex: 1; }
@media (min-width: 700px) {
  .velo { align-items: center; }
  .hoja { border-radius: 18px; max-height: 86vh; }
}
@keyframes subir { from { transform: translateY(30px); opacity: 0; } }
@keyframes aparecer { from { opacity: 0; } }

.menu-acc { display: grid; gap: 6px; }
.menu-acc .btn { justify-content: flex-start; }

/* Aviso flotante */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--barra) + 16px + env(safe-area-inset-bottom)); z-index: 80;
  background: #1f2328; color: #fff; padding: 11px 16px; border-radius: 12px; max-width: calc(100vw - 32px); box-shadow: 0 6px 20px rgba(0,0,0,.25);
  animation: subir .2s; font-weight: 500;
}
.toast.mal { background: var(--peligro); }
@media (min-width: 900px) { .toast { bottom: 24px; } }

.buscar { position: sticky; top: 58px; z-index: 10; background: var(--fondo); padding: 4px 0 10px; }
.filtros { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; scrollbar-width: none; }

/* Acceso */
.acceso { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px 16px; }
.acceso .tarjeta { width: 100%; max-width: 380px; padding: 26px 22px; }
.acceso .marca { width: 52px; height: 52px; border-radius: 15px; font-size: 24px; margin: 0 auto 12px; }
.acceso h1 { text-align: center; font-size: 22px; margin: 0 0 4px; }

.cargando { text-align: center; padding: 40px; color: var(--suave); }
.aviso-caja { background: var(--aviso-2); color: var(--aviso); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.info-caja { background: var(--acento-2); color: var(--acento); border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.estadisticas { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .estadisticas { grid-template-columns: repeat(4, 1fr); } }
.estadisticas .tarjeta { margin: 0; }
.estadisticas b { display: block; font-size: 24px; }
.color-input { width: 44px; height: 44px; padding: 2px; border: 1px solid var(--borde); border-radius: 10px; background: var(--fondo); flex: none; }
code.clave { font-size: 18px; background: var(--fondo); padding: 4px 10px; border-radius: 8px; user-select: all; }
