/* VoleyMetric · base compartida por todas las pantallas
 * Diseño limpio y claro: fondo casi blanco, tarjetas blancas, UN color de marca (el del club) y mucho aire.
 * Los colores de marca llegan como variables desde js/theme.js (--brand, --accent…). */

:root, .themed {
  --bg: #F4F6FA;
  --surface: #FFFFFF;
  --ink: #0B1220;
  --muted: #566074;
  --line: #E2E7EF;
  --line-strong: #C9D1DE;

  --brand: #1E2E3D;
  --brand-ink: #FFFFFF;
  --brand-text: #1E2E3D;
  --accent: #FBB03E;
  --accent-ink: #0B1220;
  --accent-text: #B45309;

  --brand-soft: color-mix(in srgb, var(--brand) 9%, #fff);
  --brand-line: color-mix(in srgb, var(--brand) 28%, #fff);
  --brand-deep: color-mix(in srgb, var(--brand) 82%, #000);

  --good: #0B8A5F;
  --good-soft: #E4F6EE;
  --warn: #B45309;
  --bad: #C62828;
  --bad-soft: #FDECEC;
  --neutral: #5B6678;
  --neutral-soft: #EEF1F6;

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --shadow-1: 0 1px 2px rgba(11, 18, 32, .05), 0 4px 18px rgba(11, 18, 32, .06);
  --shadow-2: 0 10px 40px rgba(11, 18, 32, .14);
  --font: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --tap: 52px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 16px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; font-variant-numeric: tabular-nums;
}
img, svg { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; }
p { margin: 0; }
a { color: var(--brand-text); }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; border-radius: 6px; }

.wrap { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 20px; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.stack > * + * { margin-top: 16px; }
.grow { flex: 1 1 auto; min-width: 0; }

/* ---------- barra superior ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.topbar__in { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; letter-spacing: -.02em; font-size: 1.125rem; }
.brand__mark { width: 34px; height: 34px; border-radius: 10px; background: #1E2E3D; display: grid; place-items: center; }
.brand__mark svg { width: 22px; height: 22px; }
.topnav { display: flex; align-items: center; gap: 6px; }

.demo-banner { background: #0B1220; color: #E8ECF4; font-size: .8125rem; text-align: center; padding: 6px 12px; }
.demo-banner strong { color: #FFB020; }

/* ---------- botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 999px; border: 1.5px solid transparent;
  font-weight: 700; font-size: 1rem; text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--brand); color: var(--brand-ink); box-shadow: 0 4px 14px color-mix(in srgb, var(--brand) 35%, transparent); }
.btn--primary:hover { background: var(--brand-deep); }
.btn--accent { background: var(--accent); color: var(--accent-ink); }
.btn--ghost { background: var(--surface); color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { border-color: var(--brand); color: var(--brand-text); }
.btn--danger { background: var(--bad); color: #fff; }
.btn--quiet { background: transparent; color: var(--brand-text); }
.btn--sm { min-height: 38px; padding: 0 14px; font-size: .9375rem; }
.btn--lg { min-height: 56px; padding: 0 28px; font-size: 1.0625rem; }
.btn--block { width: 100%; }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; display: inline-grid; place-items: center; font-size: 1rem; }
.icon-btn:hover { border-color: var(--brand); }

/* ---------- formularios ---------- */
.field { display: block; }
.field + .field { margin-top: 14px; }
.field__l { display: block; font-weight: 700; font-size: .875rem; margin-bottom: 6px; }
.field__h { display: block; color: var(--muted); margin-top: 6px; font-size: .8125rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], input[type=tel], select, textarea {
  width: 100%; min-height: 50px; padding: 10px 14px; background: var(--surface);
  border: 1.5px solid var(--line-strong); border-radius: 12px; outline: none;
}
textarea { min-height: 110px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 4px color-mix(in srgb, var(--brand) 18%, transparent); }
input[type=color] { width: 100%; height: 50px; padding: 4px; border: 1.5px solid var(--line-strong); border-radius: 12px; background: var(--surface); cursor: pointer; }
.form-grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.form-grid .field + .field { margin-top: 0; }
@media (min-width: 640px) { .form-grid--2 { grid-template-columns: 1fr 1fr; } .form-grid--3 { grid-template-columns: repeat(3, 1fr); } }
.form-error { color: var(--bad); background: var(--bad-soft); border-radius: 10px; padding: 10px 14px; font-weight: 600; font-size: .9375rem; }

/* ---------- tarjetas, chips ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow-1); padding: 20px; }
.card--flat { box-shadow: none; }
.card__title { font-size: 1.0625rem; margin-bottom: 12px; }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 28px; padding: 0 12px; border-radius: 999px; background: var(--neutral-soft); color: var(--neutral); font-weight: 700; font-size: .8125rem; }
.chip--brand { background: var(--brand-soft); color: var(--brand-text); }
.chip--good { background: var(--good-soft); color: var(--good); }
.chip--bad { background: var(--bad-soft); color: var(--bad); }
.chip--warn { background: #FEF3C7; color: #92400E; }
.chip--live { background: #FEE2E2; color: #B91C1C; }
.chip--live::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #DC2626; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { opacity: .25; } }

.mono { display: inline-grid; place-items: center; width: 44px; height: 44px; border-radius: 14px; font-weight: 800; font-size: .95rem; letter-spacing: -.02em; flex: none; }
.mono--lg { width: 72px; height: 72px; border-radius: 22px; font-size: 1.5rem; }
.mono--xl { width: 96px; height: 96px; border-radius: 28px; font-size: 2rem; }
.mono--sm { width: 32px; height: 32px; border-radius: 10px; font-size: .75rem; }

.empty { text-align: center; padding: 36px 20px; border: 2px dashed var(--line-strong); border-radius: var(--r); color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.0625rem; margin-bottom: 4px; }
.empty .btn { margin-top: 14px; }
.fatal { margin: 40px auto; max-width: 520px; padding: 16px; border-radius: 12px; background: var(--bad-soft); color: var(--bad); font-weight: 600; }

/* ---------- pestañas ---------- */
.tabs { display: flex; gap: 6px; padding: 5px; background: var(--neutral-soft); border-radius: 999px; width: max-content; max-width: 100%; overflow-x: auto; }
.tab { min-height: 42px; padding: 0 18px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; white-space: nowrap; }
.tab[aria-selected=true] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

/* ---------- tablas ---------- */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--surface); }
.tbl { width: 100%; border-collapse: collapse; font-size: .9375rem; }
.tbl th, .tbl td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #FAFBFD; font-weight: 700; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; }

/* ---------- diálogos ---------- */
.dlg { border: 0; border-radius: var(--r-lg); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: var(--shadow-2); background: var(--surface); color: var(--ink); overflow: hidden; }
.dlg[open] { display: flex; flex-direction: column; animation: pop .16s ease-out; }
.dlg::backdrop { background: rgba(11, 18, 32, .5); backdrop-filter: blur(2px); }
.dlg--wide { width: min(760px, calc(100vw - 24px)); }
.dlg__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 6px; }
.dlg__title { font-size: 1.25rem; }
.dlg__body { padding: 10px 20px 18px; overflow-y: auto; }
.dlg__foot { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--line); background: #FAFBFD; }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
@media (max-width: 640px) {
  .dlg--sheet { width: 100vw; max-width: 100vw; margin: auto 0 0; border-radius: 24px 24px 0 0; max-height: 92dvh; }
  .dlg--sheet[open] { animation: sheet .2s ease-out; }
  @keyframes sheet { from { transform: translateY(100%); } }
}

