/* Paleta granate, carbón y blanco inspirada en una sede deportiva clásica. */
:root {
  color-scheme: light;
  --wine: #7f151d;
  --wine-dark: #591016;
  --on-wine: #ffffff;
  --gold: #d7a536;
  --ink: #17191e;
  --muted: #68707d;
  --line: #e3e6eb;
  --paper: #ffffff;
  --canvas: #f2f3f5;
  --success: #176b49;
  --danger: #ad2631;
  --radius: 14px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Normalización y elementos comunes. */
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.8rem, 4vw, 2.6rem); line-height: 1.05; }
h2 { font-size: clamp(1.45rem, 3vw, 2rem); }
.muted { color: var(--muted); }
.eyebrow { margin-bottom: .45rem; color: var(--wine); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
[hidden] { display: none !important; }

/* Acceso centrado con una franja visual propia del club. */
.login-view { min-height: 100vh; display: grid; place-items: center; padding: 1.25rem; background: linear-gradient(135deg, #fafafa 0 55%, #7f151d 55% 100%); }
.login-card { width: min(100%, 430px); padding: clamp(2rem, 7vw, 3.5rem); border-top: 6px solid var(--gold); border-radius: 4px 4px var(--radius) var(--radius); background: var(--paper); box-shadow: 0 24px 70px #25040842; }
.club-mark { display: grid; width: 72px; height: 82px; margin-bottom: 1.5rem; place-items: center; border: 3px solid var(--wine); border-radius: 14px 14px 28px 28px; color: var(--wine); font-weight: 900; letter-spacing: -.05em; box-shadow: inset 0 0 0 5px white, inset 0 0 0 7px var(--gold); }
.club-mark img { width: 100%; height: 100%; border-radius: inherit; object-fit: contain; background: white; }
.club-mark.small { width: 46px; height: 52px; margin: 0; flex: 0 0 auto; border-width: 2px; border-color: var(--on-wine); color: var(--on-wine); box-shadow: inset 0 0 0 3px var(--wine-dark), inset 0 0 0 4px var(--gold); font-size: .8rem; }
.stack-form { display: grid; gap: .75rem; margin-top: 2rem; }
label { font-size: .9rem; font-weight: 700; }
input, select, textarea { width: 100%; min-height: 46px; padding: .7rem .85rem; border: 1px solid #cfd4dc; border-radius: 9px; background: white; color: var(--ink); }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 3px solid #7f151d25; border-color: var(--wine); }
.form-error { min-height: 1.25rem; color: var(--danger); font-size: .88rem; }

/* Estructura principal adaptable a escritorio y móvil. */
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; z-index: 20; width: 250px; display: flex; flex-direction: column; padding: 1.25rem; background: var(--wine-dark); color: var(--on-wine); }
.brand { display: flex; align-items: center; gap: .85rem; padding-bottom: 1.5rem; border-bottom: 1px solid #ffffff24; }
.brand strong, .brand span { display: block; }
.brand span { margin-top: .2rem; color: var(--on-wine); font-size: .78rem; opacity: .68; }
.sidebar nav { display: grid; gap: .35rem; margin-top: 1.5rem; }
.nav-item { width: 100%; padding: .78rem .9rem; border: 0; border-radius: 8px; background: transparent; color: var(--on-wine); text-align: left; text-decoration: none; font-size: .95rem; opacity: .82; }
.nav-item:hover, .nav-item:focus-visible, .nav-item.active { background: #ffffff16; color: var(--on-wine); outline: none; opacity: 1; }
.nav-item.active { box-shadow: inset 3px 0 var(--gold); font-weight: 750; }
.sidebar-footer { display: grid; gap: .25rem; margin-top: auto; padding-top: 1rem; border-top: 1px solid #ffffff24; }
.workspace { min-height: 100vh; margin-left: 250px; padding: clamp(1.25rem, 4vw, 3rem); }
.mobile-header { display: none; }

/* Cabeceras, botones y tarjetas de datos. */
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 1.75rem; }
.page-head h1 { margin-bottom: .35rem; }
.page-head p { margin-bottom: 0; }
.button { min-height: 42px; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 9px; background: white; color: var(--ink); font-weight: 750; }
.button.primary { background: var(--wine); color: var(--on-wine); }
.button.primary:hover { background: var(--wine-dark); }
.button.secondary { border-color: var(--line); }
.button.danger { color: var(--danger); border-color: #efc5c9; background: #fff8f8; }
.button.small { min-height: 34px; padding: .4rem .65rem; font-size: .83rem; }
.icon-button { width: 42px; height: 42px; border: 0; border-radius: 9px; background: transparent; color: inherit; font-size: 1.5rem; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1rem; }
.metric { min-height: 145px; padding: 1.3rem; border-radius: var(--radius); background: var(--paper); box-shadow: 0 8px 30px #1118270a; }
.metric.accent { background: var(--wine); color: var(--on-wine); }
.metric .label { color: var(--muted); font-size: .85rem; }
.metric.accent .label { color: var(--on-wine); opacity: .72; }
.metric strong { display: block; margin-top: 1.5rem; font-size: clamp(1.8rem, 4vw, 2.5rem); letter-spacing: -.05em; }
.panel { margin-top: 1.25rem; padding: 1.25rem; border-radius: var(--radius); background: var(--paper); box-shadow: 0 8px 30px #1118270a; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; }
.panel-head h2, .panel-head h3 { margin: 0; }

/* Listados en tarjetas y tablas que no pierden legibilidad en móvil. */
.player-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(275px, 1fr)); gap: 1rem; }
.player-card { overflow: hidden; border-radius: var(--radius); background: white; box-shadow: 0 8px 30px #1118270a; }
.player-top { display: flex; gap: 1rem; padding: 1.15rem; }
.avatar { width: 58px; height: 58px; flex: 0 0 auto; object-fit: cover; border-radius: 50%; background: #eceff2; color: var(--wine); display: grid; place-items: center; font-weight: 850; }
.avatar img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
.player-name { margin: .15rem 0 .25rem; font-size: 1.05rem; }
.tag { display: inline-flex; padding: .25rem .5rem; border-radius: 999px; background: #f1e5e6; color: var(--wine); font-size: .75rem; font-weight: 750; }
.stats-strip { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--line); }
.stats-strip.finance-strip { grid-template-columns: repeat(3, 1fr); }
.stats-strip div { padding: .8rem .45rem; text-align: center; }
.stats-strip span, .stats-strip strong { display: block; }
.stats-strip span { margin-top: .18rem; color: var(--muted); font-size: .7rem; }
.card-actions { display: flex; gap: .5rem; padding: .8rem 1rem; border-top: 1px solid var(--line); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: .85rem .7rem; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
td { font-size: .92rem; }
.status { font-size: .8rem; font-weight: 800; }
.status.paid { color: var(--success); }
.status.pending { color: #9b5c00; }
.empty { padding: 3rem 1rem; border: 1px dashed #c9ced6; border-radius: var(--radius); color: var(--muted); text-align: center; }

/* Formularios modales y editor de estadísticas. */
dialog { width: min(94vw, 720px); max-height: 90vh; padding: 0; border: 0; border-radius: var(--radius); box-shadow: 0 30px 90px #11182755; }
dialog::backdrop { background: #11182799; backdrop-filter: blur(3px); }
.dialog-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; padding: 1rem 1.25rem; border-bottom: 1px solid var(--line); background: white; }
.dialog-head h2 { margin: 0; font-size: 1.25rem; }
#modalBody { padding: 1.25rem; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.field.full { grid-column: 1 / -1; }
.field label { display: block; margin-bottom: .4rem; }
.field input[type="color"] { height: 52px; padding: .3rem; cursor: pointer; }
.check-field { display: flex; align-items: center; gap: .6rem; min-height: 46px; }
.check-field input { width: 20px; min-height: 20px; }
.selection-list { max-height: 260px; overflow-y: auto; padding: .75rem 1rem; border: 1px solid var(--line); border-radius: 10px; }
.selection-list legend { padding: 0 .35rem; font-weight: 750; }
.selection-list .check-field { min-height: 38px; border-bottom: 1px solid var(--line); font-weight: 500; }
.selection-list .check-field:last-child { border-bottom: 0; }
.installment-title, .season-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.installment-list { display: grid; gap: .55rem; margin-top: .65rem; }
.installment-row { display: grid; grid-template-columns: 32px minmax(150px, 1fr) 130px; align-items: center; gap: .55rem; }
.installment-row span { display: grid; width: 28px; height: 28px; place-items: center; border-radius: 50%; background: var(--wine); color: var(--on-wine); font-weight: 800; }
.season-panel { margin-bottom: 1rem; }
.season-head { margin-bottom: 1rem; }
.season-head h2 { margin: .1rem 0; }
.card-actions-inline { display: flex; gap: .55rem; flex-wrap: wrap; }
.detail-back { margin-bottom: 1rem; }
.season-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: .75rem; margin-bottom: 1rem; }
.season-totals span { display: grid; gap: .2rem; padding: .85rem; border-radius: 10px; background: var(--canvas); }
.season-totals small { color: var(--muted); }
.season-totals strong { font-size: 1.15rem; }
.form-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.25rem; }
.toast { position: fixed; right: 1.25rem; bottom: 1.25rem; z-index: 50; max-width: 360px; padding: .85rem 1rem; border-radius: 10px; background: var(--ink); color: white; opacity: 0; transform: translateY(12px); pointer-events: none; transition: .2s ease; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--danger); }
.brand-preview { display: flex; align-items: center; gap: 1rem; padding: 1.25rem; border-radius: var(--radius); background: var(--wine); color: var(--on-wine); }
.brand-preview .club-mark { margin: 0; border-color: white; color: white; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }
.admin-card { padding: 1.15rem; border: 1px solid var(--line); border-radius: var(--radius); background: white; }
.admin-card-head { display: flex; align-items: center; justify-content: space-between; gap: .75rem; }
.color-pair { display: flex; gap: .35rem; margin: .9rem 0; }
.color-swatch { width: 34px; height: 34px; min-height: 34px; padding: 0; border: 1px solid #00000018; border-radius: 50%; }
.settings-form { margin-top: 1.25rem; }

/* Adaptación de la navegación y densidad para pantallas pequeñas. */
@media (max-width: 900px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); box-shadow: 20px 0 60px #11182744; }
  .workspace { margin-left: 0; padding-top: 5.25rem; }
  .mobile-header { position: fixed; inset: 0 0 auto; z-index: 15; height: 64px; display: flex; align-items: center; justify-content: space-between; padding: 0 1rem; background: var(--wine-dark); color: var(--on-wine); }
  .mini-mark { font-size: .72rem; font-weight: 900; color: var(--gold); }
}

@media (max-width: 580px) {
  .login-view { background: var(--wine); }
  .page-head { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr 1fr; gap: .7rem; }
  .metric { min-height: 118px; padding: 1rem; }
  .metric strong { margin-top: 1rem; font-size: 1.7rem; }
  .form-grid { grid-template-columns: 1fr; }
  .field.full { grid-column: auto; }
  .player-grid { grid-template-columns: 1fr; }
  .installment-row { grid-template-columns: 28px minmax(120px, 1fr) 95px; }
  .season-head { align-items: flex-start; flex-direction: column; }
  .season-totals { grid-template-columns: 1fr; }
  .workspace { padding-inline: .8rem; }
}
