/* ==========================================================================
   Dashboard Liga Municipal
   Pensado primero para el celular: botones de 44px, navegación del torneo
   abajo (al alcance del pulgar) y partidos apilados como un marcador.
   ========================================================================== */
:root {
  --bg: #0b0b10;
  --surface: #14131a;
  --surface-2: #1c1b24;
  --surface-3: #25232f;
  --border: #292732;
  --border-strong: #3a3746;
  --text: #f5f4f8;
  --muted: #9e9aaa;
  --faint: #6d6979;
  --primary: #8c52ff;
  --primary-dim: #7440e0;
  --primary-soft: rgba(140, 82, 255, .14);
  --primary-line: rgba(140, 82, 255, .45);
  --ok: #34d399;
  --ok-soft: rgba(52, 211, 153, .12);
  --warn: #fbbf24;
  --warn-soft: rgba(251, 191, 36, .12);
  --danger: #ff6e84;
  --danger-soft: rgba(255, 110, 132, .1);
  --live: #f43f5e;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px -18px rgba(0, 0, 0, .8);
  --font: "Manrope", system-ui, sans-serif;
  --font-head: "Lexend", system-ui, sans-serif;
  --topbar-h: 60px;
  --bottomnav-h: 0px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5;
  background-image: radial-gradient(1200px 500px at 85% -10%, rgba(140, 82, 255, .10), transparent 60%);
  background-attachment: fixed; min-height: 100vh; -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
p a, .ayuda a { color: #b794ff; text-underline-offset: 3px; }
code { font-family: ui-monospace, SFMono-Regular, monospace; font-size: .85em; background: var(--surface-3); padding: 1px 6px; border-radius: 6px; }
h1, h2, h3 { font-family: var(--font-head); margin: 0; line-height: 1.2; letter-spacing: -.01em; }
h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.12rem; font-weight: 700; }
h3 { font-size: 1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.rol-cargador .solo-admin, html:not(.rol-cargador) .solo-cargador { display: none !important; }
.no-super .solo-super, html:not(.no-super) .solo-cliente { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
::selection { background: var(--primary); color: #fff; }

/* Íconos (SVG en línea, ver ICONOS en app.js) */
.ico { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Barra superior ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; height: var(--topbar-h);
  padding: 0 24px; border-bottom: 1px solid var(--border); background: rgba(11, 11, 16, .82);
  backdrop-filter: saturate(160%) blur(14px); -webkit-backdrop-filter: saturate(160%) blur(14px);
  position: sticky; top: 0; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-weight: 700; text-decoration: none; min-width: 0; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; font-size: 17px; color: #fff; flex: none;
  background: linear-gradient(135deg, #a274ff, #6b34f0); box-shadow: 0 6px 18px -6px rgba(140, 82, 255, .7);
}
.brand-text { display: grid; line-height: 1.1; }
.brand-text small { font-family: var(--font); font-weight: 600; font-size: .7rem; color: var(--muted); letter-spacing: .02em; }
.nav { display: flex; gap: 2px; align-items: center; }
.nav a {
  display: inline-flex; align-items: center; gap: 7px; text-decoration: none; padding: 8px 12px; border-radius: 10px;
  color: var(--muted); font-weight: 600; font-size: .9rem; min-height: 40px;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav a.active { color: var(--text); background: var(--surface-3); }
.nav .nav-sep { width: 1px; height: 22px; background: var(--border); margin: 0 6px; }
.nav-user { display: inline-flex; align-items: center; gap: 8px; }
.avatar {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; font-size: .72rem; font-weight: 800;
  background: var(--primary-soft); color: #c9b0ff; border: 1px solid var(--primary-line); flex: none;
}
.nav-email { display: grid; line-height: 1.2; font-size: .85rem; color: var(--text); }
.nav-rol { font-size: .7rem; color: var(--faint); font-weight: 600; }
.nav-cuenta { display: none; }

.container { max-width: 1200px; margin: 0 auto; padding: 28px 24px 72px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .lead { margin: 6px 0 0; max-width: 640px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.crumb {
  display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: .85rem; font-weight: 600;
  padding: 4px 8px 4px 2px; margin-left: -2px; border-radius: 8px;
}
.crumb:hover { color: var(--text); }
.crumb .ico { width: 16px; height: 16px; }
.head-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 8px; color: var(--muted); font-size: .88rem; }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin: 0 0 14px; }

/* ---------- Ayuda plegable ---------- */
.ayuda { margin: 0 0 18px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); max-width: 760px; }
.ayuda summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; padding: 10px 14px;
  color: var(--muted); font-size: .85rem; font-weight: 700; user-select: none;
}
.ayuda summary::-webkit-details-marker { display: none; }
.ayuda summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); transition: transform .15s; }
.ayuda[open] summary::after { transform: rotate(-135deg); }
.ayuda summary:hover { color: var(--text); }
.ayuda summary .ico { width: 16px; height: 16px; color: #b794ff; }
.ayuda > div, .ayuda > p { padding: 0 14px 12px; margin: 0; color: var(--muted); font-size: .86rem; }
.ayuda p { margin: 0 0 6px; }

/* ---------- Tarjetas ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.card > h2:first-child { margin-bottom: 4px; }
.card-danger { border-color: rgba(255, 110, 132, .3); background: linear-gradient(180deg, var(--danger-soft), transparent 70%), var(--surface); }
.grid { display: grid; gap: 16px; }
.grid-cards { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.torneo-card { display: flex; flex-direction: column; gap: 14px; text-decoration: none; transition: border-color .15s, transform .15s, box-shadow .15s; position: relative; }
.torneo-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: 0 18px 40px -24px rgba(140, 82, 255, .55); }
.grid > .torneo-card + .torneo-card { margin-top: 0; }
.torneo-link { display: flex; flex-direction: column; gap: 14px; color: inherit; text-decoration: none; }
.torneo-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.torneo-sitio { position: relative; z-index: 1; }
.torneo-oculto .torneo-link { opacity: .6; }
.torneo-top { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.torneo-top h2 { font-size: 1.15rem; }
.torneo-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.torneo-ir { color: var(--faint); transition: color .15s, transform .15s; }
.torneo-card:hover .torneo-ir { color: var(--text); transform: translateX(2px); }
/* Pie de la tarjeta: qué se ve en el sitio público */
.torneo-sitio { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding-top: 12px; border-top: 1px solid var(--border); min-height: 32px; }
.stats { display: flex; gap: 22px; }
.stat b { display: block; font-family: var(--font-head); font-size: 1.3rem; line-height: 1.2; }
.stat span { color: var(--muted); font-size: .78rem; }
.progreso { display: grid; gap: 6px; }
.progreso-txt { display: flex; justify-content: space-between; font-size: .8rem; color: var(--muted); }
.progreso-txt b { color: var(--text); font-weight: 700; }
.barra { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.barra i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), #b794ff); }
.cliente-card .cliente-top { display: flex; align-items: center; gap: 12px; }
.cliente-logo {
  width: 46px; height: 46px; border-radius: 12px; display: grid; place-items: center; flex: none; font-family: var(--font-head);
  font-weight: 700; font-size: 1rem; color: #fff; background: linear-gradient(135deg, #a274ff, #5b2bd6);
}
.card-nuevo {
  display: grid; place-items: center; gap: 6px; text-align: center; min-height: 150px; border: 1.5px dashed var(--border-strong);
  background: transparent; color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; box-shadow: none;
}
.card-nuevo:hover { color: var(--text); border-color: var(--primary); background: var(--primary-soft); }
.card-nuevo .ico { width: 26px; height: 26px; }

/* ---------- Formularios ---------- */
label { display: block; font-size: .8rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
input, select, textarea {
  width: 100%; background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px; font: inherit; min-height: 42px; transition: border-color .15s, box-shadow .15s, background .15s;
}
input::placeholder { color: var(--faint); }
input:hover, select:hover, textarea:hover { border-color: var(--border-strong); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); background: var(--surface-3); box-shadow: 0 0 0 3px rgba(140, 82, 255, .25); }
input[readonly] { color: var(--muted); }
select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239e9aaa' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
input[type=number] { -moz-appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
input[type=checkbox] { accent-color: var(--primary); min-height: 0; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); align-items: end; }
.field { margin-bottom: 14px; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: .82rem; }
.check { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: .92rem; font-weight: 600; margin: 0; cursor: pointer; min-height: 28px; }
.check input { width: 18px; height: 18px; }
.checks { display: grid; gap: 4px; max-height: 260px; overflow-y: auto; padding: 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.checks .check { padding: 6px 8px; border-radius: 8px; }
.checks .check:hover { background: var(--surface-3); }
/* Interruptor: un checkbox con forma de switch (visible en el sitio, mostrar goleadores…) */
.switch input {
  appearance: none; -webkit-appearance: none; width: 40px; height: 24px; border-radius: 99px; background: var(--surface-3);
  border: 1px solid var(--border-strong); position: relative; cursor: pointer; flex: none; margin: 0; padding: 0; transition: background .18s, border-color .18s;
}
.switch input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #cfcbd8;
  transition: transform .18s, background .18s; box-shadow: 0 1px 3px rgba(0, 0, 0, .4);
}
.switch input:checked { background: var(--primary); border-color: var(--primary); }
.switch input:checked::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; box-shadow: none; }
.switch input:disabled { opacity: .5; cursor: not-allowed; }
.switches { display: grid; gap: 4px; margin-top: 16px; padding: 6px 0; border-top: 1px solid var(--border); }
.switches .check { justify-content: space-between; flex-direction: row-reverse; padding: 10px 0; border-bottom: 1px solid var(--border); }
.switches .check:last-child { border-bottom: 0; }
.switches .check span { flex: 1; }
.switches .check small { display: block; color: var(--muted); font-weight: 500; font-size: .8rem; }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 9px 16px; min-height: 42px; font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer;
  text-decoration: none; background: var(--surface-2); color: var(--text); white-space: nowrap; transition: background .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { border-color: var(--muted); background: var(--surface-3); }
.btn:active { transform: translateY(1px); }
.btn .ico { width: 17px; height: 17px; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 6px 16px -8px rgba(140, 82, 255, .9); }
.btn-primary:hover { background: var(--primary-dim); border-color: var(--primary-dim); }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(255, 110, 132, .4); }
.btn-danger:hover { border-color: var(--danger); background: var(--danger-soft); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); border-color: var(--border); }
.btn-sm { padding: 6px 11px; min-height: 34px; font-size: .82rem; border-radius: 9px; }
.btn-icon { padding: 0; width: 42px; }
.btn-sm.btn-icon { width: 34px; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ---------- Badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: .7rem; font-weight: 800;
  text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; line-height: 1.3;
}
.badge-en_curso, .badge-jugado { color: var(--ok); background: var(--ok-soft); border-color: rgba(52, 211, 153, .3); }
.badge-borrador, .badge-pendiente { color: var(--warn); background: var(--warn-soft); border-color: rgba(251, 191, 36, .3); }
.badge-finalizado { color: var(--muted); }
.badge-destacado { color: #c9b0ff; background: var(--primary-soft); border-color: var(--primary-line); }
.badge-en_vivo { color: #fff; background: #e11d48; border-color: #e11d48; display: inline-flex; align-items: center; gap: 6px; }
.live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulso 1.2s ease-in-out infinite; font-style: normal; flex: none; }
.tab .live-dot { color: var(--live); margin-right: 4px; vertical-align: middle; }
@keyframes pulso { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
@media (prefers-reduced-motion: reduce) { .live-dot { animation: none; } }
.badge-suspendido { color: var(--danger); background: var(--danger-soft); border-color: rgba(255, 110, 132, .3); }

/* ---------- Pestañas ---------- */
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 22px; overflow-x: auto; scrollbar-width: none; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; width: fit-content; max-width: 100%; }
.tabs::-webkit-scrollbar { display: none; }
.tab {
  display: inline-flex; align-items: center; gap: 7px; background: none; border: none; color: var(--muted); font: inherit; font-weight: 700; font-size: .9rem;
  padding: 8px 14px; min-height: 38px; cursor: pointer; border-radius: 9px; white-space: nowrap; transition: color .15s, background .15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); background: var(--surface-3); box-shadow: 0 1px 0 rgba(255, 255, 255, .05) inset; }
