:root {
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-text: #1c1f26;
    --color-muted: #6b7280;
    --color-border: #e2e4e9;
    --color-primary: #1d4e89;
    --color-primary-dark: #163c69;
    --color-success-bg: #e6f4ea;
    --color-success-text: #1e7a34;
    --color-error-bg: #fdecea;
    --color-error-text: #b3261e;
    --radius: 10px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.5;
}

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

.container {
    max-width: 640px;
    margin: 0 auto;
    padding: 1rem;
}

/* Encabezado */

.site-header {
    background: var(--color-primary);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header__bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
    padding: 0.75rem 1rem;
    max-width: 640px;
    margin: 0 auto;
}

.brand {
    display: flex;
    align-items: center;
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    font-size: 1.05rem;
}

.brand-logo {
    height: 38px;
    width: auto;
    display: block;
}

.brand-logo--full {
    display: none;
}

.brand-logo--mobile {
    display: block;
}

@media (min-width: 700px) {
    .brand-logo--full {
        display: block;
    }

    .brand-logo--mobile {
        display: none;
    }
}

.site-header__user {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
    margin-right: auto;
}

.avatar-mini {
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    max-width: 50px;
    max-height: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    flex-shrink: 0;
}

.site-header__name {
    color: #fff;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 110px;
}

.site-header__right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.nav-toggle {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    cursor: pointer;
    display: block;
}

.nav-link--logout {
    color: #fff;
    background: none;
    border: none;
    border-left: 1px solid rgba(255, 255, 255, 0.35);
    padding: 0.25rem 0 0.25rem 0.75rem;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
    white-space: nowrap;
}

.site-nav {
    display: none;
    flex-direction: column;
    background: var(--color-primary-dark);
    padding: 0.5rem 1rem 1rem;
}

.site-nav.open {
    display: flex;
}

.site-nav a,
.site-nav .nav-link {
    color: #fff;
    text-decoration: none;
    padding: 0.6rem 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    text-align: left;
    font: inherit;
    cursor: pointer;
    width: 100%;
}

.site-nav a.active {
    font-weight: 700;
}

.nav-link--disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.nav-dropdown {
    position: relative;
    width: 100%;
}

.nav-dropdown__toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.nav-dropdown__menu {
    display: none;
    flex-direction: column;
    padding-left: 1rem;
}

.nav-dropdown.open .nav-dropdown__menu {
    display: flex;
}

.nav-dropdown__menu a {
    color: #fff;
    text-decoration: none;
    padding: 0.55rem 0.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    font-size: 0.95rem;
}

.nav-logout {
    margin: 0;
    padding: 0;
}

@media (min-width: 700px) {
    .nav-toggle {
        display: none;
    }

    .site-nav {
        display: flex !important;
        flex-direction: row;
        align-items: center;
        gap: 1rem;
        background: none;
        padding: 0;
    }

    .site-nav a,
    .site-nav .nav-link {
        border: none;
        width: auto;
        padding: 0.25rem 0;
    }

    .nav-dropdown {
        width: auto;
    }

    .nav-dropdown__menu {
        position: absolute;
        top: 100%;
        left: 0;
        margin-top: 0.5rem;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: 8px;
        box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
        padding: 0.4rem;
        min-width: 200px;
        z-index: 10;
    }

    .nav-dropdown__menu a {
        color: var(--color-text);
        border-bottom: none;
        border-radius: 6px;
        padding: 0.55rem 0.6rem;
    }

    .nav-dropdown__menu a:hover {
        background: var(--color-bg);
    }
}

/* Tarjetas y formularios */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.25rem;
    margin-bottom: 1rem;
}

.card--narrow {
    max-width: 420px;
    margin-left: auto;
    margin-right: auto;
}

.auth-brand {
    display: flex;
    justify-content: center;
    margin: 1.5rem 0 1rem;
}

.auth-brand__logo {
    height: 64px;
    width: auto;
    display: block;
}

.card__header {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    justify-content: space-between;
}

.card h1 {
    margin-top: 0;
    font-size: 1.3rem;
}

.card h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

.card h3 {
    margin: 1.1rem 0 0.3rem;
    font-size: 1rem;
}

form label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    margin: 0.85rem 0 0.3rem;
}

form label.checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

