/* MVM Padel · estilos (móvil primero) */
/* Tema oscuro: el predominante y el que sale por defecto */
:root {
  /* Paleta MVM: gris, verde #66BB6A y naranja #FFB74D (pastel) */
  --verde: #66BB6A;
  --naranja: #FFB74D;
  --sobre-naranja: #3e2600;
  --primario: #2E7D32;
  --primario-texto: #81C784;
  --primario-claro: #1f3324;
  --sobre-primario: #10301a;
  --grad: linear-gradient(135deg, #66BB6A 0%, #81C784 100%);
  --grad-gris: linear-gradient(135deg, #455A64 0%, #37474F 100%);
  --fondo: #121615;
  --tarjeta: #1c2321;
  --texto: #e7ecea;
  --suave: #9aaba5;
  --borde: #2e3a36;
  --ok: #4ade80;
  --ok-fondo: #12351f;
  --mal: #f87171;
  --mal-fondo: #3b1717;
  --duda: #facc15;
  --duda-fondo: #3a2e0f;
  --sombra: 0 2px 10px rgba(0, 0, 0, .35);
  --radio: 18px;
  /* zonas que cambian de color con el tema */
  --barra: #263238;
  --barra-texto: #ffffff;
  --barra-sombra: 0 2px 12px rgba(0, 0, 0, .2);
  --hover-icono: rgba(255, 255, 255, .15);
  --cabecera-fondo: var(--grad-gris);
  --cabecera-texto: #ffffff;
  --cabecera-boton: rgba(255, 255, 255, .14);
  --portada: var(--grad-gris);
  --interruptor-bola: #ffffff;
  color-scheme: dark;
}

/* Tema claro: fondo blanco y tonos claros */
html[data-tema="claro"] {
  --primario-texto: #388E3C;
  --primario-claro: #E8F5E9;
  --fondo: #f3f5f4;
  --tarjeta: #ffffff;
  --texto: #263238;
  --suave: #607D8B;
  --borde: #dfe6e2;
  --ok: #15803d;
  --ok-fondo: #dcfce7;
  --mal: #b91c1c;
  --mal-fondo: #fee2e2;
  --duda: #a16207;
  --duda-fondo: #fef3c7;
  --sombra: 0 2px 10px rgba(38, 50, 56, .08);
  --barra: #ffffff;
  --barra-texto: #263238;
  --barra-sombra: 0 1px 0 #dfe6e2, 0 2px 10px rgba(38, 50, 56, .06);
  --hover-icono: rgba(38, 50, 56, .08);
  --cabecera-fondo: linear-gradient(135deg, #ffffff 0%, #E8F5E9 100%);
  --cabecera-texto: #263238;
  --cabecera-boton: rgba(46, 125, 50, .10);
  --portada: linear-gradient(160deg, #ffffff 0%, #E8F5E9 60%, #FFF3E0 100%);
  color-scheme: light;
}

/* Cada logo solo en su tema: el blanco sobre oscuro, el negro sobre claro */
html[data-tema="claro"] .solo-oscuro, html:not([data-tema="claro"]) .solo-claro { display: none !important; }

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--fondo);
  color: var(--texto);
  font-size: 16px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primario-texto); }
svg.i { width: 22px; height: 22px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- barra superior ---------- */
.barra {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--barra); color: var(--barra-texto);
  box-shadow: var(--barra-sombra);
}
.barra h1 { flex: 1; margin: 0; font-size: 18px; font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .btn-icono { color: var(--barra-texto); }
.btn-icono {
  display: inline-grid; place-items: center; width: 40px; height: 40px;
  border: 0; border-radius: 12px; background: transparent; cursor: pointer;
}
.btn-icono:hover { background: var(--hover-icono); }

main { max-width: 760px; margin: 0 auto; padding: 16px 16px 90px; }

/* ---------- tarjetas y mosaicos ---------- */
.tarjeta {
  background: var(--tarjeta); border: 1px solid var(--borde); border-radius: var(--radio);
  padding: 16px; margin-bottom: 14px; box-shadow: var(--sombra);
}
.tarjeta h2 { margin: 0 0 10px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.tarjeta h3 { margin: 14px 0 8px; font-size: 15px; color: var(--suave); }
.mosaico { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px; }
@media (min-width: 560px) { .mosaico { grid-template-columns: repeat(3, 1fr); } }
.losa {
  position: relative; display: flex; flex-direction: column; justify-content: space-between; gap: 18px;
  min-height: 112px; padding: 14px; border-radius: var(--radio); border: 0;
  background: var(--grad); color: var(--sobre-primario); text-align: left; text-decoration: none; cursor: pointer;
  box-shadow: 0 6px 16px rgba(46, 125, 50, .22);
}
.losa svg.i { width: 30px; height: 30px; }
.losa b { font-size: 16px; font-weight: 650; }
.losa small { display: block; opacity: .85; font-size: 13px; margin-top: 2px; }
.losa.clara { background: var(--tarjeta); color: var(--texto); border: 1px solid var(--borde); box-shadow: var(--sombra); }
.losa.clara svg.i { color: var(--primario-texto); }
.losa .globo {
  position: absolute; top: 10px; right: 10px; min-width: 24px; height: 24px; padding: 0 7px;
  border-radius: 12px; background: var(--naranja); color: var(--sobre-naranja); font-size: 13px; font-weight: 700;
  display: grid; place-items: center;
}
.losa.clara .globo { background: var(--naranja); color: var(--sobre-naranja); }

.cabecera-equipo { background: var(--cabecera-fondo); color: var(--cabecera-texto); border-top: 1px solid var(--borde); border-right: 1px solid var(--borde); border-bottom: 1px solid var(--borde); border-left: 6px solid var(--naranja); border-radius: var(--radio); padding: 18px; margin-bottom: 16px; box-shadow: 0 6px 16px rgba(46, 125, 50, .22); }
.cabecera-equipo h2 { margin: 0; font-size: 20px; }
.cabecera-equipo p { margin: 4px 0 0; opacity: .9; font-size: 14px; }

/* ---------- listas ---------- */
.lista { list-style: none; margin: 0; padding: 0; }
.lista > li { display: flex; align-items: center; gap: 10px; padding: 11px 0; border-top: 1px solid var(--borde); }
.lista > li:first-child { border-top: 0; }
.lista .crece { flex: 1; min-width: 0; }
.lista .nombre { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.lista .sub { color: var(--suave); font-size: 13px; }
.puntos { font-variant-numeric: tabular-nums; font-weight: 700; text-align: right; white-space: nowrap; }
.puntos small { display: block; font-weight: 500; color: var(--suave); font-size: 12px; }
.fila-enlace { color: inherit; text-decoration: none; }

.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--primario-claro); color: var(--primario-texto); font-weight: 700; font-size: 14px;
}

/* ---------- etiquetas ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--primario-claro); color: var(--primario-texto); white-space: nowrap; }
.chip.ok { background: var(--ok-fondo); color: var(--ok); }
.chip.mal { background: var(--mal-fondo); color: var(--mal); }
.chip.duda { background: var(--duda-fondo); color: var(--duda); }
.chip.gris { background: var(--borde); color: var(--suave); }

/* ---------- botones y formularios ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 10px 18px; border-radius: 14px; border: 0; cursor: pointer;
  background: var(--grad); color: var(--sobre-primario); font-weight: 650; text-decoration: none;
}
.btn.sec { background: var(--primario-claro); color: var(--primario-texto); }
.btn.peligro { background: var(--mal-fondo); color: var(--mal); }
.btn.bloque { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.peq { min-height: 36px; padding: 6px 12px; font-size: 14px; border-radius: 10px; }
.botones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.botones > .btn { flex: 1 1 auto; }

label.campo { display: block; margin-bottom: 12px; }
label.campo > span { display: block; font-size: 14px; color: var(--suave); margin-bottom: 4px; }
input[type=text], input[type=password], input[type=url], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 46px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--borde); background: var(--fondo);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primario-texto); outline-offset: 1px; }
.casilla { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.casilla input { width: 20px; height: 20px; accent-color: var(--primario-texto); }

.segmento { display: flex; background: var(--fondo); border: 1px solid var(--borde); border-radius: 14px; padding: 4px; gap: 4px; }
.segmento button { flex: 1; min-height: 40px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-weight: 600; color: var(--suave); display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 14px; }
.segmento button.activo { background: var(--tarjeta); color: var(--primario-texto); box-shadow: var(--sombra); }
.segmento button.activo.ok { background: var(--ok-fondo); color: var(--ok); }
.segmento button.activo.mal { background: var(--mal-fondo); color: var(--mal); }
.segmento button.activo.duda { background: var(--duda-fondo); color: var(--duda); }

/* ---------- parejas ---------- */
.pareja { border: 1px solid var(--borde); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.pareja-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.pareja-num { width: 30px; height: 30px; border-radius: 50%; background: var(--naranja); color: var(--sobre-naranja); display: grid; place-items: center; font-weight: 700; flex: none; }
.pareja .jug { display: flex; justify-content: space-between; gap: 8px; padding: 3px 0; }
.pareja .jug span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pareja select { margin-bottom: 6px; }
.selector-jug { display: flex; flex-wrap: wrap; gap: 6px; }
.selector-jug button { border: 1px solid var(--borde); background: var(--tarjeta); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-size: 14px; }
.selector-jug button.fijo { border-color: var(--ok); background: var(--ok-fondo); color: var(--ok); }
.selector-jug button.fuera { border-color: var(--mal); background: var(--mal-fondo); color: var(--mal); text-decoration: line-through; }

/* ---------- avisos ---------- */
.aviso { border-radius: 12px; padding: 10px 12px; margin: 10px 0; font-size: 14px; background: var(--duda-fondo); color: var(--duda); display: flex; gap: 8px; }
.aviso.error { background: var(--mal-fondo); color: var(--mal); }
.aviso.ok { background: var(--ok-fondo); color: var(--ok); }
.aviso.info { background: var(--primario-claro); color: var(--primario-texto); }
.vacio { text-align: center; color: var(--suave); padding: 24px 8px; }
.vacio svg.i { width: 44px; height: 44px; opacity: .5; display: block; margin: 0 auto 8px; }
.suave { color: var(--suave); }
.peque { font-size: 13px; }

/* ---------- tabla ---------- */
.tabla { width: 100%; border-collapse: collapse; font-size: 14px; }
.tabla th, .tabla td { padding: 8px 6px; border-top: 1px solid var(--borde); text-align: left; }
.tabla th { color: var(--suave); font-weight: 600; font-size: 12px; text-transform: uppercase; border-top: 0; }
.tabla .num { text-align: right; font-variant-numeric: tabular-nums; }
.desliza { overflow-x: auto; }

/* ---------- acceso (login / instalación) ---------- */
.portada { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--portada); }
.portada .tarjeta { width: 100%; max-width: 400px; }
.logo { display: flex; flex-direction: column; align-items: center; gap: 8px; margin: 4px 0 18px; }
.logo img { width: 240px; max-width: 80%; height: auto; }
.logo b { font-size: 22px; }

/* ---------- modal y aviso flotante ---------- */
.velo { position: fixed; inset: 0; z-index: 50; background: rgba(15, 10, 30, .55); display: grid; align-items: end; justify-items: center; }
@media (min-width: 560px) { .velo { align-items: center; } }
.modal { width: 100%; max-width: 520px; max-height: 88vh; overflow: auto; background: var(--tarjeta); border-radius: 22px 22px 0 0; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
@media (min-width: 560px) { .modal { border-radius: 22px; } }
.modal h2 { margin-top: 0; font-size: 18px; }
.tostada {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 60; max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: #263238; color: #fff; box-shadow: 0 8px 24px rgba(0, 0, 0, .3); font-size: 15px;
}
.tostada.error { background: #991b1b; }
.cargando { display: grid; place-items: center; padding: 48px; color: var(--suave); }
.giro { width: 32px; height: 32px; border: 3px solid var(--borde); border-top-color: var(--primario-texto); border-radius: 50%; animation: giro .8s linear infinite; }
@keyframes giro { to { transform: rotate(360deg); } }
.clave-temporal { font-family: ui-monospace, Consolas, monospace; font-size: 20px; letter-spacing: 1px; background: var(--fondo); border-radius: 12px; padding: 10px 12px; margin: 6px 0 12px; user-select: all; }
.segmento button { min-width: 0; }
@media (max-width: 480px) {
  .segmento button { flex-direction: column; gap: 2px; font-size: 12px; min-height: 52px; padding: 4px 2px; }
}

.barra .logo-barra { height: 30px; width: auto; display: block; }
.cabecera-equipo .btn.sec { background: var(--cabecera-boton); color: var(--cabecera-texto); }
.losa.naranja { background: linear-gradient(135deg, #FFB74D 0%, #FFCC80 100%); color: var(--sobre-naranja); }

/* ---------- interruptor de disponibilidad ---------- */
.interruptor { position: relative; flex: none; width: 50px; height: 30px; cursor: pointer; }
.interruptor input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.interruptor span { position: absolute; inset: 0; border-radius: 999px; background: var(--borde); transition: background .2s; }
.interruptor span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: var(--interruptor-bola); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.interruptor input:checked + span { background: var(--verde); }
.interruptor input:checked + span::after { transform: translateX(20px); }
.interruptor.duda span { background: var(--naranja); }
.interruptor input:disabled { cursor: default; }
.interruptor input:disabled + span { opacity: .45; }
.interruptor input:focus-visible + span { outline: 2px solid var(--primario-texto); outline-offset: 2px; }

/* ---------- estadísticas ---------- */
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.kpi { background: var(--tarjeta); border: 1px solid var(--borde); border-top: 3px solid var(--borde); border-radius: 14px; padding: 12px 6px; text-align: center; box-shadow: var(--sombra); display: flex; flex-direction: column; align-items: center; gap: 2px; }
.kpi svg.i { color: var(--suave); width: 20px; height: 20px; }
.kpi b { font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi span { font-size: 12px; color: var(--suave); }
.kpi.ok { border-top-color: var(--verde); } .kpi.ok b { color: var(--ok); }
.kpi.mal { border-top-color: #e57373; } .kpi.mal b { color: var(--mal); }
@media (min-width: 560px) { .kpi b { font-size: 32px; } .kpi span { font-size: 14px; } }
.porcentaje { text-align: center; }
.porcentaje > b { font-size: 40px; color: var(--primario-texto); font-variant-numeric: tabular-nums; }
.porcentaje p { margin: 8px 0 0; font-size: 14px; }
.barra-pct { height: 14px; border-radius: 999px; background: var(--borde); overflow: hidden; margin-top: 8px; }
.barra-pct span { display: block; height: 100%; border-radius: 999px; background: var(--grad); }
.ranking { min-width: 720px; }
.ranking th[data-c] { cursor: pointer; user-select: none; white-space: nowrap; }
.ranking .flecha { opacity: .6; font-size: 10px; }
.ranking tbody tr { cursor: pointer; }
.ranking tbody tr:hover { background: var(--primario-claro); }
.ranking td:nth-child(2), .ranking th:nth-child(2) { position: sticky; left: 0; background: var(--tarjeta); z-index: 1; }
.ranking tbody tr:hover td:nth-child(2) { background: var(--primario-claro); }
.ranking .nombre { font-weight: 600; white-space: nowrap; }
.ranking .sub { color: var(--suave); font-size: 12px; }
.ranking tr.podio td:first-child { box-shadow: inset 4px 0 0 var(--naranja); font-weight: 700; }
.txt-ok { color: var(--ok); } .txt-mal { color: var(--mal); }

/* ---------- gráfica de evolución ---------- */
.modal.ancho { max-width: 720px; }
.modal-cab { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.modal-cab h2 { margin: 0; display: flex; align-items: center; gap: 8px; }
.grafica { position: relative; margin: 12px 0 6px; }
.grafica svg { display: block; touch-action: pan-y; }
.g-rejilla { stroke: var(--borde); stroke-width: 1; }
.g-eje { fill: var(--suave); font-size: 11px; }
.g-area { fill: var(--verde); opacity: .14; }
.g-linea { fill: none; stroke: var(--primario-texto); stroke-width: 2.5; }
.g-cruz { stroke: var(--suave); stroke-width: 1; stroke-dasharray: 3 3; }
.g-punto { stroke: var(--tarjeta); stroke-width: 2; }
.g-punto.ok { fill: var(--verde); } .g-punto.mal { fill: #e53935; } .g-punto.inicio { fill: #90A4AE; }
.g-punto.activo { r: 8; }
.g-tip { position: absolute; z-index: 2; pointer-events: none; background: #263238; color: #fff; border-radius: 10px; padding: 8px 10px; font-size: 13px; line-height: 1.45; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); max-width: 240px; }
.g-tip b { font-weight: 700; }
.leyenda { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 14px; font-size: 14px; }
.leyenda span { display: inline-flex; align-items: center; gap: 6px; }
.punto { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.punto.ok { background: var(--verde); } .punto.mal { background: #e53935; } .punto.inicio { background: #90A4AE; }
main.ancho { max-width: 1100px; }
.ranking { min-width: 780px; }
.ranking td .chip { max-width: 170px; overflow: hidden; text-overflow: ellipsis; display: inline-block; }

/* aviso de privacidad */
.texto-legal h3 { font-size: 1rem; margin: 18px 0 6px; color: var(--texto); }
.texto-legal p, .texto-legal li { line-height: 1.5; }
.texto-legal ul { padding-left: 20px; margin: 6px 0; }

/* selector de tema */
.tema-enlace { background: none; border: 0; padding: 4px; color: var(--suave); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.tema-enlace svg.i { width: 18px; height: 18px; }
