/* ===== Paleta lila + azul, escala de espacios y escala tipográfica ===== */
:root {
  --lila-800: #4e3699;
  --lila-700: #6b4fc7;
  --lila-500: #9b7fe6;
  --lila-300: #c9b8f5;
  --lila-100: #f3eeff;
  --azul-800: #1f458f;
  --azul-700: #2f5fd0;
  --azul-500: #4a7bf7;
  --azul-300: #a9c2ff;
  --azul-100: #e6efff;
  --ink: #2b2550;
  --muted: #6e6890;        /* 5.19:1 sobre blanco */
  --muted-2: #6a6489;      /* texto deshabilitado / apagado: 5.53:1 sobre blanco */
  --placeholder: #6a6489;  /* marcador de campo: 5.53:1 sobre blanco */
  --line: #e4dcfa;
  --line-2: #d9d4e4;       /* borde punteado de horas no disponibles */
  --surface: #ffffff;
  --bg: #f6f4fb;
  --off-bg: #faf9fc;
  --taken: #ece8f6;
  --stripe: rgba(106, 100, 137, .09);
  --track: #ddd6ee;
  --danger: #d6456b;
  --danger-100: #fde8ee;
  --danger-700: #bd3159;
  --danger-800: #a32550;   /* 6.11:1 sobre --danger-100 */
  --warn-100: #fff4dc;
  --warn-800: #8a5a00;     /* 5.43:1 sobre --warn-100 */
  --warn-300: #f1d9a3;
  --wa-100: #e7f8ee;
  --wa-800: #0f7a41;       /* 4.91:1 sobre --wa-100 */
  --ok: #1f9d77;
  --shadow: 0 1px 2px rgba(43, 37, 80, .06);
  --shadow-pop: 0 16px 40px -12px rgba(43, 37, 80, .35);
  --radius: 14px;

  /* Escala de espacios */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;

  /* Escala tipográfica */
  --fs-xs: .8rem;
  --fs-sm: .9rem;
  --fs-md: 1rem;
  --fs-lg: 1.125rem;
  --fs-xl: 1.375rem;
  --fs-2xl: 1.75rem;

  font-family: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  line-height: 1.45;
  accent-color: var(--lila-700);
  caret-color: var(--lila-700);
}
::selection { background: var(--lila-300); color: var(--ink); }
::placeholder { color: var(--placeholder); opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
h1, h2, h3 { margin: 0; line-height: 1.2; }
button, input, select { font: inherit; color: inherit; }
svg { width: 1.2em; height: 1.2em; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
code { font-family: ui-monospace, 'Cascadia Code', Consolas, monospace; }
:focus-visible { outline: 2px solid var(--azul-700); outline-offset: 2px; }
[hidden] { display: none !important; }

.muted { color: var(--muted); margin: 0; }
.small { font-size: var(--fs-sm); }

/* ===== Estructura ===== */
.demo-banner {
  background: var(--lila-100);
  border-bottom: 1px solid var(--line);
  color: var(--lila-800);
  font-size: var(--fs-sm);
  padding: var(--s2) var(--s4);
  text-align: center;
}
.demo-banner code { background: #fff; border-radius: 6px; padding: 1px var(--s2); font-weight: 700; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3);
  max-width: 1160px; margin: 0 auto; padding: var(--s4);
}
.brand { display: flex; align-items: center; gap: var(--s3); text-decoration: none; color: inherit; }
.brand__logo {
  display: grid; place-items: center;
  width: 44px; height: 44px; border-radius: 14px;
  background: var(--lila-700); color: #fff;
}
.brand__logo svg { width: 26px; height: 26px; }
.brand__text { display: flex; flex-direction: column; }
.brand__text strong { font-size: var(--fs-lg); font-weight: 700; }
.brand__text small { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); }
.topbar__actions { display: flex; align-items: center; gap: var(--s2); }
.who { color: var(--muted); font-size: var(--fs-sm); max-width: 180px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.container { max-width: 1160px; margin: 0 auto; padding: 0 var(--s4) 48px; display: grid; gap: var(--s5); }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s5);
  min-width: 0;
}
.card__title { display: flex; align-items: center; gap: var(--s2); font-size: var(--fs-lg); margin-bottom: var(--s4); }
.card__title svg { color: var(--lila-700); }

