/* ── Skip link (accesibilidad teclado) ── */
.skip-link {
    position: absolute;
    top: -100%;
    left: 0;
    padding: 8px 16px;
    background: var(--color-primary);
    color: var(--bg-surface);
    font-weight: 600;
    z-index: 9999;
    text-decoration: none;
    border-radius: 0 0 4px 0;
}
.skip-link:focus {
    top: 0;
}

/* ── Indicadores de foco (accesibilidad teclado) ── */
:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
/* Suprimir outline por defecto solo cuando se usa :focus-visible */
:focus:not(:focus-visible) {
    outline: none;
}

/* ── Variables globales ── */
:root {
    /* Colores de marca */
    --color-primary:         #e94560;
    --color-primary-hover:   #d63851;
    --color-success:         #4ecca3;
    --color-success-hover:   #3db890;
    --color-success-bg:      rgba(78, 204, 163, 0.15);
    --color-success-text:    #4ecca3;
    --color-warning:         #c9a227;
    --color-warning-hover:   #b8921f;
    --color-warning-bg:      rgba(201, 162, 39, 0.15);
    --color-danger:          #ff6b6b;
    --color-danger-text:     #ff6b6b;
    --color-danger-bg:       rgba(255, 107, 107, 0.15);
    --color-secondary:       #8b8b9e;
    --color-secondary-hover: #7a7a8d;
    --color-logout:          #ff6b6b;
    --color-logout-hover:    #e55a5a;
    --color-accent:          #c9a227;
    --color-gradient-end:    #7c3aed;

    /* Texto */
    --text-dark:   #e8e8e8;
    --text-body:   #d0d0d0;
    --text-medium: #b0b0c0;
    --text-muted:  #8b8b9e;
    --text-faint:  #6a6a7e;

    /* Fondos */
    --bg-page:    #1a1a2e;
    --bg-surface: #16213e;
    --bg-subtle:  #1e2a4a;
    --bg-faint:   #1b2340;

    /* Bordes */
    --border-subtle: #2a2a4a;
    --border-light:  #2e3558;
    --border-card:   #2a2a4a;
    --border-input:  #3a3a5a;

    /* Radio de borde */
    --radius-sm:   6px;
    --radius-md:   12px;
    --radius-lg:   16px;
    --radius-pill: 24px;

    /* Sombras */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.5);

    /* Tipografía */
    --font-family:  'Inter', Arial, sans-serif;
    --font-heading: 'Cinzel', 'Outfit', Arial, sans-serif;
    --line-height: 1.6;

    /* Espaciado */
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 20px;
    --space-lg: 30px;
    --space-xl: 40px;

    /* Transiciones */
    --transition-fast: 0.2s;
    --transition-base: 0.3s;
}

/* ── Estilos base ── */
* {
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    margin: 0;
    padding: 0;
    background-color: var(--bg-page);
    color: var(--text-body);
    line-height: var(--line-height);
}

input, select, textarea {
    background: var(--bg-subtle);
    color: var(--text-dark);
    border: 1px solid var(--border-input);
}

a {
    color: var(--color-primary);
}

a:hover {
    color: var(--color-primary-hover);
}

/* Contenedor principal */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: var(--space-md);
    background: var(--bg-surface);
    min-height: 100vh;
}

/* ── Página de login ── */
form#loginForm {
    margin-bottom: var(--space-md);
}

form#loginForm label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

form#loginForm input {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    background: var(--bg-subtle);
    color: var(--text-dark);
}

form#loginForm button {
    width: 100%;
    padding: 12px;
    background-color: var(--color-primary);
    color: var(--bg-surface);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 16px;
}

form#loginForm button:hover {
    background-color: var(--color-primary-hover);
}

h1, h2, h3 {
    font-family: var(--font-heading);
}

h1 {
    text-align: center;
    color: var(--text-dark);
    margin: var(--space-md) 0;
}

p {
    line-height: var(--line-height);
    text-align: justify;
    margin-bottom: var(--space-md);
}

.error {
    color: var(--color-danger-text);
    margin-top: 10px;
    display: none;
    padding: 10px;
    background-color: var(--color-danger-bg);
    border-radius: 5px;
    border: 1px solid var(--color-danger);
}

/* ── Modal ── */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
}

.modal.show {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--bg-surface);
    padding: var(--space-md);
    border-radius: 5px;
    max-width: 400px;
    width: 100%;
    box-shadow: var(--shadow-lg);
}

