/* TuLocker · Programa de referidos (octubre 2026).
   Una hoja para las tres vistas, cada bloque con su ámbito:
   1. Panel del cliente (.tlr dentro de body.tlp): mismo lenguaje que tulocker-panel-v2 "azul":
      navy = estructura, azul = acción, tintes azules = fondos; verde discreto solo para "ganado".
   2. CRM del admin (#crm-referrals-section, #admin-users-tbody .crm-ref-meta).
   3. Registro (#register-form .referral-code-group).
   Mobile-first: las columnas aparecen desde 768px. Usa los tokens de tulocker-colors-v1.css con respaldo. */

/* ═══ 1 · Panel del cliente ═══════════════════════════════════════════ */
.tlr { display: grid; gap: 1rem; }
.tlr[data-state="loading"] .tlr-code { color: rgba(255, 255, 255, .5); }
.tlr[aria-busy="true"] .tlp-stat-value { opacity: .55; }

/* Banda principal: navy → azul, código en un "boleto" blanco */
.tlr-hero {
  display: grid; gap: 1.25rem;
  padding: clamp(1.25rem, 4vw, 2rem);
  border-radius: 22px;
  background: linear-gradient(125deg, var(--tl-navy, #0B1F3A) 0%, #16325A 60%, var(--tl-blue-hover, #1257C4) 100%);
  color: #fff;
  box-shadow: 0 14px 34px rgba(11, 31, 58, .16);
  grid-template-areas: "text" "code" "share";
}
.tlr-hero-text { grid-area: text; min-width: 0; }
.tlr-eyebrow { margin: 0 0 .35rem; font-size: .8125rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: #C9D6E8; }
.tlr-hero h2 { margin: 0 0 .5rem; color: #fff; font-size: clamp(1.5rem, 4.5vw, 2.125rem); font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; }
.tlr-hero-text > p { margin: 0; color: #DCE6F4; font-size: 1rem; line-height: 1.55; max-width: 56ch; }
.tlr-hero-text strong { color: #fff; }
.tlr-welcome { margin-top: .875rem !important; padding: .625rem .875rem; border-radius: 12px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .18); font-size: .9375rem !important; }

.tlr-code-card {
  grid-area: code;
  display: grid; justify-items: center; gap: .625rem;
  padding: 1.125rem 1rem 1rem;
  border-radius: 16px;
  background: #fff;
  border: 2px dashed #8EB2EE;
  color: var(--tl-navy, #0B1F3A);
  text-align: center;
}
.tlr-code-label { margin: 0; font-size: .8125rem; font-weight: 600; color: #4B5B73; }
.tlr-code {
  margin: 0;
  font-family: 'Outfit', 'Inter', ui-monospace, monospace;
  font-size: clamp(2rem, 9vw, 2.75rem); font-weight: 700; line-height: 1.05;
  letter-spacing: .14em; padding-left: .14em; /* compensa el espaciado final para centrar */
  color: var(--tl-navy, #0B1F3A);
  font-variant-numeric: tabular-nums;
  user-select: all; -webkit-user-select: all;
  overflow-wrap: anywhere;
}
.tlr-copy { width: 100%; }

.tlr-share { grid-area: share; display: grid; gap: .5rem; min-width: 0; }
.tlr-share > label { font-size: .875rem; font-weight: 600; color: #DCE6F4; }
.tlr-share-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: .5rem; }
.tlr .tlr-share .form-control { min-height: 48px; background: rgba(255, 255, 255, .1); border-color: rgba(255, 255, 255, .32); color: #fff; font-weight: 500; font-size: .9375rem; text-overflow: ellipsis; }
.tlr .tlr-share .form-control:focus { border-color: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .22); }
.tlr-share-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.tlr-share-actions .btn, .tlr-share-row .btn { flex: 1 1 auto; }
.tlr-btn-ghost-light { background: transparent; border: 1px solid rgba(255, 255, 255, .45); color: #fff !important; }
.tlr-hero :focus-visible { outline-color: #8EC2FF; }
@media (hover: hover) and (pointer: fine) {
  .tlr-btn-ghost-light:hover { background: rgba(255, 255, 255, .1); }
}

/* Estados y tarjetas */
.tlr-error { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: .75rem; border-color: #F2C4C4 !important; background: #FDF3F3; }
.tlr-error p { margin: 0; color: var(--tl-text, #111827); }
.tlr-stats { margin-bottom: 0; grid-template-columns: minmax(0, 1fr); gap: .75rem; }
.tlr-stats .tlp-stat-icon { background: var(--tlp-blue-100, #E6EEFC); color: var(--tl-blue, #1769E8); }
.tlr-stat-note { margin: .15rem 0 0; font-size: .8125rem; color: var(--tl-text-secondary, #667085); }

.tlr-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 1rem; }
.tlr-grid > .glass-card { min-width: 0; }

/* Canje */
.tlr-redeem form { display: grid; gap: .75rem; }
.tlr-redeem .form-group { margin: 0; }
.tlr-redeem-row { display: flex; gap: .5rem; }
.tlr-redeem-row .form-control { flex: 1; min-width: 0; font-size: 1.125rem; font-weight: 600; }
.tlr-redeem-row .btn { flex: 0 0 auto; }
.tlr-redeem-preview { margin: .4rem 0 0; font-size: .875rem; color: var(--tlp-ink-2, #344054); font-variant-numeric: tabular-nums; min-height: 1.3em; }
.tlr-redeem form > .btn { width: 100%; }
.tlr-redeem-msg { margin: 0; font-size: .9375rem; line-height: 1.45; min-height: 1.4em; color: var(--tlp-ink-2, #344054); }
.tlr-redeem-msg:empty { display: none; }
.tlr-redeem-msg[data-tone="ok"] { padding: .625rem .75rem; border-radius: 10px; background: var(--tl-success-tint, rgba(22, 163, 74, .1)); color: var(--tl-navy, #0B1F3A); }
.tlr-redeem-msg[data-tone="error"] { padding: .625rem .75rem; border-radius: 10px; background: var(--tl-error-tint, rgba(220, 38, 38, .08)); color: #9B1C1C; }
.tlr-help { margin: 1rem 0 0; padding-top: .875rem; border-top: 1px solid var(--tl-border, #E5EAF0); font-size: .875rem; line-height: 1.5; color: var(--tl-text-secondary, #667085); }
.tlr-applied { margin-top: 1rem; }
.tlr-applied h4 { margin: 0 0 .5rem; font-size: .9375rem; font-weight: 700; color: var(--tl-navy, #0B1F3A); }
.tlr-applied ul { margin: 0; padding: 0; list-style: none; display: grid; gap: .375rem; }
.tlr-applied li { display: flex; justify-content: space-between; gap: 1rem; padding: .5rem .75rem; border-radius: 10px; background: var(--tlp-blue-50, #F2F6FD); font-size: .875rem; font-variant-numeric: tabular-nums; }
.tlr-applied li strong { color: var(--tl-navy, #0B1F3A); white-space: nowrap; }

/* Cómo funciona */
.tlr-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: 1rem; }
.tlr-steps li { display: flex; gap: .875rem; align-items: flex-start; }
.tlr-step-n { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; background: var(--tlp-blue-100, #E6EEFC); color: var(--tl-blue-hover, #1257C4); font-weight: 700; font-size: .9375rem; }
.tlr-steps strong { display: block; color: var(--tl-navy, #0B1F3A); font-size: .9375rem; }
.tlr-steps p { margin: .15rem 0 0; color: var(--tl-text-secondary, #667085); font-size: .875rem; line-height: 1.5; }
.tlr-terms { margin: 1.25rem 0 0; font-size: .8125rem; color: var(--tl-text-secondary, #667085); }

/* Listas: amigos y movimientos */
.tlr-list { margin: 0; padding: 0; list-style: none; }
.tlr-item { display: flex; align-items: center; gap: .75rem; padding: .75rem 0; border-bottom: 1px solid var(--tl-border, #E5EAF0); }
.tlr-item:last-child { border-bottom: 0; }
.tlr-item-main { display: grid; gap: .1rem; flex: 1; min-width: 0; }
.tlr-item-main strong { font-size: .9375rem; font-weight: 600; color: var(--tl-navy, #0B1F3A); overflow-wrap: anywhere; }
.tlr-item-main small { font-size: .8125rem; color: var(--tl-text-secondary, #667085); }
.tlr-avatar { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border-radius: 50%; background: var(--tlp-blue-100, #E6EEFC); color: var(--tl-blue-hover, #1257C4); font-weight: 700; }
.tlr-badge { flex: 0 0 auto; max-width: 48%; padding: .25rem .625rem; border-radius: 999px; font-size: .75rem; font-weight: 600; line-height: 1.35; text-align: center; border: 1px solid var(--tlp-blue-line, #C7D6F2); background: var(--tlp-blue-50, #F2F6FD); color: var(--tl-navy, #0B1F3A); }
.tlr-badge[data-tone="done"] { background: #F1F8F3; border-color: #BFE0CA; color: #15703A; }
.tlr-move-icon { display: grid; place-items: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 10px; font-size: .8125rem; background: var(--tlp-blue-100, #E6EEFC); color: var(--tl-blue-hover, #1257C4); }
.tlr-move-icon[data-sign="out"] { background: #F3F5F8; color: #4B5B73; }
.tlr-points { flex: 0 0 auto; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--tl-blue-hover, #1257C4); }
.tlr-points[data-sign="out"] { color: #4B5B73; }
.tlr-empty { padding: 1.5rem .5rem; }

/* "Mis puntos": enlace al programa */
.tlr-points-cta { display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .75rem; margin: 0 0 1rem; padding: .75rem 1rem; border-radius: 12px; background: var(--tlp-blue-50, #F2F6FD); border: 1px solid var(--tlp-blue-line, #C7D6F2); color: var(--tlp-ink-2, #344054); font-size: .9375rem; }

@media (min-width: 560px) {
  .tlr-share-row { grid-template-columns: minmax(0, 1fr) auto; }
  .tlr-share-actions .btn { flex: 0 0 auto; }
  .tlr-copy { width: auto; }
}
@media (min-width: 768px) {
  .tlr-hero { grid-template-columns: minmax(0, 1.4fr) minmax(240px, 1fr); grid-template-areas: "text code" "share share"; align-items: center; }
  .tlr-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tlr-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
@media (min-width: 1100px) {
  .tlr-hero { grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr); }
}
@media (prefers-reduced-motion: no-preference) {
  .tlr-copy, .tlr-share .btn { transition: background-color 150ms ease, border-color 150ms ease, transform 120ms cubic-bezier(0.23, 1, 0.32, 1); }
}
@media (prefers-contrast: more) {
  .tlr-code-card { border-style: solid; border-color: var(--tl-navy, #0B1F3A); }
  .tlr .tlr-share .form-control { background: var(--tl-navy, #0B1F3A); border-color: #fff; }
}

/* ═══ 2 · CRM del admin ═══════════════════════════════════════════════ */
#admin-users-tbody .crm-ref-meta { display: inline-flex; align-items: center; gap: .35rem; margin-top: .25rem; font-size: .78rem; font-weight: 600; color: #1257C4; font-variant-numeric: tabular-nums; }
#crm-referrals-section { border-left: 1px solid #d9e5ef; }
#crm-referrals-section h4 { margin: 0 0 .5rem; font-size: .95rem; color: #0B1F3A; }
.crm-ref-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .75rem; margin-bottom: .75rem; }
.crm-ref-stats > div { display: grid; gap: .15rem; padding: .75rem .85rem; border: 1px solid #DCE4EF; border-radius: 12px; background: #F2F6FD; min-width: 0; }
.crm-ref-stats small { font-size: .75rem; font-weight: 700; color: #4B5B73; }
.crm-ref-stats strong { font-size: 1.15rem; color: #0B1F3A; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.crm-ref-stats .crm-muted { font-size: .75rem; }
#crm-ref-state:empty { display: none; }
.crm-ref-adjust { margin: .75rem 0; padding-top: .75rem; border-top: 1px solid #DCE4EF; }
.crm-ref-adjust .crm-form-grid { margin-bottom: .75rem; }
.crm-ref-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .75rem; }
#crm-ref-apply { border: 1px solid #1257C4 !important; background: #fff !important; color: #1257C4 !important; font-weight: 700; min-height: 40px; }
#crm-ref-apply:disabled { opacity: .6; cursor: wait; }
#crm-ref-message { margin: 0; font-weight: 600; font-size: .875rem; color: #0B1F3A; }
#crm-ref-message[data-tone="error"] { color: #B42318; }
#crm-ref-message[data-tone="ok"] { color: #15703A; }
.crm-ref-details { margin-top: .5rem; border: 1px solid #DCE4EF; border-radius: 10px; background: #fff; }
.crm-ref-details summary { cursor: pointer; padding: .65rem .85rem; font-weight: 700; font-size: .875rem; color: #0B1F3A; }
.crm-ref-list { margin: 0; padding: 0 .85rem .5rem; list-style: none; max-height: 260px; overflow: auto; }
.crm-ref-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: .75rem; padding: .55rem 0; border-top: 1px solid #EEF2F7; font-size: .85rem; }
.crm-ref-list li .crm-status { flex: 0 0 auto; }
.crm-ref-points { flex: 0 0 auto; font-variant-numeric: tabular-nums; }
.crm-ref-points.in { color: #1257C4; }
.crm-ref-points.out { color: #4B5B73; }
@media (min-width: 701px) { .crm-ref-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }

/* ═══ 3 · Registro ════════════════════════════════════════════════════ */
#register-form .referral-code-group .form-control { text-transform: uppercase; letter-spacing: .08em; font-weight: 600; }
#register-form .referral-code-group .form-control::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; }
#register-form .referral-code-status { display: block; margin-top: 6px; font-size: .875rem; line-height: 1.4; color: var(--tl-text-secondary, #667085); }
#register-form .referral-code-status[data-tone="ok"] { color: #15703A; }
#register-form .referral-code-status[data-tone="error"] { color: var(--tl-error, #DC2626); }
#register-form .referral-code-group .form-control[aria-invalid="true"] { border-color: var(--tl-error, #DC2626); }