.loading { display: flex; align-items: center; justify-content: center; gap: var(--s2); padding: 60px 0; color: var(--muted); }
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid var(--lila-300); border-top-color: var(--azul-500);
  animation: spin .8s linear infinite; display: inline-block; margin-right: var(--s1); vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty {
  text-align: center; color: var(--muted);
  padding: var(--s5) var(--s3); border: 2px dashed var(--line); border-radius: 14px; background: #fff;
}
.empty--pending {
  display: grid; justify-items: center; gap: var(--s3);
  padding: var(--s6) var(--s4); color: var(--ink);
}
.empty--pending svg { width: 40px; height: 40px; color: var(--lila-700); }
.empty--pending p { margin: 0; max-width: 36ch; font-size: var(--fs-md); font-weight: 600; text-wrap: balance; }
.note { background: var(--azul-100); color: var(--azul-800); border-radius: 12px; padding: var(--s2) var(--s3); font-size: var(--fs-sm); margin: 0; }

/* Avisos en línea */
.notice {
  display: flex; align-items: flex-start; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s4); border-radius: 14px; border: 1px solid transparent;
  font-size: var(--fs-sm); font-weight: 600;
}
.notice > svg { margin-top: 2px; }
.notice p { margin: 0; flex: 1 1 200px; min-width: 0; }
.notice--warn { background: var(--warn-100); color: var(--warn-800); border-color: var(--warn-300); }
.notice--info { background: var(--azul-100); color: var(--azul-800); border-color: var(--azul-300); }
.notice--danger { background: var(--danger-100); color: var(--danger-800); border-color: #f4b6c8; }

/* ===== Botones ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: var(--s3) var(--s4); border-radius: 12px;
  border: 1px solid transparent; font-weight: 700; cursor: pointer;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  text-decoration: none; white-space: nowrap;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: progress; }
.btn--primary { background: var(--lila-700); color: #fff; }
.btn--primary:hover:not(:disabled) { background: var(--lila-800); }
.btn--primary:disabled, .btn--danger:disabled { background: var(--muted-2); color: #fff; }
.btn--ghost { background: #fff; border-color: var(--line); color: var(--lila-800); }
.btn--ghost:hover:not(:disabled) { background: var(--lila-100); border-color: var(--lila-300); }
.btn--ghost:disabled { color: var(--muted-2); background: var(--off-bg); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--danger:hover:not(:disabled) { background: var(--danger-700); }
.btn--ghost-danger { background: #fff; border-color: #f0b4c6; color: var(--danger-800); }
.btn--ghost-danger:hover:not(:disabled) { background: var(--danger-100); border-color: var(--danger); }
.btn--ghost-danger:disabled { color: var(--muted-2); background: var(--off-bg); border-color: var(--line); }
.accounts { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.account {
  width: 100%; display: flex; align-items: center; gap: var(--s3); padding: var(--s3); min-height: 52px;
  border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font-weight: 700; text-align: left;
}
.account:hover { background: var(--lila-100); border-color: var(--lila-300); }
.account span:last-child { overflow: hidden; text-overflow: ellipsis; }
.btn--block { width: 100%; }
.btn--lg { min-height: 52px; font-size: var(--fs-md); }
.btn--sm { min-height: 36px; padding: var(--s1) var(--s3); font-size: var(--fs-sm); border-radius: 10px; }
.btn--sm svg { width: 1em; height: 1em; }
.link-btn {
  background: none; border: 0; padding: var(--s1) 2px; cursor: pointer;
  color: var(--azul-700); font-weight: 700; text-decoration: none; font-size: var(--fs-sm);
}
.link-btn:hover { text-decoration: underline; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--lila-800);
  font-size: var(--fs-xl); line-height: 1; cursor: pointer; display: grid; place-items: center; padding-bottom: 3px;
}
.icon-btn:hover:not(:disabled) { background: var(--lila-100); }
.icon-btn:disabled { color: var(--muted-2); background: var(--off-bg); cursor: not-allowed; }

/* ===== Formularios ===== */
.form { display: grid; gap: var(--s4); }
.form__row { display: grid; grid-template-columns: 1fr 140px; gap: var(--s3); }
.form--inline { grid-template-columns: 1.3fr 1.3fr 140px auto; align-items: end; }
.field { display: grid; gap: var(--s1); margin: 0; border: 0; padding: 0; min-width: 0; }
.field > span, .field > legend { font-weight: 600; font-size: var(--fs-sm); padding: 0; }
.field input, .field select, .search {
  width: 100%; min-height: 46px; padding: var(--s3) var(--s4);
  border: 1px solid var(--line); border-radius: 12px; background: #fff;
  transition: border-color .12s, box-shadow .12s, background .12s;
}
.field input:focus, .field select:focus, .search:focus {
  outline: none; border-color: var(--lila-500); background: #fff; box-shadow: 0 0 0 4px var(--lila-100);
}
.field input[aria-invalid="true"], .field select[aria-invalid="true"], .search[aria-invalid="true"] {
  border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-100);
}
.field input[aria-invalid="true"]:focus, .field select[aria-invalid="true"]:focus {
  border-color: var(--danger); box-shadow: 0 0 0 4px var(--danger-100);
}
.field input[readonly] { background: var(--lila-100); color: var(--muted); cursor: default; }
.input--code {
  text-align: center; font-size: var(--fs-xl) !important; font-weight: 700; letter-spacing: .25em; text-transform: uppercase;
}
.input--code::placeholder {
  letter-spacing: 0; text-transform: none; font-size: var(--fs-md); font-weight: 600; color: var(--placeholder);
}
.form__error {
  margin: 0; background: var(--danger-100); color: var(--danger-800); border: 1px solid #f4b6c8;
  border-radius: 10px; padding: var(--s3); font-weight: 700; font-size: var(--fs-sm);
}
.form__error:empty { display: none; }

