/* ==========================================================================
   1. VARIABLES Y CONFIGURACIÓN GLOBAL (Design Tokens)
   ========================================================================== */
:root {
    --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --primary: #004a99;
    --primary-hover: #003670;
    --blue: #004a99;
    --blue-2: #1a6dcc;
    --blue-pale: #e8f0fe;
    
    --error-red: #c0392b;
    --error-bg: #fdeaea;
    --error-border: #fadbd8;
    --warning-orange: #ff9800;
    
    --bg-page: #f4f7f9;
    --white: #ffffff;
    --grey-text: #7f8c8d;
    --grey-light: #edf2f7;
    --text-dark: #1e293b;
    
    --radius: 18px;
    --radius-sm: 10px;
    --shadow: 0 6px 20px rgba(0, 0, 0, 0.07);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   2. LAYOUT Y CONTENEDORES PRINCIPALES
   ========================================================================== */
/* La card se ancla arriba con el mismo margen que el informe (.report-wrapper en rh-reports.css):
   así todas las páginas, cortas o largas, empiezan a la misma altura */
body {
    font-family: var(--font);
    background-color: var(--bg-page);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    margin: 0;
    padding: 24px 16px;
    overflow-x: hidden;
}

@media (max-width: 480px) {
    body { padding: 12px 10px; }
}

.card {
    background: var(--white);
    padding: 25px;
    border-radius: 24px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    width: 100%;
    max-width: 400px;
    box-sizing: border-box;
    position: relative;
}

/* ==========================================================================
   3. CABECERA, ESTADOS Y BADGES
   ========================================================================== */
.header-status {
    text-align: center;
    margin-bottom: 20px;
}

.status-badge {
    background: #e1f5fe;
    color: #0288d1;
    padding: 6px 14px;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    margin-bottom: 10px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.status-badge.error-mode {
    background: var(--error-bg);
    color: var(--error-red);
    border-color: var(--error-border);
}

.dot {
    height: 8px;
    width: 8px;
    background: #2ecc71;
    border-radius: 50%;
    margin-right: 6px;
    box-shadow: 0 0 5px #2ecc71;
    transition: all 0.3s ease;
}

.dot.error-mode {
    background: #e74c3c;
    box-shadow: 0 0 5px #e74c3c;
}

#output h2,
#output h3 {
    font-size: 1.15rem;
    color: var(--text-dark);
    margin: 0;
    font-weight: 600;
    line-height: 1.4;
    text-align: center;
}

/* ==========================================================================
   4. FORMULARIOS E INPUTS
   ========================================================================== */
.input-group {
    margin-bottom: 20px;
    position: relative;
}

label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 8px;
    color: #444;
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="time"],
textarea {
    width: 100%;
    padding: 14px;
    border: 1px solid #ced4da;
    border-radius: 12px;
    font-size: 0.95rem;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="time"]:focus,
textarea:focus {
    outline: none;
    border: 1px solid var(--primary);
}

.subtitle {
    color: var(--grey-text);
    font-size: 0.75rem;
    margin-top: 8px;
    display: block;
}

/* ==========================================================================
   5. COMPONENTES: BOTONES Y SPINNERS
   ========================================================================== */
.rh-btn {
    width: 100%;
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    gap: 8px;
    color: #fff;
    padding: 12px 18px;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: transform 0.2s, background 0.2s;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border: none;
    cursor: pointer;
    background: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 74, 153, 0.2);
}

.rh-btn::after {
    content: "";
    position: absolute;
    top: -50%;
    left: -100%;
    width: 30%;
    height: 200%;
    background: rgba(255, 255, 255, 0.25);
    transform: rotate(30deg);
}

.rh-btn:hover {
    background: var(--blue-2);
    transform: translateY(-2px);
    color: #fff;
    text-decoration: none;
}

.rh-btn:hover::after {
    left: 150%;
    transition: left 0.5s ease;
}

.rh-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.rh-btn-blue {
    background: var(--blue);
    box-shadow: 0 4px 12px rgba(0, 74, 153, 0.2);
}

.rh-btn-blue:hover {
    background: var(--blue-2);
}

.rh-btn-orange {
    background: #fc4c02; /* Color corporativo oficial de Strava */
    box-shadow: 0 4px 12px rgba(252, 76, 2, 0.25);
}

.rh-btn-orange:hover {
    background: #e04302; /* Tono más oscuro para el hover */
}

/* Spinner de carga */
.spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* El spinner de un botón, siempre a la DERECHA del texto (v5.2.7, José Manuel), esté donde esté en el HTML.
   Las filas de menú (.rb-menu-btn) ya lo llevan pegado a la derecha */
.rh-btn > .spinner,
.link-btn > .spinner {
    order: 1;
}

/* Carga de página: spinner centrado + texto (profile.html, webreport.html) */
.page-loading {
    padding: 60px 20px;
    color: #64748b;
    font-weight: 500;
    text-align: center;
}