.modal-title {
    font-size: 1.5em;
    margin-bottom: 15px;
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    margin-bottom: 0;
}

.form-group input[type="checkbox"] {
    width: auto;
    padding: 0;
    flex-shrink: 0;
}

.form-group input {
    width: 100%;
    padding: var(--space-xs);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-md);
}

.btn {
    padding: var(--space-xs) 16px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

.btn-cancel {
    background: var(--color-secondary);
    color: var(--bg-surface);
    margin-right: 10px;
}

.btn-submit {
    background: var(--color-primary);
    color: var(--bg-surface);
}

/* ── Page Header (dashboard, stats, leaderboard, admin) ── */
.dashboard-header {
    display: flex;
    flex-direction: column;
    padding: var(--space-xs) 0 var(--space-md);
    border-bottom: 2px solid var(--color-primary);
    margin-bottom: var(--space-lg);
}

.dashboard-header h1 {
    margin: 0;
    color: var(--text-dark);
    font-size: 1.8em;
}

.user-info {
    color: var(--text-muted);
    margin: 5px 0 0 0;
    font-size: 0.9em;
}

.logout-btn {
    background-color: var(--color-logout);
    color: var(--bg-surface);
    padding: 4px 12px;
    font-size: 0.85em;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: bold;
    transition: background-color var(--transition-base);
    border: none;
    cursor: pointer;
}

.logout-btn:hover {
    background-color: var(--color-logout-hover);
    color: var(--bg-surface);
    text-decoration: none;
}

.admin-btn {
    background-color: var(--color-success);
    color: var(--bg-surface);
    padding: 4px 12px;
    font-size: 0.85em;
    text-decoration: none;
    border-radius: var(--radius-sm);
    font-weight: bold;
    transition: background-color var(--transition-base);
    border: none;
    cursor: pointer;
}

.admin-btn:hover {
    background-color: var(--color-success-hover);
    color: var(--bg-surface);
    text-decoration: none;
}

.admin-btn.nav-active {
    background-color: var(--color-success-hover);
    opacity: 0.7;
    cursor: default;
    pointer-events: none;
}

/* ── Flash messages ── */
.flash-message {
    padding: 12px 16px;
    margin: 16px 0;
    border-radius: 5px;
    border-left: 4px solid;
}

.flash-message.success {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
    border-left-color: var(--color-success);
}

.flash-message.error {
    background-color: var(--color-danger-bg);
    color: var(--color-danger-text);
    border-left-color: var(--color-danger);
}

/* ── Dashboard vacío ── */
.dashboard-empty {
    text-align: center;
    padding: 60px var(--space-md);
    background: var(--bg-subtle);
    border-radius: var(--radius-lg);
    margin: var(--space-xl) 0;
}

.empty-state h2 {
    color: var(--text-dark);
    margin-bottom: 10px;
    font-size: 1.8em;
}

.empty-state p {
    color: var(--text-muted);
    margin-bottom: var(--space-lg);
    font-size: 1.1em;
}

.empty-actions {
    margin-top: var(--space-lg);
}

.small-text {
    color: var(--text-faint);
    font-size: 0.9em;
    margin-top: 10px;
}

/* ── Estadísticas del dashboard ── */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-xl);
}

.stat-card {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-gradient-end) 100%);
    color: var(--bg-surface);
    padding: 25px;
    border-radius: var(--radius-lg);
    text-align: center;
    box-shadow: var(--shadow-md);
}

.stat-card h3 {
    margin: 0 0 10px 0;
    font-size: 0.9em;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-number {
    font-size: 2.5em;
    font-weight: bold;
    margin: 0;
    line-height: 1;
}

/* ── Cabecera de sección ── */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-light);
}

.section-header h2 {
    margin: 0;
    color: var(--text-dark);
    font-size: 1.5em;
}

/* ── Tablas ── */
.candidates-table, .payments-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.candidates-table th,
.candidates-table td,
.payments-table th,
.payments-table td {
    padding: 15px var(--space-sm);
    text-align: left;
    border-bottom: 1px solid var(--border-subtle);
}

.candidates-table th,
.payments-table th {
    background-color: var(--bg-subtle);
    font-weight: 600;
    color: var(--text-medium);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
}