/* ===== Ingreso ===== */
.auth { max-width: 440px; width: 100%; margin: var(--s6) auto 0; text-align: center; display: grid; gap: var(--s3); padding: var(--s5); }
.auth .form { text-align: left; margin-top: var(--s1); }
.auth h1 { font-size: var(--fs-xl); font-weight: 700; }
.auth__icon {
  width: 64px; height: 64px; margin: 0 auto var(--s1); border-radius: 20px;
  display: grid; place-items: center; background: var(--lila-100); color: var(--lila-700);
}
.auth__icon svg { width: 32px; height: 32px; }
.auth__icon--wave { background: var(--lila-700); color: #fff; }
.auth__nocode { margin: 0; font-size: var(--fs-sm); color: var(--muted); }
.auth__nocode a { color: var(--azul-700); font-weight: 700; text-decoration: none; }
.auth__nocode a:hover { text-decoration: underline; }
.steps { list-style: none; padding: 0; margin: var(--s2) 0 0; display: grid; gap: var(--s2); text-align: left; }
.steps li { display: flex; align-items: center; gap: var(--s3); color: var(--muted); font-size: var(--fs-sm); }
.steps b {
  width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--azul-100); color: var(--azul-700); font-size: var(--fs-xs);
}

/* ===== Encabezado del estudiante ===== */
.hello {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4); flex-wrap: wrap;
  padding: var(--s2) var(--s1) 0;
}
.hello h1 { font-size: var(--fs-2xl); font-weight: 700; }
.hello p { margin: var(--s1) 0 0; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--lila-100); border: 1px solid var(--lila-300); color: var(--lila-700);
  font-size: var(--fs-xl); font-weight: 700; text-transform: uppercase;
}
.avatar--sm { width: 40px; height: 40px; font-size: var(--fs-md); }
.quota {
  display: flex; align-items: center; gap: var(--s3);
  background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: var(--s3) var(--s4);
}
.quota p { margin: 0; display: flex; flex-direction: column; }
.quota span { font-size: var(--fs-sm); color: var(--muted); }
.pills { display: flex; gap: var(--s2); }
.pill { width: 18px; height: 18px; border-radius: 50%; border: 2px solid var(--lila-300); }
.pill.is-used { background: var(--azul-700); border-color: var(--azul-700); }

/* ===== Navegación de semanas y leyenda ===== */
.weeknav { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); margin-bottom: var(--s2); }
.weeknav__label { text-align: center; display: flex; flex-direction: column; }
.weeknav__label strong { font-size: var(--fs-xl); font-weight: 700; }
.weeknav__label small { color: var(--lila-700); font-weight: 700; font-size: var(--fs-sm); }
.weeknav__label small .count { margin: 0; vertical-align: middle; }
.help { color: var(--muted); margin: var(--s1) 0 var(--s3); font-size: var(--fs-sm); }
.help b { color: var(--lila-700); }
.count { display: inline-block; margin-left: var(--s2); background: var(--azul-100); color: var(--azul-800); border-radius: 999px; padding: 1px var(--s3); font-weight: 700; font-size: var(--fs-xs); }
.legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); margin-bottom: var(--s4); font-size: var(--fs-sm); color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: var(--s2); }
.legend--compact { gap: var(--s1) var(--s3); margin-bottom: var(--s3); font-size: var(--fs-xs); }
.legend--compact span { gap: var(--s1); white-space: nowrap; }
.dot { width: 14px; height: 14px; border-radius: 5px; display: inline-block; }
.dot--free { background: var(--lila-100); border: 2px solid var(--lila-500); }
.dot--mine { background: var(--azul-700); }
.dot--taken { background: transparent; border: 1px dashed var(--muted-2); }
.dot--blocked { background: repeating-linear-gradient(45deg, var(--stripe) 0 3px, transparent 3px 6px); border: 1px dashed var(--muted-2); }

