* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
    margin: 0;
    background: #F4F1EA;
    color: #121215;
    font-family: 'Barlow', sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ===== Login ===== */
.login-body {
    background: #121215;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-box {
    background: #fff;
    width: 100%;
    max-width: 380px;
    padding: 40px 32px 32px;
    border-radius: 8px;
    box-shadow: 0 30px 60px -20px rgba(0,0,0,.6);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-title {
    font-family: 'Anton', sans-serif;
    font-size: 26px;
    letter-spacing: .02em;
}
.login-subtitle {
    display: block;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    color: #0055A4;
    font-size: 12px;
    letter-spacing: .28em;
    margin-top: 4px;
}
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 12px;
    color: #6b6559;
    margin-top: 12px;
}
.login-form input {
    padding: 11px 12px;
    border: 1px solid #ddd7cb;
    border-radius: 5px;
    font-family: 'Barlow', sans-serif;
    font-size: 15px;
    background: #F4F1EA;
}
.login-form input:focus {
    outline: 2px solid #0055A4;
    outline-offset: 1px;
    background: #fff;
}
.btn-admin-primary {
    margin-top: 22px;
    background: #0055A4;
    color: #fff;
    border: 0;
    padding: 13px;
    border-radius: 5px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    font-size: 15px;
    cursor: pointer;
    transition: background .2s;
}
.btn-admin-primary:hover { background: #003D7A; }
.login-back {
    display: block;
    text-align: center;
    margin-top: 20px;
    color: #8a8475;
    text-decoration: none;
    font-size: 13px;
}
.login-back:hover { color: #0055A4; }

.alert {
    padding: 11px 14px;
    border-radius: 5px;
    font-size: 14px;
    margin-bottom: 8px;
}
.alert-error { background: #fde8e8; color: #b91c1c; border: 1px solid #f3c2c2; }
.alert-success { background: #e5f7ee; color: #187a4c; border: 1px solid #b9e6cd; }

/* ===== Layout general del panel ===== */
.admin-header {
    background: #121215;
    border-bottom: 3px solid #0055A4;
}
.admin-header-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}
.admin-brand-title {
    font-family: 'Anton', sans-serif;
    color: #fff;
    font-size: 20px;
    margin-right: 10px;
}
.admin-brand-sub {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    color: #0055A4;
    font-size: 12px;
    letter-spacing: .2em;
}
.admin-header-actions { display: flex; gap: 10px; }
.btn-admin-ghost {
    text-decoration: none;
    color: #fff;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.2);
    padding: 8px 16px;
    border-radius: 5px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-size: 13px;
    transition: background .2s;
}
.btn-admin-ghost:hover { background: rgba(255,255,255,.18); }

.admin-layout {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 24px;
    padding: 24px;
    align-items: flex-start;
}
.admin-nav {
    flex: 0 0 220px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: #fff;
    border-radius: 8px;
    padding: 10px;
    position: sticky;
    top: 24px;
}
.admin-nav a {
    text-decoration: none;
    color: #121215;
    padding: 12px 14px;
    border-radius: 6px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    letter-spacing: .03em;
    font-size: 15px;
    transition: background .15s;
}
.admin-nav a:hover { background: #f0ede4; }
.admin-nav a.active { background: #0055A4; color: #fff; }
.permisos-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
    margin: 10px 0 4px;
}
.permisos-checks label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-family: 'Barlow', sans-serif;
    font-size: 14px;
    color: #121215;
}
.permisos-checks input { width: auto; }

.admin-nav-categoria {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    font-size: 11px;
    color: #8a8475;
    padding: 14px 14px 4px;
}
.admin-nav-categoria:first-child { padding-top: 6px; }

.admin-usuario-actual {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    line-height: 1.25;
    color: #fff;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 600;
    font-size: 14px;
    margin-right: 4px;
}
.admin-usuario-actual small {
    color: #8a8475;
    font-size: 11px;
    letter-spacing: .05em;
    text-transform: uppercase;
}

.admin-content {
    flex: 1;
    min-width: 0;
    background: #fff;
    border-radius: 8px;
    padding: 26px 28px;
}

.admin-content h1 {
    font-family: 'Anton', sans-serif;
    font-size: 26px;
    margin: 0 0 4px;
    text-transform: uppercase;
}
.admin-content .subtitle {
    color: #8a8475;
    font-size: 14px;
    margin: 0 0 22px;
}

/* ===== Tablas ===== */
.admin-table-wrap { overflow-x: auto; margin-bottom: 34px; }
.admin-filter-bar {
    background: #F4F1EA;
    border: 1px solid #ece8df;
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 20px;
}
.form-field-btn { justify-content: flex-end; }
.form-field-btn .btn-admin-secondary { width: 100%; }
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 620px;
}
.admin-table th {
    text-align: left;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    font-size: 12px;
    color: #8a8475;
    padding: 10px 8px;
    border-bottom: 2px solid #ece8df;
}
.admin-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #ece8df;
    vertical-align: middle;
}
.admin-table tr:hover td { background: #faf9f5; }
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .06em;
    color: #fff;
    background: #8a8475;
}
.badge-senior   { background: #0055A4; }
.badge-cadete   { background: #2ec27a; }
.badge-alevin   { background: #f0b232; }
.badge-benjamin { background: #b9484f; }
.badge-prebenjamin { background: #8B4FD1; }
.badge-chupetines  { background: #2F6FD0; }
.badge-win  { background: #2ec27a; }
.badge-draw { background: #f0b232; }
.badge-loss { background: #e4444c; }
.badge-success { background: #2ec27a; }
.badge-pending { background: #f0b232; }

.table-actions { white-space: nowrap; }
.table-actions > * + * { margin-left: 8px; }

/* Selector de destinatario (jugador / usuario de la app) en "Dar cromos" */
.selector-picker {
    border: 1px solid #e4e0d4;
    border-radius: 10px;
    max-height: 340px;
    overflow-y: auto;
    background: #fff;
}
.selector-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-bottom: 1px solid #f0ede3;
    cursor: pointer;
    transition: background .12s ease;
}
.selector-row:last-child { border-bottom: none; }
.selector-row:hover { background: #faf9f5; }
.selector-row input[type="radio"] {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    accent-color: #0055A4;
}
.selector-row.selected {
    background: #eef4fb;
}
.selector-avatar {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: #0055A4;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 13px;
}
.selector-avatar.es-usuario { background: #8a8475; }
.selector-meta { flex: 1 1 auto; min-width: 0; }
.selector-meta .selector-nombre {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.selector-meta .selector-sub {
    font-size: 12.5px;
    color: #8a8475;
    margin-top: 2px;
}
.selector-empty {
    padding: 18px 14px;
    color: #8a8475;
    font-style: italic;
}
.selector-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
}
.selector-tabs button {
    flex: 1 1 0;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid #e4e0d4;
    background: #fff;
    cursor: pointer;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: 13px;
    color: #4a4636;
    transition: all .12s ease;
}
.selector-tabs button.active {
    background: #0055A4;
    border-color: #0055A4;
    color: #fff;
}
.btn-icon {
    text-decoration: none;
    display: inline-block;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 13px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    border: 1px solid transparent;
    cursor: pointer;
}
.btn-icon.edit { background: #eef4fb; color: #0055A4; }
.btn-icon.edit:hover { background: #dceafb; }
.btn-icon.delete { background: #fdeceb; color: #c0392b; border: 0; }
.btn-icon.delete:hover { background: #f9d9d6; }

/* ===== Formularios ===== */
.admin-form {
    background: #F4F1EA;
    border: 1px solid #ece8df;
    border-radius: 8px;
    padding: 22px;
}
.admin-form h2 {
    font-family: 'Anton', sans-serif;
    font-size: 19px;
    margin: 0 0 16px;
    text-transform: uppercase;
}
.api-key-code {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    background: #F4F1EA;
    border: 1px solid #ece8df;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 12px;
    margin-right: 6px;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 14px;
}
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 12px;
    color: #6b6559;
}
.form-field input,
.form-field select {
    padding: 10px 11px;
    border: 1px solid #ddd7cb;
    border-radius: 5px;
    font-family: 'Barlow', sans-serif;
    font-size: 14px;
    background: #fff;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
    outline: 2px solid #0055A4;
    outline-offset: 1px;
}
.form-field textarea {
    padding: 10px 11px;
    border: 1px solid #ddd7cb;
    border-radius: 5px;
    font-family: 'Barlow', sans-serif;
    font-size: 14px;
    background: #fff;
    resize: vertical;
}
.admin-thumb {
    width: 56px;
    height: 40px;
    object-fit: cover;
    border-radius: 4px;
    display: block;
}
.admin-thumb-preview {
    width: 100%;
    max-width: 160px;
    height: 90px;
    object-fit: cover;
    border-radius: 5px;
    margin-top: 8px;
    display: block;
    border: 1px solid #ddd7cb;
}
.form-actions {
    margin-top: 18px;
    display: flex;
    gap: 10px;
}
.btn-admin-secondary {
    background: transparent;
    color: #6b6559;
    border: 1px solid #ddd7cb;
    padding: 11px 18px;
    border-radius: 5px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    font-size: 13px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}
.btn-admin-secondary:hover { background: #ece8df; }

.section-divider {
    margin: 30px 0 20px;
    border: 0;
    border-top: 1px solid #ece8df;
}

@media (max-width: 760px) {
    .admin-layout { flex-direction: column; }
    .admin-nav { flex-direction: row; flex-wrap: wrap; position: static; width: 100%; }
    .admin-nav a { flex: 1 1 auto; text-align: center; }
}

/* ===== Editor visual del cromo ===== */
.cromo-editor-wrap {
    display: grid;
    grid-template-columns: minmax(220px, 340px) 1fr;
    gap: 24px;
    align-items: start;
}
@media (max-width: 900px) {
    .cromo-editor-wrap { grid-template-columns: 1fr; }
}
.cromo-stage {
    position: relative;
    width: 100%;
    max-width: 340px;
    background: repeating-linear-gradient(135deg, #e7e3da, #e7e3da 11px, #efece4 11px, #efece4 22px);
    border: 1px solid #ddd7cb;
    border-radius: 6px;
    overflow: hidden;
    user-select: none;
    touch-action: none;
}
.cromo-stage img.cromo-stage-bg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
    z-index: 3;
}
.cromo-stage-empty {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 13px;
    color: #9a9382;
    padding: 12px;
}
.cromo-box {
    position: absolute;
    border: 2px dashed #0055A4;
    background: rgba(0,85,164,.12);
    cursor: move;
    z-index: 4;
    min-width: 24px;
    min-height: 24px;
}
.cromo-box-label {
    position: absolute;
    top: -22px;
    left: 0;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: #0055A4;
    background: #fff;
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
}
.cromo-handle {
    position: absolute;
    right: -7px;
    bottom: -7px;
    width: 14px;
    height: 14px;
    background: #0055A4;
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: nwse-resize;
    z-index: 5;
}
.cromo-point {
    position: absolute;
    transform: translate(-50%, -50%);
    cursor: move;
    z-index: 4;
    font-family: 'Anton', sans-serif;
    padding: 2px 4px;
    border-radius: 3px;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0,0,0,.5);
    outline: 1px dashed rgba(255,255,255,.7);
}
.cromo-point.dorsal { font-size: 20px; }
.cromo-point.posicion { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.cromo-help {
    font-family: 'Barlow', sans-serif;
    font-size: 13px;
    color: #6b6559;
    margin: 0 0 14px;
}
.cromo-group {
    margin-bottom: 22px;
    padding-bottom: 18px;
    border-bottom: 1px solid #ece8df;
}
.cromo-group:last-child { border-bottom: 0; }
.cromo-group h3 {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-size: 14px;
    color: #121215;
    margin: 0 0 10px;
}

/* ===== Sobres de cromos ===== */
.sobres-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.sobre-card {
    background: #fff;
    border: 1px solid #ece8df;
    border-radius: 8px;
    overflow: hidden;
}
.sobre-card-img {
    width: 100%;
    aspect-ratio: 4/3;
    object-fit: cover;
    display: block;
    background: #F4F1EA;
}
.sobre-card-img-vacio {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #9a9382;
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 13px;
}
.sobre-card-body { padding: 14px; }
.sobre-card-nombre {
    font-family: 'Anton', sans-serif;
    font-size: 16px;
    margin-bottom: 2px;
}
.sobre-card-cantidad {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 12px;
    color: #6b6559;
    text-transform: uppercase;
    letter-spacing: .06em;
    margin-bottom: 12px;
}
.sobre-card-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.btn-volver {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    background: #eef4fb;
    color: #0055A4;
    padding: 9px 16px;
    border-radius: 6px;
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    font-size: 13px;
    margin-bottom: 16px;
    transition: background .15s;
}
.btn-volver:hover { background: #dceafb; }

#visorCromo .cromo-render{
    width:360px !important;
    max-width:90vw;
    background: none !important;
}

#visorCromo img{
    max-width:100%;
}
.cromo-render-dorsal { font-family: 'Anton', sans-serif; line-height: .8; }
.cromo-render-posicion { font-family: 'Barlow Condensed', sans-serif; font-weight: 700; text-transform: uppercase; }


/* ===== Cromo ya renderizado (vista previa en tablas del panel) ===== */
.cromo-render {
    position: relative;
    width: 100%;
    container-type: inline-size;
    background: repeating-linear-gradient(135deg, #e7e3da, #e7e3da 8px, #efece4 8px, #efece4 16px);
    overflow: hidden;
    border-radius: 4px;
}
.cromo-render-foto {
    position: absolute;
    object-fit: cover;
    z-index: 2;
}
.cromo-render-marco {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    z-index: 1;
    pointer-events: none;
}
/* ===== Pagos (cuadrícula anual de cuotas) ===== */
.pagos-resumen-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 22px;
    background: #F4F1EA;
    border: 1px solid #ece8df;
    border-radius: 8px;
    padding: 14px 18px;
    margin-bottom: 20px;
}
.pagos-resumen-item { display: flex; flex-direction: column; }
.pagos-resumen-valor {
    font-family: 'Anton', sans-serif;
    font-size: 22px;
    color: #0055A4;
    line-height: 1.1;
}
.pagos-resumen-label {
    font-family: 'Barlow Condensed', sans-serif;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #8a8475;
}
.pagos-table { min-width: 900px; }
.pagos-table th, .pagos-table td { text-align: center; padding: 8px 6px; }
.pagos-table th:first-child, .pagos-table td:first-child { text-align: left; }
.pagos-table th:first-child,
.pagos-table td:first-child {
    position: sticky;
    left: 0;
    background: #fff;
    z-index: 1;
}
.pagos-table th:first-child { z-index: 2; }
.pagos-table tr:hover td:first-child { background: #faf9f5; }
.pagos-jugador {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 190px;
}
.pagos-jugador-nombre { font-weight: 600; }
.pagos-jugador-sub { font-size: 12px; color: #8a8475; }
.pagos-celda-wrap { position: relative; display: inline-block; }
.pagos-celda {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 7px;
    border: 1px solid #e4e0d4;
    background: #fbfaf6;
    color: #b3ac9a;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform .1s ease, background .15s ease;
}
.pagos-celda:hover { transform: scale(1.08); }
.pagos-celda.pagada { background: #2ec27a; border-color: #269a63; color: #fff; }
.pagos-celda-inactiva {
    background: transparent;
    border-color: transparent;
    color: #d7d2c4;
    cursor: default;
}
.pagos-celda-inactiva:hover { transform: none; }
.pagos-celda-editar {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #0055A4;
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity .12s ease;
    border: 2px solid #fff;
}
.pagos-celda-wrap:hover .pagos-celda-editar { opacity: 1; }
.pagos-resumen-jugador {
    font-family: 'Barlow Condensed', sans-serif;
    font-weight: 700;
    color: #6b6559;
    white-space: nowrap;
}
.pagos-leyenda { display: flex; gap: 18px; flex-wrap: wrap; align-items: center; margin: 10px 0 22px; font-size: 13px; color: #6b6559; }
.pagos-leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.pagos-leyenda i { width: 16px; height: 16px; border-radius: 5px; display: inline-block; border: 1px solid #e4e0d4; }
.pagos-leyenda i.pagada { background: #2ec27a; border-color: #269a63; }
.pagos-leyenda i.pendiente { background: #fbfaf6; }
.pagos-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.55);
    z-index: 999999;
    justify-content: center;
    align-items: center;
    padding: 20px;
}
.pagos-modal {
    background: #fff;
    border-radius: 10px;
    padding: 22px 24px;
    width: 100%;
    max-width: 420px;
    max-height: 90vh;
    overflow-y: auto;
}
.pagos-modal h2 { margin-top: 0; }
.pagos-metodo-nota {
    display: block;
    color: #8a5b00;
    background: #fff7e6;
    border: 1px solid #f0dca6;
    border-radius: 6px;
    padding: 6px 10px;
    margin-top: 6px;
    font-size: 12.5px;
}

.cromo-render-dorsal,
.cromo-render-posicion {
    position: absolute;
    transform: translate(-50%, -50%);
    z-index: 3;
    white-space: nowrap;
    text-shadow: 0 1px 4px rgba(0,0,0,.35);
}