:root {
  --bg: #F4F8F7;
  --surface: #FFFFFF;
  --ink: #1E3A3F;
  --muted: #5B7074;
  --line: #DCE7E4;
  --primary: #2F7A78;
  --primary-ink: #FFFFFF;
  --primary-soft: #E3F1EE;
  --blue: #3C6E91;
  --blue-soft: #E6EFF6;
  --ok: #2F7A55;      --ok-soft: #E4F3EA;
  --warn: #8A5D0E;    --warn-soft: #FBF2DF;
  --alert: #A23B3B;   --alert-soft: #FBE9E7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(30, 58, 63, .06), 0 8px 24px rgba(30, 58, 63, .06);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.5 "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--primary); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.2rem; font-weight: 800; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }

/* Barra superior */
.topbar {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.topbar-inner {
  max-width: 1100px; margin: 0 auto; padding: .75rem 1rem;
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: .5rem; font-weight: 800; color: var(--ink); text-decoration: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #8CC7BF, var(--primary));
}
.nav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.nav a {
  padding: .45rem .8rem; border-radius: 999px; text-decoration: none;
  color: var(--muted); font-weight: 700;
}
.nav a.on, .nav a:hover { background: var(--primary-soft); color: var(--primary); }
.user { display: flex; align-items: center; gap: .75rem; margin-left: auto; }
.user form { margin: 0; }

.page { max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

/* Tarjetas y rejillas */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem; box-shadow: var(--shadow); }
.card + .card { margin-top: 1rem; }
.grid > .card + .card, .semana > .card + .card { margin-top: 0; }
.grid { display: grid; gap: 1rem; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.stat .num { font-size: 2rem; font-weight: 800; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-weight: 700; font-size: .9rem; }

/* Tablas */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .7rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }

/* Etiquetas de estado */
.tag { display: inline-block; padding: .15rem .6rem; border-radius: 999px; font-size: .8rem; font-weight: 800; white-space: nowrap; }
.tag-activa { background: var(--ok-soft); color: var(--ok); }
.tag-vencida, .tag-agotada { background: var(--alert-soft); color: var(--alert); }
.tag-pendiente_pago { background: var(--warn-soft); color: var(--warn); }
.tag-cancelada, .tag-inactivo, .tag-sin, .tag-trasladada { background: #EEF2F1; color: var(--muted); }
.tag-programada, .tag-en_revision { background: var(--blue-soft); color: var(--blue); }
.tag-sincobro { background: #EFE9F7; color: #5E4B8B; }
.check-select { align-items: center; flex-wrap: wrap; }
.check-select select { width: auto; flex: 1; min-width: 140px; }
.check-destacada { background: var(--primary-soft); border-radius: 12px; padding: .6rem .75rem; }
.tag-aprobado { background: var(--ok-soft); color: var(--ok); }
.tag-rechazado { background: var(--alert-soft); color: var(--alert); }
.badge { display: inline-block; min-width: 1.4em; padding: 0 .4em; border-radius: 999px; background: var(--alert); color: #FFFFFF; font-size: .75rem; line-height: 1.4em; text-align: center; }

/* Pestañas */
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: .45rem .9rem; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 700; background: var(--surface); border: 1px solid var(--line); }
.tabs a.on { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

.card-destacada { border-color: #BFD9D4; background: #F7FBFA; }
.card-sub { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.stat-link { text-decoration: none; color: inherit; }
.stat-alerta { border-color: #F0C9C4; background: #FFF8F7; }
.stat-alerta .num { color: var(--alert); }
.comprobante { max-width: 100%; max-height: 520px; border-radius: 12px; border: 1px solid var(--line); display: block; margin-bottom: .5rem; }

/* Opciones seleccionables (planes y medios de pago) */
.check { display: flex; align-items: flex-start; gap: .5rem; font-weight: 600; margin: .35rem 0; }
.check input { width: auto; margin-top: .3rem; flex: none; }
.opciones { display: grid; gap: .5rem; }
.opciones-planes { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.opcion { display: flex; gap: .75rem; align-items: flex-start; padding: .85rem; border: 1px solid var(--line); border-radius: 14px; background: #FBFDFC; cursor: pointer; font-weight: 400; margin: 0; }
.opcion input { width: auto; margin-top: .25rem; accent-color: var(--primary); }
.opcion > span { display: flex; flex-direction: column; gap: .15rem; }
.opcion:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 0 0 1px var(--primary) inset; }
.semana { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.dia { align-self: start; padding: 1rem; }
.dia h2 { font-size: 1rem; }
.dia-pasado { opacity: .6; }
.dia-hoy { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary) inset, var(--shadow); }
.dia-hoy-titulo { color: var(--primary); }
.clase-item { display: flex; align-items: center; gap: .75rem; padding: .6rem .5rem; border-radius: 12px; text-decoration: none; color: inherit; border-bottom: 1px solid var(--line); }
a.clase-item:hover { background: var(--primary-soft); }
.clase-item:last-child { border-bottom: 0; }
.clase-hora { font-weight: 800; min-width: 5.2rem; }
.clase-info { flex: 1; }
.clase-cancelada { opacity: .6; }
.clase-cancelada .clase-hora { text-decoration: line-through; }
.clase-fija form { margin: 0; }
.cupos { font-weight: 800; font-size: .85rem; padding: .1rem .5rem; border-radius: 999px; background: var(--ok-soft); color: var(--ok); }
.cupos-llena { background: var(--alert-soft); color: var(--alert); }
.slots { display: grid; gap: .5rem; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); margin-top: .5rem; }
.slot { display: flex; justify-content: space-between; align-items: center; gap: .5rem; padding: .75rem; border: 1px solid var(--line); border-radius: 14px; background: #FBFDFC; }
.slot form { display: flex; align-items: center; gap: .5rem; margin: 0; }
.slot-mia { border-color: var(--primary); background: var(--primary-soft); }
.slot-off { opacity: .55; }
.pill-saldo { background: var(--primary-soft); color: var(--primary); font-weight: 800; padding: .4rem .9rem; border-radius: 999px; }
.fila-inactiva td { opacity: .55; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: 0; }
.inline-form select { width: auto; flex: 1; min-width: 140px; }
.input-corto { max-width: 110px; }
.big-num-sm { font-size: 1.3rem; font-weight: 800; color: var(--primary); }

/* Botones y formularios */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
  padding: .6rem 1.1rem; border-radius: 999px; border: 1px solid transparent;
  font: inherit; font-weight: 800; cursor: pointer; text-decoration: none;
  background: var(--primary); color: var(--primary-ink);
}
.btn:hover { filter: brightness(.95); }
.btn-ghost { background: transparent; color: var(--primary); border-color: var(--line); }
.btn-danger { background: transparent; color: var(--alert); border-color: #F0C9C4; }
.btn-cancelar { background: var(--alert-soft); color: var(--alert); border-color: #E7B7B1; }
.btn-cancelar:hover { background: #F6D9D5; filter: none; }
.btn-cambiar { background: var(--blue-soft); color: var(--blue); border-color: #BCD2E5; }
.btn-cambiar:hover { background: #D8E6F2; filter: none; }
.reserva-item { padding: .85rem 0; border-bottom: 1px solid var(--line); }
.reserva-item:last-child { border-bottom: 0; }
.reserva-datos { display: flex; gap: .75rem; align-items: baseline; flex-wrap: wrap; }
.reserva-plazos { margin: .35rem 0 .5rem; }
.slot form, form.slot { margin: 0; }
/* Próxima clase destacada */
.proxima { background: var(--primary-soft); border-color: #BFD9D4; }
.proxima p { margin: 0; }
.proxima-eyebrow { font-size: .8rem; font-weight: 800; color: var(--primary); text-transform: uppercase; letter-spacing: .04em; }
.proxima-cuando { font-size: 1.35rem; font-weight: 800; margin: .15rem 0 !important; }
.proxima-detalle { color: var(--muted); }
.proxima-plazos { font-size: .85rem; color: var(--muted); margin: .6rem 0 .75rem !important; }
.proxima .actions form { margin: 0; }
.proxima-mas { margin-top: .75rem !important; font-weight: 700; font-size: .9rem; }

/* Calendario del cliente */
.reservar-layout { display: grid; gap: 1rem; grid-template-columns: minmax(0, 1fr); margin-top: 1rem; }
@media (min-width: 900px) { .reservar-layout { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } }
.reservar-layout > .card + .card { margin-top: 0; }
.cal-cabecera { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; font-size: 1.05rem; }
.cal-nav { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; text-decoration: none; font-size: 1.4rem; color: var(--primary); border: 1px solid var(--line); }
.cal-nav-off { color: var(--line); }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
.cal-dow { font-size: .75rem; font-weight: 800; color: var(--muted); padding-bottom: .25rem; }
.cal-dia { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 52px; border-radius: 12px; text-decoration: none; color: var(--ink); border: 1px solid transparent; }
a.cal-dia { background: #FBFDFC; border-color: var(--line); }
a.cal-dia:hover { border-color: var(--primary); }
.cal-num { font-weight: 800; font-size: .95rem; }
.cal-libres { font-size: .75rem; font-weight: 800; color: var(--ok); }
.cal-lleno { color: var(--alert); }
.cal-sinplan { color: var(--muted); }
.cal-mia { color: var(--primary); font-size: .8rem; }
.cal-off { color: #B7C4C1; }
.cal-fuera { opacity: .45; }
.cal-hoy { border-color: var(--blue) !important; }
.cal-elegido { background: var(--primary) !important; border-color: var(--primary) !important; color: #FFFFFF; }
.cal-elegido .cal-libres, .cal-elegido .cal-mia { color: #FFFFFF; }
.cal-leyenda { margin-top: .6rem; }
.chips { display: flex; gap: .35rem; flex-wrap: wrap; margin-bottom: .75rem; }
.chip { padding: .3rem .8rem; border-radius: 999px; border: 1px solid var(--line); text-decoration: none; color: var(--muted); font-weight: 700; font-size: .85rem; background: var(--surface); }
.chip.on { background: var(--primary); border-color: var(--primary); color: #FFFFFF; }
.dia-clase { display: flex; justify-content: space-between; align-items: center; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--line); }
.dia-clase:last-child { border-bottom: 0; }
.dia-clase form { margin: 0; }
.dia-clase-mia { background: var(--primary-soft); margin: 0 -.5rem; padding: .75rem .5rem; border-radius: 12px; }
.dia-clase-off { opacity: .55; }
/* Agenda semanal del administrador */
.resumen-semana { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.resumen-semana .num { font-size: 1.6rem; }
.tabla-semana { table-layout: fixed; min-width: 640px; }
.tabla-semana th, .tabla-semana td { padding: 3px; border-bottom: 0; text-align: center; }
.tabla-semana th { text-transform: none; letter-spacing: 0; font-size: .85rem; color: var(--ink); }
.tabla-semana .th-hora { width: 78px; text-align: right; padding-right: .5rem; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.th-hoy { color: var(--primary) !important; }
.th-pasado, .td-pasado { opacity: .5; }
.celda { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 46px; border-radius: 10px; text-decoration: none; font-size: .78rem; line-height: 1.2; border: 1px solid transparent; }
.celda b { font-size: .9rem; }
.celda:hover { border-color: var(--ink); }
.c-parcial { background: var(--ok-soft); color: var(--ok); }
.c-llena { background: var(--alert-soft); color: var(--alert); }
.c-vacia { background: #F1F4F3; color: var(--muted); }
.c-cancelada { background: #F1F4F3; color: var(--muted); text-decoration: line-through; }
.celda-vacia { color: var(--line); }
.celda.mini { display: inline-block; min-height: 0; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-left: .6rem; }
.leyenda { margin: .75rem 0 0; }
.agenda-lista { display: none; }
@media (max-width: 720px) {
  .agenda-grid { display: none; }
  .agenda-lista { display: grid; gap: 1rem; margin-top: 1rem; }
  .agenda-lista > .card + .card { margin-top: 0; }
}
/* Informes */
.rango-form { margin: .75rem 0 1rem; max-width: 560px; }
.kpis { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.kpis .num { font-size: 1.5rem; }
.kpis-chicos { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .75rem; }
.kpis-chicos .stat { background: var(--bg); border-radius: 12px; padding: .75rem; }
.kpis-chicos .num { font-size: 1.4rem; }
.subtitulo { font-size: 1rem; margin-top: 1.25rem; }
.barra { height: 10px; background: #EEF3F2; border-radius: 999px; overflow: hidden; }
.barra > span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.barra-azul > span { background: var(--blue); }
.fila-barra { margin: .6rem 0; }
.fila-barra-txt { display: flex; justify-content: space-between; gap: .5rem; font-size: .9rem; margin-bottom: .25rem; }
.fila-barra-txt span { color: var(--muted); white-space: nowrap; }
.barras-mes { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: .5rem; align-items: end; height: 220px; margin-top: .5rem; }
.barra-mes { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: .25rem; text-align: center; }
.monto-mes { font-size: .72rem; white-space: nowrap; min-height: 1.1em; }
.mes-etiqueta { white-space: nowrap; font-size: .8rem; }
.columna { width: 100%; max-width: 48px; flex: 1; display: flex; align-items: flex-end; background: #F4F8F7; border-radius: 8px; }
.columna > span { display: block; width: 100%; background: var(--primary); border-radius: 8px; min-height: 2px; }
.calor { table-layout: fixed; min-width: 420px; }
.calor th, .calor td { padding: 3px; border-bottom: 0; text-align: center; text-transform: none; letter-spacing: 0; font-size: .85rem; }
.calor .th-hora { width: 78px; text-align: right; color: var(--muted); font-size: .8rem; white-space: nowrap; }
.calor-celda { display: block; border-radius: 8px; padding: .45rem 0; font-weight: 800; font-size: .8rem; }
.btn-sm { padding: .35rem .8rem; font-size: .875rem; }
.btn-block { width: 100%; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }

label { display: block; font-weight: 700; font-size: .9rem; margin-bottom: .3rem; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--ink); background: #FBFDFC;
  border: 1px solid var(--line); border-radius: 12px; padding: .6rem .75rem;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-soft); border-color: var(--primary); }
.field { margin-bottom: .9rem; }
.form-row { display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); align-items: end; }
.hint { color: var(--muted); font-size: .85rem; margin-top: .25rem; }

/* Mensajes */
.flash, .aviso { border-radius: 12px; padding: .75rem 1rem; margin-bottom: .75rem; font-weight: 700; }
.flash-ok { background: var(--ok-soft); color: var(--ok); }
.flash-alerta, .aviso-alerta { background: var(--alert-soft); color: var(--alert); }
.aviso-aviso { background: var(--warn-soft); color: var(--warn); }
.aviso-info, .flash-info { background: var(--blue-soft); color: var(--blue); }
.preview-bar { background: var(--blue-soft); color: var(--blue); font-weight: 800; text-align: center; padding: .5rem 1rem; }

/* Vista del cliente */
.hero-plan { background: linear-gradient(135deg, #E3F1EE, #E6EFF6); border: 0; }
.plan-name { font-size: 1.5rem; font-weight: 800; }
.big-num { font-size: 3rem; font-weight: 800; line-height: 1; color: var(--primary); }
.progress { height: 12px; background: #FFFFFF; border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress > span { display: block; height: 100%; background: linear-gradient(90deg, #8CC7BF, var(--primary)); border-radius: 999px; }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem; margin-top: 1rem; }
.kv div { background: rgba(255, 255, 255, .7); border-radius: 12px; padding: .75rem; }
.kv b { display: block; font-size: 1.1rem; }

/* Ingreso */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem;
  background: radial-gradient(circle at 20% 10%, #DDEFEA 0, transparent 45%),
              radial-gradient(circle at 90% 90%, #E1ECF5 0, transparent 45%), var(--bg); }
.login-card { width: 100%; max-width: 420px; text-align: center; padding: 2rem 1.5rem; }
.login-card .brand-mark { width: 56px; height: 56px; margin: 0 auto 1rem; }
.btn-google { background: #FFFFFF; color: var(--ink); border-color: var(--line); width: 100%; padding: .8rem; }
.btn-google svg { width: 20px; height: 20px; }
.divider { display: flex; align-items: center; gap: .75rem; color: var(--muted); font-size: .85rem; margin: 1.25rem 0; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }

.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }

@media (max-width: 640px) {
  h1 { font-size: 1.35rem; }
  .user .who { display: none; }
  .topbar-inner { gap: .5rem; }
  .nav { order: 3; flex: 1 1 100%; flex-wrap: nowrap; overflow-x: auto; margin: 0 -.25rem; }
  .nav a { white-space: nowrap; }
  .hide-sm { display: none; }
}
