/* Identidad Barceló Rugby: azul marino del escudo + rosa de los arcos */
:root {
  --marca: #293263;        /* azul del escudo */
  --marca-osc: #1d2450;    /* barra superior */
  --marca-claro: #e8eaf4;  /* fondo de chips y estados activos */
  --acento: #9e4a72;       /* rosa del escudo, ajustado para leerse en blanco */
  --acento-claro: #f7e8ef;
  --sobre-marca: #ffffff;  /* texto sobre el color de marca */
  --bg: #f3f4f8;
  --card: #ffffff;
  --txt: #16192b;
  --txt-2: #6b7185;
  --line: #e1e3ec;
  --rojo: #c0392b;
  --ambar: #b7791f;
  --radio: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --marca: #8b96d8;
    --marca-osc: #141834;
    --marca-claro: #232946;
    --acento: #d98cb0;
    --acento-claro: #3a2436;
    --sobre-marca: #141834;
    --bg: #0f1120;
    --card: #191d33;
    --txt: #e9eaf2;
    --txt-2: #969cb4;
    --line: #2a2f4a;
    --rojo: #e5705f;
    --ambar: #d6a13c;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--txt);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }

/* ------------------------------------------------------------- estructura */

.app { min-height: 100dvh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--marca-osc);
  color: #fff;
  padding: calc(var(--safe-t) + 10px) 12px 10px;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 1px 0 rgba(0,0,0,.15);
}
.topbar h1 { font-size: 17px; margin: 0; font-weight: 650; line-height: 1.2; flex: 1; min-width: 0; }
.topbar .sub { display: block; font-size: 12px; font-weight: 400; opacity: .75; margin-top: 2px; }
.topbar button {
  background: rgba(255,255,255,.14); color: #fff; border: 0;
  min-width: 40px; height: 40px; border-radius: 12px; font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; padding: 0 10px;
}
.topbar button:active { background: rgba(255,255,255,.28); }

main { flex: 1; padding: 12px 12px 100px; max-width: 720px; width: 100%; margin: 0 auto; }

.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: var(--card); border-top: 1px solid var(--line);
  display: flex; padding-bottom: var(--safe-b);
}
.nav a {
  flex: 1; text-align: center; padding: 9px 4px 8px; text-decoration: none;
  color: var(--txt-2); font-size: 11px; display: flex; flex-direction: column; gap: 3px; align-items: center;
}
.nav a.on { color: var(--marca); font-weight: 600; }
.nav svg { width: 23px; height: 23px; }

/* ---------------------------------------------------------------- piezas */

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radio); padding: 14px; margin-bottom: 10px;
}
.card.tap { cursor: pointer; }
.card.tap:active { background: var(--marca-claro); }

.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.muted { color: var(--txt-2); font-size: 13px; }
.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sec-title { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--txt-2); margin: 18px 4px 8px; font-weight: 700; }
.empty { text-align: center; color: var(--txt-2); padding: 40px 20px; }

.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 52px; border: 0; border-radius: var(--radio);
  background: var(--marca); color: var(--sobre-marca); font-weight: 650; font-size: 16px; cursor: pointer;
}
.btn:active { filter: brightness(.9); }
.btn.sec { background: var(--card); color: var(--txt); border: 1px solid var(--line); }
.btn.dan { background: transparent; color: var(--rojo); border: 1px solid var(--line); }
.btn.sm { min-height: 42px; font-size: 14px; width: auto; padding: 0 14px; }
.btn:disabled { opacity: .5; }

.fab {
  position: fixed; right: 16px; bottom: calc(72px + var(--safe-b)); z-index: 25;
  width: 58px; height: 58px; border-radius: 50%; border: 0; background: var(--marca);
  color: var(--sobre-marca); font-size: 30px; line-height: 1; box-shadow: 0 6px 18px rgba(0,0,0,.25); cursor: pointer;
}

.chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px;
  border-radius: 999px; font-size: 12px; font-weight: 650;
  background: var(--marca-claro); color: var(--marca);
}
.chip.b { background: var(--acento-claro); color: var(--acento); }

label { display: block; font-size: 13px; font-weight: 600; color: var(--txt-2); margin: 12px 0 5px; }
input, select, textarea {
  width: 100%; padding: 13px 12px; border: 1px solid var(--line);
  border-radius: 11px; background: var(--card); outline: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--marca); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.search {
  position: relative;
}
.search input { padding-left: 38px; font-size: 16px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; opacity: .45; }

/* -------------------------------------------------------------- plantel */

.slot {
  display: flex; align-items: center; gap: 11px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 9px 11px; margin-bottom: 6px;
  min-height: 56px; cursor: pointer; width: 100%; text-align: left;
}
.slot:active { background: var(--marca-claro); }
.slot.vacio { border-style: dashed; background: transparent; }
.num {
  flex: 0 0 34px; height: 34px; border-radius: 10px;
  background: var(--marca); color: var(--sobre-marca); font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.slot.vacio .num { background: var(--line); color: var(--txt-2); }
.slot .nom { font-weight: 600; }
.slot .pos {
  display: block; font-size: 11px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--acento);
}
.slot.vacio .pos { color: var(--txt-2); }
.slot .x { flex: 0 0 auto; color: var(--txt-2); background: transparent; border: 0; font-size: 20px; padding: 8px; cursor: pointer; }

.progreso { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }

/* ---------------------------------------------------------------- sheet */

