/* ============================================================
   Master League — Components
   Mobile-first. Editorial direction.
   ============================================================ */

/* ====================  CARD  ==================== */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
}
@media (min-width: 768px) {
    .card { padding: var(--space-5); }
}

.card-flush { padding: 0; overflow: hidden; }
.card-elevated { box-shadow: var(--shadow-md); }
.card-interactive {
    transition: border-color var(--transition-base), background var(--transition-base);
    cursor: pointer;
}
.card-interactive:hover {
    border-color: var(--color-border-strong);
    background: var(--color-surface-hover);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--color-border);
}
.card-header h2,
.card-header h3 { margin: 0; }


/* ====================  SECTION HEADER  ==================== */
.section-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}
.section-head .eyebrow {
    display: block;
    text-transform: uppercase;
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-wider);
    color: var(--color-text-muted);
    margin-bottom: var(--space-1);
}
.section-head h2 {
    font-size: var(--text-xl);
    margin: 0;
}
.section-head .section-link {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    white-space: nowrap;
}
.section-head .section-link:hover { color: var(--color-accent); }


/* ====================  KPI  ==================== */
.kpi {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
}
.kpi-label {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
    color: var(--color-text-muted);
    font-weight: var(--weight-medium);
}
.kpi-value {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: var(--weight-black);
    color: var(--color-text-strong);
    line-height: 1;
    letter-spacing: var(--tracking-tight);
    font-variant-numeric: tabular-nums;
}
.kpi-value.is-positive { color: var(--color-success); }
.kpi-value.is-negative { color: var(--color-danger); }
.kpi-meta {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}


/* ====================  BUTTON  ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--tap-target);
    padding: 0 var(--space-5);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    background: var(--color-surface-2);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.btn:hover {
    background: var(--color-surface-hover);
    color: var(--color-text-strong);
}

.btn-primary {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}
.btn-primary:hover {
    background: var(--color-accent-hover);
    border-color: var(--color-accent-hover);
    color: white;
}

.btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--color-text-muted);
}
.btn-ghost:hover {
    background: var(--color-surface-2);
    color: var(--color-text-strong);
}

.btn-danger {
    background: var(--color-danger-soft);
    border-color: transparent;
    color: var(--color-danger);
}
.btn-danger:hover {
    background: var(--color-danger);
    color: white;
}

.btn-sm { min-height: 36px; padding: 0 var(--space-3); font-size: var(--text-xs); }
.btn-lg { min-height: 52px; padding: 0 var(--space-6); font-size: var(--text-base); }
.btn-block { width: 100%; }
.btn[disabled],
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* === Btn legacy aliases (Bootstrap-like, usados en páginas pre-design-system) === */
.btn-success {
    background: var(--color-success-soft);
    border-color: transparent;
    color: var(--color-success);
}
.btn-success:hover {
    background: var(--color-success);
    color: white;
}
.btn-info {
    background: var(--color-accent-soft);
    border-color: transparent;
    color: var(--color-accent);
}
.btn-info:hover {
    background: var(--color-accent);
    color: white;
}
.btn-secondary {
    background: var(--color-surface-2);
    border-color: var(--color-border);
    color: var(--color-text);
}
.btn-secondary:hover {
    background: var(--color-surface-2-hover, var(--color-surface));
    border-color: var(--color-border-strong);
}
.btn-warning {
    background: var(--color-warning-soft);
    border-color: transparent;
    color: var(--color-warning);
}
.btn-warning:hover {
    background: var(--color-warning);
    color: white;
}


/* ====================  BADGE / TAG  ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    border-radius: var(--radius-sm);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    line-height: 1.5;
}
.badge-accent { background: var(--color-accent-soft); color: var(--color-accent); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }


/* ====================  ALERT (Atención) ==================== */
.alert-list { display: flex; flex-direction: column; gap: var(--space-2); }

.alert-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left-width: 3px;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: var(--color-text);
    transition: background var(--transition-fast), transform var(--transition-fast);
}
.alert-item:hover { background: var(--color-surface-hover); color: var(--color-text); }
.alert-item.is-danger { border-left-color: var(--color-danger); }
.alert-item.is-warning { border-left-color: var(--color-warning); }
.alert-item.is-info { border-left-color: var(--color-accent); }
.alert-item.is-success { border-left-color: var(--color-success); }

.alert-icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
}
.alert-item.is-danger .alert-icon { background: var(--color-danger-soft); color: var(--color-danger); }
.alert-item.is-warning .alert-icon { background: var(--color-warning-soft); color: var(--color-warning); }
.alert-item.is-info .alert-icon { background: var(--color-accent-soft); color: var(--color-accent); }
.alert-item.is-success .alert-icon { background: var(--color-success-soft); color: var(--color-success); }

.alert-body { flex: 1; min-width: 0; }
.alert-title {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text-strong);
    margin: 0 0 2px;
}
.alert-desc {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin: 0;
}
.alert-arrow {
    flex-shrink: 0;
    color: var(--color-text-subtle);
    font-size: var(--text-xs);
}


/* ====================  FIXTURE (próximo partido) ==================== */
.fixture {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-4) var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}
@media (min-width: 480px) {
    .fixture { gap: var(--space-3); padding: var(--space-5) var(--space-4); }
}
@media (min-width: 768px) {
    .fixture { padding: var(--space-6); gap: var(--space-5); }
}

.fixture-team {
    text-align: center;
    min-width: 0;
    overflow: hidden;
}

.fixture-logo {
    display: block;
    width: clamp(40px, 14vw, 56px);
    height: clamp(40px, 14vw, 56px);
    max-width: 100%;
    object-fit: contain;
    margin-inline: auto;
    margin-bottom: var(--space-2);
}
@media (min-width: 768px) {
    .fixture-logo { width: 80px; height: 80px; }
}

.fixture-name {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: var(--weight-bold);
    color: var(--color-text-strong);
    line-height: var(--leading-tight);
    overflow-wrap: anywhere;
    word-break: break-word;
    margin: 0;
}
@media (min-width: 480px) {
    .fixture-name { font-size: var(--text-base); }
}
@media (min-width: 768px) {
    .fixture-name { font-size: var(--text-lg); }
}