.candidates-table tr:hover,
.payments-table tr:hover {
    background-color: var(--bg-subtle);
}

/* ── Badges de estado ── */
.status {
    padding: 4px var(--space-sm);
    border-radius: var(--radius-pill);
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
}

.status.participando {
    background-color: var(--color-success-bg);
    color: var(--color-success-text);
}

.status.cambiado {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-hover);
}

.status.descalificado {
    background-color: var(--color-danger-bg);
    color: var(--color-danger-text);
}

/* Estado del candidato en su ficha (SPEC-44): antes no tenían estilo */
.status.convocable {
    background-color: var(--bg-surface);
    color: var(--color-success-text);
}

.status.no-convocable {
    background-color: #000;
    color: var(--text-dark);
    border: 1px solid rgba(255, 255, 255, 0.45);
}

.status.pending {
    background-color: var(--color-warning-bg);
    color: var(--color-warning-hover);
}

/* ── Botones ── */
.btn-primary, .btn-secondary, .btn-small {
    padding: 10px var(--space-md);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background-color: var(--color-primary);
    color: var(--bg-surface);
}

.btn-primary:hover {
    background-color: var(--color-primary-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--color-secondary);
    color: var(--bg-surface);
}

.btn-secondary:hover {
    background-color: var(--color-secondary-hover);
}

.btn-small {
    padding: 6px var(--space-sm);
    font-size: 0.85em;
}

.btn-success {
    background-color: var(--color-success);
    color: var(--bg-surface);
}

.btn-success:hover {
    background-color: var(--color-success-hover);
}

.btn-warning {
    background-color: var(--color-warning);
    color: var(--bg-surface);
}

.btn-warning:hover {
    background-color: var(--color-warning-hover);
}

.btn-refresh {
    background-color: var(--color-primary);
    color: var(--bg-surface);
}

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

/* ── Estados vacíos ── */
.no-candidates, .dashboard-empty {
    text-align: center;
    padding: 60px var(--space-md);
    background: var(--bg-subtle);
    border: 2px dashed var(--border-light);
    border-radius: var(--radius-lg);
    margin: var(--space-xl) 0;
    color: var(--text-muted);
}

.no-candidates h3 {
    color: var(--text-medium);
    margin-bottom: 10px;
}

/* ── Modal overlay ── */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-surface);
    padding: var(--space-lg);
    border-radius: var(--radius-lg);
    max-width: 500px;
    width: 90%;
    box-shadow: var(--shadow-lg);
}

.modal-content h3 {
    margin-top: 0;
    color: var(--text-dark);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: var(--space-md);
}

/* ══════════════════════════════════════════
   PAYMENT PAGE
   ══════════════════════════════════════════ */

/* Cabecera de la página de pago */
.payment-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-md) 0;
    border-bottom: 2px solid var(--color-primary);
    margin-bottom: var(--space-lg);
}

.payment-header h1 {
    margin: 0;
    font-size: 1.6rem;
    color: var(--text-dark);
    text-align: left;
}

.back-btn {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 8px var(--space-sm);
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: background var(--transition-fast);
    min-height: 44px;
}

.back-btn:hover {
    background: var(--bg-subtle);
    text-decoration: none;
}

/* Layout de dos columnas */
.payment-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
    align-items: start;
}

/* ── Columna izquierda: información ── */
.payment-info {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.payment-info h2 {
    margin: 0 0 var(--space-sm);
    font-size: 1.3rem;
    color: var(--text-dark);
}

.payment-details {
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: 10px;
    border: 1px solid var(--border-light);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: var(--space-sm);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
}

.detail-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.detail-label {
    font-weight: 600;
    color: var(--text-medium);
    font-size: 0.88rem;
    flex-shrink: 0;
}

.detail-value {
    color: var(--text-body);
    font-size: 0.9rem;
    text-align: right;
    word-break: break-all;
}

/* Círculo de importe */
.payment-amount {
    text-align: center;
    padding: var(--space-md) 0;
}

.amount-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-gradient-end) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto var(--space-sm);
    box-shadow: 0 8px 24px rgba(233, 69, 96, 0.35);
}

.amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-dark);
    font-family: var(--font-heading);
    line-height: 1;
}

.amount-description {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
    text-align: center;
    line-height: 1.4;
}

/* Lista de beneficios */
.payment-benefits {
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    border: 1px solid var(--border-light);
}

