/* =====================================================================
   Control de Cargas · Luján Rugby Club
   Sistema visual: colores del escudo, Barlow / Barlow Condensed.
   ===================================================================== */

:root {
  /* Colores del escudo */
  --club-navy: #1e2446;
  --club-navy-2: #2b3570;
  --club-blue: #3879af;

  --bg: #f2f4f8;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --surface-3: #e9eef5;
  --text: #121833;
  --muted: #5b6682;
  --subtle: #8a93aa;
  --border: #e2e7ef;
  --border-strong: #cfd7e3;
  --primary: var(--club-navy);
  --primary-text: #ffffff;
  --accent: var(--club-blue);
  --accent-soft: #e4eef8;
  --ok: #16865a;
  --ok-soft: #e3f4ec;
  --warn: #a8670a;
  --warn-soft: #fbf0dc;
  --danger: #c0342b;
  --danger-soft: #fbe6e4;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(18, 24, 51, .04), 0 2px 10px rgba(18, 24, 51, .05);
  --shadow-lg: 0 10px 30px rgba(18, 24, 51, .12);
  --font: "Barlow", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-cond: "Barlow Condensed", "Barlow", system-ui, sans-serif;
  --bar-bg: var(--club-navy);
  --hero: linear-gradient(135deg, #1e2446 0%, #263066 55%, #2f5d93 100%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1020;
    --surface: #141a30;
    --surface-2: #1a2140;
    --surface-3: #222b50;
    --text: #e9edf7;
    --muted: #a3acc4;
    --subtle: #7d87a3;
    --border: #262f55;
    --border-strong: #34406e;
    --primary: #4a8bc6;
    --primary-text: #ffffff;
    --accent: #6aa6dc;
    --accent-soft: #1d2b4d;
    --ok: #3ccf8e;
    --ok-soft: #133528;
    --warn: #f0b84a;
    --warn-soft: #3a2c10;
    --danger: #ff7a6e;
    --danger-soft: #3d1a17;
    --shadow: none;
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, .5);
    --bar-bg: #10162b;
    --hero: linear-gradient(135deg, #161d3c 0%, #1e2a58 55%, #24497a 100%);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.45;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }
.i { flex: none; vertical-align: middle; }
[hidden] { display: none !important; }

.container { max-width: 720px; margin: 0 auto; padding: 18px 16px 24px; }
.container.ancho { max-width: 1080px; }

/* ---------------------------------------------------------------- tipografía */
h1, h2, h3 { font-family: var(--font-cond); letter-spacing: .01em; }
h1 { font-size: 2rem; line-height: 1.05; margin: 6px 0 12px; font-weight: 700; }
h2 { font-size: 1.25rem; margin: 22px 0 10px; font-weight: 700; }
h3 { font-size: 1.12rem; margin: 0 0 2px; font-weight: 600; line-height: 1.2; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.center { text-align: center; }
.pad { padding: 28px 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.eyebrow { font-family: var(--font-cond); font-weight: 600; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }

/* ---------------------------------------------------------------- barra superior */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--bar-bg); color: #fff;
  border-bottom: 3px solid var(--club-blue);
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; max-width: 720px; margin: 0 auto; }
.container.ancho ~ * .brand, .brand.ancho { max-width: 1080px; }
.brand img { height: 34px; width: auto; filter: drop-shadow(0 1px 2px rgba(0,0,0,.3)); }
.brand .t1 { font-family: var(--font-cond); font-weight: 700; font-size: 1.15rem; letter-spacing: .02em; line-height: 1; display: block; }
.brand .t2 { font-size: .72rem; opacity: .75; letter-spacing: .04em; display: block; margin-top: 2px; }

/* ---------------------------------------------------------------- barra inferior */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; justify-content: center;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(12px); -webkit-backdrop-filter: saturate(1.6) blur(12px);
  border-top: 1px solid var(--border);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
}
.tabbar a {
  flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 6px 4px; font-size: .72rem; font-weight: 600; text-decoration: none; color: var(--subtle);
  border-radius: 12px; transition: color .15s, background .15s;
}
.tabbar a .i { width: 22px; height: 22px; }
.tabbar a.active { color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- tarjetas */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 10px; }
a.card { display: block; text-decoration: none; transition: transform .12s, box-shadow .12s, border-color .12s; }
a.card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); }
a.card:active { transform: scale(.99); }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