.page-loading p { margin: 0; }

.loader {
    width: 32px;
    height: 32px;
    margin: 0 auto 16px;
    border: 4px solid #e1e8ed;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading .spinner {
    display: block;
}

/* ==========================================================================
   6. COMPONENTES: TOOLTIPS, TILES Y CAPTCHA
   ========================================================================== */
.tooltip {
    position: absolute;
    background: white;
    color: #333;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.8rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 100;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
    border: 1px solid #ddd;
    align-items: center;
    gap: 6px;
}

.tooltip::before {
    content: '';
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid #ddd;
}

.tooltip .icon {
    background: var(--warning-orange);
    color: white;
    width: 18px;
    height: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-weight: bold;
}

.captcha-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-top: 20px;
    min-height: 65px;
}

/* Texto sobre el widget de Turnstile (newuser.html) */
.captcha-status {
    width: 100%;
    margin-bottom: 10px;
    font-size: 0.85rem;
    color: #666;
    text-align: center;
}

.radio-tiles {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 5px;
}

.tile input {
    display: none;
}

.tile-content {
    border: 1px solid var(--grey-light);
    padding: 12px 5px;
    text-align: center;
    border-radius: 14px;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.tile-content span {
    font-size: 0.95rem;
    font-weight: 600;
    color: #555;
}

.tile input:disabled:checked + .tile-content {
    background: #f8fafc;
    border-color: var(--primary);
    opacity: 1;
}

.tile input:disabled:checked + .tile-content span {
    color: var(--primary);
}

.tile input:checked + .tile-content {
    border-color: var(--primary);
    background: #f0f7ff;
}

.tile input:checked + .tile-content span {
    color: var(--primary);
}

/* ==========================================================================
   7. ESTADOS ESPECIALES
   ========================================================================== */
/* Permisos de Strava insuficientes (profile.html, status=scopes) */
.scopes-container {
    text-align: center;
}

.scopes-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-dark);
    margin: 0 0 6px 0;
}

.scopes-lead {
    color: #475569;
    font-size: 0.9rem;
    line-height: 1.5;
    margin: 0 0 18px 0;
}

/* Ilustración de la pantalla de autorización de Strava: marco gris + réplica reducida y no interactiva */
.strava-mock-frame {
    margin: 0 0 20px 0;
    padding: 10px 14px 16px;
    background: #eef2f6;
    border-radius: 16px;
    pointer-events: none;
    user-select: none;
}

.strava-mock-caption {
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #94a3b8;
    margin-bottom: 8px;
}

.strava-mock {
    text-align: left;
    max-width: 280px;
    margin: 0 auto;
    border: 1px solid #dfe5ec;
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

.strava-mock-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    background: #fafafa;
    border-bottom: 1px solid var(--grey-light);
    font-size: 0.65rem;
    font-weight: 600;
    color: #64748b;
}

.strava-mock-logo {
    height: 10px;
}

.strava-mock-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    font-size: 0.7rem;
    color: #94a3b8;
}

.strava-mock-row + .strava-mock-row {
    border-top: 1px solid var(--grey-light);
}

.strava-mock-row.is-required {
    color: var(--text-dark);
    font-weight: 600;
    background: #fff4ee;
    box-shadow: inset 3px 0 0 #fc4c02;
}

.strava-mock-box {
    flex: 0 0 14px;
    height: 14px;
    border-radius: 4px;
    background: #fc4c02;
    color: #fff;
    font-size: 10px;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    animation: scopes-pulse 1.8s ease-in-out infinite;
}

.strava-mock-box.is-optional {
    background: #fff;
    border: 2px solid #cbd5e1;
    box-sizing: border-box;
    animation: none;
}

.strava-mock-label {
    flex: 1;
    line-height: 1.35;
}

.strava-mock-tag {
    font-size: 0.55rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: #fc4c02;
    background: #ffe3d4;
    padding: 2px 6px;
    border-radius: 50px;
    white-space: nowrap;
}

.strava-mock-tag.is-optional {
    color: #94a3b8;
    background: var(--grey-light);
}

@keyframes scopes-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(252, 76, 2, 0.45); }
    50%      { box-shadow: 0 0 0 6px rgba(252, 76, 2, 0); }
}

.strava-mock-hint {
    display: block;
    margin-top: 2px;
    font-size: 0.62rem;
    font-weight: 500;
    color: #64748b;
}

.scopes-note {
    font-size: 0.72rem;
    color: var(--grey-text);
    margin: 12px 0 0 0;
}

@media (prefers-reduced-motion: reduce) {
    .strava-mock-box { animation: none; }
}

/* «Powered by Strava» (logo oficial, separado y menos destacado que la marca de RankHub) */
.powered-strava { display: flex; justify-content: center; margin: 18px 0 4px; }
.powered-strava img { height: 14px; width: auto; }

