/* ── Forms / Modals ───────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.form-group label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--slate-700);
  letter-spacing: .01em;
}
.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  font-size: var(--text-base);
  color: var(--slate-800);
  background: var(--white);
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  min-height: 38px;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--cead-celeste);
  box-shadow: 0 0 0 3px rgba(0,174,239,.12);
}
.form-group input:hover:not(:focus),
.form-group select:hover:not(:focus),
.form-group textarea:hover:not(:focus) { border-color: var(--slate-300); }
.form-group textarea { resize: vertical; min-height: 72px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-info {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: var(--text-xs);
  color: var(--slate-500);
  margin-top: 4px;
  line-height: 1.5;
  padding: 8px 10px;
  background: var(--slate-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--slate-200);
}
.form-info svg { flex-shrink: 0; margin-top: 1px; }
.req { color: var(--rose-500); }

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  z-index: 200;
  backdrop-filter: blur(2px);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn .2s ease;
}
.modal-sm { max-width: 420px; }
.modal-carnet { max-width: 720px; }

@keyframes modalIn {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--slate-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  background: linear-gradient(to right, var(--cead-dark) 0%, var(--cead-medium) 100%);
}
.modal-title {
  font-family: var(--font-display);
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--white);
}
.modal-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  border: 1px solid rgba(255,255,255,.18);
  font-size: 1rem;
  color: rgba(255,255,255,.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.modal-close:hover { background: rgba(255,255,255,.22); color: var(--white); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--slate-100);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
  background: var(--slate-50);
}

/* ── Info banner ──────────────────────────────────────────── */
.info-banner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--blue-50);
  border-left: 3px solid var(--blue-500);
  font-size: .82rem;
  color: var(--blue-800);
  line-height: 1.5;
}
.info-banner-warn {
  background: var(--amber-100);
  border-left-color: var(--gold-500);
  color: var(--gold-600);
}
.info-banner .icon { font-size: 1rem; flex-shrink: 0; margin-top: 2px; }

/* ── Empty State ──────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 48px 24px;
  text-align: center;
}
.empty-state .icon { font-size: 2.5rem; opacity: .35; }
.empty-state p {
  font-size: .88rem;
  color: var(--slate-500);
  max-width: 280px;
  line-height: 1.6;
}
.empty-text {
  font-size: .84rem;
  color: var(--slate-400);
  text-align: center;
  padding: 24px;
}

/* ── Toast ────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-lg);
  background: var(--slate-900);
  color: var(--white);
  font-size: var(--text-base);
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  pointer-events: auto;
  animation: toastIn .25s ease;
  max-width: 380px;
  border-left: 4px solid rgba(255,255,255,.2);
}
.toast-success, .toast.success { background: var(--cead-success); border-left-color: #4ade80; }
.toast-error,   .toast.error   { background: var(--rose-600); border-left-color: #fca5a5; }
.toast-warn,    .toast.warn    { background: var(--amber-600); border-left-color: #fde68a; }
/* Toast de subida de nivel */
.toast-levelup {
  background: linear-gradient(135deg, var(--cead-dark) 0%, var(--cead-medium) 100%);
  border-left: 4px solid var(--cead-celeste);
  display: flex;
}
.toast-out { animation: toastOut .3s ease forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(8px) scale(.96); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
@keyframes toastOut {
  to { opacity: 0; transform: translateY(4px) scale(.95); }
}

/* ── Tipo fuente (historial) ──────────────────────────────── */
.tipo-fuente {
  display: inline-block;
  font-size: .67rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: 4px;
}
.tipo-fuente.gasto      { background: var(--teal-100);   color: var(--teal-700); }
.tipo-fuente.asistencia { background: var(--blue-100);   color: var(--blue-700); }
.tipo-fuente.referido   { background: var(--green-100);  color: var(--green-600); }
.tipo-fuente.youtube    { background: var(--rose-100);   color: var(--rose-600); }
.tipo-fuente.ajuste     { background: var(--slate-100);  color: var(--slate-600); }
.tipo-fuente.sistema    { background: var(--amber-100);  color: var(--amber-600); }

/* ── Portal (dentro de admin) ─────────────────────────────── */
.portal-shell {
  background: linear-gradient(145deg, var(--blue-900) 0%, var(--blue-800) 50%, var(--teal-700) 100%);
  min-height: 100%;
  padding: 24px;
}
.portal-shell-inside {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.portal-hero {
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 32px 20px 24px;
}
.portal-hero-copy {
  flex: 1;
  min-width: 0;
}
.portal-search-card-hero {
  flex: 0 0 300px;
  width: 300px;
}
.portal-eyebrow {
  display: inline-block;
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--blue-300, #93c5fd);
  margin-bottom: 10px;
}
.portal-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  color: var(--white);
  line-height: 1.2;
  margin-bottom: 8px;
}
.portal-subtitle {
  font-size: .9rem;
  color: var(--blue-200);
  max-width: 400px;
}
.portal-kicker {
  font-size: .78rem;
  color: var(--blue-300);
  margin-top: 8px;
}

/* Search card portal */
.portal-search-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 24px;
  box-shadow: var(--shadow-lg);
}
.portal-search-card-hero { text-align: center; margin-bottom: 18px; }
.portal-search-card-hero h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 4px;
}
.portal-search-card-hero p { font-size: .82rem; color: var(--slate-500); }