/* ---------- avisos ---------- */
.toasts { position: fixed; left: 0; right: 0; bottom: calc(18px + env(safe-area-inset-bottom)); display: grid; justify-items: center; gap: 8px; z-index: 200; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 999px; font-weight: 600; font-size: .9375rem; box-shadow: var(--shadow-2); animation: pop .18s ease-out; }
.toast--bad { background: var(--bad); }
.toast--good { background: var(--good); }
.toast--out { opacity: 0; transition: opacity .4s; }

footer.foot { margin-top: 56px; padding: 32px 0 40px; color: var(--muted); font-size: .875rem; border-top: 1px solid var(--line); background: var(--surface); }
.foot__in { display: grid; gap: 14px 32px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .foot__in { grid-template-columns: 1.2fr 1fr; } .foot__legal { grid-column: 1 / -1; } }
.foot__brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); font-weight: 800; font-size: 1.0625rem; width: max-content; }
.foot__logo { height: 30px; width: auto; max-width: 160px; flex: none; object-fit: contain; }
.foot__fallback { display: none; align-items: center; gap: 10px; }
.foot__mark { width: 30px; height: 30px; border-radius: 9px; background: #1E2E3D; display: grid; place-items: center; }
.foot__mark svg { width: 20px; height: 20px; }
.foot__brand.no-logo .foot__logo { display: none; }
.foot__brand.no-logo .foot__fallback { display: inline-flex; }
.foot__tag { grid-column: 1; margin-top: -4px; }
.foot__nav { display: flex; flex-wrap: wrap; gap: 8px 18px; align-content: start; grid-row: 1 / span 2; grid-column: 2; }
@media (max-width: 759px) { .foot__nav { grid-row: auto; grid-column: 1; } }
.foot__nav a, .foot__legal a { color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.foot__nav a:hover, .foot__legal a:hover { color: var(--brand-text); text-decoration: underline; }
.foot__ig { font-weight: 700; color: var(--ink) !important; }
.foot__legal { display: flex; flex-wrap: wrap; gap: 6px 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: .8125rem; }
.foot__legal span { margin-left: auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}

/* Escudo (monograma) sobre fondos de color de marca: se invierte para que siempre se vea */
.club-hero .mono, .rep-hero .mono, .auth__head .mono { background: var(--brand-ink) !important; color: var(--brand) !important; }

/* Los hijos de una rejilla no deben ensanchar la página (tablas con scroll propio) */
.rep > *, .two > *, .club-body > *, .adm > *, .quick > *, .live > *, .live__main > *, .live__side > *, .hero__grid > *, .setup > * { min-width: 0; }
.card { min-width: 0; }
.tbl--wrap th, .tbl--wrap td { white-space: normal; }
@media (max-width: 420px) { .hide-xs { display: none; } .brand { font-size: 1.0625rem; } }

/* ---------- logo VoleyMetric (img/voleymetric-logo.webp) ---------- */
.brand { flex: none; }
.brand__logo { height: 36px; width: auto; max-width: 180px; flex: none; object-fit: contain; }
.topnav { min-width: 0; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 480px) { .brand__logo { height: 30px; max-width: 130px; } }
.brand__fallback { display: none; align-items: center; gap: 10px; }
.brand.no-logo .brand__logo { display: none; }
.brand.no-logo .brand__fallback { display: inline-flex; }
.brand__mark { background: #1E2E3D; }
.adm-top .brand { margin-right: 6px; }

/* ---------- logo propio del club ---------- */
.mono--logo, .club-hero .mono.mono--logo, .rep-hero .mono.mono--logo, .auth__head .mono.mono--logo { background: #fff !important; position: relative; overflow: hidden; border: 1px solid var(--line); }
.mono--logo img { position: absolute; inset: 7%; width: 86%; height: 86%; object-fit: contain; }
.club-hero .mono, .rep-hero .mono, .auth__head .mono { justify-self: start; }

/* ---------- animaciones suaves ---------- */
@keyframes vm-rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes vm-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes vm-zoom { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

body:not(.match-page) main, body:not(.match-page) .dash-top__in, body:not(.match-page) .adm-top__in { animation: vm-fade .35s ease-out both; }
body:not(.match-page) :is(.card, .match-card, .team-card, .club-card, .club-row, .kpi, .stat, .tbl-wrap, .preview__card, .empty) { animation: vm-rise .42s cubic-bezier(.22, .8, .3, 1) backwards; }
body:not(.match-page) :is(.matches, .teams, .clubs, .club-grid, .kpis, .stats) > :nth-child(2) { animation-delay: .05s; }
body:not(.match-page) :is(.matches, .teams, .clubs, .club-grid, .kpis, .stats) > :nth-child(3) { animation-delay: .1s; }
body:not(.match-page) :is(.matches, .teams, .clubs, .club-grid, .kpis, .stats) > :nth-child(4) { animation-delay: .15s; }
body:not(.match-page) :is(.matches, .teams, .clubs, .club-grid, .kpis, .stats) > :nth-child(5) { animation-delay: .2s; }
body:not(.match-page) :is(.matches, .teams, .clubs, .club-grid, .kpis, .stats) > :nth-child(n+6) { animation-delay: .25s; }
.auth__card { animation: vm-zoom .4s cubic-bezier(.22, .8, .3, 1) both; }

.match-card, .team-card, .club-card, .club-row, .btn, .tab, .chip { transition: transform .18s ease, box-shadow .2s ease, background-color .2s ease, border-color .2s ease, color .2s ease, opacity .2s ease; }
@media (hover: hover) {
  .match-card:hover, .club-card:hover, .club-row:hover { transform: translateY(-3px); box-shadow: var(--shadow-2); }
  .btn:hover { transform: translateY(-1px); }
}
.btn:active { transform: scale(.97); }
.team-card__body:not([hidden]) { animation: vm-rise .25s ease-out backwards; }
[role=tabpanel]:not([hidden]) { animation: vm-fade .3s ease-out both; }
.team-chev { transition: transform .22s ease; }

/* ---------- skeletons (carga) ---------- */
.skel { position: relative; overflow: hidden; background: var(--neutral-soft); border-radius: 10px; }
.skel::after { content: ''; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .65), transparent); animation: vm-shimmer 1.4s ease-in-out infinite; }
@keyframes vm-shimmer { to { transform: translateX(100%); } }
.skel-line { height: 14px; width: 100%; }
.skel-line--lg { height: 28px; }
.skel-line--xl { height: 44px; border-radius: 14px; }
.skel-w30 { width: 30%; } .skel-w45 { width: 45%; } .skel-w60 { width: 60%; } .skel-w80 { width: 80%; }
.skel-sq { width: 72px; height: 72px; border-radius: 22px; flex: none; }
.skel-sq--xl { width: 96px; height: 96px; border-radius: 28px; }
.skel-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 20px; box-shadow: var(--shadow-1); display: grid; gap: 12px; align-content: start; }
.skel-row { display: flex; align-items: center; gap: 16px; }
.skel-row > .skel-stack { flex: 1; display: grid; gap: 10px; min-width: 0; }
.skel-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.skel-grid--wide { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.skel-stats { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.skel-on-brand .skel { background: rgba(255, 255, 255, .22); }
.skel-on-brand .skel::after { background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .35), transparent); }
.skel-hero { padding-block: 44px 56px; display: grid; gap: 18px; }
.skel-stagger > :nth-child(2) .skel::after { animation-delay: .1s; } .skel-stagger > :nth-child(3) .skel::after { animation-delay: .2s; }

/* demo pública y aviso de conexión */
.demo-banner--pub { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 14px; }
.demo-banner__act { display: inline-flex; gap: 10px; align-items: center; }
.demo-banner__act a, .demo-banner__act button { color: #fff; background: rgba(255,255,255,.12); border: 0; border-radius: 999px; padding: 4px 11px; font: inherit; font-weight: 700; font-size: .75rem; text-decoration: none; cursor: pointer; }
.demo-banner__act a { background: var(--accent, #FBB03E); color: #1E2E3D; }
.net-pill { position: fixed; z-index: 120; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 8px); max-width: calc(100% - 24px); padding: 8px 14px; border-radius: 999px; font-size: .8125rem; font-weight: 700; text-align: center; box-shadow: 0 6px 20px rgba(0,0,0,.25); animation: vm-fade .2s ease; }
.net-pill[hidden] { display: none; }
.net-pill--off { background: #B45309; color: #fff; }
.net-pill--sync { background: #1E2E3D; color: #fff; }
.net-pill--ok { background: #15803D; color: #fff; }