/* portada del inicio */
.hero {
  position: relative; overflow: hidden; border-radius: 20px; padding: 20px 18px 18px;
  background: var(--hero); color: #fff; box-shadow: var(--shadow-lg); margin-bottom: 14px;
}
.hero::after {
  content: ""; position: absolute; right: -40px; top: -30px; width: 190px; height: 190px;
  background: url("../icons/escudo.png") center / contain no-repeat; opacity: .08; transform: rotate(-12deg);
}
.hero .saludo { font-family: var(--font-cond); font-size: 2.1rem; font-weight: 700; line-height: 1; margin: 2px 0 6px; }
.hero .sub { opacity: .8; font-size: .92rem; }
.hero .ciclo { display: inline-flex; align-items: center; gap: 6px; margin-top: 14px; padding: 6px 12px; border-radius: 999px;
  background: rgba(255,255,255,.14); font-weight: 600; font-size: .85rem; }
.progreso { margin-top: 12px; display: flex; gap: 4px; }
.progreso span { flex: 1; height: 5px; border-radius: 99px; background: rgba(255,255,255,.18); }
.progreso span.hecha { background: rgba(255,255,255,.55); }
.progreso span.hoy { background: #fff; }
.progreso-txt { font-size: .75rem; opacity: .75; margin-top: 6px; }

/* acceso rápido y avisos */
a.card.accion, .card.accion { display: flex; align-items: center; gap: 14px; }
.accion .ic { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); flex: none; }
.accion strong { display: block; font-size: 1rem; }
.accion .der { color: var(--subtle); }
.aviso { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--text); text-decoration: none; font-size: .9rem; margin-bottom: 10px; border: 1px solid transparent; }
.aviso .i { color: var(--accent); margin-top: 1px; }
.aviso.warn { background: var(--warn-soft); }
.aviso.warn .i { color: var(--warn); }
a.aviso:hover { border-color: var(--border-strong); }

/* grupos de rutinas */
details.grupo { margin-top: 18px; }
details.grupo > summary {
  list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px;
  font-family: var(--font-cond); font-weight: 700; font-size: 1.2rem; padding: 6px 2px 10px;
}
details.grupo > summary::-webkit-details-marker { display: none; }
details.grupo > summary .cuenta { font-family: var(--font); font-size: .75rem; font-weight: 600; color: var(--muted); background: var(--surface-3); padding: 2px 8px; border-radius: 99px; }
details.grupo > summary .flecha { margin-left: auto; color: var(--subtle); transition: transform .2s; }
details.grupo[open] > summary .flecha { transform: rotate(90deg); }
details.grupo > summary span:first-child { flex: none; }

a.card.rut, .card.rut { display: flex; align-items: center; gap: 14px; }
.rut .dia { width: 48px; height: 48px; border-radius: 12px; flex: none; display: grid; place-items: center;
  background: var(--primary); color: var(--primary-text); font-family: var(--font-cond); font-weight: 700; font-size: 1.15rem; line-height: 1; }