/* Ayuda plegable */
.help-toggle { margin-bottom: var(--s3); border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.help-toggle summary {
  display: flex; align-items: center; gap: var(--s2); min-height: 44px; padding: 0 var(--s4);
  cursor: pointer; font-weight: 700; font-size: var(--fs-sm); color: var(--lila-800); list-style: none;
}
.help-toggle summary::-webkit-details-marker { display: none; }
.help-toggle summary::before {
  content: ''; width: 8px; height: 8px; flex: none; margin-right: var(--s1);
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor;
  transform: rotate(-45deg); transition: transform .15s ease;
}
.help-toggle[open] summary::before { transform: rotate(45deg); }
.help-toggle > :not(summary) { padding: 0 var(--s4) var(--s3); margin: 0; }

/* ===== Casillas ===== */
.slot {
  width: 100%; min-height: 52px; border-radius: 10px; padding: var(--s1) var(--s2);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  border: 1px solid transparent; cursor: pointer; font-size: var(--fs-sm); font-weight: 700;
  transition: background .15s ease, border-color .15s ease;
  overflow: hidden;
}
.slot:disabled { cursor: default; }
.slot__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot__sub { font-weight: 600; font-size: var(--fs-xs); opacity: .9; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot__reason { font-weight: 600; font-size: var(--fs-xs); line-height: 1.2; color: var(--muted-2); max-width: 100%; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot--free { background: var(--lila-100); border-color: var(--lila-500); color: var(--lila-800); }
.slot--free:hover { background: var(--lila-300); }
.slot--free-full { background: transparent; border: 1px dashed var(--lila-300); color: var(--muted-2); }
.slot--mine, .slot--booked { background: var(--azul-700); color: #fff; }
.slot--mine:hover, .slot--booked:hover { background: var(--azul-800); }
.slot--mine-past, .slot--booked-past { background: var(--azul-100); color: var(--azul-800); }
.slot--taken { background: transparent; border: 1px dashed var(--line-2); color: var(--muted-2); font-weight: 600; }
.slot--blocked { background: repeating-linear-gradient(45deg, var(--stripe) 0 6px, transparent 6px 12px); border: 1px dashed var(--line-2); color: var(--muted-2); font-weight: 600; }
.slot--blocked:not(:disabled):hover { border-color: var(--muted-2); }
.slot--past { background: transparent; color: var(--muted-2); font-weight: 600; }
.grid__hour, .row__time, .agenda__time, .hchip { font-variant-numeric: tabular-nums; }

/* Cuadrícula (escritorio) */
.grid {
  display: grid;
  grid-template-columns: 138px repeat(var(--cols), minmax(0, 1fr));
  gap: var(--s2);
}
.nowline { position: absolute; left: 0; right: 0; height: 2px; background: var(--lila-700); z-index: 2; pointer-events: none; }
.nowline::before {
  content: ''; position: absolute; left: 0; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--lila-700);
}
.row .nowline { left: 146px; } /* no pasa sobre la hora: columna de 136px + 10px de separación */
.grid, .row { position: relative; }
.grid__corner { position: sticky; top: 0; }
.grid__day {
  text-align: center; padding: var(--s2) var(--s1); border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 0;
  position: sticky; top: 0; background: #fff; z-index: 1;
}
.grid__day span { color: var(--muted); font-weight: 700; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .04em; }
.grid__day strong { font-size: var(--fs-xl); font-weight: 700; }
.grid__day .link-btn { font-size: var(--fs-xs); padding: 0; }
.grid__day.is-today span, .grid__day.is-today strong { color: var(--lila-700); }
.grid__hour { display: flex; align-items: center; justify-content: flex-end; padding-right: var(--s2); color: var(--ink); font-weight: 700; font-size: var(--fs-xs); white-space: nowrap; }

/* Lista por día (celular) */
.daylist { display: none; }
.daytabs { display: flex; gap: var(--s2); overflow-x: auto; padding: 2px 2px var(--s3); scroll-snap-type: x mandatory; scrollbar-width: none; }
.daytabs::-webkit-scrollbar { display: none; }
.daytab {
  flex: 1 0 54px; scroll-snap-align: start;
  display: flex; flex-direction: column; align-items: center; padding: var(--s2) var(--s1);
  border-radius: 14px; border: 1px solid var(--line); background: #fff; cursor: pointer; min-height: 60px;
}
.daytab span { font-size: var(--fs-xs); font-weight: 700; color: var(--muted); text-transform: uppercase; }
.daytab strong { font-size: var(--fs-xl); font-weight: 700; }
.daytab.is-today { border-color: var(--lila-300); }
.daytab.is-active { background: var(--lila-700); border-color: transparent; color: #fff; }
.daytab.is-active span { color: rgba(255, 255, 255, .85); }
.daylist__head { display: flex; justify-content: space-between; align-items: center; margin: var(--s1) 0 var(--s3); }
.daylist__head h3 { font-size: var(--fs-md); }
.day-past { margin: 0; padding: var(--s5) var(--s3); text-align: center; color: var(--muted); font-weight: 600; border: 1px dashed var(--line-2); border-radius: 12px; }
.rows { display: grid; gap: var(--s2); }
.row { display: grid; grid-template-columns: 136px 1fr; gap: var(--s3); align-items: center; }
.row__time { font-weight: 700; font-size: var(--fs-sm); white-space: nowrap; }
.row .slot { min-height: 54px; font-size: var(--fs-md); }

@media (max-width: 820px) {
  .grid { display: none; }
  .daylist { display: block; }
}

/* ===== Mis clases ===== */
.mylist { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
.mylist__item { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-radius: 14px; background: var(--azul-100); }
.mylist__item.is-past { background: var(--lila-100); color: var(--muted-2); }
.mylist__item.is-past .mylist__icon { color: var(--muted-2); }
.mylist__icon { width: 42px; height: 42px; border-radius: 10px; background: #fff; color: var(--azul-700); display: grid; place-items: center; flex: none; }
.mylist__info { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.mylist__info span { color: var(--muted-2); font-size: var(--fs-sm); }
.tag { background: #fff; color: var(--muted); border-radius: 999px; padding: 2px var(--s3); font-size: var(--fs-xs); font-weight: 700; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(43, 37, 80, .45);
  display: grid; place-items: center; padding: var(--s4);
  animation: fade .15s ease;
}
.modal {
  position: relative; width: 100%; max-width: 460px; max-height: calc(100vh - 32px); overflow: auto;
  background: #fff; border-radius: 16px; padding: var(--s5); box-shadow: 0 20px 50px -20px rgba(43, 37, 80, .35);
  animation: pop .18s ease;
}
.modal h2 { font-size: var(--fs-xl); font-weight: 700; margin-bottom: var(--s4); padding-right: var(--s6); }
.modal__close {
  position: absolute; top: var(--s3); right: var(--s3); width: 38px; height: 38px; border-radius: 50%;
  border: 0; background: var(--lila-100); color: var(--lila-800); font-size: var(--fs-xl); line-height: 1; cursor: pointer;
}
.modal__body { display: grid; gap: var(--s4); }
.modal__text { margin: 0; color: var(--muted); }
.modal__actions { display: flex; justify-content: flex-end; gap: var(--s3); flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@media (max-width: 520px) {
  .modal-backdrop { place-items: end center; padding: 0; }
  .modal {
    border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh;
    padding-bottom: calc(var(--s5) + env(safe-area-inset-bottom));
  }
  .modal__actions .btn { flex: 1; }
}
.when { display: flex; align-items: center; gap: var(--s3); background: var(--lila-100); border-radius: 14px; padding: var(--s3) var(--s4); }
.when > div:last-child { display: flex; flex-direction: column; }
.when span { color: var(--lila-800); font-weight: 600; }
.when__icon { width: 44px; height: 44px; border-radius: 10px; background: #fff; color: var(--lila-700); display: grid; place-items: center; flex: none; }
.details { margin: 0; display: grid; gap: var(--s2); }
.details > div { display: flex; justify-content: space-between; gap: var(--s3); padding: var(--s2) 0; border-bottom: 1px solid var(--line); }
.details dt { color: var(--muted); display: flex; align-items: center; gap: var(--s2); }
.details dd { margin: 0; font-weight: 700; text-align: right; }

/* ===== Panel del instructor ===== */
.tabs {
  position: relative;
  display: flex; gap: var(--s2); background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: var(--s2);
  overflow-x: auto; box-shadow: var(--shadow); scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  flex: 1; min-height: 44px; border: 0; background: none; border-radius: 12px; cursor: pointer;
  font-weight: 700; color: var(--muted); white-space: nowrap; padding: 0 var(--s3);
}
.tabs button:hover { background: var(--lila-100); color: var(--lila-800); }
.tabs button.is-active { background: var(--lila-100); color: var(--lila-800); }
.tabs__more { display: none; align-items: center; justify-content: center; gap: var(--s1); }
.tabs__more::after {
  content: ''; width: 6px; height: 6px; margin-bottom: 3px;
  border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg);
}
.tabs__more[aria-expanded="true"]::after { transform: rotate(-135deg); margin-bottom: -2px; }
.tabs__menu {
  position: absolute; z-index: 20; top: calc(100% + var(--s1)); right: 0; min-width: 200px;
  display: grid; gap: 2px; padding: var(--s2);
  background: #fff; border: 1px solid var(--line); border-radius: 16px;
  box-shadow: 0 20px 50px -20px rgba(43, 37, 80, .35);
}
.tabs .tabs__menu button { flex: none; width: 100%; min-height: 44px; text-align: left; padding: 0 var(--s4); }

#panel { display: grid; gap: var(--s4); min-width: 0; }
.agenda__head { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-bottom: var(--s2); }
.agenda__head .card__title { margin: 0; }
.agenda__head > .icon-btn { flex: none; margin-left: auto; }
.agenda__day { font-size: var(--fs-md); color: var(--lila-700); margin: var(--s4) 0 var(--s2); }
.agenda { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.agenda li {
  display: grid; grid-template-columns: 160px 1fr auto; gap: var(--s3); align-items: center;
  padding: var(--s3) var(--s4); border-radius: 12px; background: #fff; border: 1px solid var(--line);
}
.agenda__time { font-weight: 700; color: var(--azul-700); }
.agenda__name { font-weight: 700; }
.agenda__place { color: var(--muted); }
.search { max-width: 260px; min-height: 40px; }

.form--student { grid-template-columns: repeat(4, minmax(0, 1fr)); align-items: end; }
.form--student .field--wide { grid-column: span 2; }
.form--student .form__error, .form--student .form__foot, .form--student .kid-fields { grid-column: 1 / -1; }
.form--stack { grid-template-columns: 1fr; }
.form--stack > * { grid-column: 1 / -1 !important; }
.form__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; }
.kid-fields {
  display: grid; grid-template-columns: 120px 1fr; gap: var(--s3);
  background: var(--lila-100); border: 1px solid var(--lila-300); border-radius: 14px; padding: var(--s3) var(--s4);
}
.switch--field { min-height: 46px; padding: var(--s2) var(--s3); border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.switch__text { display: flex; flex-direction: column; line-height: 1.25; }
.switch__text small { color: var(--muted); font-size: var(--fs-xs); }
.badge {
  display: inline-block; vertical-align: 2px; margin-left: var(--s1); padding: 1px var(--s2); border-radius: 999px;
  background: var(--lila-100); color: var(--lila-700); font-size: var(--fs-xs); font-weight: 700;
}
.wa-btn {
  display: inline-flex; align-items: center; gap: var(--s1); margin-left: var(--s2); padding: 2px var(--s3); border-radius: 999px;
  background: var(--wa-100); color: var(--wa-800) !important; font-size: var(--fs-xs); font-weight: 700;
}
.wa-btn:hover { background: #d2f2df; }
#reminder:empty { display: none; }
.reminder {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap;
  padding: var(--s3) var(--s4); border-radius: 14px; background: var(--danger-100); color: var(--danger-800);
}
.reminder p { margin: 0; }
.badge--warn { background: var(--danger-100); color: var(--danger-800); margin-left: 0; }
.far { color: var(--danger-800); font-weight: 700; }
.picker { min-height: 46px; }
.picker gmp-place-autocomplete { width: 100%; color-scheme: light; border: 1px solid var(--line); border-radius: 12px; }
.form--inline-2 { grid-template-columns: 1fr auto; align-items: end; }
@media (max-width: 640px) { .form--inline-2 { grid-template-columns: 1fr; } }
/* Fila compacta: campo de 120 px y botón al lado (en ≤360 px se apilan) */
.form--compact { display: grid; grid-template-columns: 120px auto; gap: var(--s2); align-items: end; justify-content: start; }
.form--compact > :first-child { min-width: 0; width: 100%; }
@media (max-width: 360px) {
  .form--compact { grid-template-columns: 1fr; justify-content: stretch; }
  .form--compact > .btn { width: 100%; }
}
.avatar--kid { background: var(--azul-100); border-color: var(--azul-300); color: var(--azul-700); }
.student__contact { display: inline-flex; align-items: center; gap: var(--s1); flex-wrap: wrap; }
.student__contact svg, .details svg { width: 1em; height: 1em; }
.student a, .details a, .agenda a { color: var(--azul-700); font-weight: 700; text-decoration: none; }
.agenda__name, .agenda__place { display: flex; flex-direction: column; }
.agenda__name small, .agenda__place small { color: var(--muted); font-weight: 600; font-size: var(--fs-xs); }
.agenda__place { align-items: flex-end; text-align: right; }
.agenda__phone { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 2px; }
@media print { .wa-btn { display: none !important; } }
.students { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s2); }
.student {
  display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: start; gap: var(--s1) var(--s3);
  padding: var(--s3); border-radius: 14px; border: 1px solid var(--line);
}
.student.is-off { background: var(--off-bg); }
.student.is-off .student__info > strong, .student.is-off .student__info span { color: var(--muted-2); }
.student__info { grid-column: 2; min-width: 0; display: flex; flex-direction: column; }
.student__info span { color: var(--muted); font-size: var(--fs-sm); }
.student > .code { grid-column: 3; align-self: start; }
.code { background: var(--azul-100); color: var(--azul-800); border-radius: 8px; padding: var(--s1) var(--s3); font-weight: 700; letter-spacing: .12em; }
.student__actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.student > .student__actions { grid-column: 2 / -1; }

.track__count { margin: 0; display: flex; flex-direction: column; text-align: right; }
.track__count span { color: var(--muted); font-size: var(--fs-sm); }

.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chip span {
  display: inline-block; padding: var(--s2) var(--s4); border-radius: 999px; border: 1px solid var(--line);
  background: #fff; font-weight: 700; color: var(--muted); transition: all .12s;
}
.chip input:checked + span { background: var(--lila-700); color: #fff; border-color: transparent; }
.chip input:focus-visible + span { outline: 2px solid var(--azul-700); outline-offset: 2px; }
/* Selector segmentado: mismo aspecto que .tabs */
.chips--segmented {
  display: flex; flex-wrap: wrap; gap: var(--s1); width: fit-content; max-width: 100%;
  background: #fff; border: 1px solid var(--line); border-radius: 16px; padding: var(--s1);
  box-shadow: var(--shadow);
}
.chips--segmented .chip span {
  border: 0; background: none; border-radius: 12px; padding: var(--s2) var(--s3); color: var(--muted);
}
.chips--segmented .chip:hover span { background: var(--lila-100); color: var(--lila-800); }
.chips--segmented .chip input:checked + span { background: var(--lila-100); color: var(--lila-800); }
.daycfgs { display: grid; gap: var(--s3); margin-top: var(--s2); }
.daycfg { border: 1px solid var(--line); border-radius: 16px; padding: var(--s3) var(--s4); background: #fff; transition: background .12s; }
.daycfg.is-off { background: var(--off-bg); }
.daycfg.is-off .hourchips, .daycfg.is-off .daycfg__copy { display: none; }
.daycfg__head { display: flex; align-items: center; gap: var(--s3); flex-wrap: wrap; }
.daycfg__sum { color: var(--muted); font-size: var(--fs-sm); flex: 1; }
.daycfg.is-off .daycfg__sum { color: var(--muted-2); }
.daycfg__copy { font-size: var(--fs-sm); }
.switch { display: inline-flex; align-items: center; gap: var(--s3); cursor: pointer; min-width: 150px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch__track {
  width: 44px; height: 26px; border-radius: 999px; background: var(--track); position: relative; flex: none; transition: background .15s;
}
.switch__track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .2); transition: transform .15s;
}
.switch input:checked + .switch__track { background: var(--lila-700); }
.switch input:checked + .switch__track::after { transform: translateX(18px); }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--azul-700); outline-offset: 2px; }
.hourchips { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: var(--s2); margin-top: var(--s3); }
.hchip {
  min-height: 40px; padding: var(--s1) var(--s2); white-space: nowrap; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--muted); font-weight: 700; font-size: var(--fs-sm);
  transition: background .1s, border-color .1s, color .1s;
}
.hchip:hover { border-color: var(--lila-300); color: var(--lila-700); }
.hchip.is-on { background: var(--lila-100); border-color: var(--lila-500); color: var(--lila-800); }
.hours__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); flex-wrap: wrap; margin-top: var(--s4); }
.hours__actions { display: flex; gap: var(--s2); flex-wrap: wrap; }
.slot--off { cursor: default; background: transparent; border: 0; }
.preview { margin: 0; background: var(--azul-100); color: var(--azul-800); padding: var(--s3) var(--s4); border-radius: 12px; font-weight: 600; }

/* ===== Avisos emergentes ===== */
.toast {
  position: fixed; left: var(--s4); right: var(--s4); margin-inline: auto; bottom: calc(var(--s5) + env(safe-area-inset-bottom, 0px));
  z-index: 60; transform: translateY(var(--s4));
  width: fit-content; max-width: min(520px, calc(100vw - 32px)); padding: var(--s3) var(--s4); border-radius: 14px;
  background: var(--ink); color: #fff; font-weight: 700; text-align: center; box-shadow: var(--shadow-pop);
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
}
.toast.is-show { opacity: 1; transform: translateY(0); }
.toast--ok { background: var(--ink); }
.toast--info { background: var(--ink); }
.toast--error { background: var(--danger-100); color: var(--danger-800); border: 1px solid var(--danger); }

/* ===== Celular ===== */
@media (max-width: 640px) {
  .topbar { padding: var(--s3) var(--s4); }
  .demo-banner { font-size: var(--fs-xs); padding: var(--s1) var(--s3); }
  .brand__text small { display: none; }
  .who { display: none; }
  .container { gap: var(--s4); }
  .card { padding: var(--s4); }
  .hello h1 { font-size: var(--fs-xl); }
  .quota { width: 100%; }
  .form__row { grid-template-columns: 1fr; }
  .form--inline { grid-template-columns: 1fr; }
  .form--student { grid-template-columns: 1fr; }
  .form--student > * { grid-column: 1 / -1 !important; }
  .kid-fields { grid-template-columns: 90px 1fr; }
  .agenda__place { align-items: flex-start; text-align: left; }
  .agenda li { grid-template-columns: 1fr; gap: 2px; }
  .search { max-width: none; }
  .tabs { gap: 0; padding: var(--s1); overflow: visible; }
  .tabs button { flex: 1 1 auto; min-width: 0; padding: 0 2px; font-size: var(--fs-xs); letter-spacing: -.01em; }
  .tabs__more { display: inline-flex; flex: 0 0 auto; padding: 0 var(--s1); }
  .tabs .tabs__menu button { font-size: var(--fs-sm); overflow: visible; }
  .mylist__item { flex-wrap: wrap; }
  .hourchips { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hours__actions { flex-direction: column; width: 100%; }
  .hours__actions .btn { width: 100%; }
  .student > .student__actions { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .student__actions .btn { padding-inline: var(--s2); }
}

/* ===== Pantallas táctiles: áreas de toque ===== */
@media (pointer: coarse) {
  .btn--sm { min-height: 44px; }
  .modal__close { width: 44px; height: 44px; top: var(--s2); right: var(--s2); }
  .wa-btn { min-height: 32px; padding: var(--s1) var(--s3); }
  .link-btn { display: inline-flex; align-items: center; min-height: 40px; padding: var(--s2) var(--s1); }
  .grid__day .link-btn { min-height: 40px; padding: var(--s2) var(--s1); }
  .hchip { min-height: 44px; }
  .tabs button { min-height: 44px; }
  .chip span { min-height: 44px; display: inline-flex; align-items: center; }
  .chips--segmented .chip span { min-height: 44px; }
  .help-toggle summary { min-height: 44px; }
}

/* ===== Impresión (Agenda) ===== */
@media print {
  body { background: #fff; }
  .topbar, .tabs, .demo-banner, .weeknav button, .no-print, .toast, #reminder { display: none !important; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .agenda li { break-inside: avoid; }
}

/* ===== Ajustes de seguimiento ===== */
.card > .student__actions { margin-bottom: var(--s4); }
.btn svg { width: 1.1em; height: 1.1em; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 2; }
.btn--sm svg { width: 1.1em; height: 1.1em; }
.student__info strong .code { display: inline-block; margin-left: var(--s2); vertical-align: baseline; }
.form__error:not(:empty) { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.form__error[hidden] { display: none; }
@media (max-width: 640px) {
  .student > .student__actions { display: flex; flex-wrap: wrap; }
  .student > .student__actions .btn { flex: 1 1 auto; gap: var(--s1); white-space: nowrap; }
}
