/* Componentes reutilizables */

/* Utilidades de layout y texto */
.l-row  { display: flex; align-items: center; gap: var(--sp-3); }
.l-grow { flex: 1; min-width: 0; }
.l-two  { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: var(--sp-3); }
.l-two > * { min-width: 0; }
.l-wrap { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }

.t-sub    { display: block; color: var(--c-muted); font-size: var(--text-base); }
.t-muted  { color: var(--c-muted); font-size: var(--text-base); }
.t-big    { font-size: var(--text-xl); font-weight: var(--fw-black); }
.t-ok     { color: var(--c-ok); }
.t-warn   { color: var(--c-warn); }
.t-danger { color: var(--c-danger); }
.t-right  { text-align: right; }
.t-cap    { text-transform: capitalize; }

/* Tarjeta */
.card {
  display: block; width: 100%;
  margin-bottom: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-surface);
  border: 0;
  border-radius: var(--r-lg);
  color: inherit; text-align: left;
}
.card--link { cursor: pointer; }
.card--center { text-align: center; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
.stats .card { margin: 0; }

.empty { padding: var(--sp-8) 0; text-align: center; color: var(--c-muted); }

.num {
  flex-shrink: 0;
  display: grid; place-items: center;
  width: var(--tap-sm); height: var(--tap-sm);
  border-radius: var(--r-md);
  background: var(--c-surface-3);
  font-weight: var(--fw-black);
}
.score { white-space: nowrap; font-size: var(--text-lg); font-weight: var(--fw-black); }
.rank  { width: 1.75rem; color: var(--c-muted); font-weight: var(--fw-black); }

/* Insignia de resultado */
.badge {
  padding: 0 var(--sp-2);
  border: 1px solid var(--c-line);
  border-radius: var(--r-pill);
  font-size: var(--text-base);
  white-space: nowrap;
}
.badge--ok     { color: var(--c-ok);     border-color: var(--c-ok); }
.badge--warn   { color: var(--c-warn);   border-color: var(--c-warn); }
.badge--danger { color: var(--c-danger); border-color: var(--c-danger); }

/* Botones */
.btn {
  display: block; width: 100%;
  min-height: var(--tap);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-accent);
  color: var(--c-on-accent);
  border: 0; border-radius: var(--r-md);
  font-size: var(--text-md); font-weight: var(--fw-bold);
  text-align: center; text-decoration: none;
}
.btn--sec { background: var(--c-surface-3); border: 1px solid var(--c-line); color: var(--c-text); }
.btn--sm  { width: auto; min-height: var(--tap-sm); padding: var(--sp-2) var(--sp-3); font-size: var(--text-base); }
.btn--danger {
  width: 100%; padding: var(--sp-4);
  background: none; border: 0;
  color: var(--c-danger); font-size: var(--text-base);
}

.fab {
  position: fixed; z-index: 6;
  right: var(--sp-4);
  bottom: calc(var(--nav-h) + var(--sp-3) + env(safe-area-inset-bottom));
  width: var(--fab); height: var(--fab);
  border-radius: 50%; border: 0;
  background: var(--c-accent); color: var(--c-on-accent);
  font-size: var(--text-2xl);
  box-shadow: 0 6px 20px color-mix(in srgb, var(--c-team-1) 40%, transparent);
}

/* Encabezado de mes */
.month-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); margin-bottom: var(--sp-3); }
.month-head__title { font-size: var(--text-xl); font-weight: var(--fw-black); letter-spacing: -0.01em; }
.month-head__nav { display: flex; gap: var(--sp-2); }
.month-head__btn {
  width: var(--tap); height: var(--tap);
  background: var(--c-surface); border: 0; border-radius: 50%;
  font-size: var(--text-lg);
}

/* Tira de días */
.days {
  display: flex; gap: var(--sp-2);
  margin: 0 calc(-1 * var(--sp-4)) var(--sp-5);
  padding: 0 var(--sp-4) var(--sp-1);
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
}
.days::-webkit-scrollbar { display: none; }
.day {
  flex: 0 0 var(--day-w);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--sp-3) 0 var(--sp-2);
  background: var(--c-surface); border: 2px solid transparent; border-radius: var(--r-pill);
  scroll-snap-align: center;
}
.day__dow { color: var(--c-muted); font-size: var(--text-base); text-transform: lowercase; }
.day__num { font-size: var(--text-lg); font-weight: var(--fw-black); line-height: var(--lh-tight); }
.day__dot { width: 6px; height: 6px; border-radius: 50%; background: var(--c-accent-line); visibility: hidden; }
.day--has .day__dot { visibility: visible; }
.day--has { border-color: var(--c-accent-line); }
.day--today { background: var(--c-ink); color: var(--c-on-ink); }
.day--today .day__dow { color: var(--c-on-ink); }
.day--today .day__dot { background: var(--c-on-ink); }