.success-message-text {
    font-size: 0.85rem;
    color: var(--grey-text);
    text-align: center;
    margin-top: 8px;
}

.locked-text {
    display: block;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
    margin-top: 12px;
    font-weight: 500;
    width: 100%;
}

/* newuser.html: «Paso 1 de 3 · …» sobre cada paso del alta */
.step-indicator {
    margin: 0 0 14px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--grey-text);
}

/* userlogin.html: enlace al registro bajo «Enviar acceso» */
.login-register {
    margin: 14px 0 0;
    text-align: center;
    font-size: 0.85rem;
    color: var(--grey-text);
}

.login-register a {
    color: var(--primary);
    font-weight: 600;
}

/* profile.html: casilla del boletín semanal */
.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0;
    padding: 12px 14px;
    border: 1px solid var(--grey-light);
    border-radius: 14px;
    font-weight: 500;
    cursor: pointer;
}

.check-row input {
    flex: 0 0 auto;
    width: 18px;
    height: 18px;
    margin: 0;
    accent-color: var(--primary);
    cursor: pointer;
}

/* profile.html: botón del informe de actividades, bajo "Actualizar datos" */
.btn-report {
    margin-top: 12px;
}

.btn-report.loading img {
    display: none;
}

/* profile.html: pie con enlaces discretos (darse de baja · cerrar sesión · volver a acceder) */
.profile-footer {
    margin-top: 24px;
    padding-top: 12px;
    border-top: 1px solid var(--grey-light);
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 4px 0;
}

/* Separador "·" delante de cada enlace visible salvo el primero (lo marca updateFooter) */
.profile-footer .sep::before {
    content: "·";
    display: inline-block;
    margin-right: 10px;
    color: #cbd5e1;
}

.link-btn {
    background: none;
    border: none;
    padding: 4px 8px;
    font: inherit;
    font-size: 0.85rem;
    color: var(--grey-text);
    text-decoration: underline;
    cursor: pointer;
}

.link-btn:hover {
    color: var(--primary);
}

/* Enlace «Mi perfil» en la esquina superior derecha (agenda, informe de actividades) */
.corner-link {
    display: flex;
    justify-content: flex-end;
    margin: -8px -8px 4px 0;
}

/* Pie con los enlaces a la derecha (esquina inferior derecha) */
.profile-footer.footer-right {
    justify-content: flex-end;
}

/* «Mi perfil» sin subrayado */
.corner-link .link-btn,
.footer-right .link-btn {
    text-decoration: none;
}

/* «Mi perfil en Club» arriba: en una línea; si el nombre del club no cabe, se corta con «…» */
.corner-link .profile-link {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* «Mi cuenta de RankHub»: en el pie, en azul y con el globo de RankHub (no el muñeco de «Mi perfil») */
.acct-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--blue);
    white-space: nowrap;
}

.acct-link:hover {
    color: var(--blue-2);
}

.acct-link .acct-ico {
    flex: none;
}

/* El mismo enlace en el menú de la rueda dentada del perfil */
.account-menu [role="menuitem"].acct {
    color: var(--blue);
}

.link-danger,
.link-danger:hover {
    color: var(--error-red);
}

/* Botón secundario (perfil → agenda; agenda → guardar duplicado) */
.rh-btn-outline {
    background: var(--white);
    color: var(--blue);
    border: 1.5px solid var(--blue);
    box-shadow: none;
}

.rh-btn-outline:hover {
    background: var(--blue-pale);
    color: var(--blue);
}

.rh-btn-outline .spinner {
    border-color: rgba(0, 74, 153, 0.2);
    border-top-color: var(--blue);
}

/* profile.html: pestañas Usuario / Reto */
.profile-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    margin: 4px 0 20px;
    background: var(--grey-light);
    border-radius: var(--radius-sm);
}

.profile-tab {
    flex: 1;
    border: none;
    background: none;
    padding: 10px 8px;
    font: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--grey-text);
    border-radius: 8px;
    cursor: pointer;
}

