/* Asistrainer — identidad sobria y profesional.
   Tinta azul profunda + acento azul eléctrico; los colores de estado se reservan para alertas. */
:root {
  --ink: #142033;
  --ink-2: #3b4a5f;
  --muted: #6a7789;
  --line: #dde3eb;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --accent: #2448d8;
  --accent-ink: #ffffff;
  --accent-soft: #e6ecfd;
  --danger: #c4312b;
  --danger-soft: #fbe7e6;

  /* Estados y alertas */
  --st-activo: #ffffff;
  --st-amarillo: #f2b705; --st-amarillo-soft: #fff5d6;
  --st-rojo: #d6403a;     --st-rojo-soft: #fde4e2;
  --st-celeste: #2aa3cf;  --st-celeste-soft: #def3fb;
  --st-verde: #2e9d5b;    --st-verde-soft: #e1f4e8;
  --st-morado: #7a4cc2;   --st-morado-soft: #efe7fb;
  --st-gris: #7b8796;     --st-gris-soft: #eceff3;
  --st-naranjo: #e9741f;

  --font: 'Public Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-display: 'Archivo', 'Public Sans', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
  --radius: 10px;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-size: 15px; line-height: 1.5;
  color: var(--ink); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.15; margin: 0; text-wrap: balance; }
h1 { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 1.15rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 700; }
p { margin: 0; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--font-mono); }