.payment-benefits h3 {
    margin: 0 0 var(--space-sm);
    font-size: 1rem;
    color: var(--text-dark);
}

.payment-benefits ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.payment-benefits li {
    font-size: 0.9rem;
    color: var(--text-body);
    line-height: 1.4;
}

/* ── Columna derecha: estado y métodos ── */
.payment-status {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.payment-status > h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-dark);
}

/* Tarjeta de estado */
.status-card {
    border-radius: var(--radius-md);
    padding: var(--space-md);
    text-align: center;
    border: 2px solid var(--border-card);
}

.status-card.pending {
    border-color: var(--color-warning);
    background: var(--color-warning-bg);
}

.status-card.paid {
    border-color: var(--color-success);
    background: var(--color-success-bg);
}

.status-icon {
    font-size: 2.5rem;
    line-height: 1;
    margin-bottom: var(--space-xs);
    display: block;
}

.status-card h4 {
    margin: 0 0 var(--space-xs);
    color: var(--text-dark);
    font-size: 1.05rem;
}

.status-card p {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.88rem;
    text-align: center;
    line-height: 1.5;
}

/* Métodos de pago */
.payment-methods h4 {
    margin: 0 0 var(--space-sm);
    font-size: 0.95rem;
    color: var(--text-dark);
}

.method-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-sm);
}

.payment-method {
    background: var(--bg-subtle);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    text-align: center;
    transition: box-shadow var(--transition-fast);
}

.payment-method:hover {
    box-shadow: var(--shadow-sm);
}

.method-icon {
    font-size: 1.8rem;
    line-height: 1;
    margin-bottom: 6px;
    display: block;
}

.payment-method h5 {
    margin: 0 0 4px;
    font-size: 0.82rem;
    color: var(--text-dark);
    font-weight: 600;
}

.payment-method p {
    margin: 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1.4;
    text-align: center;
    word-break: break-all;
}

/* Botones de acción */
.payment-actions {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}

.btn-large {
    padding: 14px var(--space-lg);
    font-size: 1rem;
    font-weight: 600;
    width: 100%;
    border-radius: var(--radius-md);
    min-height: 48px;
}

/* ══════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════ */

/* ── 1024px (tablets horizontal, laptops pequeños) ── */
@media (max-width: 1024px) {
    .dashboard-stats {
        grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    }

    #map {
        height: 340px;
    }

    .summary-cards {
        flex-wrap: wrap;
    }
}

/* ── 768px (tablets vertical) ── */
@media (max-width: 768px) {
    .container {
        padding: var(--space-sm);
    }

    /* Cabecera: apilada verticalmente */
    .dashboard-header {
        flex-direction: column;
        gap: var(--space-sm);
        align-items: stretch;
        text-align: center;
        min-height: unset;
    }

    .dashboard-header h1 {
        font-size: 1.4em;
    }

    .header-actions {
        justify-content: center;
    }

    nav[aria-label="Navegación principal"] {
        position: relative;
    }

    /* Dropdown: posicionado bajo el botón hamburguesa */
    .nav-links.open {
        display: flex;
        position: absolute;
        top: calc(100% + 4px);
        right: 0;
        background: var(--bg-surface);
        border: 1px solid var(--border-light);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-md);
        padding: var(--space-xs);
        flex-direction: column;
        align-items: stretch;
        min-width: 180px;
        z-index: 200;
    }

    .nav-links .admin-btn,
    .nav-links .logout-btn {
        width: 100%;
        justify-content: center;
        border-radius: var(--radius-sm);
    }

    /* Stats */
    .dashboard-stats {
        grid-template-columns: 1fr;
    }

    .summary-cards {
        flex-direction: column;
    }

    /* Cabecera de sección */
    .section-header {
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }

    .section-header .btn-secondary {
        width: 100%;
        text-align: center;
    }

    /* Tablas: scroll horizontal */
    .candidates-section,
    .payments-section {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .candidates-table th,
    .candidates-table td,
    .payments-table th,
    .payments-table td {
        padding: 10px 8px;
        font-size: 14px;
        white-space: nowrap;
    }

    /* Modal: ancho completo */
    .modal-content {
        width: calc(100% - 32px);
        max-width: 100%;
        max-height: 85vh;
        overflow-y: auto;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions button,
    .modal-actions a {
        width: 100%;
    }

    /* Modal de registro (index.html) */
    .modal .modal-content {
        width: calc(100% - 32px);
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Mapa */
    #map {
        height: 260px;
    }

    /* Admin */
    .admin-section {
        padding: var(--space-sm);
    }

    /* Payment */
    .payment-content {
        grid-template-columns: 1fr;
    }

    .payment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-xs);
    }

    .payment-header h1 {
        font-size: 1.3rem;
    }

    .method-grid {
        grid-template-columns: 1fr;
    }
}