.fixture-elo {
    margin: var(--space-1) 0 0;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}

.fixture-vs {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    padding-inline: var(--space-1);
}
@media (min-width: 480px) {
    .fixture-vs { font-size: var(--text-xl); padding-inline: var(--space-2); }
}
@media (min-width: 768px) {
    .fixture-vs { font-size: var(--text-2xl); }
}

.fixture-meta {
    grid-column: 1 / -1;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: var(--space-2);
    padding-top: var(--space-3);
    margin-top: var(--space-2);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}

/* En la fila del fixture, los pips W/D/L se reducen ligeramente en móvil */
.fixture-team .form-row { justify-content: center; flex-wrap: wrap; }
.fixture-team .form-pip {
    width: 16px;
    height: 16px;
    font-size: 9px;
}
@media (min-width: 480px) {
    .fixture-team .form-pip { width: 18px; height: 18px; font-size: 10px; }
}
@media (min-width: 768px) {
    .fixture-team .form-pip { width: 20px; height: 20px; font-size: 10px; }
}


/* ====================  FORM INDICATORS (W/D/L) ==================== */
.form-row {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}
.form-pip {
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--weight-bold);
    color: white;
    font-family: var(--font-display);
}
.form-pip.win { background: var(--color-success); }
.form-pip.draw { background: var(--color-warning); }
.form-pip.loss { background: var(--color-danger); }
.form-pip.empty { background: var(--color-surface-2); color: var(--color-text-subtle); }


/* ====================  PROGRESS  ==================== */
.progress {
    display: block;
    width: 100%;
    height: 6px;
    background: var(--color-surface-2);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.progress-bar {
    display: block;
    height: 100%;
    background: var(--color-accent);
    border-radius: inherit;
    transition: width var(--transition-slow);
}
.progress-bar.is-success { background: var(--color-success); }
.progress-bar.is-warning { background: var(--color-warning); }
.progress-bar.is-danger { background: var(--color-danger); }


/* ====================  SPLIT METER (probabilidad ELO) ==================== */
.split-meter {
    display: flex;
    height: 8px;
    border-radius: var(--radius-full);
    overflow: hidden;
    background: var(--color-surface-2);
}
.split-meter > span {
    display: block;
    height: 100%;
    transition: width var(--transition-slow);
}
.split-meter > span.you { background: var(--color-accent); }
.split-meter > span.draw { background: var(--color-warning); }
.split-meter > span.rival { background: var(--color-text-subtle); }

.split-legend {
    display: flex;
    justify-content: space-between;
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}


/* ====================  EMPTY STATE  ==================== */
.empty {
    text-align: center;
    padding: var(--space-6) var(--space-4);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}
.empty .empty-icon {
    font-size: var(--text-2xl);
    color: var(--color-text-subtle);
    margin-bottom: var(--space-2);
}


/* ====================  TABLE (ligera, mobile-first) ==================== */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.modern-table th,
.modern-table td {
    padding: var(--space-3) var(--space-2);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
    font-variant-numeric: tabular-nums;
}
.modern-table th {
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-muted);
    font-weight: var(--weight-semibold);
    background: var(--color-surface);
}
.modern-table tbody tr:hover { background: var(--color-surface-hover); }


/* ====================  HEADER NAV  ==================== */
.site-header {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    background: var(--bg-header);
    border-bottom: 1px solid var(--color-border);
    /* IMPORTANTE: NO usar backdrop-filter acá — crea un containing block
       que rompe el position:fixed del .site-nav (drawer móvil). */
}
/* Blur solo en desktop, donde el nav NO es un drawer fixed */
@media (min-width: 1024px) {
    .site-header {
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
    }
}

.site-header__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    height: var(--header-height);
    max-width: var(--container-max);
    margin-inline: auto;
}

.site-header__logo {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-shrink: 0;
    max-width: 60%;
    overflow: hidden;
}
.site-header__logo img {
    height: 36px;
    width: auto;
    max-height: 36px;
    max-width: 100%;
    object-fit: contain;
    display: block;
}

.site-header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.site-header__user {
    display: none;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    margin-right: var(--space-2);
}
@media (min-width: 768px) {
    .site-header__user { display: inline; }
}

/* Hamburger / nav toggle */
.nav-toggle {
    width: var(--tap-target);
    height: var(--tap-target);
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    color: var(--color-text);
    background: transparent;
    border: 1px solid transparent;
}
.nav-toggle:hover { background: var(--color-surface-2); }
@media (min-width: 1024px) {
    .nav-toggle { display: none; }
}

/* Drawer / Mobile nav */
.site-nav {
    position: fixed;
    top: var(--header-height);
    inset-inline: 0;
    bottom: 0;
    background: var(--color-bg);
    border-top: 1px solid var(--color-border);
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform var(--transition-base);
    visibility: hidden;
    z-index: var(--z-drawer);
}
.site-nav.is-open {
    transform: translateX(0);
    visibility: visible;
}