.profile-tab[aria-selected="true"] {
    background: var(--white);
    color: var(--blue);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.profile-tab:focus-visible {
    outline: 2px solid var(--blue);
    outline-offset: 2px;
}

/* Texto explicativo dentro de una pestaña (vincular Strava, unirse al reto...) */
.tab-note {
    margin: 0 0 16px;
    font-size: 0.9rem;
    line-height: 1.45;
    color: var(--grey-text);
    text-align: center;
}

/* Botón que sigue a otro en la misma pestaña */
.btn-gap {
    margin-top: 12px;
}

/* Cambio de email pendiente de confirmar */
.pending-note {
    color: var(--warning-orange);
}

/* ==========================================================================
   AGENDA DEL CLUB (agenda.html)
   ========================================================================== */
textarea {
    font-family: inherit;
    resize: vertical;
    min-height: 90px;
}

input[type="date"],
input[type="time"] {
    font-family: inherit;
    background: var(--white);
    min-height: 48px;
}

.agenda-heading {
    font-size: 1rem;
    color: var(--text-dark);
    margin: 0 0 12px;
}

/* Cabecera de la lista con el botón de añadir a la derecha */
.agenda-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.agenda-head .agenda-heading {
    margin: 0;
}

.rh-btn.agenda-add-top {
    width: auto;
    padding: 7px 12px;
    font-size: 0.75rem;
    white-space: nowrap;
}

/* Barra sobre los meses: filtro por tipo (segmentado) y plegar / desplegar todo, como el calendario de la web */
.agenda-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.agenda-filter {
    display: inline-flex;
    padding: 4px;
    gap: 4px;
    border-radius: 999px;
    background: var(--grey-light);
}

.agenda-filter-btn {
    min-height: 40px;
    padding: 0 14px;
    border: none;
    border-radius: 999px;
    background: transparent;
    color: #475569;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
}

.agenda-filter-btn[aria-pressed="true"] {
    background: var(--white);
    color: var(--blue);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}

.agenda-fold {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 40px;
    padding: 0 4px;
    border: none;
    background: transparent;
    color: var(--blue);
    font: inherit;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
}

/* Cuña (la de todos los plegables): arriba, todo abierto (plegar); abajo, algo plegado (desplegar) */
.agenda-fold::after {
    content: "";
    box-sizing: border-box;
    width: 10px;
    height: 10px;
    border: solid #004a99;
    border-width: 0 3px 3px 0;
    margin-top: 4px;
    transform: rotate(-135deg);
    transition: transform 0.15s;
}

.agenda-fold.is-folded::after {
    margin-top: -4px;
    transform: rotate(45deg);
}

.agenda-filter-btn:focus-visible,
.agenda-fold:focus-visible {
    outline: 2px solid var(--blue-2);
    outline-offset: 2px;
}

@media (hover: hover) {
    .agenda-filter-btn:not([aria-pressed="true"]):hover {
        color: var(--text-dark);
    }

    .agenda-fold:hover {
        text-decoration: underline;
    }
}

/* «✨ Novedades (X)»: solo si hay novedades. Morado como la etiqueta «Novedad»; va pegado al filtro en PC y,
   en el móvil, a la izquierda de la fila de «Plegar todo» (no añade una fila) */
.agenda-filter-new {
    margin-right: auto;
    border: 1.5px solid #7c3aed;
    background: var(--white);
    color: #7c3aed;
}

.agenda-filter-new[aria-pressed="true"] {
    background: #7c3aed;
    color: #fff;
    box-shadow: 0 1px 4px rgba(124, 58, 237, 0.35);
}

@media (hover: hover) {
    .agenda-filter-new:not([aria-pressed="true"]):hover {
        color: #6d28d9;
        background: #f5f3ff;
    }
}

/* Móvil: el filtro ocupa todo el ancho, con los tres botones a partes iguales */
@media (max-width: 480px) {
    .agenda-filter {
        display: flex;
        width: 100%;
    }

    .agenda-filter .agenda-filter-btn {
        flex: 1;
        padding: 0 8px;
    }
}

/* Meses plegables (como el calendario de la web) */
.agenda-months {
    margin-bottom: 16px;
}

.agenda-monthgroup + .agenda-monthgroup {
    margin-top: 14px;
}

.agenda-month-title {
    display: flex;
    align-items: center;
    gap: 10px;
    padding-bottom: 6px;
    margin-bottom: 12px;
    border-bottom: 2px solid #e2e8f0;
    font-size: 1rem;
    font-weight: 800;
    color: #1e293b;
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.agenda-month-title::-webkit-details-marker {
    display: none;
}

.agenda-month-title .num {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
}

/* Cuña (la de todos los plegables): abajo plegado, arriba abierto */
.agenda-month-title::after {
    content: "";
    flex: 0 0 auto;
    box-sizing: border-box;
    margin: -4px 4px 0 auto;
    width: 10px;
    height: 10px;
    border: solid #004a99;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
    transition: transform 0.15s;
}

.agenda-monthgroup[open] > .agenda-month-title::after {
    transform: rotate(-135deg);
    margin-top: 4px;
}

.agenda-monthgroup:not([open]) > .agenda-month-title {
    margin-bottom: 0;
}

.agenda-monthgroup > .agenda-list {
    margin-bottom: 0;
}

.agenda-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.agenda-empty {
    text-align: center;
    margin-bottom: 16px;
}

.agenda-item {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-dark);
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    background: var(--white);
    line-height: 1.45;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.agenda-date {
    flex: 0 0 52px;
    height: 56px;
    box-sizing: border-box;
    border-radius: 12px;
    border: 2px solid var(--blue);
    box-shadow: 0 2px 6px rgba(0, 74, 153, 0.15);
    background: var(--blue-pale);
    color: var(--blue);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    line-height: 1.1;
}

.agenda-day {
    font-size: 1.2rem;
    font-weight: 800;
}

.agenda-month {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* Cuadro de fecha + título; el resto de la tarjeta (inscripciones, descripción, botones) va a todo el ancho */
.agenda-headrow {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.agenda-body {
    min-width: 0;
    flex: 1;
}

.agenda-reg {
    color: #475569;
    font-size: 0.82rem;
}

.agenda-reg.is-open {
    color: #15803d;
    font-weight: 700;
}

.agenda-reg.is-closed {
    color: var(--error-red);
    font-weight: 700;
}

/* «Novedad»: evento dado de alta en los últimos 7 días (mismo distintivo que el calendario de la web).
   Pestaña sobre el borde superior del cuadro de la fecha: no desplaza el título */
.agenda-date {
    position: relative;
}

.agenda-new {
    position: absolute;
    top: -9px;
    left: 50%;
    transform: translateX(-50%);
    padding: 1px 5px;
    border-radius: 999px;
    background: #7c3aed;
    color: #fff;
    font-size: 0.56rem;
    font-weight: 800;
    letter-spacing: 0.3px;
    line-height: 1.4;
    text-transform: uppercase;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(124, 58, 237, 0.35);
}

.agenda-title {
    font-weight: 800;
    font-size: 1rem;
    color: #1e293b;
    text-decoration: none;
    overflow-wrap: anywhere;
}

/* Con web del evento: azul, con el icono de enlace; sin ella, en negro y sin icono */
a.agenda-title[href] {
    color: var(--blue);
}

a.agenda-title[href]:hover {
    text-decoration: underline;
}

/* Icono de enlace externo tras el título con web (igual que el calendario de la web) */
.agenda-title .ext {
    display: inline-block;
    margin-left: 5px;
    vertical-align: -1px;
}

.agenda-meta,
.agenda-counts {
    color: #64748b;
    font-size: 0.78rem;
    margin-top: 2px;
}

/* Día y hora: mismo tamaño que en el calendario de la web */
.agenda-meta {
    font-size: 0.8rem;
}

/* Lugar con enlace (Google Maps…): sin subrayar, como en el calendario de la web */
.agenda-location-link {
    color: var(--blue);
    font-weight: 600;
    text-decoration: none;
}

@media (hover: hover) {
    .agenda-location-link:hover {
        text-decoration: underline;
    }
}

.agenda-meta .nowrap {
    white-space: nowrap;
}

.agenda-meta::first-letter {
    text-transform: uppercase;
}

.agenda-desc {
    white-space: pre-line;
    overflow-wrap: anywhere;
    font-size: 0.875rem;
    color: #475569;
}

/* "Me interesa" / "Asistiré": mismo comportamiento que el calendario de la web; la marca solo cambia el texto */
.agenda-marks {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: auto;   /* abajo, alineados entre tarjetas de la misma fila (como el calendario) */
}

.agenda-mark {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--grey-light);
    background: var(--white);
    color: var(--text-dark);
    font: inherit;
    cursor: pointer;
    transition: border-color 0.15s;
}

.agenda-mark .lbl {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.8rem;
    font-weight: 700;
}

.agenda-mark .ico {
    flex: none;
}

.agenda-mark .cnt {
    font-size: 0.7rem;
    color: var(--grey-text);
}

@media (hover: hover) {
    .agenda-mark:hover:not(:disabled) {
        border-color: var(--blue-2);
    }
}

.agenda-mark:focus {
    outline: none;
}

.agenda-mark:focus-visible {
    outline: 2px solid var(--blue-2);
    outline-offset: 2px;
}

/* Botones de marcar con el ojo de la lista encima, a la derecha (es otro botón, no va dentro) */
.agenda-mark-cell {
    position: relative;
    display: grid;
}

.agenda-eye {
    position: absolute;
    bottom: 1px;        /* a la altura del recuento: el texto de arriba ocupa casi todo el ancho */
    right: 3px;
    display: flex;
    padding: 4px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--grey-text);
    cursor: pointer;
}

.agenda-eye[hidden] {
    display: none;
}

@media (hover: hover) {
    .agenda-eye:hover {
        color: var(--blue);
        background: var(--blue-pale);
    }
}

.agenda-eye:focus-visible {
    outline: 2px solid var(--blue-2);
}

/* Diálogo con las listas de apuntados e interesados: con el aspecto de las cards */
.agenda-dialog {
    margin: auto;
    width: min(400px, calc(100vw - 32px));
    box-sizing: border-box;
    max-height: 80vh;
    padding: 25px;
    border: none;
    border-radius: 24px;
    background: var(--white);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.08);
    color: var(--text-dark);
}

.agenda-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.agenda-dialog-close {
    position: absolute;
    top: 14px;
    right: 14px;
    border: none;
    background: transparent;
    font-size: 1rem;
    line-height: 1;
    color: var(--grey-text);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
}

@media (hover: hover) {
    .agenda-dialog-close:hover {
        background: var(--grey-light);
        color: var(--text-dark);
    }
}

.agenda-dialog-head {
    text-align: center;
    padding: 0 24px;
}

.agenda-dialog-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 800;
    color: var(--blue);
}