/* Franja de versión de prueba */
.beta-band {
  background: repeating-linear-gradient(-45deg, #ffcf33 0 14px, #ffbf00 14px 28px);
  color: #1a1a1a; text-align: center; font-weight: 800; font-size: .8rem;
  letter-spacing: .12em; padding: 4px 8px; text-transform: uppercase;
}

/* Barra superior */
.topbar {
  background: var(--ink); color: #fff;
  position: sticky; top: 0; z-index: 20;
}
.topbar-in {
  max-width: 1180px; margin: 0 auto; padding: 0 16px;
  display: flex; align-items: center; gap: 18px; min-height: 58px; flex-wrap: wrap;
}
.brand {
  display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
  font-family: var(--font-display); font-weight: 800; font-size: 1.12rem; letter-spacing: -0.01em;
}
.brand-mark { width: 30px; height: 30px; flex: none; }
.nav { display: flex; gap: 2px; flex-wrap: wrap; flex: 1; }
.nav a {
  color: #c9d3e2; text-decoration: none; padding: 8px 11px; border-radius: 7px;
  font-size: .9rem; font-weight: 600; position: relative;
}
.nav a:hover { color: #fff; background: rgba(255,255,255,.07); }
.nav a.is-active { color: #fff; background: rgba(255,255,255,.12); }
.nav .count {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 4px; border-radius: 9px;
  background: var(--st-amarillo); color: #1a1a1a; font-size: .72rem; text-align: center; line-height: 18px;
}
.menu { position: relative; margin-left: auto; }
.menu > button {
  background: transparent; border: 1px solid rgba(255,255,255,.22); color: #fff;
  border-radius: 8px; padding: 7px 12px; font: inherit; font-weight: 600; cursor: pointer;
}
.menu-list {
  position: absolute; right: 0; top: calc(100% + 6px); background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius); min-width: 200px;
  box-shadow: 0 10px 30px rgba(20,32,51,.16); padding: 6px; display: none;
}
.menu.open .menu-list { display: block; }
.menu-list a, .menu-list button {
  display: block; width: 100%; text-align: left; padding: 9px 12px; border-radius: 7px;
  color: var(--ink); text-decoration: none; background: none; border: 0; font: inherit; cursor: pointer;
}
.menu-list a:hover, .menu-list button:hover { background: var(--bg); }
.menu-list .who { padding: 8px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 4px; font-size: .85rem; }
.menu-list .who strong { display: block; font-size: .95rem; }
.nav-toggle { display: none; }

/* Contenido */
.page { max-width: 1180px; margin: 0 auto; padding-inline: 16px; padding-block: 24px 64px; }
.page.narrow { max-width: 560px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .sub { color: var(--muted); margin-top: 4px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); text-decoration: none; font-weight: 600; font-size: .9rem; margin-bottom: 10px; }
.back:hover { color: var(--accent); }

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.grid-2 > *, .grid-3 > * { min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }

/* Botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 16px; border-radius: 8px; border: 1px solid transparent;
  font: inherit; font-weight: 700; font-size: .92rem; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink); line-height: 1.2;
}
.btn:hover { filter: brightness(1.08); }
.btn.secondary { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn.secondary:hover { background: var(--bg); filter: none; }
.btn.ghost { background: transparent; color: var(--ink-2); border-color: transparent; }
.btn.danger { background: var(--danger); }
.btn.danger-outline { background: var(--surface); color: var(--danger); border-color: #efc2bf; }
.btn.xl { padding: 16px 26px; font-size: 1.05rem; border-radius: 10px; }
.btn.sm { padding: 6px 10px; font-size: .82rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
:focus-visible { outline: 3px solid #7c98ff; outline-offset: 2px; }

/* Formularios */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: .88rem; }
.field .hint { font-size: .8rem; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=search], select, textarea {
  width: 100%; min-width: 0; font: inherit; color: var(--ink); background: #fff;
  border: 1px solid #cdd5df; border-radius: 8px; padding: 10px 12px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { min-height: 90px; resize: vertical; }
.pw { display: flex; gap: 6px; }
.pw button { flex: none; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-row > * { min-width: 0; }

/* Mensajes */
.notice { border-radius: 8px; padding: 12px 14px; font-weight: 600; margin-bottom: 16px; }
.notice.ok { background: #e1f4e8; color: #1d6a3d; }
.notice.error { background: var(--danger-soft); color: #962620; }
.notice.warn { background: var(--st-amarillo-soft); color: #7a5a00; }

/* Tablas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  font-weight: 700; padding: 11px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #fafbfd; }
td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tfoot td { background: var(--soft, #f6f7fa); border-top: 2px solid var(--line); border-bottom: 0; }
td .name { font-weight: 700; color: var(--ink); text-decoration: none; }
td .name:hover { color: var(--accent); }
td .small { font-size: .8rem; color: var(--muted); }
tr.row-amarillo td:first-child { box-shadow: inset 4px 0 var(--st-amarillo); }
tr.row-rojo td:first-child { box-shadow: inset 4px 0 var(--st-rojo); }
tr.row-celeste td:first-child { box-shadow: inset 4px 0 var(--st-celeste); }
tr.row-gris td:first-child { box-shadow: inset 4px 0 var(--st-gris); }
tr.row-amarillo { background: #fffbec; }
tr.row-rojo { background: #fff6f5; }
tr.row-celeste { background: #f3fbfe; }
.empty { text-align: center; color: var(--muted); padding: 36px 16px; }

/* Chips de estado */
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px;
  font-size: .78rem; font-weight: 700; white-space: nowrap; }
.chip::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.chip.activo { background: #eaf0fb; color: #2a4f9a; }
.chip.por_finalizar, .chip.amarillo { background: var(--st-amarillo-soft); color: #8a6400; }
.chip.finalizado, .chip.sin_plan, .chip.rojo { background: var(--st-rojo-soft); color: #a3302a; }
.chip.congelado, .chip.celeste { background: var(--st-celeste-soft); color: #176f8f; }
.chip.inactivo, .chip.gris { background: var(--st-gris-soft); color: #4f5b69; }
.chip.verde { background: var(--st-verde-soft); color: #20703f; }
.chip.morado { background: var(--st-morado-soft); color: #5d3498; }

/* Filtros tipo pestaña */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.tabs a { text-decoration: none; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  color: var(--ink-2); background: var(--surface); font-weight: 600; font-size: .86rem; }
.tabs a.is-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs a .n { opacity: .7; margin-left: 4px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar form.search { display: flex; gap: 8px; flex: 1; min-width: 240px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); margin-bottom: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }

/* Métricas */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font-family: var(--font-display); font-size: 1.9rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi .l { font-size: .82rem; color: var(--muted); font-weight: 600; }
.kpi .d { font-size: .78rem; color: var(--ink-2); margin-top: 4px; }
.list-kv { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; font-size: .92rem; }
.list-kv dt { color: var(--ink-2); }
.list-kv dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; text-align: right; }

/* Gráfico de barras */
.chart { display: grid; grid-template-columns: 40px 1fr; gap: 8px; }
.chart-axis { position: relative; height: 220px; font-size: .72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.chart-axis span { position: absolute; right: 0; transform: translateY(50%); }
.chart-plot { position: relative; height: 220px; border-left: 1px solid var(--line); border-bottom: 1px solid #b8c2cf; }
.chart-grid { position: absolute; left: 0; right: 0; border-top: 1px dashed #e6eaf0; }
.chart-bars { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; padding: 0 6px; align-items: end; }
.bar { position: relative; background: #c5d1f5; border-radius: 4px 4px 0 0; min-height: 2px; }
.bar.now { background: var(--accent); }
.bar b { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); font-size: .72rem; padding-bottom: 3px; font-variant-numeric: tabular-nums; color: var(--ink-2); }
.chart-labels { grid-column: 2; display: grid; grid-template-columns: repeat(12, 1fr); gap: 8px; padding: 6px 6px 0; font-size: .72rem; color: var(--muted); text-align: center; }
.chart-wrap { overflow-x: auto; padding-top: 12px; }
.chart-bars { gap: 6px; padding: 0 4px; }
.chart-labels { gap: 6px; padding: 6px 4px 0; }
@media (max-width: 600px) { .chart-wrap > .chart { min-width: 520px; } }

/* Resumen de sesiones (cliente) */
.big-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; text-align: center; }
.big-stats div { background: var(--bg); border-radius: 8px; padding: 12px 6px; }
.big-stats b { display: block; font-family: var(--font-display); font-size: 1.8rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.big-stats span { font-size: .8rem; color: var(--muted); font-weight: 600; }
.progress { height: 8px; border-radius: 4px; background: var(--bg); overflow: hidden; margin-top: 14px; }
.progress i { display: block; height: 100%; background: var(--accent); }
.progress.warn i { background: var(--st-amarillo); }

/* Navegación por mes */
.month-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.month-nav strong { font-family: var(--font-display); font-size: 1.05rem; }

/* Acordeón de sesiones */
details.group { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
details.group + details.group { margin-top: 8px; }
details.group summary { cursor: pointer; padding: 12px 14px; display: flex; justify-content: space-between; gap: 10px; font-weight: 700; list-style: none; }
details.group summary::-webkit-details-marker { display: none; }
details.group summary::after { content: '▾'; color: var(--muted); }
details.group[open] summary::after { content: '▴'; }
details.group ul { margin: 0; padding: 0 14px 12px; list-style: none; }
details.group li { padding: 8px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; font-size: .9rem; font-variant-numeric: tabular-nums; }

/* Pantallas de cliente y entrenador */
.hello { background: var(--ink); color: #fff; padding: 26px 16px 30px; }
.hello-in { max-width: 560px; margin: 0 auto; }
.hello .eyebrow { font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; color: #9fb0c8; font-weight: 700; }
.hello h1 { margin-top: 4px; }
.hello .period { margin-top: 10px; display: inline-block; background: rgba(255,255,255,.1); padding: 5px 10px; border-radius: 6px; font-weight: 600; font-size: .9rem; }
.cta-block { margin-top: -20px; }
.warn-band { background: var(--st-amarillo); color: #3d2e00; font-weight: 800; text-align: center; padding: 8px; border-radius: 8px; margin-bottom: 14px; letter-spacing: .02em; }
.finished { background: var(--st-naranjo); color: #fff; border-radius: var(--radius); padding: 30px 20px; text-align: center; }
.finished h2 { font-size: 1.5rem; font-weight: 800; color: #fff; }
.finished p { margin-top: 8px; opacity: .95; }
.finished .btn { margin-top: 18px; background: #1f8a4c; }
.frozen { background: var(--st-celeste-soft); color: #145f7a; border-radius: var(--radius); padding: 22px 20px; text-align: center; }
.frozen h2 { color: #145f7a; }

/* QR del cliente */
.focus-head { background: var(--ink); color: #fff; padding: 16px; text-align: center; }
.focus-head h1 { font-size: 1.15rem; letter-spacing: .04em; text-transform: uppercase; }
.qr-box { text-align: center; }
.qr-img { width: min(300px, 100%); aspect-ratio: 1; margin: 0 auto; background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--line); }
.qr-img svg { width: 100%; height: 100%; display: block; }
.qr-code { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; letter-spacing: .25em; margin-top: 12px; }
.ring { position: relative; width: 74px; height: 74px; margin: 14px auto 4px; }
.ring svg { transform: rotate(-90deg); }
.ring b { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-display); font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.state-msg { font-weight: 700; margin-top: 10px; }
.state-msg.ok { color: #1d6a3d; }
.done-badge { width: 76px; height: 76px; border-radius: 50%; background: #e1f4e8; color: #1d8a4c; display: grid; place-items: center; margin: 6px auto 12px; font-size: 2.4rem; }

/* Escáner del entrenador */
.scan-view { width: 100%; max-width: 420px; margin: 0 auto; border-radius: 12px; overflow: hidden; background: #0d1622; aspect-ratio: 1; position: relative; }
.scan-view video { width: 100% !important; height: 100% !important; object-fit: cover; }
#reader { width: 100%; height: 100%; }
#reader img[alt="Info icon"], #reader__dashboard_section_csr span:first-child { display: none !important; }
.scan-placeholder { position: absolute; inset: 0; display: grid; place-items: center; color: #9fb0c8; text-align: center; padding: 20px; }
.result { border-radius: var(--radius); padding: 20px; text-align: center; }
.result.ok { background: #e1f4e8; color: #1d6a3d; }
.result.error { background: var(--danger-soft); color: #962620; }
.result h2 { color: inherit; }
.code-entry { display: flex; gap: 8px; }
.code-entry input { font-family: var(--font-mono); text-transform: uppercase; letter-spacing: .2em; text-align: center; font-size: 1.1rem; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; margin: 18px 0; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }

/* Ficha */
.profile { display: flex; gap: 14px; align-items: center; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; font-family: var(--font-display); font-weight: 800; flex: none; }
.profile .lines { font-size: .9rem; color: var(--ink-2); min-width: 0; overflow-wrap: anywhere; }

/* Alertas */
.alert-item { display: grid; grid-template-columns: 6px 1fr auto; gap: 14px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 14px 0; overflow: hidden; }
.alert-item + .alert-item { margin-top: 10px; }
.alert-item .stripe { align-self: stretch; margin: -14px 0; }
.stripe.gris { background: var(--st-gris); } .stripe.morado { background: var(--st-morado); }
.stripe.verde { background: var(--st-verde); } .stripe.amarillo { background: var(--st-amarillo); } .stripe.rojo { background: var(--st-rojo); }
.alert-item .what { font-size: .85rem; color: var(--ink-2); margin-top: 3px; }
.alert-item .acts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.alert-sum { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 16px; }
.alert-sum a { text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; border-top-width: 4px; }
.alert-sum a.is-active { box-shadow: 0 0 0 2px var(--ink) inset; }
.alert-sum a b { display: block; font-family: var(--font-display); font-size: 1.6rem; font-variant-numeric: tabular-nums; }
.alert-sum a span { font-size: .8rem; color: var(--ink-2); font-weight: 600; }
.alert-sum .gris { border-top-color: var(--st-gris); } .alert-sum .morado { border-top-color: var(--st-morado); }
.alert-sum .verde { border-top-color: var(--st-verde); } .alert-sum .amarillo { border-top-color: var(--st-amarillo); } .alert-sum .rojo { border-top-color: var(--st-rojo); }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-side { background: var(--ink); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; position: relative; overflow: hidden; }
.auth-side .brand { font-size: 1.3rem; }
.auth-side h2 { font-size: 2.2rem; font-weight: 800; max-width: 14ch; line-height: 1.08; color: #fff; }
.auth-side p { color: #b6c3d6; max-width: 38ch; margin-top: 14px; }
.auth-side .pattern { position: absolute; right: -60px; bottom: -60px; opacity: .14; width: 360px; }
.auth-main { display: grid; place-items: center; padding: 32px 16px; background: var(--surface); }
.auth-card { width: 100%; max-width: 380px; }
.auth-card h1 { margin-bottom: 6px; }
.auth-card .sub { color: var(--muted); margin-bottom: 22px; }
.auth-foot { margin-top: 16px; text-align: center; font-size: .9rem; }

.footer { text-align: center; color: var(--muted); font-size: .78rem; padding: 24px 16px 32px; }

/* Modal de confirmación */
dialog { border: 0; border-radius: 12px; padding: 22px; max-width: 420px; width: calc(100% - 32px); box-shadow: 0 20px 50px rgba(20,32,51,.25); }
dialog::backdrop { background: rgba(20,32,51,.45); }
dialog h2 { margin-bottom: 8px; }
dialog .btn-row { margin-top: 18px; justify-content: flex-end; }

@media (max-width: 860px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-side { padding: 28px 20px; min-height: auto; }
  .auth-side h2 { font-size: 1.6rem; margin-top: 18px; }
  .auth-side .pattern, .auth-side .foot { display: none; }
  .nav-toggle { display: inline-flex; margin-left: auto; background: transparent; color: #fff; border: 1px solid rgba(255,255,255,.22); border-radius: 8px; padding: 7px 10px; font: inherit; font-weight: 600; }
  .nav { display: none; order: 3; flex-basis: 100%; flex-direction: column; padding-bottom: 10px; }
  .topbar.open .nav { display: flex; }
  .menu { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .alert-item { grid-template-columns: 6px 1fr; }
  .alert-item .acts { grid-column: 2; justify-content: flex-start; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