/* ── 480px (móviles pequeños) ── */
@media (max-width: 480px) {
    .stat-card {
        padding: 18px;
    }

    .stat-number {
        font-size: 2em;
    }

    .candidates-table th,
    .candidates-table td,
    .payments-table th,
    .payments-table td {
        padding: 8px 6px;
        font-size: 12px;
    }

    .stats-table th,
    .stats-table td {
        padding: 8px 10px;
        font-size: 12px;
    }

    #map {
        height: 200px;
    }

    .summary-card {
        padding: var(--space-sm) var(--space-md);
    }

    .summary-card .card-value {
        font-size: 1.8rem;
    }

    .error-page-code {
        font-size: 4rem;
    }

    .modal-content {
        padding: var(--space-md);
    }

    /* Payment */
    .amount-circle {
        width: 100px;
        height: 100px;
    }

    .amount {
        font-size: 1.6rem;
    }
}

/* ── Acción de registro (index.html) ── */
.register-action {
    text-align: center;
    margin-top: var(--space-md);
}

/* ── Filas de candidatos fallecidos ── */
.row-dead {
    opacity: 0.5;
}
.row-dead a {
    text-decoration: line-through;
}

/* ── Acciones de cabecera (nav links + selector) ── */
.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: var(--space-xs);
}

/* ── Touch targets (mínimo 44×44px, WCAG 2.5.5) ── */
.btn-primary,
.btn-secondary,
.btn-success,
.btn-warning,
.btn-small,
.btn-refresh,
.btn {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.admin-btn,
.logout-btn {
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ── Hamburguesa / menú móvil ── */

/* Mobile-first: oculto por defecto; visible en desktop vía min-width */
.nav-links {
    display: none;
}

@media (min-width: 769px) {
    .nav-links {
        display: flex;
        align-items: center;
        gap: 10px;
        flex-wrap: wrap;
    }
}

.menu-toggle {
    display: none; /* oculto en desktop */
    flex-direction: column;
    gap: 5px;
    background: none;
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: var(--space-xs);
    min-width: 44px;
    min-height: 44px;
    align-items: center;
    justify-content: center;
}

.menu-toggle-bar {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text-dark);
    border-radius: 2px;
    transition: transform var(--transition-fast), opacity var(--transition-fast);
}

.menu-toggle[aria-expanded="true"] .menu-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}
.menu-toggle[aria-expanded="true"] .menu-toggle-bar:nth-child(2) {
    opacity: 0;
}
.menu-toggle[aria-expanded="true"] .menu-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Visible solo en móvil — esta regla va después del display:none global para ganar en cascada */
@media (max-width: 768px) {
    .menu-toggle {
        display: flex;
    }
}

/* ── Wrapper para tablas con scroll horizontal en móvil ── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
}

/* ── Tarjetas de resumen (stats.html) ── */
.summary-cards {
    display: flex;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    flex-wrap: wrap;
}
.summary-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: var(--space-md) 28px;
    flex: 1;
    min-width: 160px;
    text-align: center;
}
.summary-card .card-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: var(--text-dark);
    line-height: 1;
}
.summary-card .card-label {
    font-size: 0.85rem;
    color: var(--color-secondary);
    margin-top: 6px;
}

/* ── Mapa ── */
#map {
    height: 420px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-card);
    margin-bottom: var(--space-lg);
}
.map-note {
    font-size: 0.8rem;
    color: var(--text-faint);
    margin-bottom: var(--space-xs);
}

/* ── Título de sección ── */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-body);
    margin-bottom: var(--space-sm);
}

/* ── Tabla de stats ── */
.stats-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-card);
}
.stats-table th {
    background: var(--bg-faint);
    padding: 10px 14px;
    text-align: left;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--color-secondary);
    letter-spacing: 0.04em;
}
.stats-table td {
    padding: 10px 14px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.9rem;
    color: var(--text-body);
}
.stats-table tr:hover td {
    background: var(--bg-faint);
}