.tab.active .ico { color: #b794ff; }
.tab .ico { width: 17px; height: 17px; }
.tab-label { display: inline-flex; align-items: center; }
.tab.has-live .ico { color: var(--live); }
.tab .live-dot { display: none; }

/* ---------- Tablas ---------- */
.table-wrap { overflow-x: auto; }
.card.table-wrap { padding: 6px 8px; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th { text-align: left; color: var(--faint); font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 800; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
td { padding: 11px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }
tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: center; font-variant-numeric: tabular-nums; }
td.acciones { text-align: right; white-space: nowrap; }
.team { display: flex; align-items: center; gap: 10px; min-width: 0; }
.crest { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; background: var(--surface-3); display: grid; place-items: center; font-size: .66rem; font-weight: 800; color: var(--muted); flex-shrink: 0; border: 1px solid var(--border); }

img.crest { object-fit: contain; border-radius: 0; background: transparent; border: 0; }

/* ---------- Resultados: barra de herramientas ---------- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.toolbar-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.fecha-nav { display: flex; align-items: center; gap: 6px; }
.fecha-nav select { width: auto; min-width: 150px; font-weight: 700; text-align: center; }

/* ---------- Partidos ---------- */
.jornada { margin-bottom: 28px; }
.jornada-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.jornada-head h2 { font-size: 1.2rem; }
.match {
  display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; align-items: center; gap: 10px 14px; padding: 14px 16px;
  background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--border-strong); border-radius: 12px; margin-bottom: 8px;
  transition: border-color .2s, box-shadow .2s;
}
.match:has(.badge-jugado) { border-left-color: var(--ok); }
.match:has(.badge-pendiente) { border-left-color: var(--warn); }
.match:has(.badge-suspendido) { border-left-color: var(--danger); }
.match .home { justify-content: flex-end; text-align: right; }
.match .team { font-weight: 700; }
.score { display: flex; align-items: center; gap: 6px; }
.score input { width: 54px; height: 46px; text-align: center; font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; padding: 4px; }
.match-meta { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; font-size: .8rem; color: var(--muted); }
.match-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
/* "Guardar" se apaga mientras no haya cambios y se enciende al tocar el marcador */
.match:not(.dirty) .match-actions .btn-primary:not([data-fin]) { background: transparent; border-color: var(--border-strong); color: var(--muted); box-shadow: none; }
.match.dirty { border-color: var(--primary-line); box-shadow: 0 0 0 3px rgba(140, 82, 255, .12); }
.match.dirty .match-actions .btn-primary { animation: latido 1.6s ease-in-out infinite; }
@keyframes latido { 0%, 100% { box-shadow: 0 0 0 0 rgba(140, 82, 255, .55); } 50% { box-shadow: 0 0 0 6px rgba(140, 82, 255, 0); } }
.match.saved { border-color: rgba(52, 211, 153, .6); animation: guardado 1.2s ease-out; }
@keyframes guardado { 0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, .5); } 100% { box-shadow: 0 0 0 10px rgba(52, 211, 153, 0); } }
@media (prefers-reduced-motion: reduce) { .match.dirty .match-actions .btn-primary, .match.saved { animation: none; } }