.site-nav__list {
    list-style: none;
    margin: 0;
    padding: var(--space-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.site-nav__link,
.site-nav__group-trigger {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    width: 100%;
    min-height: var(--tap-target);
    padding: var(--space-3) var(--space-4);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    color: var(--color-text);
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    transition: background var(--transition-base), color var(--transition-base);
}
.site-nav__link {
    justify-content: flex-start;
}
.site-nav__group-trigger {
    justify-content: space-between;
}
.site-nav__link:hover,
.site-nav__group-trigger:hover {
    background: var(--color-surface);
    color: var(--color-text-strong);
}
.site-nav__link.is-active {
    color: var(--color-accent);
    background: var(--color-accent-soft);
}

/* Íconos dentro de nav links: tamaño + ancho fijos para alineamiento limpio */
.site-nav__link i:not(.chev),
.site-nav__group-trigger > i:not(.chev) {
    width: 1.1em;
    text-align: center;
    font-size: 0.95em;
    flex-shrink: 0;
    opacity: 0.85;
}

/* Admin: link destacado en accent */
.site-nav__admin {
    color: var(--color-accent) !important;
    font-weight: var(--weight-semibold);
}
.site-nav__admin:hover {
    background: var(--color-accent-soft) !important;
    color: var(--color-accent-strong, var(--color-accent)) !important;
}
.site-nav__admin.is-active {
    background: var(--color-accent-soft);
}

.site-nav__sub {
    list-style: none;
    margin: 0;
    padding: 0 0 var(--space-2) var(--space-4);
    display: none;
}
.site-nav__group.is-expanded .site-nav__sub { display: block; }
.site-nav__group.is-expanded .site-nav__group-trigger .chev { transform: rotate(180deg); }

.site-nav__group-trigger .chev {
    transition: transform var(--transition-base);
    color: var(--color-text-subtle);
    font-size: var(--text-xs);
}

.site-nav__sub .site-nav__link {
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    padding-block: var(--space-2);
    min-height: 36px;
}
.site-nav__sub .site-nav__link:hover {
    color: var(--color-text);
}

/* Desktop nav: horizontal, sin drawer */
@media (min-width: 1024px) {
    .site-nav {
        position: static;
        inset: auto;
        background: transparent;
        border: none;
        overflow: visible;
        transform: none;
        visibility: visible;
        flex: 1;
    }
    .site-nav__list {
        flex-direction: row;
        align-items: center;
        gap: 2px;
        padding: 0;
    }
    .site-nav__group { position: relative; }
    .site-nav__link,
    .site-nav__group-trigger {
        min-height: 0;
        padding: var(--space-2) var(--space-3);
        font-size: var(--text-sm);
        color: var(--color-text-muted);
    }
    .site-nav__link:hover,
    .site-nav__group-trigger:hover {
        color: var(--color-text-strong);
        background: var(--color-surface);
    }
    .site-nav__link.is-active {
        color: var(--color-accent);
        background: var(--color-accent-soft);
    }
    .site-nav__sub {
        position: absolute;
        top: calc(100% + 4px);
        left: 0;
        min-width: 220px;
        padding: var(--space-2);
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-lg);
        z-index: var(--z-dropdown);
        opacity: 0;
        transform: translateY(-4px);
        pointer-events: none;
        transition: opacity var(--transition-base), transform var(--transition-base);
    }
    .site-nav__group.is-expanded .site-nav__sub,
    .site-nav__group:hover .site-nav__sub,
    .site-nav__group:focus-within .site-nav__sub {
        display: block;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
    .site-nav__group:hover .site-nav__group-trigger .chev,
    .site-nav__group:focus-within .site-nav__group-trigger .chev {
        transform: rotate(180deg);
    }
    .site-nav__sub::before {
        /* puente invisible para que no se cierre al pasar del trigger al menú */
        content: '';
        position: absolute;
        top: -8px;
        left: 0;
        right: 0;
        height: 8px;
    }
    .site-nav__sub .site-nav__link {
        padding: var(--space-2) var(--space-3);
        border-radius: var(--radius-sm);
    }
    .site-nav__sub .site-nav__link:hover {
        background: var(--color-surface-2);
        color: var(--color-text);
    }
    .site-nav__group-trigger .chev { display: none; }
}

/* Drawer backdrop */
.nav-backdrop {
    position: fixed;
    inset: 0;
    top: var(--header-height);
    background: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-drawer) - 1);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-base);
}
.nav-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}
@media (min-width: 1024px) {
    .nav-backdrop { display: none; }
}

/* Bell */
.notif { position: relative; }
.notif-bell {
    width: var(--tap-target);
    height: var(--tap-target);
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    background: transparent;
    border: 1px solid transparent;
    position: relative;
}
.notif-bell:hover { background: var(--color-surface-2); color: var(--color-text); }
.notif-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--color-danger);
    color: white;
    font-size: 10px;
    font-weight: var(--weight-bold);
    border-radius: var(--radius-full);
    display: grid;
    place-items: center;
    border: 2px solid var(--color-bg);
}
.notif-dropdown {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    width: min(320px, calc(100vw - var(--space-4) * 2));
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: none;
    z-index: var(--z-dropdown);
}
.notif-dropdown.is-open { display: block; }
.notif-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
}
.notif-list { max-height: 360px; overflow-y: auto; }
.notif-row {
    display: block;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text);
}
.notif-row:hover { background: var(--color-surface-hover); }
.notif-row.unread { border-left: 3px solid var(--color-accent); }
.notif-row__title { font-size: var(--text-sm); font-weight: var(--weight-semibold); margin: 0 0 2px; }
.notif-row__desc { font-size: var(--text-xs); color: var(--color-text-muted); margin: 0; }
.notif-empty { padding: var(--space-6); text-align: center; color: var(--color-text-muted); font-size: var(--text-sm); }


/* ====================  FOOTER  ==================== */
.site-footer {
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    padding-block: var(--space-6);
    margin-top: var(--space-8);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
}
.site-footer__grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-5);
}
@media (min-width: 768px) {
    .site-footer__grid { grid-template-columns: 1.5fr 1fr 1fr; gap: var(--space-6); }
}
.site-footer h4 {
    font-size: var(--text-sm);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-strong);
    margin: 0 0 var(--space-3);
}
.site-footer ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
}
.site-footer a { color: var(--color-text-muted); }
.site-footer a:hover { color: var(--color-accent); }
.site-footer__bottom {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-3);
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
}
.site-footer__social {
    display: flex;
    gap: var(--space-2);
}
.site-footer__social a {
    width: var(--tap-target);
    height: var(--tap-target);
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
}
.site-footer__social a:hover { background: var(--color-accent-soft); color: var(--color-accent); }


/* ====================  HERO COMPACT (mi club) ==================== */
.club-hero {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-6);
}
.club-hero__logo {
    width: 64px;
    height: 64px;
    object-fit: contain;
    flex-shrink: 0;
}
@media (min-width: 768px) {
    .club-hero__logo { width: 96px; height: 96px; }
}
.club-hero__body { flex: 1; min-width: 0; }
.club-hero__name {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-black);
    color: var(--color-text-strong);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    margin: 0;
    overflow-wrap: break-word;
}
@media (min-width: 768px) {
    .club-hero__name { font-size: var(--text-3xl); }
}
.club-hero__meta {
    margin-top: var(--space-1);
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}