.agenda-dialog-date {
    margin: 4px 0 0;
    font-size: 0.82rem;
    color: var(--grey-text);
}

.agenda-dialog-sec {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 14px;
    background: var(--bg-page);
}

.agenda-dialog-sec h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 0.9rem;
    font-weight: 800;
}

.agenda-dialog-sec h4 .num {
    margin-left: auto;
    min-width: 22px;
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--white);
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--grey-text);
    text-align: center;
}

.agenda-dialog-empty {
    margin: 8px 0 0;
    font-size: 0.85rem;
    color: var(--grey-text);
}

.agenda-dialog-list {
    margin: 8px 0 0;
    padding-left: 22px;
    font-size: 0.88rem;
    color: var(--grey-text);
}

.agenda-dialog-list li {
    padding: 3px 0;
}

.agenda-mark:disabled {
    cursor: default;
}

/* Evento celebrado (se lista hasta 8 días después) */
.agenda-item.is-past .agenda-date {
    border-color: #64748b;
    background: #f1f5f9;
    color: #64748b;
    box-shadow: none;
}

.agenda-reg.is-past {
    color: #64748b;
    font-weight: 700;
}

.agenda-mark.is-busy {
    opacity: 0.6;
    pointer-events: none;
}

.agenda-mark-error {
    margin-top: 3px;
    font-size: 0.75rem;
    color: var(--error-red);
}