/* ── Secciones admin ── */
.admin-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    overflow-x: auto;
}

.admin-section h2 {
    margin: 0 0 16px 0;
    font-size: 1.1em;
    color: var(--text-dark);
}

/* ── Formulario inline de admin (generar invitación, etc.) ── */
.admin-inline-form {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.admin-text-input {
    flex: 1;
    min-width: 220px;
    padding: 8px 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text-dark);
    font-family: var(--font-family);
    font-size: 0.95em;
}

.admin-text-input::placeholder {
    color: var(--text-faint);
}

.admin-text-input:focus {
    border-color: var(--color-primary);
    outline: none;
}

/* ── Selector de temporada ── */
.season-form {
    display: inline;
}

.season-historical-note {
    margin: 4px 0 0;
    font-size: 0.9em;
    color: var(--text-muted);
}

.season-select {
    padding: 6px 10px;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: 0.9em;
    color: var(--text-body);
    background: var(--bg-surface);
    cursor: pointer;
}

/* ── Leaderboard expandible ── */
.leaderboard-row.has-hits {
    cursor: pointer;
}
.leaderboard-row.has-hits:hover,
.leaderboard-row.has-hits:focus {
    background-color: var(--bg-subtle);
    outline: none;
}
.leaderboard-row.has-hits:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: -3px;
}
.leaderboard-row.leader {
    font-weight: bold;
}
.leaderboard-table {
    margin-top: 24px;
}
.empty-note {
    margin-top: 24px;
    color: var(--text-muted);
}

/* ── Validación inline de formularios ── */
.field-error {
    display: block;
    min-height: 1.2em;
    font-size: 0.82rem;
    color: var(--color-danger-text);
    margin-top: 3px;
}
input[aria-invalid="true"] {
    border-color: var(--color-danger) !important;
    outline-color: var(--color-danger);
}

/* ── Spinner en botones ── */
.btn-spinner {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--text-dark);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
.btn-primary.loading .btn-spinner,
.btn-submit.loading .btn-spinner {
    display: inline-block;
}
.btn-primary.loading,
.btn-submit.loading {
    opacity: 0.8;
    cursor: not-allowed;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Página de política de privacidad ── */
.privacy-page {
    max-width: 800px;
    margin: 0 auto;
    padding: var(--space-lg) 0;
}

.privacy-header {
    margin-bottom: var(--space-lg);
    border-bottom: 2px solid var(--color-primary);
    padding-bottom: var(--space-md);
}

.privacy-header h1 {
    margin: 0 0 var(--space-xs);
    text-align: left;
}

.privacy-updated {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin: 0;
    text-align: left;
}

.privacy-content {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.privacy-section h2 {
    font-size: 1.1rem;
    color: var(--text-dark);
    margin: 0 0 var(--space-sm);
    padding-bottom: 6px;
    border-bottom: 1px solid var(--border-light);
}

.privacy-section p,
.privacy-section li {
    font-size: 0.95rem;
    color: var(--text-body);
    line-height: 1.7;
}

.privacy-section ul {
    padding-left: var(--space-lg);
    margin: var(--space-xs) 0;
}

.privacy-section li {
    margin-bottom: 6px;
}

.privacy-back {
    margin-top: var(--space-xl);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-light);
}

/* ── Páginas de error (404, 500) ── */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    text-align: center;
    gap: var(--space-md);
}
.error-page-code {
    font-family: var(--font-heading);
    font-size: 6rem;
    font-weight: 700;
    color: var(--color-danger);
    line-height: 1;
}
.error-page-title {
    font-size: 1.5rem;
    color: var(--text-dark);
    margin: 0;
}
.error-page-desc {
    color: var(--text-muted);
    margin: 0;
}
.expand-icon {
    display: inline-block;
    margin-left: var(--space-xs);
    font-size: 11px;
    color: var(--color-secondary);
    transition: transform var(--transition-fast);
}
.hits-detail {
    display: none;
    background-color: var(--bg-subtle);
}
.hits-detail.open {
    display: table-row;
}
.hits-detail-inner {
    padding: var(--space-xs) 24px 16px 40px;
}
.hits-inner-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}
.hits-inner-table th {
    text-align: left;
    padding: 6px var(--space-sm);
    color: var(--color-secondary);
    font-weight: 600;
    border-bottom: 1px solid var(--border-light);
}
.hits-inner-table td {
    padding: 6px var(--space-sm);
    color: var(--text-body);
    border-bottom: 1px solid var(--border-subtle);
}
.hits-inner-table tr:last-child td {
    border-bottom: none;
}
.hits-inner-table td:last-child {
    color: var(--color-success);
    font-weight: 600;
}