/* ====================  STAT GRID (KPI bar) ==================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}
@media (min-width: 640px) {
    .stat-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-grid .card { padding: var(--space-3) var(--space-4); }


/* ====================  DIVIDER ==================== */
.divider {
    height: 1px;
    background: var(--color-border);
    margin-block: var(--space-5);
}


/* ====================  PILL  ==================== */
.pill {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: var(--weight-medium);
}


/* ====================  AVATAR ==================== */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
}
.avatar-sm { width: 24px; height: 24px; }
.avatar-lg { width: 48px; height: 48px; }


/* ====================  FORM CONTROLS  ==================== */
.form-control,
input[type="text"],
input[type="number"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="date"],
input[type="datetime-local"],
input[type="tel"],
input[type="url"],
select,
textarea {
    display: block;
    width: 100%;
    min-height: var(--tap-target);
    padding: 0 var(--space-3);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    color: var(--color-text);
    background-color: var(--color-surface);
    background-clip: padding-box;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-md);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

textarea {
    min-height: 96px;
    padding: var(--space-2) var(--space-3);
    line-height: var(--leading-relaxed);
    resize: vertical;
}

.form-control:hover,
input:hover,
select:hover,
textarea:hover {
    border-color: var(--color-text-subtle);
}

.form-control:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--shadow-focus);
}

.form-control::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--color-text-subtle);
    opacity: 1;
}

/* Select arrow custom (chevron blanco) */
select,
select.form-control {
    padding-right: var(--space-8);
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'><path d='M3 5l3 3 3-3' stroke='%239ca3af' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/></svg>");
    background-repeat: no-repeat;
    background-position: right var(--space-3) center;
    background-size: 12px;
    cursor: pointer;
}

/* Las opciones del select usan colores del SO; forzamos legibilidad */
select option {
    background-color: var(--color-surface);
    color: var(--color-text);
}

/* Tamaños */
.form-control-sm,
input.form-control-sm,
select.form-control-sm {
    min-height: 36px;
    font-size: var(--text-xs);
    padding: 0 var(--space-2);
}
select.form-control-sm { padding-right: var(--space-6); }

/* Inline form */
.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    align-items: center;
}

/* Label */
label,
.form-label {
    display: inline-block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
}

/* Checkbox / radio */
input[type="checkbox"],
input[type="radio"] {
    width: 1.1em;
    height: 1.1em;
    min-height: 0;
    accent-color: var(--color-accent);
    margin-right: var(--space-2);
    vertical-align: middle;
}


/* ====================  TREND (flecha de cambio) ==================== */
.trend {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    font-variant-numeric: tabular-nums;
}
.trend.is-up { color: var(--color-success); }
.trend.is-down { color: var(--color-danger); }
.trend.is-flat { color: var(--color-text-muted); }


/* ====================  METRIC GRID (PJ G E P GF GC DG Pts) ==================== */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1px;
    background: var(--color-border);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    overflow: hidden;
}
@media (min-width: 480px) {
    .metric-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); }
}
.metric-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-2) var(--space-1);
    background: var(--color-surface);
    text-align: center;
    min-height: 56px;
}
.metric-cell .metric-label {
    font-size: 10px;
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-muted);
    margin-bottom: 2px;
}
.metric-cell .metric-value {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    color: var(--color-text-strong);
    font-variant-numeric: tabular-nums;
    line-height: 1;
}
.metric-cell.is-highlight .metric-value { color: var(--color-accent); font-size: var(--text-lg); }
.metric-cell.is-positive .metric-value { color: var(--color-success); }
.metric-cell.is-negative .metric-value { color: var(--color-danger); }


/* ====================  POSITION CIRCLE (gran posición) ==================== */
.position-display {
    display: flex;
    align-items: baseline;
    gap: var(--space-2);
}
.position-display .position-number {
    font-family: var(--font-display);
    font-size: var(--text-display);
    font-weight: var(--weight-black);
    color: var(--color-text-strong);
    line-height: 0.85;
    letter-spacing: var(--tracking-tight);
    font-variant-numeric: tabular-nums;
}
.position-display .position-suffix {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: var(--weight-semibold);
    color: var(--color-text-muted);
}
.position-display .position-of {
    font-size: var(--text-xs);
    color: var(--color-text-subtle);
    margin-left: var(--space-1);
}


/* ====================  SPARKLINE  ==================== */
.sparkline {
    width: 100%;
    height: 56px;
    display: block;
}
.sparkline-bg { fill: none; stroke: var(--color-border-strong); stroke-width: 1; stroke-dasharray: 2 4; opacity: 0.5; }
.sparkline-line { fill: none; stroke: var(--color-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sparkline-area { fill: var(--color-accent-soft); stroke: none; }
.sparkline-dot { fill: var(--color-accent); stroke: var(--color-bg); stroke-width: 2; }
.sparkline-dot.last { r: 4; fill: var(--color-text-strong); stroke: var(--color-accent); }
.sparkline-axis-label {
    font-size: 10px;
    fill: var(--color-text-subtle);
    font-family: var(--font-body);
}


/* ====================  COMPARE (vs temporada pasada) ==================== */
.compare-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3);
    background: var(--color-surface-2);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
}
.compare-row .compare-label { color: var(--color-text-muted); }
.compare-row .compare-value {
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    font-variant-numeric: tabular-nums;
}