.agenda-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 2px;
    min-height: 24px;   /* misma altura con enlaces (propias) o solo «Creado por:» */
    margin-top: -4px;
}

.agenda-actions .link-btn {
    padding: 2px 6px;
    font-size: 0.8rem;
}

/* Compartir por WhatsApp: a la izquierda del pie de la tarjeta */
.agenda-share {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-right: auto;
    padding: 2px 6px 2px 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #128c7e;
    text-decoration: none;
}

.agenda-share:hover {
    text-decoration: underline;
}

.agenda-mine {
    font-size: 0.75rem;
    color: var(--grey-text);
    margin-right: 4px;
}

.agenda-form {
    margin-top: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--grey-light);
}

.dup-box {
    border: 1px solid #fde68a;
    background: #fffbeb;
    border-radius: 14px;
    padding: 12px;
    margin-bottom: 16px;
}

.dup-title {
    margin: 0 0 10px;
    font-weight: 700;
    font-size: 0.9rem;
    color: #92400e;
}

.dup-box .subtitle {
    display: block;
    margin: 0 0 10px;
}

#btnAgenda {
    margin-top: 12px;
}

.agenda-cancel {
    margin-top: 10px;
    text-align: center;
}

/* Tipo de evento (carrera / quedada) sobre el título */
/* Cinta diagonal en la esquina superior derecha: carrera / quedada (igual que el calendario de la web) */
.agenda-item.has-ribbon {
    position: relative;
    overflow: hidden;
}

.agenda-item.has-ribbon .agenda-title {
    display: block;
    padding-right: 40px;
}

/* La cinta apenas llega a la segunda línea: la fecha usa casi todo el ancho */
.agenda-item.has-ribbon .agenda-meta {
    display: block;
    padding-right: 12px;
}