/* ── Requisitos de contraseña ── */
.password-requirements {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
    font-size: 0.82em;
    color: var(--text-muted);
}
.password-requirements li {
    padding: 2px 0;
}
.password-requirements li::before {
    content: '○ ';
    color: var(--text-muted);
}
.password-requirements li.req-ok::before {
    content: '✓ ';
    color: var(--color-success);
}
.password-requirements li.req-ok {
    color: var(--color-success);
}
.password-requirements li.req-fail::before {
    content: '✗ ';
    color: var(--color-danger);
}
.password-requirements li.req-fail {
    color: var(--color-danger);
}

/* ── Perfil de usuario ── */
.profile-section {
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.profile-section h2 {
    margin: 0 0 var(--space-md) 0;
    font-size: 1.1em;
    color: var(--text-dark);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--border-light);
}

.profile-form {
    max-width: 480px;
}

.profile-actions {
    margin-top: var(--space-md);
}

@media (max-width: 480px) {
    .profile-section {
        padding: var(--space-md);
    }
    .profile-form {
        max-width: 100%;
    }
}

/* ── Zona de peligro (eliminación de cuenta) ── */
.btn-danger {
    background-color: var(--color-danger);
    color: #fff;
    padding: 10px var(--space-md);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all var(--transition-fast);
    text-decoration: none;
    display: inline-block;
}

.btn-danger:hover {
    background-color: #dc2626;
    transform: translateY(-1px);
}

.danger-zone {
    border: 1.5px solid var(--color-danger);
    border-radius: var(--radius-md);
    padding: var(--space-md);
    margin-top: var(--space-md);
    background-color: var(--color-danger-bg);
}

.danger-zone h3 {
    color: var(--color-danger-text);
    margin: 0 0 var(--space-sm) 0;
    font-size: 1em;
}

.warning-text {
    color: var(--color-danger-text);
    font-size: 0.9em;
    margin-bottom: var(--space-md);
}

/* ───── Pie de página legal ───── */
.site-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.site-footer a {
    color: inherit;
    text-decoration: underline;
}

.site-footer a:hover {
    color: var(--color-primary);
}

/* ── Utilidades CSP (SPEC-13) ── */
/* Transformación de texto para campo de código de invitación */
.input-uppercase {
    text-transform: uppercase;
}

/* ── Clases usadas en plantillas sin definición CSS (SPEC-29 D4) ── */
.error-message {
    display: block;
    color: var(--color-danger-text);
    font-size: 0.9rem;
    margin-top: 6px;
}

.help-text {
    display: block;
    color: var(--text-faint);
    font-size: 0.85rem;
    margin-top: 4px;
}

.checkbox-group {
    margin-top: var(--space-sm);
}

.payment-container {
    max-width: 900px;
    margin: 0 auto;
}

/* Clase genérica para ocultar elementos — sustituye a style="display:none" inline */
.hidden {
    display: none !important;
}

/* Estilos para bloques que antes usaban style= inline en candidate_detail.html */
.candidate-detail-content {
    margin-top: 24px;
}
.candidate-detail-stat-number {
    font-size: 1rem;
}
.candidate-detail-links {
    margin-top: 16px;
}
.candidate-detail-owners {
    margin-top: 32px;
}
.candidate-detail-empty {
    color: var(--text-medium);
}