/* Tiles (bento) */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); margin-bottom: var(--sp-5); }
.tile {
  display: flex; flex-direction: column; gap: var(--sp-1);
  min-height: 8.5rem; padding: var(--sp-4);
  background: var(--c-surface); color: var(--c-text);
  border: 0; border-radius: var(--r-tile);
  text-align: left;
}
.tile--wide   { grid-column: 1 / -1; min-height: 0; }
.tile--accent { background: var(--c-accent); color: var(--c-on-accent); }
.tile--ink    { background: var(--c-ink);    color: var(--c-on-ink); }
.tile__label  { font-size: var(--text-base); font-weight: var(--fw-bold); }
.tile__title  { font-size: var(--text-xl); font-weight: var(--fw-black); line-height: var(--lh-tight); letter-spacing: -0.01em; }
.tile__meta   { color: var(--c-muted); font-size: var(--text-base); }
.tile__big    { margin-top: auto; font-size: var(--text-3xl); font-weight: var(--fw-black); line-height: var(--lh-tight); letter-spacing: -0.02em; }
.tile__big--md { font-size: var(--text-2xl); }
.tile__foot   { display: flex; align-items: baseline; gap: var(--sp-2); margin-top: var(--sp-3); }
.tile--accent .tile__meta, .tile--ink .tile__meta { color: inherit; }

/* Hoja inferior (modal) */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: flex-end; justify-content: center;
  background: var(--c-overlay);
  overscroll-behavior: none;
}
.overlay--top { z-index: 30; }
.overlay--lineup { z-index: 25; }
.sheet {
  width: 100%; max-width: 40rem; max-height: 92vh; max-height: 92dvh;
  overflow-x: hidden; overflow-y: auto;
  /* Sin desplazamiento lateral ni rebote: la hoja solo se desplaza hacia arriba y abajo */
  overscroll-behavior: none;
  padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
  background: var(--c-sheet);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
}
.sheet:not(.sheet--tall) { touch-action: pan-y; touch-action: pan-y pinch-zoom; } /* la alineación necesita gestos libres para las formaciones */
.sheet--tall { max-height: 97vh; max-height: 97dvh; }
.sheet__title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--sp-3);
  font-size: var(--text-lg);
}
.sheet__close {
  min-width: var(--tap); min-height: var(--tap);
  background: none; border: 0;
  color: var(--c-muted); font-size: var(--text-xl);
}
.sheet__text { margin-bottom: var(--sp-4); }

.field-label { display: block; margin: var(--sp-3) 0 var(--sp-1); color: var(--c-muted); font-size: var(--text-base); }

/* Selector de dos opciones */
.seg { display: flex; padding: 3px; background: var(--c-surface-2); border: 1px solid var(--c-line); border-radius: var(--r-md); }
.seg__btn {
  flex: 1; min-height: var(--tap-sm);
  background: none; border: 0; border-radius: var(--r-md);
  color: var(--c-muted); font-size: var(--text-base);
}
.seg__btn--on { background: var(--c-accent); color: var(--c-on-accent); }

/* Contador − n + */
.step { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); }
.step__btn {
  width: var(--tap-sm); height: var(--tap-sm);
  background: var(--c-surface-3); border: 1px solid var(--c-line); border-radius: var(--r-md);
  font-size: var(--text-lg);
}
.step__val { min-width: 1.25rem; text-align: center; }

/* Fila de lista */
.list-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) 0; border-bottom: 1px solid var(--c-line); }
.list-row:last-child { border: 0; }

/* Estado de pago */
.chip {
  min-width: 5.5rem; min-height: var(--tap-sm);
  padding: var(--sp-1) var(--sp-3);
  background: var(--c-surface-2); border: 1px solid var(--c-line); border-radius: var(--r-pill);
  color: var(--c-muted); font-size: var(--text-base);
}
.chip--debe { color: var(--c-warn); border-color: var(--c-warn); }
.chip--pago { color: var(--c-ok);   border-color: var(--c-ok); }

/* Interruptor */
.toggle { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); padding: var(--sp-3) 0; }
.switch { position: relative; flex-shrink: 0; width: 3rem; height: 1.75rem; border: 0; border-radius: var(--r-pill); background: var(--c-line-strong); }
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 1.375rem; height: 1.375rem; border-radius: 50%;
  background: var(--c-on-accent); transition: left 0.2s;
}
.switch--on { background: var(--c-ok); }
.switch--on::after { left: calc(100% - 1.375rem - 3px); }

.notice {
  margin-top: var(--sp-2); padding: var(--sp-2) var(--sp-3);
  background: var(--c-warn-bg); border: 1px solid var(--c-warn); border-radius: var(--r-md);
  color: var(--c-warn); font-size: var(--text-base);
}

/* Menú de opciones */
.menu__item {
  display: block; width: 100%;
  margin-bottom: var(--sp-2); padding: var(--sp-4);
  background: var(--c-surface-2); border: 1px solid var(--c-line); border-radius: var(--r-md);
  font-size: var(--text-md); text-align: left; text-decoration: none;
}

/* Avisos */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--sp-8)); z-index: 40;
  transform: translateX(-50%);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-ink); color: var(--c-on-ink); border: 0; border-radius: var(--r-pill);
  font-size: var(--text-base);
}
.update-bar {
  position: fixed; left: var(--sp-4); right: var(--sp-4); z-index: 45;
  bottom: calc(var(--nav-h) + var(--sp-3) + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--c-ink); color: var(--c-on-ink); border: 0; border-radius: var(--r-lg);
  font-size: var(--text-base);
}