.agenda-ribbon {
    position: absolute;
    top: 16px;
    right: -34px;
    width: 124px;
    padding: 3px 0;
    transform: rotate(45deg);
    text-align: center;
    font-size: 0.64rem;
    font-weight: 800;
    letter-spacing: 0.6px;
    text-transform: uppercase;
    color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.agenda-ribbon.is-race {
    background: #d9480f;
}

.agenda-ribbon.is-meetup {
    background: #15803d;
}

/* Código de acceso (perfil): 6 cifras grandes y espaciadas */
.otp-input {
    text-align: center;
    font-size: 1.4rem !important;
    font-weight: 700;
    letter-spacing: 0.4em;
    font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   AGENDA EN ESCRITORIO: tarjeta más ancha, eventos del mes en dos columnas y
   formulario centrado con un ancho cómodo. En móvil no cambia nada.
   ========================================================================== */
@media (min-width: 768px) {
    .card.card-wide {
        max-width: 860px;
        padding: 30px 32px;
    }

    .card-wide .agenda-monthgroup > .agenda-list,
    .card-wide .dup-box > .agenda-list {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }

    .card-wide .agenda-form,
    .card-wide .agenda-empty {
        max-width: 520px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Mismo tamaño que en móvil: a 520px quedaba demasiado grande */
    .card-wide #btnNew {
        max-width: var(--btn-max);
        margin-left: auto;
        margin-right: auto;
        display: flex;
    }
}

/* Móviles estrechos: un poco más de sitio para que la fecha de la tarjeta quepa en una línea */
@media (max-width: 400px) {
    .agenda-item {
        padding: 12px 10px;
    }

    .agenda-headrow {
        gap: 10px;
    }

    .agenda-item.has-ribbon .agenda-meta {
        padding-right: 0;
    }
}

/* Diálogo de resultado del perfil: se abre al guardar (Usuario y Reto) con el éxito o el error */
.result-dialog {
    margin: auto;
    width: min(380px, calc(100vw - 32px));
    box-sizing: border-box;
    padding: 28px 25px 22px;
    border: none;
    border-radius: 24px;
    background: var(--white);
    box-shadow: var(--shadow-md);
    color: var(--text-dark);
    text-align: center;
}

.result-dialog::backdrop {
    background: rgba(15, 23, 42, 0.45);
}

.result-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: var(--blue-pale);
    color: var(--blue);
    font-size: 1.5rem;
    font-weight: 800;
}

/* Resultado: check verde si se guardó; triángulo amarillo con admiración si hubo un problema */
#resultIcon {
    background: #dcfce7;
    color: #16a34a;
}

#resultIcon .ico-error,
.result-dialog.is-error #resultIcon .ico-ok {
    display: none;
}

.result-dialog.is-error #resultIcon {
    background: #fef9c3;
}

.result-dialog.is-error #resultIcon .ico-error {
    display: block;
}

.result-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--blue);
}

.result-dialog.is-error .result-title {
    color: var(--error-red);
}

.result-text {
    margin: 10px 0 20px;
    font-size: 0.95rem;
    line-height: 1.45;
    white-space: pre-line;
}

.result-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-actions .rh-btn {
    margin: 0;
}

/* Fila de iconos del perfil, encima del título y pegada a la esquina superior derecha: acceso a la
   administración (god/master) y la rueda dentada. Sin iconos, profile.html la oculta. */
.corner-actions {
    position: relative;
    z-index: 10;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
    margin: -12px -12px -4px 0;
}

.corner-actions[hidden] {
    display: none;
}

/* Iconos juntos: botón de 36 px (área táctil algo menor que 44, compensada al no haber nada alrededor) */
.corner-actions .account-menu-btn {
    width: 36px;
    height: 36px;
}

/* Rueda dentada de la ficha del perfil con el menú de la cuenta: cerrar sesión y bajas.
   Cada opción pide confirmación en #confirmDlg. */
.account-menu-wrap {
    position: relative;
}

a.account-menu-btn {
    text-decoration: none;
}

.account-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--grey-text);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.account-menu-btn[aria-expanded="true"] {
    background: var(--grey-light);
    color: var(--primary);
}

.account-menu {
    position: absolute;
    top: 48px;
    right: 0;
    min-width: 230px;
    padding: 6px;
    border-radius: 14px;
    background: var(--white);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
}

.account-menu[hidden],
.account-menu [hidden] {
    display: none;
}

.account-menu [role="menuitem"] {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 44px;
    padding: 0 14px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-dark);
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    cursor: pointer;
}

.account-menu [role="menuitem"].danger {
    color: var(--error-red);
}

/* Baja del reto en naranja (oscuro, para que se lea sobre blanco); baja del club en rojo (.danger) */
.account-menu [role="menuitem"].warn {
    color: #c2410c;
}

/* Icono de cada opción: del color de su texto (negro en cerrar sesión, naranja y rojo en las bajas) */
.account-menu .mnu-ico {
    flex: none;
    color: currentColor;
}

/* Baja del reto: logotipo de Strava sin modificar (naranja de marca) y un signo menos en el naranja del texto */
.account-menu [role="menuitem"].warn .mnu-ico {
    color: #c2410c;
}

.account-menu [role="menuitem"][hidden] {
    display: none;
}

.account-menu [role="menuitem"]:focus-visible {
    outline: 2px solid var(--blue-2);
    outline-offset: -2px;
}

@media (hover: hover) {
    .account-menu-btn:hover {
        background: var(--grey-light);
        color: var(--primary);
    }

    .account-menu [role="menuitem"]:hover {
        background: var(--grey-light);
    }
}

.account-menu-btn:focus-visible {
    outline: 2px solid var(--blue-2);
    outline-offset: 2px;
}

/* Botón de acción destructiva (confirmar cierre de sesión o baja) */
.rh-btn-danger {
    background: var(--error-red);
    color: var(--white);
}

.rh-btn-danger:hover:not(:disabled) {
    background: #a5281b;
}

/* Diálogo de confirmación: icono y título en tono de aviso */
.result-dialog.is-warning .result-icon {
    background: #fff4e5;
    color: #b45309;
}