.rut .dia small { display: block; font-size: .6rem; letter-spacing: .08em; opacity: .7; }
.rut .meta { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.rut .der { color: var(--subtle); }

/* ---------------------------------------------------------------- chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px; font-size: .75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-3); color: var(--muted); border: 1px solid transparent; white-space: nowrap;
}
.chip.accent { color: var(--accent); background: var(--accent-soft); }
.chip.ok { color: var(--ok); background: var(--ok-soft); }
.chip .i { width: 13px; height: 13px; }

/* ---------------------------------------------------------------- formularios */
label { display: block; font-size: .82rem; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%; font: inherit; color: var(--text);
  background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; min-height: 46px; transition: border-color .15s, box-shadow .15s;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.field + .field { margin-top: 14px; }

/* ---------------------------------------------------------------- botones */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
  min-height: 46px; padding: 10px 18px; border-radius: 12px;
  background: var(--surface); color: var(--text); border: 1px solid var(--border-strong);
  transition: background .15s, border-color .15s, transform .08s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .85rem; border-radius: 10px; }
.btn.icono { min-height: 38px; width: 38px; padding: 0; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.btn .i { width: 18px; height: 18px; }
.list-actions { display: flex; gap: 6px; flex: none; }

/* control segmentado */
.tabs { display: flex; gap: 4px; padding: 4px; margin-bottom: 16px; background: var(--surface-3); border-radius: 14px; overflow-x: auto; }
.tabs > * { flex: 1; border: none !important; background: transparent; min-height: 40px; border-radius: 10px; color: var(--muted); white-space: nowrap; }
.tabs > .on, .tabs > .primary { background: var(--surface) !important; color: var(--text) !important; box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- rutina */
.volver { display: inline-flex; align-items: center; gap: 2px; font-size: .9rem; font-weight: 600; color: var(--muted); text-decoration: none; margin-left: -4px; }
.volver:hover { color: var(--text); }
.cabecera-rutina .chips { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -4px; }
h2.seccion {
  font-size: .82rem; text-transform: uppercase; letter-spacing: .12em; color: var(--accent);
  margin: 26px 0 10px; display: flex; align-items: center; gap: 10px;
}
h2.seccion::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.ej-head { display: flex; gap: 12px; align-items: flex-start; }
.ej-bloque {
  flex: none; min-width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px;
  background: var(--primary); color: var(--primary-text); font-family: var(--font-cond); font-weight: 700; font-size: 1rem;
}
.prescr { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: .85rem; }
.prescr .target { font-weight: 700; font-family: var(--font-cond); font-size: 1.05rem; letter-spacing: .02em; }
.target { font-weight: 600; }
.last { font-size: .82rem; color: var(--muted); margin-top: 10px; display: flex; gap: 6px; align-items: center; }
.last .i { width: 15px; height: 15px; }
.card.compact { padding: 12px 14px; }
.card.compact + .card.compact { margin-top: 8px; }
.card.compact h3 { font-size: 1.02rem; }

.sets { margin-top: 12px; display: grid; gap: 6px; }
.sets-head, .set { display: grid; grid-template-columns: 30px 1fr 1fr 46px; gap: 8px; align-items: center; }
.sets-head { font-size: .72rem; font-weight: 600; color: var(--subtle); text-transform: uppercase; letter-spacing: .06em; text-align: center; }
.set .n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-3); color: var(--muted); font-size: .8rem; font-weight: 700; justify-self: center; }
.set input { text-align: center; padding: 8px 4px; font-weight: 600; font-size: 1.05rem; background: var(--surface-2); }
.set .btn { padding: 0; min-height: 46px; }
.set.done .n { background: var(--ok); color: #fff; }
.set.done input { border-color: color-mix(in srgb, var(--ok) 55%, transparent); background: var(--ok-soft); }
.set.done .btn { background: var(--ok); color: #fff; border-color: var(--ok); }

/* ---------------------------------------------------------------- tablas */
table { width: 100%; border-collapse: collapse; font-size: .92rem; }
th, td { text-align: left; padding: 10px 6px; border-bottom: 1px solid var(--border); }
tr:last-child td { border-bottom: none; }
th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }

/* ---------------------------------------------------------------- gráficos */
.chart { width: 100%; height: auto; display: block; }
.chart .line { fill: none; stroke: var(--accent); stroke-width: 4; stroke-linejoin: round; }
.chart .dot { fill: var(--surface); stroke: var(--accent); stroke-width: 3; }
.chart .grid { stroke: var(--border); stroke-width: 2; }
.chart text { fill: var(--subtle); font-size: 22px; font-family: var(--font); }
.chart .bar { fill: var(--accent); opacity: .35; }
.chart .bar.actual { opacity: 1; }
.chart.barras { max-width: 640px; margin: 0 auto; }

/* ---------------------------------------------------------------- métricas */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.stat b { display: block; font-family: var(--font-cond); font-size: 2.1rem; line-height: 1; color: var(--text); font-weight: 700; }
.stat b small { font-size: 1rem; color: var(--muted); font-weight: 600; }
.stat span { display: block; margin-top: 6px; font-size: .8rem; color: var(--muted); line-height: 1.3; }
.card-titulo { display: flex; align-items: center; gap: 8px; font-family: var(--font-cond); font-weight: 700; font-size: 1.1rem; margin-bottom: 6px; }
.card-titulo .i { color: var(--accent); }
.barrita { height: 8px; background: var(--surface-3); border-radius: 99px; overflow: hidden; }
.barrita span { display: block; height: 100%; background: var(--accent); border-radius: 99px; }
.m-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 10px; }
.m-cols .card + .card { margin-top: 0; }
.m-cols + .card, .card + .m-cols { margin-top: 10px; }

/* ---------------------------------------------------------------- perfil */
.perfil-head { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: var(--hero); color: #fff; font-family: var(--font-cond); font-weight: 700; font-size: 1.6rem; box-shadow: var(--shadow-lg); }
.perfil-head h1 { margin: 0; font-size: 1.7rem; }
.dato { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.dato:last-child { border-bottom: none; }
.dato span:first-child { color: var(--muted); }

/* ---------------------------------------------------------------- modal y aviso flotante */
.modal { border: none; border-radius: 20px; padding: 16px; width: min(680px, calc(100vw - 24px)); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.modal::backdrop { background: rgba(8, 12, 28, .6); backdrop-filter: blur(2px); }
.modal-body { margin-bottom: 12px; }
.modal-body h3 { font-size: 1.3rem; margin-bottom: 10px; }
.video { position: relative; width: 100%; aspect-ratio: 16 / 9; border-radius: 12px; overflow: hidden; background: #000; }
.video iframe, .video video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.ej-img { display: block; width: 100%; height: auto; border-radius: 12px; margin: 6px 0 12px; background: #fff; }

.toast {
  position: fixed; left: 50%; bottom: calc(92px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(16px);
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 999px; font-size: .9rem; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100vw - 32px); box-shadow: var(--shadow-lg); z-index: 50;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--danger); color: #fff; }

/* ---------------------------------------------------------------- ingreso */
body.sin-sesion { background: var(--bg); padding-bottom: 0; }
body.sin-sesion::before { content: ""; position: fixed; inset: 0 0 auto 0; height: 300px; background: var(--hero); z-index: -1; }
.auth { max-width: 420px; margin: 8px auto 24px; }
.auth .marca { text-align: center; color: #fff; margin: 10px 0 18px; }
.auth .logo { display: block; margin: 0 auto 10px; height: 104px; width: auto; filter: drop-shadow(0 6px 16px rgba(0,0,0,.35)); }
.auth .marca h1 { margin: 0; font-size: 1.9rem; color: #fff; }
.auth .marca p { margin: 4px 0 0; opacity: .8; font-size: .92rem; }
.auth .card { padding: 20px; box-shadow: var(--shadow-lg); }
.auth .tabs { margin-bottom: 14px; }
.auth .link { display: block; text-align: center; font-size: .88rem; color: var(--accent); font-weight: 600; text-decoration: none; margin-top: 14px; }
.auth h2.t { margin: 0 0 4px; font-size: 1.5rem; }

/* ---------------------------------------------------------------- puestos */
.puestos { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.puestos .btn { min-height: 56px; font-size: 1rem; justify-content: flex-start; padding-left: 16px; }
.puestos .btn.on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }

/* ---------------------------------------------------------------- subir planilla */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer;
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 30px 16px; margin: 14px 0; background: var(--surface-2); color: var(--text);
  transition: border-color .15s, background .15s;
}
.drop .i { color: var(--accent); width: 34px; height: 34px; }
.drop:hover, .drop.over { border-color: var(--accent); background: var(--accent-soft); }

/* ---------------------------------------------------------------- calendario y planificación */
.ciclo-fila { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.ciclo-fila input[type=date] { width: 168px; }
.chips-sel { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-sel .btn { min-width: 44px; }
.chips-sel .btn.on { background: var(--primary); color: var(--primary-text); border-color: var(--primary); }
.chips-sel .btn.vacia { border-style: dashed; color: var(--subtle); }
.prow { display: grid; grid-template-columns: 76px minmax(170px, 1fr) 56px 76px 84px 64px 44px 124px; gap: 6px; align-items: center; margin-top: 6px; }
.prow input { min-height: 40px; padding: 6px 8px; font-size: .9rem; }
.prow.phead { font-size: .72rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--subtle); margin-top: 12px; }
.p-carga { display: flex; align-items: center; gap: 4px; margin: 0; font-size: .8rem; color: var(--muted); }
.p-carga input { width: auto; min-height: 0; }
.p-acc { display: flex; gap: 4px; }
@media (max-width: 760px) {
  .prow { grid-template-columns: 64px 1fr 1fr 1fr; padding: 10px 0; border-top: 1px solid var(--border); }
  .prow .p-ej { grid-column: 2 / -1; }
  .prow .p-carga { grid-column: 1; }
  .prow .p-acc { grid-column: 2 / -1; justify-content: flex-end; }
  .prow.phead { display: none; }
}

/* ---------------------------------------------------------------- pantallas grandes */
@media (min-width: 900px) {
  h1 { font-size: 2.3rem; }
  .hero { padding: 26px 24px 22px; }
}

.nw { white-space: nowrap; }
