/* Cuatro Houses · San Rafael Arcángel
   Azul marino del uniforme como escenario; el color lo ponen las cuatro Houses. */

@font-face { font-family: "Poppins"; font-weight: 400; font-display: swap; src: url("../fonts/poppins-regular.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 500; font-display: swap; src: url("../fonts/poppins-medium.woff") format("woff"); }
@font-face { font-family: "Poppins"; font-weight: 700; font-display: swap; src: url("../fonts/poppins-bold.woff") format("woff"); }

:root {
  --navy: #16233F;
  --navy-2: #22335B;
  --navy-3: #31446F;
  --chalk: #F2F4F8;
  --card: #FFFFFF;
  --ink: #142034;
  --ink-2: #56617A;
  --ink-3: #8A94A6;
  --line: #DCE2EB;
  --line-2: #EBEEF4;
  --gold: #D9A93B;
  --silver: #A9B3C1;
  --bronze: #C2814B;
  --ok: #1F7A45;
  --ok-bg: #E5F3EA;
  --err: #B3261E;
  --err-bg: #FBE9E7;
  --info-bg: #E8F0FB;
  --focus: #F2B500;
  --r-s: 8px;
  --r-m: 14px;
  --r-l: 20px;
  --tabbar: 64px;
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--chalk);
  font-variant-numeric: tabular-nums;
}
img { max-width: 100%; display: block; }
h1, h2, h3 { line-height: 1.2; margin: 0; }
p { margin: 0; }
a { color: var(--navy-3); }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 0; background: #fff; padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: 1rem; }
.muted { color: var(--ink-2); }
.hint { color: var(--ink-2); font-size: 13px; }
.center { text-align: center; }
.ico { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
[hidden] { display: none !important; }

/* ---------- Cabecera ---------- */

.topbar { background: var(--navy); color: #fff; position: sticky; top: 0; z-index: 30; padding-top: env(safe-area-inset-top); }
.topbar-in { display: flex; align-items: center; gap: 16px; max-width: 1180px; margin: 0 auto; padding: 10px 16px; }
.brand { display: flex; align-items: center; gap: 10px; color: #fff; text-decoration: none; min-width: 0; }
.brand-tiles { display: grid; grid-template-columns: repeat(2, 15px); gap: 2px; }
.brand-tiles img { width: 15px; height: 15px; border-radius: 3px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 16px; font-weight: 700; letter-spacing: -.01em; }
.brand-text small { font-size: 11.5px; color: #B7C2D8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topnav { display: none; gap: 2px; margin-left: auto; }
.topnav a { color: #C9D2E4; text-decoration: none; padding: 8px 12px; border-radius: 999px; font-size: 14px; font-weight: 500; }
.topnav a:hover { color: #fff; background: var(--navy-2); }
.topnav a[aria-current="page"] { color: var(--navy); background: #fff; }
.logout { margin-left: auto; }
.logout-btn { display: flex; align-items: center; gap: 8px; background: none; border: 1px solid var(--navy-3); color: #C9D2E4; border-radius: 999px; padding: 6px 10px 6px 12px; cursor: pointer; font-size: 13px; }
.logout-btn:hover { color: #fff; border-color: #6A7BA3; }
.logout-btn .ico { width: 18px; height: 18px; }
.logout-btn .who { max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Barra de carrera: proporcional a los puntos de cada House. */
.race { display: flex; height: 28px; text-decoration: none; }
.race-seg {
  background: var(--c); color: var(--t, #fff);
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  min-width: 0; padding: 0 10px; font-size: 12px; transition: flex-grow .8s cubic-bezier(.2,.7,.2,1);
}
.race-seg b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.race-seg i { font-style: normal; font-weight: 700; }

/* ---------- Estructura ---------- */

.main { max-width: 1180px; margin: 0 auto; padding: 20px 16px calc(var(--tabbar) + 32px + env(safe-area-inset-bottom)); }
.page-title { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-bottom: 4px; }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.lede { color: var(--ink-2); margin-bottom: 18px; max-width: 62ch; }
.section-title { font-size: 18px; font-weight: 700; margin: 0 0 12px; }
.narrow { max-width: 560px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--r-m); padding: 18px; }
.panel + .panel { margin-top: 16px; }
.panel-title { font-size: 17px; font-weight: 700; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* ---------- Mensajes ---------- */

.flash { border-radius: var(--r-s); padding: 11px 14px; margin-bottom: 14px; font-size: 14px; border: 1px solid transparent; }
.flash-ok { background: var(--ok-bg); color: var(--ok); border-color: #BFE0CB; }
.flash-error { background: var(--err-bg); color: var(--err); border-color: #F2C4BF; }
.flash-info { background: var(--info-bg); color: var(--navy-2); border-color: #C9D9F2; }

/* ---------- Botones y formularios ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid transparent; border-radius: 999px; padding: 10px 18px;
  font-weight: 500; font-size: 15px; text-decoration: none; cursor: pointer; min-height: 44px;
  transition: background-color .15s, border-color .15s, transform .1s;
}
.btn:active:not(:disabled) { transform: scale(.98); }
.btn:disabled { cursor: not-allowed; opacity: .55; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--navy-2); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink-3); }
.btn-danger { background: #fff; border-color: #F2C4BF; color: var(--err); }
.btn-small { min-height: 34px; padding: 6px 12px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-big { min-height: 56px; font-size: 16.5px; font-weight: 700; padding: 12px 22px; }
.btn .ico { width: 19px; height: 19px; }
.link-btn { background: none; border: 0; color: var(--navy-3); font-weight: 500; cursor: pointer; padding: 4px 0; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.icon-btn { background: none; border: 1px solid var(--line); border-radius: 999px; width: 38px; height: 38px; display: grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn .ico { width: 18px; height: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; color: var(--ink); }
.field input, .field select, .field textarea, .input {
  border: 1px solid var(--line); border-radius: var(--r-s); background: #fff; padding: 10px 12px; min-height: 44px;
  font-weight: 400; font-size: 16px; width: 100%;
}
.field textarea { min-height: 140px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 14px; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { outline: none; border-color: var(--navy-3); box-shadow: 0 0 0 3px #D6E0F3; }
.check { display: flex; gap: 10px; align-items: center; font-size: 14.5px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--navy); }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.grid-2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px; margin: 0 -2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 999px;
  padding: 7px 14px; font-size: 14px; cursor: pointer; min-height: 38px; text-decoration: none; white-space: nowrap;
}
.chip:hover { border-color: var(--ink-3); }
.chip[aria-pressed="true"], .chip[aria-current="page"], .chip.is-on { background: var(--navy); color: #fff; border-color: var(--navy); }
.chip-house img { width: 20px; height: 20px; border-radius: 4px; }
.chip-house[aria-pressed="true"], .chip-house.is-on { background: var(--c); border-color: var(--c); color: var(--t, #fff); }
.badge { display: inline-block; font-style: normal; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--gold); color: var(--ink); vertical-align: 2px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }

/* ---------- Premiar ---------- */

.award-form { display: flex; flex-direction: column; gap: 26px; margin-top: 16px; }
.step { display: flex; flex-direction: column; gap: 14px; }
.step-q { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 700; padding: 0; }
.step-n { width: 28px; height: 28px; border-radius: 50%; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 14px; }

.seg { display: inline-flex; background: #E3E8F0; border-radius: 999px; padding: 4px; align-self: flex-start; max-width: 100%; }
.seg-opt { position: relative; }
.seg-opt input { position: absolute; opacity: 0; inset: 0; }
.seg-opt span { display: block; padding: 9px 18px; border-radius: 999px; font-weight: 500; font-size: 14.5px; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg-opt input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(20, 32, 52, .15); }
.seg-opt input:focus-visible + span { outline: 3px solid var(--focus); }

.house-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
@media (min-width: 720px) { .house-pick { grid-template-columns: repeat(4, 1fr); } }
.house-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  background: #fff; border: 2px solid var(--line); border-radius: var(--r-l); padding: 16px 10px 14px; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.house-tile input { position: absolute; opacity: 0; }
.house-tile img { width: 88px; height: 88px; border-radius: 18px; margin-bottom: 6px; transition: transform .2s; }
.house-tile .ht-name { font-weight: 700; font-size: 16px; }
.house-tile .ht-sub { font-size: 13px; color: var(--ink-2); }
.house-tile:has(input:checked) { border-color: var(--c); background: color-mix(in srgb, var(--c) 10%, #fff); }
.house-tile:has(input:checked) img { transform: scale(1.06); }
.house-tile:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }

.picker { background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.picker-tools { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-bottom: 1px solid var(--line-2); }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 999px; padding: 0 14px; background: var(--chalk); }
.search .ico { color: var(--ink-3); width: 19px; height: 19px; }
.search input { border: 0; background: none; padding: 10px 0; min-height: 44px; width: 100%; font-size: 16px; }
.search input:focus { outline: none; }
.search:focus-within { border-color: var(--navy-3); box-shadow: 0 0 0 3px #D6E0F3; }
.picker-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; font-size: 13.5px; border-bottom: 1px solid var(--line-2); }
.st-list { list-style: none; margin: 0; padding: 6px; display: grid; gap: 4px; grid-template-columns: 1fr; max-height: 420px; overflow-y: auto; }
@media (min-width: 720px) { .st-list { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .st-list { grid-template-columns: 1fr 1fr 1fr; } }
.st {
  width: 100%; display: grid; grid-template-columns: 26px 1fr; grid-template-rows: auto auto; column-gap: 10px;
  text-align: left; background: #fff; border: 1px solid transparent; border-left: 4px solid var(--c);
  border-radius: var(--r-s); padding: 8px 10px; cursor: pointer; min-height: 52px;
}
.st:hover { background: var(--chalk); }
.st-check { grid-row: 1 / 3; align-self: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; }
.st-name { font-weight: 500; font-size: 15px; line-height: 1.3; }
.st-meta { font-size: 12.5px; color: var(--ink-2); }
.st[aria-pressed="true"] { background: color-mix(in srgb, var(--c) 12%, #fff); border-color: color-mix(in srgb, var(--c) 45%, #fff); border-left-color: var(--c); }
.st[aria-pressed="true"] .st-check { background: var(--c); border-color: var(--c); }
.st[aria-pressed="true"] .st-check::after { content: ""; width: 10px; height: 6px; border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff; transform: rotate(-45deg) translate(1px, -1px); }
.st-empty { padding: 20px; color: var(--ink-2); text-align: center; }

.tray { margin-top: 12px; background: var(--navy); color: #fff; border-radius: var(--r-m); padding: 12px 14px; }
.tray-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; font-size: 14px; }
.tray .link-btn { color: #C9D2E4; }
.tray-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.tray-chip { background: var(--navy-2); color: #fff; border: 0; border-left: 4px solid var(--c); border-radius: 6px; padding: 5px 10px; font-size: 13.5px; cursor: pointer; }
.tray-chip::after { content: " ×"; color: #9FAACC; }
.tray-chip:hover { background: var(--navy-3); }

.cat-pick { display: grid; gap: 8px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .cat-pick { grid-template-columns: 1fr 1fr; } }
@media (min-width: 1040px) { .cat-pick { grid-template-columns: repeat(3, 1fr); } }
.cat { position: relative; display: flex; flex-direction: column; gap: 2px; background: #fff; border: 2px solid var(--line); border-radius: var(--r-m); padding: 12px 14px 12px 44px; cursor: pointer; }
.cat input { position: absolute; left: 14px; top: 15px; width: 20px; height: 20px; accent-color: var(--navy); }
.cat-name { font-weight: 700; font-size: 15px; }
.cat-hint { font-size: 13px; color: var(--ink-2); }
.cat:has(input:checked) { border-color: var(--navy); background: #F5F7FC; }
.cat-challenge { border-color: #EBCF8A; background: #FFFBEF; }
.cat-challenge:has(input:checked) { border-color: var(--gold); background: #FFF4D6; }

.points { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.pt-btn { width: 52px; height: 52px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 26px; line-height: 1; cursor: pointer; }
.pt-btn:disabled { opacity: .35; cursor: not-allowed; }
.pt-value { min-width: 64px; text-align: center; font-size: 40px; font-weight: 700; letter-spacing: -.02em; }
.pt-quick { display: flex; gap: 6px; margin-left: 8px; }
.pt-quick .chip { min-width: 44px; justify-content: center; font-weight: 500; }

.extra summary { cursor: pointer; color: var(--navy-3); font-weight: 500; padding: 6px 0; }
.extra[open] summary { margin-bottom: 10px; }
.extra .field + .field { margin-top: 12px; }

.submit-bar {
  position: sticky; bottom: calc(var(--tabbar) + env(safe-area-inset-bottom) + 10px); z-index: 10;
  display: flex; flex-direction: column; gap: 8px;
}
.submit-bar .btn-big { width: 100%; box-shadow: 0 6px 20px rgba(22, 35, 63, .28); }
.form-error { background: var(--err-bg); color: var(--err); padding: 10px 14px; border-radius: var(--r-s); font-size: 14px; }

.recent { margin-top: 40px; }
.recent-list { list-style: none; margin: 0 0 10px; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line-2); }
.recent-item:first-child { border-top: 0; }
.recent-item form { margin: 0; }
.ri-main { flex: 1; min-width: 0; font-size: 14.5px; }
.ri-meta { display: block; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ri-pts { font-weight: 700; white-space: nowrap; }
.is-void { opacity: .55; }
.is-void .ri-pts { font-weight: 400; font-size: 13px; }

/* Ventana de confirmación: el único momento con animación. */
.done {
  border: 0; border-radius: var(--r-l); padding: 28px 22px 22px; width: min(420px, calc(100vw - 32px));
  text-align: center; color: var(--ink); box-shadow: 0 20px 60px rgba(10, 18, 36, .4);
}
.done::backdrop { background: rgba(14, 22, 40, .6); }
.done-burst { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.done-burst figure { margin: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; }
.done-burst img { width: 84px; height: 84px; border-radius: 18px; }
.done[open] .done-burst figure { animation: pop .55s cubic-bezier(.2, 1.4, .4, 1) both; }
.done[open] .done-burst figure:nth-child(2) { animation-delay: .07s; }
.done[open] .done-burst figure:nth-child(3) { animation-delay: .14s; }
.done[open] .done-burst figure:nth-child(4) { animation-delay: .21s; }
@keyframes pop { from { transform: scale(.4) rotate(-8deg); opacity: 0; } to { transform: none; opacity: 1; } }
.done-title { font-size: 34px; font-weight: 700; letter-spacing: -.02em; }
.done-sub { color: var(--ink-2); margin: 4px 0 20px; }
.done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- Clasificación ---------- */

.podium { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; align-items: end; margin: 8px 0 24px; }
.pod { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; min-width: 0; }
.pod-rank { font-weight: 700; font-size: 15px; color: var(--ink-2); }
.pod-total { font-size: clamp(26px, 6vw, 46px); font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.pod-bar { width: 100%; background: var(--c); border-radius: var(--r-m) var(--r-m) 6px 6px; min-height: 24px; position: relative; transition: height .9s cubic-bezier(.2, .7, .2, 1); }
.pod-bar img { width: min(72px, 80%); height: auto; aspect-ratio: 1; border-radius: 14px; position: absolute; left: 50%; top: 10px; transform: translateX(-50%); box-shadow: 0 0 0 3px rgba(255, 255, 255, .5); }
.pod-name { font-weight: 700; font-size: 15px; }
.pod-meta { font-size: 12.5px; color: var(--ink-2); line-height: 1.35; }
.pod-week { font-size: 12.5px; font-weight: 500; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; }
.pod.is-first .pod-rank { color: var(--ink); }
.pod.is-first .pod-rank::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); margin-right: 5px; }

.table-wrap { overflow-x: auto; background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 12px; text-align: left; border-top: 1px solid var(--line-2); vertical-align: middle; }
table.data thead th { border-top: 0; font-weight: 500; color: var(--ink-2); font-size: 13px; background: #FAFBFD; white-space: nowrap; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; }
table.data tfoot td { font-weight: 700; background: #FAFBFD; }
table.data .lead { font-weight: 700; }
.hcell { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.hcell img { width: 26px; height: 26px; border-radius: 6px; }
.cell-lead { background: color-mix(in srgb, var(--c) 14%, #fff); font-weight: 700; }

.winners { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.winner { display: flex; align-items: center; gap: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 12px; }
.winner img { width: 40px; height: 40px; border-radius: 9px; }
.winner small { display: block; color: var(--ink-2); font-size: 12.5px; }

/* ---------- Rankings ---------- */

.filters { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
.filters .row select { width: auto; min-width: 140px; }
.rank-group { margin-bottom: 26px; }
.rank-group-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.rank-group-head img { width: 36px; height: 36px; border-radius: 8px; }
.rank-list { list-style: none; margin: 0; padding: 0; background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); overflow: hidden; }
.rank-item a { display: grid; grid-template-columns: 40px 1fr auto; align-items: center; gap: 10px; padding: 10px 14px; text-decoration: none; color: inherit; border-top: 1px solid var(--line-2); }
.rank-item:first-child a { border-top: 0; }
.rank-item a:hover { background: #FAFBFD; }
.rank-pos { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--line-2); color: var(--ink-2); }
.rank-item.r1 .rank-pos { background: var(--gold); color: var(--ink); }
.rank-item.r2 .rank-pos { background: var(--silver); color: var(--ink); }
.rank-item.r3 .rank-pos { background: var(--bronze); color: #fff; }
.rank-name { font-weight: 500; line-height: 1.3; }
.rank-meta { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.rank-meta .dot { width: 8px; height: 8px; }
.rank-pts { font-size: 20px; font-weight: 700; text-align: right; line-height: 1.1; }
.rank-pts small { display: block; font-size: 11.5px; font-weight: 400; color: var(--ink-2); }
.medal { font-size: 11.5px; font-weight: 500; padding: 1px 7px; border-radius: 999px; border: 1px solid var(--line); color: var(--ink-2); }
.medal-Bronce { border-color: var(--bronze); color: #8A542A; }
.medal-Plata { border-color: var(--silver); color: #5B6677; }
.medal-Oro { border-color: var(--gold); color: #8A6510; background: #FFF6DE; }
.medal-Leyenda { border-color: var(--navy); background: var(--navy); color: #fff; }
.cap { font-size: 11.5px; font-weight: 500; color: var(--navy-3); }

/* Ficha de alumno */
.profile { display: flex; gap: 16px; align-items: center; margin-bottom: 18px; }
.profile img { width: 76px; height: 76px; border-radius: 16px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 20px; }
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; }
.stat b { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.stat span { font-size: 13px; color: var(--ink-2); }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(110px, 30%) 1fr 36px; gap: 10px; align-items: center; font-size: 14px; }
.bar-track { height: 10px; background: var(--line-2); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--c, var(--navy)); border-radius: 999px; }

/* ---------- Historial ---------- */

.filter-panel { background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px; margin-bottom: 14px; }
.filter-panel summary { cursor: pointer; font-weight: 500; }
.filter-grid { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); margin-top: 12px; }
@media (min-width: 900px) { .filter-grid { grid-template-columns: repeat(4, 1fr); } }
.filter-grid .field { font-size: 13px; }
.filter-grid .field input, .filter-grid .field select { min-height: 40px; padding: 7px 10px; font-size: 15px; }
.filter-actions { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.result-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; font-size: 14px; }
.hist-who { font-weight: 500; }
.hist-sub { font-size: 12.5px; color: var(--ink-2); }
tr.is-void td { color: var(--ink-3); text-decoration: line-through; }
tr.is-void td.actions { text-decoration: none; }
td.actions { white-space: nowrap; }
td.actions form { display: inline; }
.tag { display: inline-block; font-size: 11.5px; padding: 1px 8px; border-radius: 999px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.tag-void { background: var(--err-bg); color: var(--err); }
.pager { display: flex; gap: 8px; justify-content: center; margin-top: 16px; align-items: center; }

/* Tarjetas en móvil para el historial */
@media (max-width: 719px) {
  table.data.stack-sm thead { display: none; }
  table.data.stack-sm, table.data.stack-sm tbody, table.data.stack-sm tr, table.data.stack-sm td { display: block; width: 100%; }
  table.data.stack-sm tr { padding: 10px 12px; border-top: 1px solid var(--line-2); position: relative; }
  table.data.stack-sm tr:first-child { border-top: 0; }
  table.data.stack-sm td { border: 0; padding: 1px 0; }
  table.data.stack-sm td[data-l]::before { content: attr(data-l) ": "; color: var(--ink-3); font-size: 12.5px; }
  table.data.stack-sm td.num { text-align: left; }
  table.data.stack-sm td.pts { position: absolute; right: 12px; top: 10px; font-size: 18px; font-weight: 700; }
  table.data.stack-sm td.actions { margin-top: 6px; }
}

/* ---------- Datos para el PowerPoint ---------- */

.slide-grid { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 980px) { .slide-grid { grid-template-columns: 1fr 1fr; } }
.slide { background: var(--navy); color: #fff; border-radius: var(--r-m); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.slide-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.slide-kicker { font-size: 12px; color: #9FB0D3; }
.slide-title { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.slide .copy-btn { background: var(--navy-2); color: #fff; border: 1px solid var(--navy-3); }
.slide .copy-btn:hover { border-color: #8193BF; }
.copy-btn.is-done { background: var(--ok) !important; border-color: var(--ok) !important; }
.slide-houses { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.sh { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.sh img { width: 54px; height: 54px; border-radius: 12px; }
.sh b { font-size: 26px; line-height: 1; }
.sh small { font-size: 11.5px; color: #B7C2D8; line-height: 1.3; }
.sh .up { color: #8EE0A9; }
.sh .down { color: #FF9C8A; }
.slide-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.slide-list li { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; background: var(--navy-2); border-radius: 10px; padding: 8px 12px; border-left: 4px solid var(--c, transparent); }
.slide-list .pos { font-weight: 700; color: var(--gold); }
.slide-list .nm { font-weight: 500; line-height: 1.25; }
.slide-list .nm small { display: block; font-weight: 400; font-size: 12px; color: #B7C2D8; }
.slide-list .pt { font-weight: 700; font-size: 18px; }
.slide-empty { color: #9FB0D3; font-size: 14px; }
.slide-note { font-size: 12.5px; color: #9FB0D3; }
.slide-light { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.slide-light .slide-kicker, .slide-light .slide-note { color: var(--ink-2); }
.slide-light .copy-btn { background: #fff; color: var(--ink); border-color: var(--line); }
.slide-light .slide-list li { background: var(--chalk); }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.fact b { display: block; font-size: 26px; font-weight: 700; line-height: 1.1; }
.fact span { font-size: 13px; color: var(--ink-2); }
.ideas { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; color: var(--ink); font-size: 14.5px; max-width: 70ch; }

/* ---------- Administración ---------- */

.admin-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.admin-card { display: flex; flex-direction: column; gap: 4px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); padding: 16px; text-decoration: none; color: var(--ink); }
.admin-card:hover { border-color: var(--ink-3); }
.admin-card b { font-size: 16px; }
.admin-card span { font-size: 13.5px; color: var(--ink-2); }
.admin-card .ico { color: var(--navy-3); margin-bottom: 6px; }
.crumbs { font-size: 13.5px; margin-bottom: 6px; }
.crumbs a { color: var(--ink-2); }
.newpass { background: #FFF6DE; border: 1px solid #EBCF8A; border-radius: var(--r-m); padding: 14px 16px; margin-bottom: 16px; }
.newpass code { font-size: 22px; font-weight: 700; letter-spacing: .04em; background: #fff; padding: 4px 10px; border-radius: 6px; display: inline-block; margin: 6px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.house-edit { border-top: 6px solid var(--c); }
.house-edit-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.house-edit-head img { width: 52px; height: 52px; border-radius: 12px; }
.admin-row { border: 1px solid var(--line); border-radius: var(--r-m); padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 10px; }
.admin-row legend { font-size: 13.5px; padding: 0 6px; color: var(--ink-2); }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.inline-form .field { flex: 1 1 160px; }
.code-sample { background: var(--chalk); border: 1px dashed var(--line); border-radius: var(--r-s); padding: 10px 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; white-space: pre; overflow-x: auto; }
.empty-page { text-align: center; padding: 60px 16px; display: flex; flex-direction: column; gap: 14px; align-items: center; }
.empty-page h1 { font-size: 26px; }

/* ---------- Pantallas sin menú (entrar, instalar) ---------- */

body.plain { background: var(--navy); min-height: 100vh; }
.plain-main { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; gap: 22px; }
.plain-crest { display: grid; grid-template-columns: repeat(4, 56px); gap: 8px; }
.plain-crest img { width: 56px; height: 56px; border-radius: 12px; }
.plain-card { background: #fff; border-radius: var(--r-l); padding: 26px 22px; width: min(420px, 100%); display: flex; flex-direction: column; gap: 14px; }
.plain-wide { width: min(560px, 100%); }
.plain-title { font-size: 26px; font-weight: 700; letter-spacing: -.02em; }
.plain-sub { color: var(--ink-2); margin-top: -8px; font-size: 14.5px; }

/* ---------- Barra inferior (móvil) ---------- */

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; background: #fff; border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, 1fr); height: calc(var(--tabbar) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
}
.tabbar > a, .tab-more > summary {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--ink-3); text-decoration: none; font-size: 11px; font-weight: 500; cursor: pointer; list-style: none; height: var(--tabbar);
}
.tab-more > summary::-webkit-details-marker { display: none; }
.tabbar > a[aria-current="page"], .tab-more[data-current] > summary, .tab-more[open] > summary { color: var(--navy); }
.tabbar > a[aria-current="page"] .ico { stroke-width: 2.3; }
.tab-more { position: relative; }
.more-sheet {
  position: absolute; right: 8px; bottom: calc(var(--tabbar) + 8px); width: min(300px, 90vw);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-m); box-shadow: 0 12px 40px rgba(14, 22, 40, .2); padding: 6px;
}
.more-sheet a, .more-sheet button { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 10px; color: var(--ink); text-decoration: none; background: none; border: 0; width: 100%; text-align: left; cursor: pointer; font-size: 15px; }
.more-sheet a:hover, .more-sheet button:hover { background: var(--chalk); }
.more-sheet a[aria-current="page"] { background: var(--chalk); font-weight: 700; }
.more-sheet form { margin: 0; border-top: 1px solid var(--line-2); margin-top: 4px; padding-top: 4px; }

@media (min-width: 900px) {
  :root { --tabbar: 0px; }
  .tabbar { display: none; }
  .topnav { display: flex; }
  .logout { margin-left: 8px; }
  .main { padding-top: 28px; }
  .page-title { font-size: 32px; }
  .submit-bar { position: static; }
  .submit-bar .btn-big { width: auto; align-self: flex-start; min-width: 340px; box-shadow: none; }
}
@media (max-width: 899px) {
  .logout { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .tabbar, .filter-panel, .btn, .pager { display: none !important; }
  body { background: #fff; }
  .main { padding: 0; }
}

/* Tabla de categorías en móvil: solo escudos en la cabecera */
@media (max-width: 719px) {
  .hcell-sm-logo .hname { display: none; }
  table.data.compact th, table.data.compact td { padding: 9px 8px; }
}
.st-list { overscroll-behavior: contain; }
.btn-big:disabled { background: #8E9AB3; opacity: 1; box-shadow: none; }

.nowrap { white-space: nowrap; }

/* ---------- Housepoints / Demerit ---------- */
:root { --demerit: #B3261E; --demerit-bg: #FDEDEB; }
.kind { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kind-opt { position: relative; cursor: pointer; }
.kind-opt input { position: absolute; opacity: 0; inset: 0; }
.kind-opt span { display: flex; flex-direction: column; gap: 2px; border: 2px solid var(--line); background: #fff; border-radius: var(--r-m); padding: 12px 14px; height: 100%; }
.kind-opt b { font-size: 16.5px; }
.kind-opt small { font-size: 12.5px; color: var(--ink-2); line-height: 1.35; }
.kind-plus input:checked + span { border-color: var(--navy); background: #F5F7FC; }
.kind-minus input:checked + span { border-color: var(--demerit); background: var(--demerit-bg); }
.kind-minus input:checked + span b { color: var(--demerit); }
.kind-opt input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 2px; }
.is-demerit .step-n { background: var(--demerit); }
.is-demerit .submit-bar .btn-primary:not(:disabled) { background: var(--demerit); }
.is-demerit .cat:has(input:checked) { border-color: var(--demerit); background: var(--demerit-bg); }
.is-demerit .extra { background: #fff; border: 1px solid #F2C4BF; border-radius: var(--r-m); padding: 6px 14px 14px; }
.is-demerit .extra summary { color: var(--demerit); }
.neg, .pts-neg { color: var(--demerit); }
.done.is-demerit .done-title { color: var(--demerit); }
.tag-demerit { background: var(--demerit-bg); color: var(--demerit); }
.rank-minus { display: block; font-size: 11.5px; font-weight: 500; color: var(--demerit); }

/* Lista completa de alumnos */
.full-table td.num { font-variant-numeric: tabular-nums; }
.full-table .sort-link { color: inherit; text-decoration: none; }
.full-table .sort-link[aria-current="true"] { color: var(--ink); text-decoration: underline; text-underline-offset: 3px; }
.full-table tr.zero td { color: var(--ink-3); }
.full-table tr.zero td:first-child a { color: var(--ink-2); }

.only-narrow { display: none; }
@media (max-width: 719px) {
  .full-table .col-wide { display: none; }
  .full-table .only-narrow { display: flex; }
  .full-table th, .full-table td { padding: 9px 8px; }
  .full-table td:first-child { min-width: 9.5em; }
}
.is-demerit .submit-bar .btn-big:not(:disabled) { background: #B3261E !important; opacity: 1; }
.is-demerit .submit-bar .btn-big:disabled { background: #C9A3A0; }