.result-dialog.is-warning .result-title {
    color: var(--text-dark);
}

/* ==========================================================================
   MI CUENTA (account.html, v4): el usuario de RankHub, sus clubes y sus servicios
   ========================================================================== */
.acct-who { margin: 0 0 18px; color: var(--grey-text); font-size: 0.92rem; text-align: center; overflow-wrap: anywhere; }
.acct-section { margin: 0 0 20px; }
.acct-section h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--grey-text); margin: 0 0 8px; }
.acct-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.acct-item { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--grey-light);
    border-radius: var(--radius-sm); background: var(--white); }
.acct-item-main { flex: 1; min-width: 0; }
.acct-item-title { font-weight: 600; color: var(--text-dark); }
.acct-item-sub { font-size: 0.85rem; color: var(--grey-text); overflow-wrap: anywhere; }
.acct-item .rh-btn { width: auto; flex: none; margin: 0; padding: 8px 14px; font-size: 0.9rem; text-decoration: none; }
.acct-item-main .link-btn { margin: 2px 0 0; padding: 0; font-size: 0.85rem; }
.acct-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: 999px; font-size: 0.72rem;
    font-weight: 600; background: var(--blue-pale); color: var(--blue); vertical-align: middle; }
.acct-tag.pending { background: #fff4e5; color: #8a5300; }
.acct-empty { font-size: 0.9rem; color: var(--grey-text); margin: 0; }
.acct-danger { margin: 28px 0 0; padding-top: 16px; border-top: 1px solid var(--grey-light); }
.acct-danger p { font-size: 0.88rem; color: var(--grey-text); margin: 0 0 10px; }

/* ==========================================================================
   BOTONES Y CAMPOS EN ESCRITORIO (v5.2.7, José Manuel): en todas las páginas, ni los botones ni las cajas de texto
   crecen con la pantalla. Botones (--btn-max) y campos de formulario (--field-max: etiqueta, caja, aviso y ayuda)
   tienen el mismo tope y quedan centrados, alineados entre sí; las filas de varios botones, centradas por cada página.
   En móvil no cambia nada.
   ========================================================================== */
@media (min-width: 768px) {
    :root {
        --btn-max: 400px;
        --field-max: 400px;
    }

    .card .rh-btn {
        max-width: var(--btn-max);
        margin-left: auto;
        margin-right: auto;
    }

    .card form .input-group,
    .card .captcha-container {
        max-width: var(--field-max);
        margin-left: auto;
        margin-right: auto;
    }

    /* Rutómetro: crear grupo y «Usar código» sin el rutómetro, con el mismo tope */
    .card .rb-group-form,
    .card #noAccess .rb-group-join {
        max-width: var(--field-max);
        margin-left: auto;
        margin-right: auto;
    }

    /* Salvo el editor de tracks del rutómetro: el nombre y las notas van en su columna, junto al mapa y el perfil */
    .card .rb-ed-side .input-group {
        max-width: none;
        margin-left: 0;
        margin-right: 0;
    }

    /* Los que van en una fila con otros elementos se quedan donde estaban */
    .card .agenda-add-top {
        margin-left: 0;
        margin-right: 0;
    }
}

/* Perfil, pestaña Reto: «Desconectar de Strava» plegado, como «Desconectar de Garmin Connect» en el rutómetro */
.strava-manage { margin-top: 18px; font-size: 0.8rem; color: var(--grey-text, #64748b); }
.strava-manage[hidden] { display: none; }
.strava-manage summary { cursor: pointer; }
.strava-manage .strava-disconnect { margin-top: 8px; width: 100%; color: #b91c1c; border-color: #fca5a5; }

/* Perfil del club: escudo de la administración en color. Verde para el administrador del club,
   azul para el superadministrador (como la pastilla «Panel de superadministrador» de /admin) */
.account-menu-btn.admin-shield {
    color: #1e7b3a;
}

.account-menu-btn.admin-shield.is-god {
    color: var(--primary);
}

/* Cuña de plegar y desplegar (v4.39.5): la misma en todos los plegables, la de «Ver las tomas» de la nutrición.
   Abajo, plegado; arriba, desplegado. Va con :where para que cada componente pueda colocarla a su manera. */
:where(details:not(.rb-more-menu)) > summary {
    list-style: none;
    cursor: pointer;
}

:where(details:not(.rb-more-menu)) > summary::-webkit-details-marker {
    display: none;
}

:where(details:not(.rb-more-menu)) > summary::after {
    content: "";
    display: inline-block;
    box-sizing: border-box;
    width: 10px;
    height: 10px;
    margin: 0 4px 3px 10px;
    vertical-align: middle;
    border: solid #004a99;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
    transition: transform 0.15s;
}

:where(details[open]:not(.rb-more-menu)) > summary::after {
    transform: rotate(-135deg);
    margin-bottom: -2px;
}