/* ====================  TIER BAR (distribución S/A/B/C) ==================== */
.tier-bar {
    display: flex;
    width: 100%;
    height: 28px;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
}
.tier-bar__seg {
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--text-xs);
    color: white;
    transition: filter var(--transition-fast);
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}
.tier-bar__seg:hover { filter: brightness(1.1); }
.tier-bar__seg.tier-S { background: #0ea5e9; }
.tier-bar__seg.tier-A { background: #22c55e; }
.tier-bar__seg.tier-B { background: #eab308; color: #1a2030; }
.tier-bar__seg.tier-C { background: #ef4444; }
.tier-bar__seg.tier-OTR { background: var(--color-text-subtle); }

.tier-legend {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    margin-top: var(--space-2);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}
.tier-legend__dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: var(--radius-sm);
    margin-right: 4px;
    vertical-align: middle;
}
.tier-legend__dot.tier-S { background: #0ea5e9; }
.tier-legend__dot.tier-A { background: #22c55e; }
.tier-legend__dot.tier-B { background: #eab308; }
.tier-legend__dot.tier-C { background: #ef4444; }


/* ====================  LINE GRID (POR/DEF/MED/DEL) ==================== */
.line-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: var(--space-3);
}
@media (min-width: 768px) {
    .line-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.line-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3);
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    border-top: 3px solid var(--color-border-strong);
}
.line-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
}
.line-card__name {
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-strong);
    margin: 0;
}
.line-card__icon {
    width: 28px;
    height: 28px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    font-size: var(--text-sm);
}
.line-card__count {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-black);
    color: var(--color-text-strong);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.line-card__count-label {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}
.line-card__stats {
    display: flex;
    gap: var(--space-3);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
    padding-top: var(--space-2);
    font-variant-numeric: tabular-nums;
}
.line-card__stats strong { color: var(--color-text-strong); font-weight: var(--weight-semibold); }
.line-card__top {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
}
.line-card__top-name {
    flex: 1;
    min-width: 0;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    color: var(--color-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.line-card__top-ca {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    color: var(--color-accent);
    font-variant-numeric: tabular-nums;
}
.line-card__top-foto {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    flex-shrink: 0;
}


/* ====================  STAR ROSTER (top 3 estrellas) ==================== */
.star-roster {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: var(--space-3);
}

.star-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-2);
    text-align: center;
    text-decoration: none;
    color: var(--color-text);
    transition: border-color var(--transition-fast), background var(--transition-fast);
    position: relative;
    overflow: hidden;
}
.star-card:hover {
    border-color: var(--color-border-strong);
    background: var(--color-surface-hover);
    color: var(--color-text);
}
.star-card.rank-1 { border-top: 3px solid #facc15; }
.star-card.rank-2 { border-top: 3px solid #cbd5e1; }
.star-card.rank-3 { border-top: 3px solid #b45309; }

.star-card__rank {
    position: absolute;
    top: 6px;
    right: 8px;
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    color: var(--color-text-subtle);
}
.star-card__foto {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--color-surface-2);
    border: 2px solid var(--color-border);
    margin: 0 auto var(--space-2);
}
.star-card__name {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text-strong);
    margin: 0 0 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.star-card__pos {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-muted);
    margin: 0 0 var(--space-2);
}
.star-card__ca {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-black);
    color: var(--color-accent);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.star-card__ca-label {
    display: block;
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-subtle);
    font-weight: var(--weight-semibold);
    margin-top: 2px;
}


/* ====================  STANDINGS TABLE (clasificación)  ==================== */
.standings-table th,
.standings-table td {
    padding: var(--space-3) var(--space-2);
    vertical-align: middle;
}

.position-circle {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    background: var(--color-surface-2);
    color: var(--color-text-strong);
    font-weight: var(--weight-bold);
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-variant-numeric: tabular-nums;
}
.position-circle.is-champion { background: rgba(250, 204, 21, 0.15); color: #facc15; }
.position-circle.is-relegated { background: var(--color-danger-soft); color: var(--color-danger); }

.team-cell {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    text-decoration: none;
    color: var(--color-text);
    min-width: 0;
}
.team-cell:hover { color: var(--color-accent); }
.team-cell__logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}
.team-cell__name {
    font-weight: var(--weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Responsive: en móvil esconder algunas columnas y compactar nombre */
@media (max-width: 639px) {
    .standings-table .col-g,
    .standings-table .col-e,
    .standings-table .col-p,
    .standings-table .col-gf,
    .standings-table .col-gc,
    .standings-table .col-form { display: none; }
    .standings-table th,
    .standings-table td { padding: var(--space-3) var(--space-1); }
    .team-cell__name {
        font-size: var(--text-sm);
        max-width: 120px;
    }
}


/* ====================  PARTIDOS LIST (partidos.php)  ==================== */
.jornada-block { margin-bottom: var(--space-3); }
.jornada-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-strong);
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--text-base);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.jornada-toggle:hover { background: var(--color-surface-hover); }
.jornada-toggle .chev { transition: transform var(--transition-base); color: var(--color-text-muted); font-size: var(--text-xs); }
.jornada-block.is-open .jornada-toggle { border-radius: var(--radius-md) var(--radius-md) 0 0; border-bottom: 0; }
.jornada-block.is-open .jornada-toggle .chev { transform: rotate(180deg); }
.jornada-meta {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-weight: var(--weight-regular);
    text-transform: none;
    letter-spacing: 0;
}

.jornada-list {
    display: none;
    border: 1px solid var(--color-border);
    border-top: 0;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden;
}
.jornada-block.is-open .jornada-list { display: block; }

.match-row {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
    transition: background var(--transition-fast);
}
.match-row:last-child { border-bottom: 0; }
.match-row:hover { background: var(--color-surface-hover); }

.match-row__team {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 1 1 0;
    min-width: 0;
    text-decoration: none;
    color: var(--color-text);
}
.match-row__team:hover { color: var(--color-accent); }
.match-row__team.local { justify-content: flex-end; text-align: right; }
.match-row__team.visit { justify-content: flex-start; text-align: left; }
.match-row__name {
    font-weight: var(--weight-medium);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.match-row__logo {
    width: 24px;
    height: 24px;
    object-fit: contain;
    flex-shrink: 0;
}
.match-row__score {
    flex: 0 0 auto;
    min-width: 64px;
    text-align: center;
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    font-size: var(--text-base);
    color: var(--color-text-strong);
    padding: 4px 12px;
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
    font-variant-numeric: tabular-nums;
    text-decoration: none;
}
.match-row__score:hover { background: var(--color-accent-soft); color: var(--color-accent); }
.match-row__score.is-pending {
    color: var(--color-text-subtle);
    background: transparent;
    font-family: var(--font-body);
    font-weight: var(--weight-medium);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}
.match-row__status {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex: 0 0 auto;
}
.match-row__status .status-pill {
    display: inline-flex;
    align-items: center;
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    white-space: nowrap;
}
.match-row__status .status-pill.played { background: var(--color-success-soft); color: var(--color-success); }
.match-row__status .status-pill.pending { background: var(--color-accent-soft); color: var(--color-accent); }
.match-row__status .status-pill.suspended { background: var(--color-danger-soft); color: var(--color-danger); }

.icon-btn {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    background: transparent;
    border: 1px solid transparent;
    transition: background var(--transition-fast), color var(--transition-fast);
    cursor: pointer;
    text-decoration: none;
    font-size: var(--text-sm);
}
.icon-btn:hover { background: var(--color-surface-2); color: var(--color-text-strong); }

@media (max-width: 560px) {
    .match-row { flex-wrap: wrap; padding: var(--space-3) var(--space-2); }
    .match-row__team { flex: 1 1 calc(50% - var(--space-3) - 32px); }
    .match-row__status {
        order: 5;
        flex: 1 1 100%;
        justify-content: center;
        padding-top: var(--space-2);
        margin-top: var(--space-2);
        border-top: 1px dashed var(--color-border);
    }
    .match-row__name { font-size: var(--text-sm); }
}


/* ====================  PARTIDO DETALLE (hero + eventos)  ==================== */
.match-hero {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5) var(--space-4);
    margin-bottom: var(--space-5);
    text-align: center;
}
.match-hero__teams {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: var(--space-3);
    margin-block: var(--space-4);
}
.match-hero__team { text-align: center; min-width: 0; }
.match-hero__logo {
    width: clamp(56px, 18vw, 100px);
    height: clamp(56px, 18vw, 100px);
    object-fit: contain;
    margin-inline: auto;
    margin-bottom: var(--space-2);
}
.match-hero__name {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: var(--weight-bold);
    color: var(--color-text-strong);
    line-height: var(--leading-tight);
    overflow-wrap: anywhere;
    margin: 0;
}
@media (min-width: 768px) {
    .match-hero__name { font-size: var(--text-xl); }
    .match-hero { padding: var(--space-6); }
}
.score-display {
    font-family: var(--font-display);
    font-weight: var(--weight-black);
    font-size: clamp(2.5rem, 12vw, 5rem);
    color: var(--color-text-strong);
    line-height: 1;
    letter-spacing: var(--tracking-wide);
    font-variant-numeric: tabular-nums;
    padding: var(--space-2) var(--space-4);
    background: var(--color-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    display: inline-block;
}
.score-display.is-pending {
    font-size: var(--text-2xl);
    font-weight: var(--weight-medium);
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wider);
}

.events-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.events-list li {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}
.events-list li:last-child { border-bottom: 0; }
.event-icon {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: var(--radius-md);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    flex-shrink: 0;
}
.event-icon.is-goal { background: var(--color-success-soft); color: var(--color-success); }
.event-icon.is-assist { background: var(--color-accent-soft); color: var(--color-accent); }
.event-icon.is-yellow { background: var(--color-warning-soft); color: var(--color-warning); }
.event-icon.is-red { background: var(--color-danger-soft); color: var(--color-danger); }
.event-icon.is-mvp { background: rgba(250, 204, 21, 0.15); color: #facc15; }
.event-body { flex: 1; min-width: 0; }
.event-name {
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-text-strong);
    text-decoration: none;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.event-name:hover { color: var(--color-accent); }
.event-type {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-muted);
}


/* ====================  TIER BADGE (jugador) ==================== */
.tier-badge {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-weight: var(--weight-black);
    font-size: var(--text-xs);
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}
.tier-badge.tier-S { background: #0ea5e9; }
.tier-badge.tier-A { background: #22c55e; }
.tier-badge.tier-B { background: #eab308; color: #1a2030; text-shadow: none; }
.tier-badge.tier-C { background: #ef4444; }
.tier-badge.tier-OTR { background: var(--color-text-subtle); }


/* ====================  PLAYER HERO  ==================== */
.player-hero {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
    padding: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    margin-bottom: var(--space-5);
    position: relative;
    overflow: hidden;
}
@media (min-width: 768px) {
    .player-hero { flex-direction: row; align-items: center; gap: var(--space-6); padding: var(--space-6); }
}
.player-hero__avatar-wrap {
    position: relative;
    flex-shrink: 0;
    align-self: center;
}
.player-hero__avatar {
    width: clamp(100px, 30vw, 140px);
    height: clamp(100px, 30vw, 140px);
    border-radius: var(--radius-full);
    object-fit: cover;
    background: var(--color-surface-2);
    border: 3px solid var(--color-accent);
}
.player-hero__club {
    position: absolute;
    bottom: -4px;
    right: -4px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--color-bg);
    padding: 4px;
    border: 1px solid var(--color-border);
    object-fit: contain;
}
.player-hero__body {
    flex: 1;
    min-width: 0;
    text-align: center;
}
@media (min-width: 768px) {
    .player-hero__body { text-align: left; }
}
.player-hero__name {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: var(--weight-black);
    color: var(--color-text-strong);
    line-height: var(--leading-tight);
    letter-spacing: var(--tracking-tight);
    margin: 0;
    overflow-wrap: break-word;
}
.player-hero__meta {
    margin-top: var(--space-2);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-3);
    justify-content: center;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
}
@media (min-width: 768px) {
    .player-hero__meta { justify-content: flex-start; }
}
.player-hero__capa {
    display: flex;
    gap: var(--space-3);
    align-self: center;
}
.player-hero__capa-stat {
    text-align: center;
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface-2);
    border-radius: var(--radius-lg);
    min-width: 76px;
}
.player-hero__capa-value {
    display: block;
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-black);
    line-height: 1;
    font-variant-numeric: tabular-nums;
}
.player-hero__capa-stat.is-ca .player-hero__capa-value { color: var(--color-success); }
.player-hero__capa-stat.is-pa .player-hero__capa-value { color: var(--color-accent); }
.player-hero__capa-label {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-muted);
    font-weight: var(--weight-semibold);
}


/* ====================  ATRIBUTOS (jugador detalle)  ==================== */
.attr-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--space-2);
}
@media (min-width: 480px) {
    .attr-grid { grid-template-columns: repeat(2, 1fr); }
}
.attr-row {
    display: grid;
    grid-template-columns: 1fr auto 28px;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface-2);
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
}
.attr-row__name {
    color: var(--color-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.attr-row__bar {
    width: 80px;
    height: 4px;
    background: var(--color-border);
    border-radius: var(--radius-full);
    overflow: hidden;
}
.attr-row__bar > span {
    display: block;
    height: 100%;
    background: var(--color-accent);
}
.attr-row.is-high .attr-row__bar > span { background: var(--color-success); }
.attr-row.is-mid .attr-row__bar > span { background: var(--color-warning); }
.attr-row.is-low .attr-row__bar > span { background: var(--color-text-subtle); }
.attr-row__value {
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    text-align: right;
    font-variant-numeric: tabular-nums;
    color: var(--color-text-strong);
}
.attr-row.is-high .attr-row__value { color: var(--color-success); }
.attr-row.is-mid .attr-row__value { color: var(--color-warning); }
.attr-row.is-low .attr-row__value { color: var(--color-text-muted); }


/* ====================  PITCH (posición en el campo)  ==================== */
.pitch {
    width: 100%;
    max-width: 240px;
    aspect-ratio: 2 / 3.2;
    background:
        linear-gradient(0deg, rgba(0,0,0,0.18) 50%, transparent 50%) 0 0 / 100% 50% no-repeat,
        #153227;
    margin: 0 auto;
    border: 1px solid var(--color-border);
    position: relative;
    border-radius: var(--radius-md);
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.5);
}
.pitch__line {
    position: absolute;
    border: 1px solid rgba(255, 255, 255, 0.12);
}
.pitch__mid { top: 50%; left: 0; right: 0; height: 0; }
.pitch__circle {
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    transform: translate(-50%, -50%);
}
.pitch__box-top {
    top: 0;
    left: 50%;
    width: 100px;
    height: 45px;
    transform: translateX(-50%);
    border-top: 0;
}
.pitch__box-bot {
    bottom: 0;
    left: 50%;
    width: 100px;
    height: 45px;
    transform: translateX(-50%);
    border-bottom: 0;
}
.pitch__dot {
    position: absolute;
    width: 12px;
    height: 12px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: transform var(--transition-base), background var(--transition-base);
    z-index: 2;
}
.pitch__dot.is-active {
    background: var(--color-success);
    box-shadow: 0 0 14px rgba(16, 185, 129, 0.7);
    transform: translate(-50%, -50%) scale(1.6);
    border: 2px solid white;
    z-index: 3;
}
.pitch__label {
    position: absolute;
    font-size: 9px;
    color: rgba(255, 255, 255, 0.25);
    font-weight: var(--weight-bold);
    transform: translate(-50%, 8px);
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    z-index: 1;
}
.pitch__dot.is-active + .pitch__label {
    color: white;
    font-size: 11px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}


/* ====================  TRANSFER TYPE (mercado / ofertas)  ==================== */
.transfer-type {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    white-space: nowrap;
}
.transfer-type.money    { background: var(--color-accent-soft); color: var(--color-accent); }
.transfer-type.player   { background: rgba(168, 85, 247, 0.15); color: #a78bfa; }
.transfer-type.loan     { background: var(--color-warning-soft); color: var(--color-warning); }
.transfer-type.embargo  { background: var(--color-danger-soft); color: var(--color-danger); }
.transfer-type.pago     { background: var(--color-success-soft); color: var(--color-success); }
.transfer-type.infra    { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.transfer-type.clausula { background: rgba(250, 204, 21, 0.12); color: #facc15; }


/* ====================  CLAUSE TAG  ==================== */
.clause-tag {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    background: rgba(250, 204, 21, 0.12);
    color: #facc15;
    border-radius: var(--radius-sm);
    font-size: 10px;
    font-weight: var(--weight-bold);
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
}


/* ====================  OFFER BLOCK (ofertas)  ==================== */
.offer-block {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: var(--space-3);
}
.offer-block.is-incoming { border-left: 3px solid var(--color-warning); }
.offer-block.is-outgoing { border-left: 3px solid var(--color-accent); }
.offer-block.is-confirmed { border-left: 3px solid var(--color-success); }

.offer-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
}
.offer-head__title {
    font-family: var(--font-display);
    font-weight: var(--weight-bold);
    color: var(--color-text-strong);
    font-size: var(--text-base);
    margin: 0;
}
.offer-head__meta {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    font-weight: var(--weight-regular);
    margin-bottom: 2px;
    text-transform: none;
    letter-spacing: 0;
}
.offer-head__actions {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.offer-detail {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-border);
    font-size: var(--text-sm);
}
.offer-detail:last-child { border-bottom: 0; }
.offer-detail__flow {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
    flex: 1;
    min-width: 200px;
}
.offer-detail__team {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    color: var(--color-text);
}
.offer-detail__team img { width: 18px; height: 18px; object-fit: contain; }
.offer-detail__arrow { color: var(--color-text-subtle); }
.offer-detail__payload {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    flex-wrap: wrap;
}
.offer-detail__payload img.face {
    width: 24px;
    height: 24px;
    border-radius: var(--radius-full);
    object-fit: cover;
}
.offer-detail__period {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    background: var(--color-surface-2);
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
}

.offer-clauses {
    padding: var(--space-3) var(--space-4);
    background: var(--color-surface-2);
    border-top: 1px solid var(--color-border);
    font-size: var(--text-xs);
    color: var(--color-text-muted);
}
.offer-clauses h6 {
    margin: 0 0 var(--space-1);
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: var(--tracking-wide);
    color: var(--color-text-muted);
}

.offer-actions {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--color-border);
    background: rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-2);
    flex-wrap: wrap;
}


/* ====================  FILA TRANSFERENCIA (editar/hacer oferta)  ==================== */
.fila-transferencia {
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    padding: var(--space-3);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-3);
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: var(--space-3);
    align-items: end;
    position: relative;
}

