/* =============================================================================
 * styles.css — Estilos comunes extraídos del Prototipo_UX_v2 (aprobado).
 * Mobile-first, paleta navy/verde/rojo/ámbar, targets táctiles ≥52px.
 * ===========================================================================*/
:root {
  --navy: #1F3A5F; --navy-d: #16293F; --navy-soft: #2C4F7C;
  --green: #2E7D4F; --green-bg: #E6F2EB;
  --red: #B23A48; --red-bg: #F7E7E9;
  --amber: #C98A1B; --amber-bg: #FBF1DD;
  --ink: #1E293B; --muted: #64748B; --faint: #94A3B8;
  --line: #E5EAF1; --card: #FFFFFF; --app-bg: #EEF2F7;
  --page-bg: #DCE3EC;
  --pill: #EAF0F7;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(16, 32, 55, .06), 0 8px 24px rgba(16, 32, 55, .08);
  --nav-h: 72px;
  --app-max: 440px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--page-bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Contenedor de app: columna estilo teléfono, centrada en desktop ----------- */
.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--app-max);
  min-height: 100vh;
  margin: 0 auto;
  background: var(--app-bg);
  box-shadow: 0 0 40px rgba(16, 32, 55, .10);
}

/* ---------- App header ---------- */
.appbar {
  background: var(--navy); color: #fff;
  padding: max(18px, env(safe-area-inset-top)) 18px 14px;
  display: flex; align-items: center; gap: 11px; flex-shrink: 0;
  position: sticky; top: 0; z-index: 20;
}
.crest {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, #3a6098, #1F3A5F);
  display: grid; place-items: center; font-weight: 800; font-size: 13px;
  color: #cfe0f5; border: 1px solid rgba(255, 255, 255, .18); flex-shrink: 0;
}
.appbar .t { line-height: 1.15; }
.appbar .t b { font-size: 15px; font-weight: 700; letter-spacing: .01em; display: block; }
.appbar .t span { font-size: 11px; color: #aac4e2; }
.conn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 600; color: #cfe9d8;
  background: rgba(46, 125, 79, .22); padding: 5px 9px; border-radius: 999px; white-space: nowrap;
}
.conn .dot { width: 8px; height: 8px; border-radius: 50%; background: #5fd08a; box-shadow: 0 0 0 3px rgba(95, 208, 138, .18); }
.conn.off { color: #f0c9cd; background: rgba(178, 58, 72, .22); }
.conn.off .dot { background: #e88; box-shadow: 0 0 0 3px rgba(232, 136, 136, .18); }
.gear { margin-left: 8px; cursor: pointer; color: #aac4e2; display: grid; place-items: center; }
.gear:hover { color: #fff; }

/* ---------- Cuerpo scrolleable ---------- */
.body { flex: 1; padding: 14px 14px calc(var(--nav-h) + 18px); }

/* ---------- Bottom nav ---------- */
.nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: var(--app-max); height: var(--nav-h);
  background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: 6px; z-index: 30;
}
.nav a {
  background: none; border: none; cursor: pointer; text-decoration: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 3px; color: var(--faint); font-size: 11px; font-weight: 600;
}
.nav a svg { width: 25px; height: 25px; }
.nav a.on { color: var(--navy); }
.nav a.on .ico { background: var(--pill); }
.nav .ico { width: 46px; height: 30px; border-radius: 10px; display: grid; place-items: center; transition: .14s; }

/* ---------- UI compartida ---------- */
.pills { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; margin-bottom: 4px; }
.pills::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0; padding: 10px 15px; border-radius: 999px; background: var(--pill);
  color: var(--navy-soft); font-size: 13px; font-weight: 600; border: 1px solid transparent;
  cursor: pointer; white-space: nowrap; min-height: 38px;
}
.pill.on { background: var(--navy); color: #fff; }

.section-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); font-weight: 700; margin: 14px 4px 8px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(16, 32, 55, .05); }

.summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 9px 6px; text-align: center; }
.stat b { display: block; font-size: 19px; font-weight: 800; line-height: 1; }
.stat span { font-size: 10.5px; color: var(--muted); font-weight: 600; }
.stat.g b { color: var(--green); } .stat.r b { color: var(--red); } .stat.a b { color: var(--amber); } .stat.m b { color: var(--faint); }

.session-banner { background: linear-gradient(135deg, #22456e, #1F3A5F); color: #fff; border-radius: 14px; padding: 13px 15px; margin-bottom: 12px; display: flex; align-items: center; gap: 12px; }
.session-banner .sb-ico { width: 38px; height: 38px; border-radius: 10px; background: rgba(255, 255, 255, .12); display: grid; place-items: center; flex-shrink: 0; }
.session-banner b { font-size: 14px; } .session-banner span { font-size: 12px; color: #bcd2ec; display: block; margin-top: 1px; }
.session-banner .edit { margin-left: auto; font-size: 11px; color: #fff; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .25); padding: 7px 11px; border-radius: 8px; cursor: pointer; }

/* Filas de jugadores */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 11px 13px; cursor: pointer; transition: .12s; min-height: 60px; }
.row:active { transform: scale(.99); }
.row:hover { border-color: #cdd8e6; }
.ava { width: 40px; height: 40px; border-radius: 11px; background: var(--pill); color: var(--navy); font-weight: 800; font-size: 14px; display: grid; place-items: center; flex-shrink: 0; }
.row .who { min-width: 0; }
.row .who b { font-size: 14.5px; font-weight: 700; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who span { font-size: 12px; color: var(--muted); }
.chip { margin-left: auto; font-size: 11.5px; font-weight: 700; padding: 8px 12px; border-radius: 999px; white-space: nowrap; }
.chip.pres { background: var(--green-bg); color: var(--green); }
.chip.aus { background: var(--red-bg); color: var(--red); }
.chip.just { background: var(--amber-bg); color: var(--amber); }
.chip.none { background: #EEF1F5; color: var(--faint); }
.pencil { margin-left: auto; color: var(--faint); display: grid; place-items: center; width: 38px; height: 38px; border-radius: 8px; cursor: pointer; flex-shrink: 0; }
.row:hover .pencil { color: var(--navy); }

/* Botones */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 52px; border-radius: 13px; border: none; cursor: pointer; font-size: 15px; font-weight: 700; text-decoration: none; }
.btn svg { flex-shrink: 0; }
.btn.primary { background: var(--navy); color: #fff; }
.btn.ghost { background: #fff; border: 1px solid var(--line); color: var(--navy); }
.btn.green { background: var(--green); color: #fff; }
.btn.danger { background: var(--red); color: #fff; }
.btn:disabled { opacity: .55; cursor: default; }
.btn-row { display: flex; gap: 10px; margin-top: 12px; }
.btn-row .btn { flex: 1; }
.btn-sm { height: 46px; font-size: 14px; }

.search { display: flex; align-items: center; gap: 9px; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 0 13px; height: 48px; margin-bottom: 10px; color: var(--faint); }
.search input { border: none; outline: none; flex: 1; font-size: 14px; color: var(--ink); background: none; height: 100%; }

/* ---------- Ficha de jugador ---------- */
.back { display: inline-flex; align-items: center; gap: 7px; color: var(--navy); font-weight: 700; font-size: 14px; cursor: pointer; margin-bottom: 6px; background: none; border: none; text-decoration: none; }
.pHero { background: linear-gradient(135deg, #22456e, #1F3A5F); border-radius: 16px; padding: 18px; color: #fff; display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.pHero .big { width: 58px; height: 58px; border-radius: 15px; background: rgba(255, 255, 255, .14); display: grid; place-items: center; font-size: 22px; font-weight: 800; color: #dff; flex-shrink: 0; }
.pHero h2 { font-size: 19px; font-weight: 800; }
.pHero .meta { font-size: 12.5px; color: #bcd2ec; margin-top: 3px; }
.pHero .num { margin-left: auto; text-align: center; }
.pHero .num b { font-size: 30px; font-weight: 800; display: block; line-height: 1; }
.pHero .num span { font-size: 10px; color: #bcd2ec; }
.badge-act { display: inline-block; font-size: 10.5px; font-weight: 700; color: var(--green); background: #dff0e6; padding: 2px 8px; border-radius: 999px; margin-top: 6px; }
.badge-act.off { color: var(--muted); background: #EEF1F5; }

.kv { padding: 6px 0; }
.kv-row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.kv-row:last-child { border-bottom: none; }
.kv-row span { color: var(--muted); } .kv-row b { font-weight: 600; text-align: right; }

.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.metric { background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; }
.metric .lab { font-size: 11px; color: var(--muted); font-weight: 600; }
.metric .val { font-size: 23px; font-weight: 800; color: var(--navy); margin-top: 3px; }
.metric .val small { font-size: 13px; color: var(--faint); font-weight: 700; }
.bar { height: 7px; border-radius: 99px; background: #EEF1F5; margin-top: 8px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--green); }
.metric.cmp .val { color: var(--green); }
.metric.cmp .val.neg { color: var(--red); }
.vs { font-size: 11px; color: var(--muted); margin-top: 6px; }

.log { display: flex; flex-direction: column; }
.log-item { padding: 12px 14px; border-bottom: 1px solid var(--line); }
.log-item:last-child { border-bottom: none; }
.log-meta { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; }
.log-meta .au { font-size: 12.5px; font-weight: 700; color: var(--navy); }
.log-meta .dt { font-size: 11px; color: var(--faint); margin-left: auto; }
.log-item p { font-size: 13.5px; color: var(--ink); line-height: 1.45; }
.add-note { display: flex; align-items: center; gap: 9px; padding: 14px; color: var(--navy); font-weight: 700; font-size: 13.5px; cursor: pointer; border-top: 1px dashed var(--line); }

/* ---------- Sesiones ---------- */
.ses { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; margin-bottom: 9px; }
.ses .date { width: 46px; text-align: center; flex-shrink: 0; }
.ses .date b { font-size: 18px; font-weight: 800; display: block; color: var(--navy); line-height: 1; }
.ses .date span { font-size: 10px; color: var(--muted); text-transform: uppercase; font-weight: 700; }
.ses .si { min-width: 0; flex: 1; }
.ses .si b { font-size: 14px; display: block; }
.ses .si span { font-size: 12px; color: var(--muted); }
.type { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-left: auto; white-space: nowrap; align-self: flex-start; }
.type.ent { background: var(--green-bg); color: var(--green); }
.type.par { background: #E4ECF7; color: var(--navy-soft); }
.type.reu { background: var(--amber-bg); color: var(--amber); }
.type.otr { background: #EEF1F5; color: var(--faint); }
.ses-att { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ---------- Reportes / dashboard ---------- */
.toggle { display: flex; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 4px; margin-bottom: 12px; }
.toggle button { flex: 1; border: none; background: none; cursor: pointer; padding: 11px; border-radius: 9px; font-size: 13.5px; font-weight: 700; color: var(--muted); }
.toggle button.on { background: var(--navy); color: #fff; }
.rep-row { display: flex; align-items: center; gap: 11px; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 11px 13px; margin-bottom: 8px; }
.rep-row .ava { width: 34px; height: 34px; font-size: 12px; }
.rep-row .who { flex: 1; min-width: 0; }
.rep-row .who b { font-size: 14px; display: block; } .rep-row .who span { font-size: 11.5px; color: var(--muted); }
.rep-bar { flex: 1; height: 8px; border-radius: 99px; background: #EEF1F5; overflow: hidden; max-width: 90px; margin-left: auto; }
.rep-bar i { display: block; height: 100%; }
.pct { font-size: 14px; font-weight: 800; width: 42px; text-align: right; }
.hero-pct { background: linear-gradient(135deg, #22456e, #1F3A5F); border-radius: 16px; padding: 18px; color: #fff; margin-bottom: 12px; }
.hero-pct .big { font-size: 44px; font-weight: 800; line-height: 1; }
.hero-pct .lab { font-size: 12.5px; color: #bcd2ec; margin-top: 2px; }
.evo { display: flex; align-items: flex-end; gap: 9px; height: 74px; margin-top: 14px; padding: 0 2px; }
.evo .b { flex: 1; background: rgba(255, 255, 255, .85); border-radius: 5px 5px 0 0; position: relative; min-height: 2px; }
.evo .b span { position: absolute; bottom: -17px; left: 0; right: 0; text-align: center; font-size: 9.5px; color: #bcd2ec; }
.evo-wrap { padding-bottom: 18px; }
.thr { display: flex; gap: 9px; margin-bottom: 12px; }
.thr .c { flex: 1; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 13px; text-align: center; }
.thr .c b { font-size: 26px; font-weight: 800; display: block; }
.thr .c.over b { color: var(--green); } .thr .c.under b { color: var(--red); }
.thr .c span { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ---------- Usuarios ---------- */
.urow { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: 13px; padding: 12px 13px; margin-bottom: 8px; }
.urow .who { flex: 1; min-width: 0; }
.urow .who b { font-size: 14.5px; font-weight: 700; display: block; }
.urow .who span { font-size: 11.5px; color: var(--muted); }
.role { font-size: 10.5px; font-weight: 700; padding: 3px 9px; border-radius: 999px; margin-left: auto; white-space: nowrap; }
.role.admin { background: #E4ECF7; color: var(--navy-soft); }
.role.dt { background: var(--green-bg); color: var(--green); }

/* Alta y borrado de categorías */
.cat-add { display: flex; gap: 10px; align-items: stretch; margin-bottom: 12px; }
.cat-add .btn { width: auto; padding: 0 18px; white-space: nowrap; }
.cat-del { margin-left: auto; flex-shrink: 0; background: var(--red-bg); color: var(--red); border: none; width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; cursor: pointer; }
.cat-del:hover { background: var(--red); color: #fff; }

/* ---------- Login ---------- */
.login {
  min-height: 100vh; background: linear-gradient(160deg, #1F3A5F 0%, #16293F 100%);
  display: flex; flex-direction: column; justify-content: center; padding: 30px 26px; color: #fff;
}
.login-inner { width: 100%; max-width: 360px; margin: 0 auto; }
.login .crest-l { width: 74px; height: 74px; border-radius: 20px; background: rgba(255, 255, 255, .1); border: 1px solid rgba(255, 255, 255, .2); display: grid; place-items: center; font-size: 26px; font-weight: 800; color: #cfe0f5; margin: 0 auto 18px; }
.login h2 { text-align: center; font-size: 21px; font-weight: 800; }
.login .sub { text-align: center; font-size: 13px; color: #aac4e2; margin: 6px 0 26px; }
.field { margin-bottom: 13px; }
.field label { font-size: 12px; color: #aac4e2; font-weight: 600; display: block; margin-bottom: 6px; }
.field input { width: 100%; height: 52px; border-radius: 13px; border: 1px solid rgba(255, 255, 255, .18); background: rgba(255, 255, 255, .08); color: #fff; padding: 0 14px; font-size: 15px; outline: none; }
.field input::placeholder { color: #7f9bbd; }
.field input:focus { border-color: rgba(255, 255, 255, .45); }
.login .btn.green { margin-top: 10px; }
.login .help { text-align: center; font-size: 11.5px; color: #7f9bbd; margin-top: 18px; line-height: 1.5; }
.login .err { background: rgba(178, 58, 72, .25); border: 1px solid rgba(178, 58, 72, .5); color: #ffd7dc; font-size: 13px; padding: 10px 12px; border-radius: 11px; margin-bottom: 14px; text-align: center; display: none; }
.login .err.show { display: block; }

/* ---------- Estado vacío ---------- */
.empty { text-align: center; color: var(--faint); padding: 40px 20px; }
.empty svg { width: 38px; height: 38px; opacity: .5; margin: 0 auto 10px; display: block; }
.empty p { font-size: 13.5px; line-height: 1.5; max-width: 280px; margin: 0 auto; }

/* ---------- Skeleton / loading ---------- */
.loading { text-align: center; color: var(--faint); font-size: 13px; padding: 30px; }
.banner-info { background: var(--amber-bg); border: 1px solid #f0dca8; color: #8a5d10; font-size: 12.5px; padding: 11px 13px; border-radius: 12px; margin-bottom: 12px; line-height: 1.5; }

/* ---------- Form labels (modal / formularios) ---------- */
.field-l { margin-bottom: 12px; }
.field-l label { font-size: 12px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 5px; }
.field-l input, .field-l select, .field-l textarea {
  width: 100%; min-height: 48px; border-radius: 11px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); padding: 12px 13px; font-size: 14.5px; outline: none; font-family: inherit;
}
.field-l textarea { min-height: 96px; resize: vertical; }
.field-l input:focus, .field-l select:focus, .field-l textarea:focus { border-color: var(--navy-soft); }

/* ---------- Modal ---------- */
.modal-overlay { position: fixed; inset: 0; background: rgba(16, 32, 55, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 100; padding: 0; }
.modal { background: #fff; width: 100%; max-width: var(--app-max); border-radius: 20px 20px 0 0; padding: 18px 18px max(18px, env(safe-area-inset-bottom)); max-height: 90vh; overflow-y: auto; box-shadow: 0 -8px 40px rgba(16, 32, 55, .25); }
.modal-head { display: flex; align-items: center; margin-bottom: 16px; }
.modal-head b { font-size: 17px; font-weight: 800; color: var(--navy); }
.modal-x { margin-left: auto; background: var(--pill); border: none; width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; cursor: pointer; color: var(--muted); }
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
  .modal { border-radius: 20px; }
}

/* ---------- Selector de días (generar sesiones) ---------- */
/* Grilla 4+3: cuatro días en la primera fila, tres en la segunda. */
.day-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.day-chip {
  display: flex; align-items: center; justify-content: center; gap: 5px;
  min-height: 48px; padding: 8px 10px; border-radius: 11px;
  background: #fff; color: var(--ink); border: 1px solid var(--line);
  font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; text-align: center;
}
.day-chip:hover { border-color: #cdd8e6; }
.day-chip.on {
  background: var(--navy); color: #fff; border-color: var(--navy);
}
.day-chip.on::before { content: "✓"; font-weight: 800; }

/* ---------- Checkbox de confirmación (acciones destructivas) ---------- */
.confirm-check {
  display: flex; align-items: center; gap: 10px; min-height: 48px;
  padding: 6px 2px; cursor: pointer; user-select: none;
  font-size: 14px; color: var(--ink); font-weight: 600;
}
.confirm-check input { width: 22px; height: 22px; accent-color: var(--red); cursor: pointer; flex-shrink: 0; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: calc(var(--nav-h) + 16px); left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 13.5px; font-weight: 600;
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: .22s; z-index: 200; max-width: 90%; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: var(--red); }
.toast.success { background: var(--green); }

/* ---------- Header de sección con acción ---------- */
.sec-head { display: flex; align-items: center; justify-content: space-between; margin: 14px 4px 8px; }
.sec-head .section-title { margin: 0; }
.admin-tag { display: inline-flex; align-items: center; gap: 8px; color: var(--amber); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; font-weight: 700; margin: 4px 4px 10px; }