/* Biografía de la ficha: descripción y foto (SPEC-42) */
.candidate-profile {
    margin-top: 32px;
}
.candidate-profile-card {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: var(--space-md);
    align-items: start;
    padding: var(--space-md);
    background: var(--bg-subtle);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.candidate-profile-photo {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius-md);
}
/* Fallecido: la foto pierde el color; los distintivos, no (SPEC-44) */
.candidate-profile-photo--deceased img {
    filter: grayscale(1);
}
/* Silueta de reserva para las fichas sin foto (SPEC-44) */
.candidate-profile-silhouette {
    aspect-ratio: 3 / 4;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
}
.candidate-profile-silhouette svg {
    display: block;
    width: 78%;
    height: auto;
    fill: var(--text-faint);
}
/* Crespón: franja negra en diagonal, esquina superior izquierda (SPEC-44) */
.candidate-photo-ribbon {
    position: absolute;
    top: 16px;
    left: -42px;
    width: 140px;
    height: 20px;
    background: #000;
    border-top: 1px solid rgba(255, 255, 255, 0.45);
    border-bottom: 1px solid rgba(255, 255, 255, 0.45);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.5);
    transform: rotate(-45deg);
    pointer-events: none;
}
/* Corona: es el capitán de quien mira, esquina superior derecha (SPEC-44) */
.candidate-photo-crown {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    line-height: 1;
    background: rgba(22, 33, 62, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    pointer-events: none;
}
.candidate-profile-photo img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
}
.candidate-profile-text {
    min-width: 0;
}
.candidate-profile-text p {
    margin: 0 0 12px;
    text-align: left;
    line-height: 1.6;
    color: var(--text-body);
}
.candidate-profile-text p:last-child {
    margin-bottom: 0;
}
.candidate-profile-text .candidate-profile-lead {
    color: var(--text-dark);
    font-weight: 700;
}
.candidate-profile-lead::first-letter {
    text-transform: uppercase;
}
.candidate-profile-card--link {
    color: inherit;
    text-decoration: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.candidate-profile-card--link:hover {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-md);
    text-decoration: none;
}
.candidate-profile-text .candidate-profile-empty {
    color: var(--text-medium);
}
/* Créditos de fotos y textos de las fichas, en el aviso legal (SPEC-42, RF-8) */
.legal-credits-details summary {
    cursor: pointer;
    color: var(--text-dark);
    font-weight: 600;
    padding: 8px 0;
}
.legal-credits-details[open] summary {
    margin-bottom: 12px;
}
.legal-credits-wrap {
    overflow-x: auto;
}
.legal-credits td {
    overflow-wrap: anywhere;
    vertical-align: top;
}
.legal-credits td:last-child {
    white-space: nowrap;
}
@media (max-width: 768px) {
    .candidate-profile-card {
        grid-template-columns: 1fr;
    }
    .candidate-profile-photo {
        width: 100%;
        max-width: 260px;
        margin: 0 auto;
    }
}

/* Estilos para bloques que antes usaban style= inline en 2fa_setup.html */
.totp-qr-block {
    text-align: center;
    margin: 1.5rem 0;
}
.totp-qr-img {
    max-width: 220px;
    border: 4px solid #fff;
    border-radius: 8px;
}
.totp-secret-block {
    font-family: monospace;
    font-size: 1.1rem;
    letter-spacing: 0.15em;
    text-align: center;
    padding: 0.75rem;
}
.totp-confirm-heading {
    margin-top: 1.5rem;
}

/* Estilos para bloques que antes usaban style= inline en 2fa_recovery_codes.html */
.recovery-codes-block {
    font-family: monospace;
    font-size: 0.95rem;
    line-height: 2;
}
.recovery-codes-actions {
    margin-top: 1.5rem;
}

/* Estilos para bloques que antes usaban style= inline en profile.html */
.profile-export-actions {
    margin-bottom: 1.5rem;
}

/* Estilos para bloques que antes usaban style= inline en admin.html */
.admin-year-input {
    width: 160px;
}
.admin-date-input {
    width: 160px;
}
.admin-carryover-input {
    width: 120px;
}
.admin-text-muted-block {
    margin-bottom: 1rem;
}
/* Formularios inline del admin (sustituye a style="display:inline") */
.admin-inline-action-form {
    display: inline;
}
/* Formulario de crear temporada (sustituye a style="margin-bottom: 1.5rem") */
.admin-create-season-form {
    margin-bottom: 1.5rem;
}

.admin-toggle-subform {
    display: none;
    margin-top: 0.5rem;
}
.admin-toggle-subform.admin-toggle-subform-open {
    display: block;
}

/* Estilos para bloques que antes usaban style= inline en payment.html */
.payment-info-flex {
    flex: 1;
}
.payment-closed-card {
    background: var(--color-error, #c0392b);
    color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1rem;
}
.payment-closed-back {
    margin-top: 1.5rem;
}

/* Error message oculto (transferPaidWarning) */
.error-message-hidden {
    display: none;
}