.btn-remove {
    background: var(--color-danger);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    display: grid;
    place-items: center;
    position: absolute;
    top: -10px;
    right: -10px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    z-index: 2;
}
.btn-remove:hover { filter: brightness(1.1); }


/* ====================  STAT BADGE (transferibles)  ==================== */
.stat-badge {
    display: inline-block;
    padding: 2px var(--space-2);
    border-radius: var(--radius-sm);
    font-weight: var(--weight-bold);
    font-size: var(--text-xs);
    font-variant-numeric: tabular-nums;
    background: var(--color-surface-2);
    color: var(--color-text-muted);
}
.stat-badge.bg-master { background: var(--color-accent-soft); color: var(--color-accent); }
.stat-badge.bg-wonder { background: rgba(236, 72, 153, 0.15); color: #f472b6; }


/* ====================  DATATABLES OVERRIDES  ==================== */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    color: var(--color-text);
    padding: 6px var(--space-3);
    border-radius: var(--radius-md);
    margin-left: var(--space-2);
    min-height: 36px;
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: var(--shadow-focus);
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    margin-top: var(--space-3);
    color: var(--color-text-muted) !important;
    font-size: var(--text-xs);
}
.dataTables_paginate .paginate_button {
    background: var(--color-surface) !important;
    border: 1px solid var(--color-border) !important;
    color: var(--color-text) !important;
    border-radius: var(--radius-sm) !important;
    padding: 4px 10px !important;
    margin: 0 2px;
}
.dataTables_paginate .paginate_button:hover {
    background: var(--color-surface-hover) !important;
    border-color: var(--color-border-strong) !important;
    color: var(--color-text-strong) !important;
}
.dataTables_paginate .paginate_button.current,
.dataTables_paginate .paginate_button.current:hover {
    background: var(--color-accent) !important;
    border-color: var(--color-accent) !important;
    color: white !important;
}
.dataTables_paginate .paginate_button.disabled,
.dataTables_paginate .paginate_button.disabled:hover {
    background: transparent !important;
    color: var(--color-text-subtle) !important;
    border-color: transparent !important;
}
table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc { background-image: none !important; padding-right: var(--space-3) !important; }
table.dataTable thead .sorting_asc::after { content: ' ↑'; color: var(--color-accent); }
table.dataTable thead .sorting_desc::after { content: ' ↓'; color: var(--color-accent); }