.portal-input-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.portal-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid var(--slate-200);
  border-radius: var(--radius);
  font-size: .9rem;
  font-family: var(--font-body);
  color: var(--slate-800);
  outline: none;
  transition: border-color var(--transition);
}
.portal-input-row input:focus { border-color: var(--blue-400); }
.portal-error {
  font-size: .8rem;
  color: var(--rose-600);
  padding: 8px 0 0;
  text-align: center;
}

/* Portal result */
.portal-result { display: flex; flex-direction: column; gap: 14px; }

.portal-patient-header {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 20px 22px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 16px;
}
.portal-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue-600), var(--teal-500));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--white);
  flex-family: var(--font-display);
  flex-shrink: 0;
  font-family: var(--font-display);
}
.portal-patient-info { flex: 1; min-width: 0; }
.portal-patient-info h2 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--slate-900);
  margin-bottom: 5px;
}
.portal-action-btns {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.portal-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* Score card */
.portal-score-card {
  background: linear-gradient(135deg, var(--blue-700), var(--blue-600));
  border-radius: var(--radius-xl);
  padding: 20px;
  color: var(--white);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.portal-score-card .label { font-size: .75rem; opacity: .8; text-transform: uppercase; letter-spacing: .06em; }
.portal-score-card .value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
}
.portal-score-card .sub { font-size: .78rem; opacity: .75; }

/* Nivel card */
.portal-nivel-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.portal-nivel-card .label { font-size: .75rem; color: var(--slate-500); text-transform: uppercase; letter-spacing: .05em; }
.portal-nivel-card .nivel-nombre {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--slate-900);
  margin: 4px 0;
}
.portal-nivel-info { font-size: .76rem; color: var(--slate-500); }
.portal-plan-badge { font-size: 1.8rem; margin-bottom: 4px; }

/* Progress card */
.portal-progress-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
  grid-column: 1 / -1;
}
.portal-progress-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.portal-progress-top span { font-size: .82rem; color: var(--slate-600); font-weight: 500; }
.portal-progress-top strong { font-size: .9rem; font-weight: 700; color: var(--blue-700); }
.portal-progress-card .mini-progress-track { height: 10px; border-radius: 99px; }

/* Summary card */
.portal-summary-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  padding: 18px 20px;
  box-shadow: var(--shadow-md);
  grid-column: 1 / -1;
}
.portal-summary-card h3 {
  font-family: var(--font-display);
  font-size: .88rem;
  font-weight: 700;
  color: var(--slate-800);
  margin-bottom: 12px;
}
.portal-mini-stats { display: flex; gap: 0; }
.portal-mini-stat { flex: 1; text-align: center; padding: 8px; border-right: 1px solid var(--slate-100); }
.portal-mini-stat:last-child { border-right: none; }
.portal-stat-val {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--slate-900);
}
.portal-stat-key { font-size: .7rem; color: var(--slate-500); margin-top: 2px; }
.portal-stats-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Portal tabs */
.portal-tabs {
  display: flex;
  gap: 4px;
  background: rgba(255,255,255,.12);
  padding: 4px;
  border-radius: var(--radius-lg);
  flex-wrap: wrap;
}
.portal-tab {
  flex: 1;
  padding: 8px 12px;
  border-radius: var(--radius);
  font-size: .8rem;
  font-weight: 600;
  color: var(--blue-200);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
  font-family: var(--font-body);
}
.portal-tab:hover { background: rgba(255,255,255,.1); color: var(--white); }
.portal-tab.active { background: var(--white); color: var(--blue-800); }
.portal-tab-panel { display: none; }
.portal-tab-panel.active { display: block; }

/* Portal cards */
.portal-section-title {
  font-family: var(--font-display);
  font-size: .82rem;
  font-weight: 700;
  color: var(--slate-700);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 14px 18px 8px;
}

.portal-breakdown-card,
.portal-history-card,
.portal-table-card,
.portal-gasto-card {
  background: var(--white);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.portal-beneficios-list { display: flex; flex-direction: column; }
.portal-beneficio-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 18px;
  border-bottom: 1px solid var(--slate-100);
  font-size: .84rem;
}
.portal-beneficio-item:last-child { border-bottom: none; }