/* ---------- Imágenes ---------- */
.img-field { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.img-preview { width: 64px; height: 64px; border-radius: 12px; background: var(--surface-2); border: 1.5px dashed var(--border-strong); display: grid; place-items: center; overflow: hidden; flex-shrink: 0; }
.img-preview.wide { width: 100%; height: auto; aspect-ratio: 4 / 1; }
.img-preview img { width: 100%; height: 100%; object-fit: contain; }
.img-preview span { color: var(--faint); font-size: .72rem; text-align: center; padding: 4px; }
.img-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.img-actions label.btn { margin: 0; color: var(--text); font-size: .8rem; }

/* ---------- Sponsors ---------- */
.sponsor-list { display: grid; gap: 10px; }
.sponsor { display: grid; grid-template-columns: 240px minmax(0, 1fr) auto; gap: 16px; align-items: center; padding: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; }
.sponsor.off { opacity: .55; }
.sponsor-img { aspect-ratio: 4 / 1; background: var(--surface-3); border-radius: 8px; overflow: hidden; }
.sponsor-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sponsor-info { min-width: 0; }
.sponsor-info b { display: block; }
.sponsor-info a { color: var(--muted); font-size: .82rem; overflow-wrap: anywhere; }
.sponsor-actions { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- En vivo ---------- */
.btn-live { background: transparent; color: #fb7185; border-color: rgba(244, 63, 94, .45); }
.btn-live:hover { border-color: var(--live); background: rgba(244, 63, 94, .1); }
.btn-warn { background: var(--warn-soft); color: var(--warn); border-color: rgba(251, 191, 36, .45); }
.match.is-live { border-color: rgba(244, 63, 94, .55); border-left-color: var(--live); background: linear-gradient(90deg, rgba(244, 63, 94, .08), transparent 50%), var(--surface); }
.score.live { gap: 6px; }
.periodos { display: inline-flex; border: 1px solid var(--border-strong); border-radius: 9px; overflow: hidden; }
.periodo-btn { background: var(--surface-2); color: var(--muted); border: 0; border-left: 1px solid var(--border-strong); font: inherit; font-size: .78rem; font-weight: 800; padding: 6px 12px; min-height: 32px; cursor: pointer; }
.periodo-btn:first-child { border-left: 0; }
.periodo-btn:hover { color: var(--text); }
.periodo-btn.on { background: #e11d48; color: #fff; }
.periodo-btn:disabled { opacity: .6; }
.score.live b { font-family: var(--font-head); font-size: 1.7rem; min-width: 32px; text-align: center; font-variant-numeric: tabular-nums; }
.gol-btn { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text); font-size: 1.2rem; font-weight: 700; cursor: pointer; line-height: 1; touch-action: manipulation; }
.gol-btn.plus { background: var(--primary-soft); border-color: var(--primary-line); color: #d6c4ff; }
.gol-btn:hover { border-color: var(--muted); }
.gol-btn:active { transform: scale(.94); }
.gol-btn:disabled { opacity: .5; }
.jornada.oculta .match { opacity: .6; }
#envivo .gol-btn { width: 46px; height: 46px; font-size: 1.45rem; }
#envivo .score.live b { font-size: 2.1rem; }
.envivo-titulo { display: flex; align-items: center; gap: 10px; margin: 0 0 12px; }
.envivo-titulo + .card.empty { margin-bottom: 8px; }

/* ---------- Sponsors: logos y espacios ---------- */
.sponsor.is-logo { grid-template-columns: 160px minmax(0, 1fr) auto; }
.sponsor.is-logo .sponsor-img { aspect-ratio: 5 / 2; background: #24222b; display: grid; place-items: center; padding: 10px; }
.sponsor.is-logo .sponsor-img img { width: auto; height: auto; max-width: 100%; max-height: 44px; object-fit: contain; filter: grayscale(1); }
.sponsor:not(.is-logo) .sponsor-img { aspect-ratio: 728 / 90; }
#sponsorsBanners .sponsor { grid-template-columns: 340px minmax(0, 1fr) auto; }
.slot-title { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 22px 0 8px; font-family: var(--font); font-weight: 800; }
.slot-title:first-child { margin-top: 0; }
.slot-publicite { display: inline-flex; margin: 0 0 10px; }
.ad-slot-preview { border: 2px dashed rgba(140, 82, 255, .35); border-radius: 12px; padding: 14px; display: grid; justify-items: center; gap: 2px; text-align: center; }
.ad-slot-preview span { font-size: .7rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.ad-slot-preview b { color: var(--primary); font-family: var(--font-head); }
.ad-slot-preview small { color: var(--muted); }
[data-panel="sponsors"] .card + .card { margin-top: 16px; }

/* ---------- Zonas y playoff ---------- */
.zonas-lista { display: flex; flex-wrap: wrap; gap: 8px; }
.zona-chip { display: flex; align-items: center; gap: 8px; padding: 5px 5px 5px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }
.zona-select { padding: 6px 30px 6px 10px; min-height: 36px; width: auto; }
tr.clasifica td:first-child { box-shadow: inset 3px 0 0 var(--primary); color: #b794ff; font-weight: 700; }
.clasifica-dot { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--primary); vertical-align: middle; margin-right: 4px; }
.penales { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); }
.penales input { width: 46px; min-height: 32px; padding: 3px 6px; text-align: center; }
.match.tbd { opacity: .65; }
.campeon { display: flex; align-items: center; gap: 10px; padding: 16px 18px; margin-bottom: 18px; border-radius: 14px; background: linear-gradient(90deg, rgba(251, 191, 36, .18), transparent); border: 1px solid rgba(251, 191, 36, .45); font-size: 1.05rem; }
.sponsor.is-vertical { grid-template-columns: 90px minmax(0, 1fr) auto; }
#sponsorsBanners .sponsor.is-vertical { grid-template-columns: 90px minmax(0, 1fr) auto; }
.sponsor.is-vertical .sponsor-img { aspect-ratio: 1 / 2; }
.ad-slot-preview.vertical { max-width: 160px; aspect-ratio: 1 / 2; align-content: center; }
.playoff-config { display: flex; gap: 8px; align-items: flex-end; flex-wrap: wrap; }

/* Armado manual del playoff */
.modal.modal-wide { max-width: 640px; max-height: 90vh; overflow-y: auto; }
.modal .field select#mNCruces { display: inline-block; margin-right: 8px; }
.cruces { display: grid; gap: 8px; margin: 6px 0 10px; }
.cruce { display: grid; grid-template-columns: 64px minmax(0, 1fr) auto minmax(0, 1fr); gap: 8px; align-items: center; }
@media (max-width: 640px) {
  .cruce { grid-template-columns: 1fr; gap: 4px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
}

/* ---------- Goles y tarjetas por jugador ---------- */
/* Debajo de cada equipo (las celdas van en la grilla del partido) */
.match-incidencias { display: contents; }
.match-incidencias span { font-size: .8rem; color: var(--muted); }
.match-incidencias .home { grid-column: 1; text-align: right; }
.match-incidencias .visit { grid-column: 3; }
.modal-planilla { max-width: 720px; }
.planilla-marcador { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto minmax(0, 1fr); align-items: center; gap: 8px; margin-bottom: 8px; font-weight: 700; padding: 12px; background: var(--surface-2); border-radius: 12px; }
.planilla-marcador .home { text-align: right; }
.planilla-marcador input { width: 56px; text-align: center; font-family: var(--font-head); font-weight: 700; font-size: 1.2rem; padding: 6px; }
.planilla-marcador b { font-family: var(--font-head); font-size: 1.4rem; }
.planilla-penales { text-align: center; font-size: .85rem; color: var(--muted); }
.planilla-penales input { width: 52px; text-align: center; padding: 4px; display: inline-block; }
.planilla-equipo { margin-top: 18px; }
.planilla-equipo h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; margin-bottom: 6px; flex-wrap: wrap; }
.planilla-equipo .crest { width: 22px; height: 22px; }
.planilla-suma-mal { color: var(--danger); }
.planilla-tabla td { padding: 4px 6px; }
.planilla-tabla th { padding: 6px; }
.planilla-tabla input[type=number] { width: 52px; min-height: 38px; text-align: center; padding: 4px; }
.planilla-tabla input[type=checkbox] { width: 20px; height: 20px; }
@media (max-width: 640px) {
  .planilla-tabla input[type=number] { width: 44px; }
  .planilla-tabla td:first-child, .planilla-tabla th:first-child { display: none; }
  .planilla-tabla th { font-size: .62rem; letter-spacing: .02em; white-space: normal; }
}

/* ---------- Copiar ---------- */
.copy { display: flex; gap: 8px; }
.copy input { font-family: ui-monospace, monospace; font-size: .82rem; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(5, 5, 8, .7); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 50; animation: aparecer .15s ease-out; }
.modal { width: 100%; max-width: 480px; max-height: 92vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 18px; padding: 24px; box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .8); animation: subir .2s ease-out; }
.modal h2 { margin-bottom: 18px; font-size: 1.25rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
@keyframes aparecer { from { opacity: 0; } }
@keyframes subir { from { opacity: 0; transform: translateY(16px); } }

/* ---------- Toast ---------- */
#toast {
  position: fixed; bottom: calc(22px + var(--bottomnav-h)); left: 50%; transform: translateX(-50%) translateY(20px); background: var(--surface-3);
  border: 1px solid var(--border-strong); padding: 11px 18px; border-radius: 12px; font-weight: 700; opacity: 0; transition: .2s; z-index: 60;
  pointer-events: none; box-shadow: 0 16px 40px -12px rgba(0, 0, 0, .8); max-width: calc(100vw - 32px); display: flex; align-items: center; gap: 8px;
}
#toast::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { border-color: var(--danger); color: var(--danger); }
#toast.error::before { background: var(--danger); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login { width: 100%; max-width: 400px; padding: 32px 28px; }
.login .brand { flex-direction: column; justify-content: center; margin-bottom: 26px; font-size: 1.3rem; text-align: center; gap: 12px; }
.login .brand-mark { width: 56px; height: 56px; font-size: 28px; border-radius: 16px; }
.login .brand small { display: block; font-family: var(--font); font-weight: 600; font-size: .85rem; color: var(--muted); margin-top: 4px; }
.login .btn { min-height: 48px; font-size: 1rem; margin-top: 6px; }
.error-msg { color: var(--danger); font-size: .85rem; min-height: 1.2em; margin: 6px 0 0; }

.empty { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-ico { display: grid; place-items: center; width: 52px; height: 52px; margin: 0 auto 12px; border-radius: 14px; background: var(--surface-2); color: var(--faint); }
.empty-ico .ico { width: 26px; height: 26px; }

.match { grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto; }
.match .team span { min-width: 0; overflow-wrap: break-word; hyphens: auto; }

/* ---------- Tablas que en el celular se ven como tarjetas ---------- */
@media (max-width: 640px) {
  table.tabla-cards thead { display: none; }
  table.tabla-cards, .tabla-cards tbody, .tabla-cards tr, .tabla-cards td { display: block; }
  .tabla-cards tr { padding: 12px 6px; border-bottom: 1px solid var(--border); }
  .tabla-cards tr:last-child { border-bottom: 0; }
  .tabla-cards td { border: 0; padding: 3px 0; display: flex; align-items: center; justify-content: space-between; gap: 12px; text-align: right; }
  .tabla-cards td:first-child { padding-bottom: 8px; text-align: left; }
  .tabla-cards td[data-label]::before { content: attr(data-label); color: var(--faint); font-size: .75rem; font-weight: 700; text-align: left; flex: none; }
  .tabla-cards td.acciones { justify-content: flex-start; flex-wrap: wrap; padding-top: 10px; gap: 6px; text-align: left; }
  .tabla-cards td.empty { display: block; text-align: center; }
  .card.table-wrap:has(.tabla-cards) { padding: 4px 14px; }
}

/* ==========================================================================
   Celular
   ========================================================================== */
@media (max-width: 640px) {
  :root { --topbar-h: 56px; }
  body { font-size: 15px; }
  h1 { font-size: 1.45rem; }
  .topbar { padding: 0 12px 0 16px; }
  .brand-text { display: none; }
  .nav-email, .nav-label, .nav-rol, .nav .nav-sep { display: none; }
  .nav a { padding: 8px 10px; }
  .nav a .ico { width: 20px; height: 20px; }
  .container { padding: 18px 16px calc(48px + var(--bottomnav-h)); }
  .page-head { margin-bottom: 16px; align-items: flex-start; }
  .page-head > .btn, .page-actions .btn { flex: 1; }
  .page-head:has(> .btn-ver-sitio) { flex-wrap: nowrap; }
  .page-head > .btn-ver-sitio { flex: none; width: 44px; padding: 0; margin-top: 2px; }
  .page-actions { width: 100%; }
  .btn-ver-sitio .btn-txt { display: none; }
  .card { padding: 16px; border-radius: 14px; }
  .modal-actions .btn { flex: 1; min-height: 46px; }
  .grid-cards { grid-template-columns: 1fr; gap: 12px; }

  /* Navegación del torneo y del cliente: barra fija abajo, al alcance del pulgar */
  body.con-bottomnav { --bottomnav-h: calc(64px + env(safe-area-inset-bottom)); }
  body.con-bottomnav .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; margin: 0; width: auto; max-width: none; border-radius: 0; border: 0;
    border-top: 1px solid var(--border); background: rgba(16, 15, 22, .94); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); gap: 0; justify-content: space-around; overflow: visible;
  }
  body.con-bottomnav .tab {
    flex: 1 1 0; min-width: 0; flex-direction: column; gap: 3px; padding: 6px 2px; min-height: 52px; font-size: .66rem; font-weight: 700;
    letter-spacing: .01em; border-radius: 10px; position: relative;
  }
  body.con-bottomnav .tab .ico { width: 22px; height: 22px; }
  body.con-bottomnav .tab.active { background: transparent; box-shadow: none; color: #d6c4ff; }
  body.con-bottomnav .tab.active .ico { color: #b794ff; }
  body.con-bottomnav .tab.active::before { content: ""; position: absolute; top: -7px; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--primary); }
  body.con-bottomnav .tab .live-dot { display: inline-block; position: absolute; top: 6px; right: calc(50% - 18px); margin: 0; }
  body.con-bottomnav .tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }

  /* Modales: hoja que sube desde abajo */
  .modal-bg { place-items: end center; padding: 0; }
  .modal, .modal.modal-wide { max-width: none; max-height: 92dvh; border-radius: 20px 20px 0 0; padding: 20px 16px 0; border-bottom: 0; animation: hoja .22s ease-out; }
  .modal::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: -8px auto 14px; }
  .modal-actions { position: sticky; bottom: 0; margin: 18px -16px 0; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); }
  @keyframes hoja { from { transform: translateY(40px); opacity: .4; } }

  /* Resultados: fecha a todo el ancho, acciones abajo */
  .toolbar { gap: 10px; }
  .fecha-nav { width: 100%; }
  .fecha-nav select { flex: 1; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { flex: 1; }
  .jornada-head h2 { font-size: 1.1rem; }

  /* Partido en el celular: como un marcador, un equipo por renglón con su resultado a la derecha */
  .match { grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 8px; padding: 12px 12px 12px 14px; row-gap: 8px; }
  .match .match-meta { grid-column: 1 / -1; grid-row: 1; gap: 6px 10px; }
  .match .team { grid-column: 1; font-size: .95rem; gap: 10px; }
  .match .team.home { grid-row: 2; flex-direction: row-reverse; justify-content: flex-end; text-align: left; }
  .match .team:not(.home) { grid-row: 4; }
  .match .team span { overflow-wrap: anywhere; }
  .match .crest { width: 26px; height: 26px; }
  .match .score { display: contents; }
  .match .score > .muted { display: none; }
  .match .score input { width: 58px; height: 46px; font-size: 1.3rem; grid-column: 4; }
  .match .score input[name=gl] { grid-row: 2; }
  .match .score input[name=gv] { grid-row: 4; }
  .match .score.live > :nth-child(1) { grid-column: 2; grid-row: 2; }
  .match .score.live > :nth-child(2) { grid-column: 3; grid-row: 2; }
  .match .score.live > :nth-child(3) { grid-column: 4; grid-row: 2; }
  .match .score.live > :nth-child(5) { grid-column: 4; grid-row: 4; }
  .match .score.live > :nth-child(6) { grid-column: 3; grid-row: 4; }
  .match .score.live > :nth-child(7) { grid-column: 2; grid-row: 4; }
  .score.live b { font-size: 1.5rem; min-width: 30px; }
  .gol-btn { width: 40px; height: 40px; }
  #envivo .gol-btn { width: 50px; height: 50px; font-size: 1.6rem; }
  #envivo .score.live b { font-size: 2rem; min-width: 38px; }
  .match-incidencias span { grid-column: 1 / -1 !important; text-align: left !important; padding-left: 36px; margin-top: -6px; }
  .match .match-incidencias .home { grid-row: 3; }
  .match .match-incidencias .visit { grid-row: 5; }
  .match .match-actions { grid-column: 1 / -1; grid-row: 6; justify-content: flex-start; gap: 6px; padding-top: 10px; border-top: 1px solid var(--border); }
  .match .match-actions .btn { min-height: 40px; }
  .match .match-actions .btn-primary { flex: 1 1 100%; order: -1; min-height: 44px; }
  .match:not(.dirty) .match-actions .btn-primary:not([data-fin]) { flex: 0 1 auto; order: 0; min-height: 40px; }
  .match.tbd .score { display: none; }
  .match.tbd .team:not(.home) { grid-row: 3; }
  .match.tbd .match-actions { grid-row: 4; }

  .sponsor, .sponsor.is-logo, #sponsorsBanners .sponsor { grid-template-columns: 1fr; }
  .sponsor-actions { justify-content: flex-start; }
}
@media (max-width: 380px) {
  .match .score input { width: 50px; }
  .gol-btn { width: 36px; height: 36px; }
  #envivo .gol-btn { width: 44px; height: 44px; }
}


/* Cliente: equipos y plantel */
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .75rem; white-space: nowrap; }
.jugador-foto { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; background: var(--surface-2); display: inline-grid; place-items: center; font-size: .75rem; color: var(--muted); flex: none; }
tr.inactivo td { opacity: .5; }

/* Planillas: botón de imprimir y fotos de la planilla firmada en Resultados */
.fotos-modal { display: grid; gap: 12px; }
.fotos-modal figure { margin: 0; display: grid; gap: 6px; }
.fotos-modal img { width: 100%; border-radius: 8px; border: 1px solid var(--border); background: #fff; }
.fotos-modal figcaption { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: .8rem; color: var(--muted); }
.planilla-chip { background: none; border: 0; padding: 0; font: inherit; color: var(--ok); cursor: pointer; text-decoration: underline dotted; }

/* Carga desde el QR de la planilla (pensado para celular) */
.cargar { max-width: 560px; }
.cargar-cab { margin-bottom: 16px; }
.cargar-cab h1 { margin-top: 4px; }
.cargar .card + .card { margin-top: 14px; }
.cargar-marcador { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 6px; align-items: stretch; }
.cargar-lado { display: grid; grid-template-rows: 1fr auto; gap: 10px; justify-items: center; text-align: center; min-width: 0; }
.cargar-eq { align-self: start; display: grid; justify-items: center; gap: 6px; font-weight: 700; font-family: var(--font-head); overflow-wrap: anywhere; }
.cargar-eq .crest { width: 44px; height: 44px; }
.cargar-vs { align-self: end; font-size: 1.3rem; color: var(--muted); padding-bottom: 12px; }
.cargar-stepper { display: flex; align-items: center; gap: 4px; }
.cargar-stepper input { width: 54px; height: 52px; text-align: center; font-family: var(--font-head); font-weight: 700; font-size: 1.8rem; padding: 4px; }
.cargar-stepper .gol-btn { width: 36px; height: 40px; font-size: 1.3rem; flex: none; }
.cargar-penales { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 16px; color: var(--muted); font-weight: 600; }
.cargar-penales input { width: 58px; text-align: center; font-weight: 700; font-size: 1.2rem; }
.cargar-aviso { margin: 16px 0 0; padding: 10px 12px; border-radius: 8px; background: rgba(251, 191, 36, .1); border: 1px solid rgba(251, 191, 36, .35); color: var(--warn); font-size: .88rem; }
.cargar-aviso.ok { background: rgba(52, 211, 153, .1); border-color: rgba(52, 211, 153, .4); color: var(--ok); }
.btn-grande { width: 100%; padding: 13px 16px; font-size: 1rem; margin-top: 14px; }
.cargar-botones { display: grid; gap: 0; }
.cargar-botones .btn-grande { margin-top: 10px; }
.cargar-fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.cargar-foto { margin: 0; display: grid; gap: 4px; }
.cargar-foto a { display: grid; place-items: center; aspect-ratio: 3 / 4; border-radius: 8px; overflow: hidden; background: var(--surface-2); border: 1px solid var(--border); }
.cargar-foto img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 400px) {
  .cargar .card { padding: 16px 12px; }
  .cargar-stepper .gol-btn { width: 30px; height: 38px; }
  .cargar-stepper input { width: 46px; font-size: 1.6rem; }
}
.cargar-incidencias { display: grid; gap: 4px; margin-top: 12px; font-size: .85rem; color: var(--muted); }
.cargar-incidencias span:empty { display: none; }