/* ====================  CALCULATOR RESULT  ==================== */
.tier-result {
    text-align: center;
    padding-block: var(--space-4);
}
.tier-result__name {
    font-family: var(--font-display);
    font-size: var(--text-4xl);
    font-weight: var(--weight-black);
    line-height: 1;
    margin: var(--space-2) 0;
    letter-spacing: var(--tracking-tight);
}


/* ====================  POSITION BADGES (medalla por puesto)  ==================== */
.pos-badge {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-sm);
    font-family: var(--font-display);
    font-size: var(--text-xs);
    font-weight: var(--weight-bold);
    background: var(--color-surface-2);
    color: var(--color-text-muted);
    font-variant-numeric: tabular-nums;
}
.pos-badge.is-1   { background: rgba(250, 204, 21, 0.18); color: #facc15; }
.pos-badge.is-2   { background: rgba(203, 213, 225, 0.18); color: #cbd5e1; }
.pos-badge.is-3   { background: rgba(180, 83, 9, 0.18); color: #f59e0b; }
.pos-badge.is-low { color: var(--color-text-subtle); opacity: 0.6; }


/* ====================  VIEW TOGGLE (Tabla/Gráfico)  ==================== */
.view-toggle {
    display: inline-flex;
    background: var(--color-surface-2);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 4px;
}
.view-toggle button {
    padding: 6px var(--space-3);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-weight: var(--weight-semibold);
    font-size: var(--text-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
}
.view-toggle button:hover { color: var(--color-text); }
.view-toggle button.is-active {
    background: var(--color-accent);
    color: white;
}


/* ====================  TROPHY CARD (palmarés)  ==================== */
.trophy-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    position: relative;
    overflow: hidden;
    border-top: 3px solid var(--color-accent);
}
.trophy-card.is-wonder { border-top-color: var(--color-warning); }
.trophy-card__head {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding-bottom: var(--space-3);
    margin-bottom: var(--space-3);
    border-bottom: 1px solid var(--color-border);
}
.trophy-card__logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    flex-shrink: 0;
}
.trophy-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.trophy-list li {
    padding: var(--space-2) 0;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text-muted);
    font-size: var(--text-sm);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}
.trophy-list li:last-child { border-bottom: 0; }
.trophy-list li i { color: #facc15; }


/* ====================  HEAT TABLE (estadísticas_posiciones)  ==================== */
.heat-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}
.heat-table th, .heat-table td {
    padding: var(--space-2);
    border: 1px solid var(--color-border);
    text-align: center;
    vertical-align: middle;
}
.heat-table th { background: var(--color-surface); color: var(--color-text-muted); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: var(--tracking-wide); }
.heat-table td.cell-team {
    text-align: left;
    background: var(--color-bg);
    position: sticky;
    left: 0;
    z-index: 2;
    border-right: 2px solid var(--color-accent);
    min-width: 140px;
    max-width: 140px;
}
.heat-table thead th.cell-team {
    background: var(--color-surface);
    z-index: 3;
    border-bottom: 2px solid var(--color-accent);
}
.heat-table .cell-pts {
    background: var(--color-accent-soft);
    color: var(--color-accent);
    font-weight: var(--weight-bold);
}


/* ====================  VS FORM (comparador equipos)  ==================== */
.vs-form {
    display: flex;
    align-items: end;
    justify-content: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    padding: var(--space-5);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
}
.vs-form__select { flex: 1 1 220px; min-width: 0; }
.vs-form__badge {
    font-family: var(--font-display);
    font-size: var(--text-2xl);
    font-weight: var(--weight-black);
    color: var(--color-accent);
    align-self: center;
}


/* ====================  ANIMATIONS  ==================== */
@keyframes fade-in-up {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-in { animation: fade-in-up 320ms ease both; }
.animate-fade-in { animation: fade-in-up 320ms ease both; }   /* alias legacy */