form input[type="text"],
form input[type="password"],
form input[type="email"],
form input[type="file"],
form input[type="number"],
form input[type="date"],
form input[type="search"],
form select,
form textarea {
    width: 100%;
    padding: 0.55rem 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: 1rem;
    background: #fff;
    color: var(--color-text);
    font-family: inherit;
}

form input:disabled {
    background: var(--color-bg);
    color: var(--color-muted);
}

.btn {
    display: inline-block;
    margin-top: 1rem;
    padding: 0.6rem 1.1rem;
    border-radius: 6px;
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
    cursor: pointer;
}

.btn--primary {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.link-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-primary);
    text-decoration: underline;
    cursor: pointer;
    font-size: 0.9rem;
}

.hint {
    color: var(--color-muted);
    font-size: 0.9rem;
}

.hint--error {
    color: var(--color-error-text);
}

.plan-option {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.65rem 0.8rem;
    margin: 0.4rem 0;
    cursor: pointer;
    font-weight: 400;
}

.plan-option input {
    margin-top: 0.2rem;
}

.badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge--pendiente {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.badge--reportado {
    background: #fff4e0;
    color: #8a5a00;
}

.badge--confirmado {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge--atrasado {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.badge--al_corriente {
    background: var(--color-success-bg);
    color: var(--color-success-text);
}

.badge--sin_plan {
    background: #eef0f2;
    color: var(--color-muted);
}

.avatar-preview {
    width: 96px;
    height: 96px;
    object-fit: cover;
    border-radius: 50%;
    border: 1px solid var(--color-border);
}

/* Alertas */

.alert {
    padding: 0.7rem 0.9rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

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

.alert--error {
    background: var(--color-error-bg);
    color: var(--color-error-text);
}

.alert--info {
    background: #eef2f7;
    color: var(--color-text);
}

/* Tablas */

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    text-align: left;
    padding: 0.55rem 0.6rem;
    border-bottom: 1px solid var(--color-border);
    white-space: nowrap;
}

/* Listados (jugadores, control de pagos, pendientes, grupos): encabezado y
   1ra columna (identifica al jugador) fijos al hacer scroll, en todos los
   anchos de pantalla. El scroll (vertical Y horizontal) queda contenido
   dentro de .table-wrap--sticky, nunca hay que ir al fondo de la pagina
   para encontrar la barra horizontal. */

.table-wrap--sticky {
    max-height: 75vh;
    overflow: auto;
}

/* border-collapse: separate (en vez de collapse) + box-shadow en vez de
   border-bottom: con collapse, los bordes se COMPARTEN entre celdas
   vecinas y el fondo opaco de una celda sticky no alcanza a cubrir el
   borde de la celda de al lado — se veian letras de las filas de abajo
   "transparentandose" a traves de esa rendija al hacer scroll. */
.table-wrap--sticky table {
    border-collapse: separate;
    border-spacing: 0;
}

.table-wrap--sticky th,
.table-wrap--sticky td {
    border-bottom: none;
    box-shadow: inset 0 -1px 0 var(--color-border);
    background-color: var(--color-surface);
}

.table-wrap--sticky thead th {
    position: sticky;
    top: 0;
    z-index: 2;
}

.table-wrap--sticky tbody td:first-child,
.table-wrap--sticky thead th:first-child {
    position: sticky;
    left: 0;
    z-index: 1;
}

.table-wrap--sticky thead th:first-child {
    z-index: 3;
}

td.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: center;
    white-space: normal;
}

td.actions form {
    display: inline;
    margin: 0;
}

/* Tablero de control de pagos */

.stat-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.stat-tile {
    flex: 1 1 150px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0.7rem 0.9rem;
}

.stat-tile__value {
    font-size: 1.4rem;
    font-weight: 700;
}

.stat-tile__label {
    color: var(--color-muted);
    font-size: 0.85rem;
}

.stat-tile--accent {
    background: #fff4e0;
    border-color: #f0c580;
}

.stat-tile--accent .stat-tile__value {
    color: #8a5a00;
}

.filter-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.9rem;
}

.filter-tabs a {
    display: inline-block;
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}

.filter-tabs a.active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.reported-list {
    flex-basis: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.reported-item {
    background: #fff4e0;
    border-radius: 6px;
    padding: 0.45rem 0.6rem;
    font-size: 0.85rem;
    white-space: normal;
}

/* Menu de admin */

.admin-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.admin-menu a {
    display: block;
    padding: 0.6rem 0.75rem;
    background: var(--color-bg);
    border-radius: 6px;
    text-decoration: none;
}