/* Beneficios del siguiente nivel — bloqueados en portal */
.portal-beneficios-locked { opacity: 1; }
.portal-beneficio-preview {
  opacity: .35;
  pointer-events: none;
  user-select: none;
}

.portal-table-scroll { overflow-x: auto; }
.portal-table-scroll table { width: 100%; border-collapse: collapse; font-size: .82rem; }
.portal-table-scroll th {
  padding: 9px 14px;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--slate-400);
  border-bottom: 1px solid var(--slate-100);
}
.portal-table-scroll td {
  padding: 9px 14px;
  border-bottom: 1px solid var(--slate-100);
  color: var(--slate-700);
  vertical-align: middle;
}
.portal-table-scroll tbody tr:last-child td { border-bottom: none; }

/* Gasto card */
.portal-gasto-total {
  padding: 16px 18px 8px;
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}
.portal-gasto-amount {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--teal-700);
}
.portal-gasto-meta { font-size: .76rem; color: var(--slate-500); margin-bottom: 2px; }
.portal-puntos-gasto { font-size: .82rem; font-weight: 600; color: var(--gold-600); }
.portal-gasto-fill .mini-progress-fill { background: linear-gradient(90deg, var(--teal-600), var(--teal-400)); }
.portal-gasto-restante { padding: 4px 18px 14px; font-size: .76rem; color: var(--slate-500); }

/* Portal hint */
.portal-hint {
  font-size: .78rem;
  color: var(--blue-600);
  background: var(--blue-50);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin: 8px 18px;
  line-height: 1.5;
}

/* Carnet modal */
#carnetPreview {
  width: 100%;
  max-width: 680px;
  border-radius: var(--radius-xl);
  display: block;
  margin: 0 auto;
  box-shadow: var(--shadow-lg);
}
.carnet-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  padding-top: 4px;
}

/* ── Portal Rules ─────────────────────────────────────────── */
.portal-rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 16px;
}
.portal-rule-card {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.15);
  border-radius: var(--radius-lg);
  padding: 14px;
  color: var(--white);
  text-align: center;
  backdrop-filter: blur(4px);
}
.portal-rule-card .icon { font-size: 1.6rem; margin-bottom: 6px; }
.portal-rule-card strong { display: block; font-size: .9rem; font-weight: 700; margin-bottom: 3px; }
.portal-rule-card span { font-size: .74rem; opacity: .8; line-height: 1.4; }
.portal-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
  opacity: .75;
}
.portal-icon svg { width: 56px; height: 56px; color: var(--slate-300); }

/* ── Carnet CSS (portal carnet inline) ───────────────────── */
.portal-carnet-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--gold-500), var(--gold-400));
  color: var(--white);
  font-size: .84rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(245,158,11,.35);
  transition: box-shadow var(--transition), transform var(--transition);
  font-family: var(--font-body);
}
.portal-carnet-btn:hover {
  box-shadow: 0 5px 16px rgba(245,158,11,.45);
  transform: translateY(-1px);
}


/* ── Login: olvidé contraseña ───────────────────────────────── */
.login-forgot-wrap { text-align: center; margin-top: 6px; }
.login-forgot-link { background: none; border: none; color: var(--cead-medium,#1a6bbd); font-size: .8rem; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.login-forgot-link:hover { color: var(--cead-dark,#0d2d5e); }
.login-captcha-wrap { display: flex; flex-direction: column; align-items: center; gap: 6px; margin: 4px 0 2px; }
.login-captcha-note { font-size: .72rem; color: #64748b; text-align: center; margin: 0; }

/* ── Cambio de contraseña obligatorio ───────────────────────── */
.change-pwd-screen { position: fixed; inset: 0; background: rgba(13,45,94,.7); display: flex; align-items: center; justify-content: center; z-index: 9999; }
.change-pwd-card { background: #fff; border-radius: 16px; padding: 36px 32px 28px; width: 100%; max-width: 420px; box-shadow: 0 20px 60px rgba(0,0,0,.25); display: flex; flex-direction: column; gap: 14px; }
.change-pwd-icon { text-align: center; color: var(--cead-medium,#1a6bbd); }
.change-pwd-title { font-size: 1.2rem; font-weight: 800; text-align: center; margin: 0; }
.change-pwd-sub { font-size: .84rem; color: #64748b; text-align: center; margin: 0; line-height: 1.5; }
.change-pwd-policy { font-size: .75rem; color: #64748b; margin: 0; background: #f8fafc; border-radius: 6px; padding: 8px 10px; }