.backdrop {
  /* --vh/--vtop son el alto y el offset reales del área visible
     (los calcula app.js con visualViewport). Anclamos ahí en vez
     de restar el teclado con "bottom", así el panel siempre ocupa
     el alto visible completo y queda arriba del teclado, la
     primera vez y también al reabrir el buscador. */
  position: fixed; left: 0; right: 0;
  top: var(--vtop, 0px); height: var(--vh, 100dvh);
  background: rgba(0,0,0,.45); z-index: 40;
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .15s ease;
}
@keyframes fade { from { opacity: 0 } }
.sheet {
  background: var(--bg); width: 100%; max-width: 720px;
  border-radius: 18px 18px 0 0; max-height: 100%;
  display: flex; flex-direction: column; animation: up .2s ease;
  padding-bottom: var(--safe-b);
}
/* Panel de búsqueda: ocupa todo el alto visible para que la lista tenga aire */
.sheet.alta { height: 100%; }
/* min-height:0 evita que el item de flex se estire de más por su
   propio contenido (bug clásico de Chrome/Android con listas cortas
   dentro de un flex-column) y garantice que .body siempre ocupe el
   espacio restante, tenga 0 o 50 resultados. */
.sheet.alta .body { flex: 1; min-height: 0; }
@keyframes up { from { transform: translateY(30px) } }
.sheet header {
  padding: 12px 14px 10px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; background: var(--card);
  border-radius: 18px 18px 0 0;
}
.sheet header h2 { font-size: 16px; margin: 0; flex: 1; }
.sheet header button { background: transparent; border: 0; font-size: 22px; color: var(--txt-2); padding: 4px 8px; cursor: pointer; }
.sheet .body { overflow-y: auto; padding: 12px 14px calc(16px + var(--safe-b)); -webkit-overflow-scrolling: touch; }
.sheet .sticky { padding: 10px 14px; background: var(--card); border-bottom: 1px solid var(--line); }

.plist { list-style: none; margin: 8px 0 0; padding: 0; }
.plist li {
  display: flex; align-items: center; gap: 10px; padding: 12px 10px;
  border-bottom: 1px solid var(--line); cursor: pointer; min-height: 56px;
}
.plist li:active { background: var(--marca-claro); }
.plist li.usado { opacity: .55; }
.plist .ini {
  flex: 0 0 38px; height: 38px; border-radius: 50%; background: var(--marca-claro);
  color: var(--marca); font-weight: 700; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}

.toast {
  position: fixed; left: 50%; bottom: calc(88px + var(--safe-b) + var(--kb, 0px)); transform: translateX(-50%);
  background: #111; color: #fff; padding: 11px 18px; border-radius: 999px;
  font-size: 14px; z-index: 60; max-width: 90vw; text-align: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.3);
}
.toast.err { background: var(--rojo); }

.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-box { width: 100%; max-width: 380px; }
.login-box .logo { text-align: center; margin-bottom: 24px; }
.login-box .logo img {
  width: 132px; height: 132px; display: block; margin: 0 auto;
  background: #fff; border-radius: 50%; padding: 8px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
}
.login-box h1 { text-align: center; font-size: 21px; margin: 16px 0 0; }
.login-box .claim { text-align: center; color: var(--txt-2); font-size: 14px; margin-top: 4px; }

/* logo chico en la barra superior */
.topbar .marca { flex: 0 0 32px; width: 32px; height: 32px; border-radius: 50%; background: #fff; padding: 2px; }

.export-box {
  white-space: pre-wrap; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px; max-height: 44dvh; overflow-y: auto;
}

/* ----------------------------------------------------------- en vivo */

.marcador {
  display: flex; align-items: stretch; gap: 8px;
  background: var(--marca-osc); color: #fff;
  border-radius: var(--radio); padding: 14px 12px; margin-bottom: 10px;
}
.marcador .lado { flex: 1; min-width: 0; text-align: center; }
.marcador .eq {
  display: block; font-size: 12px; font-weight: 650; opacity: .8;
  text-transform: uppercase; letter-spacing: .04em;
}
.marcador .pts { display: block; font-size: 40px; font-weight: 750; line-height: 1.1; }
.marcador .sep { align-self: center; font-size: 26px; opacity: .5; }

.reloj-card { text-align: center; }
.reloj {
  font-size: 52px; font-weight: 700; letter-spacing: .02em;
  font-variant-numeric: tabular-nums; margin: 6px 0 12px; color: var(--txt-2);
}
.reloj.on { color: var(--txt); }

.segmento {
  display: flex; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 3px; gap: 3px;
}
.segmento button {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--txt-2);
  padding: 10px 6px; border-radius: 9px; font-weight: 650; font-size: 14px; cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.segmento button.on { background: var(--marca); color: var(--sobre-marca); }

.grid-puntos { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.btn.punto {
  flex-direction: column; gap: 2px; min-height: 62px; font-size: 15px;
}
.btn.punto small { font-size: 11px; font-weight: 600; opacity: .75; }
.btn.punto.tarjeta { background: var(--card); color: var(--txt); border: 1px solid var(--line); }

.tarj { flex: 0 0 16px; width: 16px; height: 22px; border-radius: 3px; }
.tarj.amarilla { background: #e8b93a; }
.tarj.roja { background: #d0453a; }
.cuenta {
  flex: 0 0 auto; font-variant-numeric: tabular-nums; font-weight: 700;
  color: var(--acento); font-size: 15px;
}
.cuenta.ok { color: var(--txt-2); font-weight: 600; font-size: 13px; }

.evento .min {
  flex: 0 0 40px; text-align: center; font-weight: 700; font-size: 14px;
  color: var(--marca); font-variant-numeric: tabular-nums;
}
.evento .x { color: var(--txt-2); background: transparent; border: 0; font-size: 20px; padding: 6px 8px; cursor: pointer; }

.card.vivo { border-color: var(--acento); }
.chip.vivo-chip { background: var(--acento); color: #fff; letter-spacing: .04em; }
.marcador-mini { font-weight: 750; font-size: 18px; font-variant-numeric: tabular-nums; }
