/* ===================================================================
   Sorteo de portátiles — hoja de estilos (moderno minimalista)
   =================================================================== */

:root {
  --bg: #ffffff;
  --bg-elev: #ffffff;
  --bg-subtle: #f6f7f9;
  --text: #1b2143;
  --text-soft: #5d6478;
  --text-faint: #9aa0ad;
  --border: #ebecf0;
  --border-strong: #dde0e6;
  --accent: #16a98a;          /* turquesa del logo Sesame */
  --accent-soft: #e3f6f0;
  --accent-text: #ffffff;
  --price: #1f2d52;           /* azul navy para los precios (acento secundario) */
  --price-soft: #eaedf4;
  --teal: #16a98a;            /* acento de marca (más oscuro para contraste) */
  --teal-soft: #e6f7f1;
  --logo-ink: #1f2d52;        /* navy del logo (texto + hexágono) */
  --logo-teal: #55e5bc;       /* verde/turquesa del logo */
  --shadow-sm: 0 1px 2px rgba(27, 33, 67, .04);
  --shadow-md: 0 6px 20px rgba(27, 33, 67, .07);
  --shadow-lg: 0 18px 48px rgba(27, 33, 67, .14);
  --radius: 12px;
  --radius-sm: 8px;

  --ok: #1a8f63;     --ok-bg: #ecf5f0;
  --good: #3a6ea5;   --good-bg: #eef2f7;
  --fair: #b67b1e;   --fair-bg: #f7f1e6;
  --parts: #c0544f;  --parts-bg: #f7ecea;
}

:root[data-theme="dark"] {
  --bg: #0f131c;
  --bg-elev: #161b26;
  --bg-subtle: #11161f;
  --text: #eef1f6;
  --text-soft: #a6afbd;
  --text-faint: #6d7787;
  --border: #232a36;
  --border-strong: #313a49;
  --accent: #2cc9a4;
  --accent-soft: #13261f;
  --price: #5f82dd;
  --price-soft: #1b2030;
  --teal: #46d3ac;
  --teal-soft: #14231f;
  --logo-ink: #eef1f8;        /* en oscuro, el texto del logo se aclara */
  --logo-teal: #55e5bc;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .4);
  --shadow-lg: 0 22px 56px rgba(0, 0, 0, .6);

  --ok-bg: #122a20;
  --good-bg: #14233a;
  --fair-bg: #2f2710;
  --parts-bg: #321a18;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 20px;
}

/* -------------------- Cabecera -------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg-elev) 80%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.header-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 16px;
  padding-top: 14px;
  padding-bottom: 14px;
}
.header-side-left { grid-column: 1; justify-self: start; display: flex; align-items: center; min-width: 0; }
.brand-center { grid-column: 2; justify-self: center; display: flex; align-items: center; }
.header-actions { grid-column: 3; justify-self: end; display: flex; align-items: center; gap: 12px; }
.actions-row { display: flex; align-items: center; gap: 12px; }
.brand-logo-img { height: 42px; width: auto; aspect-ratio: 1216 / 401; display: block; flex-shrink: 0; }
.brand-divider { width: 1px; height: 24px; background: var(--border-strong); flex-shrink: 0; }
.brand-text { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.brand-title { font-size: 19px; font-weight: 800; margin: 0; letter-spacing: -.03em; line-height: 1.05; }
.brand-title .accent-it { color: var(--teal); }
.brand-sub { font-size: 11.5px; color: var(--text-faint); margin: 2px 0 0; font-weight: 500; letter-spacing: .01em; }
.deadline-pill[hidden] { display: none; }
.deadline-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px; font-weight: 700;
  color: #7a4e00;
  background: #ffd84d;
  border: 1px solid #f0c020;
  padding: 6px 13px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 10px rgba(240, 192, 32, .35);
}
.deadline-pill svg { flex-shrink: 0; }
:root[data-theme="dark"] .deadline-pill {
  color: #ffe08a;
  background: #4a3a08;
  border-color: #6a5410;
  box-shadow: none;
}
.icon-btn {
  width: 42px; height: 42px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-soft);
  border-radius: 10px;
  cursor: pointer;
  font-size: 18px;
  display: grid; place-items: center;
  transition: border-color .15s, color .15s, transform .1s;
}
.icon-btn:hover { color: var(--text); }
.icon-btn:hover { border-color: var(--border-strong); }
.icon-btn:active { transform: scale(.94); }

/* -------------------- Sesión Google (cabecera) -------------------- */
.auth-area { display: flex; align-items: center; }
.auth-area:empty { display: none; }
.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 6px 4px 5px;
}
.avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.avatar-fallback { display: grid; place-items: center; font-size: 15px; }
.user-name { font-size: 13.5px; font-weight: 600; max-width: 110px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.signout-btn {
  border: none;
  background: var(--bg);
  color: var(--text-soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.signout-btn:hover { color: var(--text); background: var(--border); }

/* Identidad mostrada dentro del formulario del modal */
.signed-as {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
  margin-bottom: 14px;
}
.signed-as .avatar { width: 40px; height: 40px; }
.sa-info { min-width: 0; }
.sa-name { font-size: 14.5px; font-weight: 700; }
.sa-email { font-size: 13px; color: var(--text-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.modal-signin { display: flex; justify-content: center; padding: 6px 0 4px; min-height: 44px; }
.auth-warn { font-size: 12.5px; font-weight: 600; color: var(--fair); background: var(--fair-bg); padding: 7px 12px; border-radius: 999px; white-space: nowrap; }

/* -------------------- Pantalla de login (muro) -------------------- */
body.gated { overflow: hidden; }
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 300;
  background:
    radial-gradient(900px 500px at 50% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 70%),
    radial-gradient(700px 460px at 100% 110%, var(--teal-soft), transparent 65%),
    var(--bg);
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-gate[hidden] { display: none; }
.login-card {
  width: 100%;
  max-width: 410px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: var(--shadow-lg);
  padding: 44px 38px 36px;
  text-align: center;
  animation: pop .3s cubic-bezier(.2,.9,.3,1.1);
}
.login-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 0 auto 22px;
}
.login-logo-img { height: 34px; width: auto; aspect-ratio: 1216 / 401; display: block; }
.login-brand-divider { width: 1px; height: 26px; background: var(--border-strong); }
.login-brand-name { font-size: 22px; font-weight: 800; letter-spacing: -.03em; color: var(--text); line-height: 1; }
.login-brand-name .accent-it { color: var(--teal); }
.login-welcome { font-size: 15px; font-weight: 600; color: var(--text); margin: 0 0 4px; letter-spacing: -.01em; }
.login-lead { font-size: 13.5px; color: var(--text-soft); margin: 0 0 26px; line-height: 1.5; }
.login-title { font-size: 20px; font-weight: 650; color: var(--text); margin: 0 0 26px; letter-spacing: -.01em; line-height: 1.4; }
.login-title code { background: var(--bg-subtle); padding: 1px 5px; border-radius: 5px; font-size: 14px; }
.login-btn-wrap { display: flex; justify-content: center; min-height: 44px; }
.login-loading { font-size: 13.5px; color: var(--text-faint); }
.login-foot { font-size: 12.5px; color: var(--text-faint); margin: 18px 0 0; }

/* -------------------- Botón propio de inicio de sesión -------------------- */
.gsi-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 11px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
  box-shadow: var(--shadow-sm);
}
.gsi-btn:hover { background: var(--bg-subtle); border-color: var(--text-faint); box-shadow: var(--shadow-md); }
.gsi-btn:active { transform: translateY(1px); }
.gsi-btn:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.gsi-btn .gsi-g { flex-shrink: 0; }
/* Grande: muro de login y modal de inscripción */
.gsi-btn-lg { width: 100%; max-width: 300px; padding: 13px 22px; font-size: 15px; }
/* Pequeño: cabecera */
.gsi-btn-sm { padding: 8px 14px; font-size: 13px; }

/* -------------------- Controles -------------------- */
.controls {
  position: sticky;
  top: var(--header-h, 90px);
  z-index: 40;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.controls-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding-top: 16px;
  padding-bottom: 16px;
  flex-wrap: wrap;
}
.search-wrap {
  position: relative;
  flex: 1 1 280px;
  min-width: 0;
}
.search-icon {
  position: absolute; left: 14px; top: 50%;
  transform: translateY(-50%);
  width: 18px; height: 18px;
  color: var(--text-faint);
  pointer-events: none;
}
#search {
  width: 100%;
  padding: 12px 14px 12px 42px;
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
#search:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
.filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.chip {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text-soft);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--border-strong); color: var(--text); }
.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

/* -------------------- Cómo funciona (condiciones del sorteo) -------------------- */
.rules {
  margin: 18px 0 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.rules-summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  cursor: pointer;
  list-style: none;
  font-weight: 700;
  color: var(--text);
  -webkit-user-select: none;
  user-select: none;
}
.rules-summary::-webkit-details-marker { display: none; }
.rules-ico { width: 20px; height: 20px; color: var(--accent); flex-shrink: 0; }
.rules-title { font-size: 15px; letter-spacing: -.01em; }
.rules-caret { width: 18px; height: 18px; color: var(--text-faint); margin-left: auto; transition: transform .2s; flex-shrink: 0; }
.rules[open] .rules-caret { transform: rotate(180deg); }
.rules-content {
  padding: 4px 16px 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 16px 32px;
  align-items: center;
}
.rules-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.rules-list li {
  position: relative;
  padding-left: 27px;
  font-size: 13.5px;
  color: var(--text-soft);
  line-height: 1.45;
}
.rules-list li::before {
  content: "✓";
  position: absolute;
  left: 0; top: 1px;
  width: 18px; height: 18px;
  display: grid; place-items: center;
  font-size: 11px; font-weight: 800;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 50%;
}
.rules-list strong { color: var(--text); font-weight: 700; }
.rules-dates { display: grid; gap: 10px; }
.rule-date {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-subtle);
  white-space: nowrap;
}
.rule-date svg { width: 20px; height: 20px; color: var(--text-soft); flex-shrink: 0; }
.rule-date-accent { background: var(--accent); border-color: var(--accent); }
.rule-date-accent svg,
.rule-date-accent .rd-label,
.rule-date-accent .rd-value { color: var(--accent-text); }
.rd-text { display: flex; flex-direction: column; line-height: 1.25; }
.rd-label { font-size: 10.5px; color: var(--text-faint); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.rd-value { font-size: 15px; font-weight: 700; color: var(--text); }

/* -------------------- Catálogo -------------------- */
.result-count {
  color: var(--text-soft);
  font-size: 13.5px;
  margin: 22px 0 14px;
  font-weight: 500;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 22px;
  padding-bottom: 40px;
}
.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s ease, box-shadow .15s ease;
  cursor: pointer;
}
.card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}
.card-media {
  position: relative;
  aspect-ratio: 4 / 3;
  background: #fff;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.card-media img,
.card-media svg {
  width: 100%; height: 100%;
  object-fit: contain;
  display: block;
  padding: 14px;
}
.card-media svg { padding: 0; object-fit: cover; }
.badge {
  position: absolute;
  top: 10px; left: 10px;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 6px;
  letter-spacing: .01em;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-soft);
}
.price-pill {
  position: absolute;
  top: 10px; right: 10px;
  font-size: 14px;
  font-weight: 700;
  color: #fff;
  background: var(--price);
  padding: 6px 13px;
  border-radius: 999px;
  letter-spacing: -.01em;
  box-shadow: 0 2px 10px rgba(30, 39, 80, .22);
}
:root[data-theme="dark"] .price-pill { color: var(--text); background: var(--price-soft); border: 1px solid var(--border-strong); }
.badge.ok    { color: var(--ok); }
.badge.good  { color: var(--good); }
.badge.fair  { color: var(--fair); }
.badge.parts { color: var(--parts); }

/* Aviso de cargador (esquina inferior derecha de la imagen) */
.charger-pill {
  position: absolute;
  bottom: 10px; right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: .01em;
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(27, 33, 67, .14);
}
.charger-pill.no  { color: #fff; background: var(--parts); }
.charger-pill.yes { color: #fff; background: var(--ok); }
.modal-media .charger-pill { bottom: 14px; right: 14px; font-size: 12px; padding: 5px 12px; }

.card-body { padding: 15px 16px 16px; display: flex; flex-direction: column; flex: 1; }
.card-brand {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-faint);
}
.card-model {
  font-size: 16px; font-weight: 700;
  margin: 4px 0 8px;
  letter-spacing: -.01em;
}
.spec-line {
  font-size: 13px;
  color: var(--text-soft);
  margin: 0 0 14px;
  font-weight: 500;
}
.spec-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 16px;
}
.spec {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-soft);
  background: var(--bg);
  border: 1px solid var(--border);
  padding: 4px 9px;
  border-radius: 8px;
}
.spec .ico { opacity: .7; }
.card-cta {
  margin-top: auto;
  display: flex;
  gap: 8px;
}
.btn {
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  padding: 11px 16px;
  transition: filter .15s, transform .1s, background .15s, border-color .15s;
}
.btn:active { transform: scale(.98); }
.btn-primary { background: var(--accent); color: var(--accent-text); flex: 1; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--bg); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.empty-state {
  text-align: center;
  color: var(--text-soft);
  padding: 60px 20px;
  font-size: 15px;
}

/* -------------------- Apuntados en la tarjeta -------------------- */
.card.is-joined { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset, var(--shadow-sm); }
.joined-flag {
  position: absolute;
  bottom: 12px; left: 12px;
  font-size: 12px; font-weight: 700;
  color: #fff;
  background: var(--accent);
  padding: 5px 11px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.joined-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  min-height: 30px;
}
.joined-row.empty { color: var(--text-faint); }
.joined-none { font-size: 12.5px; font-weight: 500; }
.avatar-stack { display: flex; }
.mini-avatar {
  width: 30px; height: 30px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--bg-elev);
  margin-left: -8px;
  background: var(--accent-soft);
  box-shadow: 0 1px 2px rgba(0,0,0,.12);
}
.avatar-stack .mini-avatar:first-child { margin-left: 0; }
.mini-fallback {
  display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
  color: var(--accent);
}
.mini-more {
  display: grid; place-items: center;
  font-size: 11.5px; font-weight: 700;
  color: var(--text-soft);
  background: var(--bg);
}
.joined-count { font-size: 12.5px; font-weight: 600; color: var(--text-soft); }
.btn-joined {
  flex: 1;
  background: var(--accent-soft);
  color: var(--accent);
  cursor: pointer;
}
.btn-joined:hover { filter: brightness(.98); }

/* -------------------- Participantes en el modal -------------------- */
.participants { margin-bottom: 4px; }
.participants-title { font-size: 15px; font-weight: 700; margin: 0 0 12px; }
.participants-empty { font-size: 13.5px; color: var(--text-soft); margin: 0 0 4px; }
.participants-list { display: flex; flex-wrap: wrap; gap: 8px; }
.participant {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 12px 4px 4px;
  max-width: 100%;
}
.p-avatar {
  width: 28px; height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--accent-soft);
  flex-shrink: 0;
}
.p-fallback { display: grid; place-items: center; font-size: 12px; font-weight: 700; color: var(--accent); }
.p-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Ya apuntado (dentro del modal) */
.already-joined {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--accent-soft);
  border-radius: 14px;
  padding: 16px 18px;
}
.already-joined .aj-check {
  width: 40px; height: 40px;
  flex-shrink: 0;
  display: grid; place-items: center;
  background: var(--accent);
  color: #fff;
  font-size: 22px;
  border-radius: 50%;
}
.aj-title { font-size: 15.5px; font-weight: 700; }
.aj-sub { font-size: 13.5px; color: var(--text-soft); margin-top: 2px; }

/* -------------------- Footer -------------------- */
.site-footer {
  border-top: 1px solid var(--border);
  padding: 28px 0;
  text-align: center;
}
.site-footer p { color: var(--text-faint); font-size: 13.5px; margin: 0; }

/* -------------------- Modal -------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 12, 18, .6);
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: fade .18s ease;
}
/* El atributo hidden DEBE ganar al display:grid de arriba, o el modal
   queda siempre activo y bloquea todos los clics de la página. */
.modal-overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  animation: pop .22s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes pop { from { opacity: 0; transform: translateY(16px) scale(.98); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute;
  top: 14px; right: 16px;
  z-index: 2;
  width: 36px; height: 36px;
  border: none;
  background: color-mix(in srgb, var(--bg-elev) 70%, transparent);
  color: var(--text);
  font-size: 26px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
  display: grid; place-items: center;
}
.modal-close:hover { background: var(--bg); }
.modal-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #fff;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
  border-radius: 16px 16px 0 0;
}
.modal-media img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 18px; }
.modal-media svg { width: 100%; height: 100%; object-fit: cover; display: block; }
.modal-content { padding: 22px 24px 26px; }
.modal-brand { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin: 4px 0 16px; }
.modal-title { font-size: 23px; font-weight: 800; margin: 0; letter-spacing: -.02em; }
.modal-price {
  flex-shrink: 0;
  font-size: 19px;
  font-weight: 700;
  color: #fff;
  background: var(--price);
  padding: 7px 16px;
  border-radius: 999px;
  white-space: nowrap;
  box-shadow: 0 2px 12px rgba(30, 39, 80, .2);
}
:root[data-theme="dark"] .modal-price { color: var(--text); background: var(--price-soft); }

.spec-table { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 18px; }
.spec-item {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 11px 13px;
}
.spec-item .label { font-size: 11.5px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.spec-item .value { font-size: 14.5px; font-weight: 600; margin-top: 2px; }
.spec-item.full { grid-column: 1 / -1; }

.damage-box {
  background: var(--bg-subtle);
  border-left: 3px solid var(--fair);
  border-radius: 0 8px 8px 0;
  padding: 11px 14px;
  margin-bottom: 8px;
}
.damage-box .label { font-size: 11px; font-weight: 600; color: var(--fair); text-transform: uppercase; letter-spacing: .04em; }
.damage-box .text { font-size: 14px; color: var(--text); margin-top: 3px; }
.damage-box.clean { border-left-color: var(--ok); }
.damage-box.clean .label { color: var(--ok); }

.tag-list { display: flex; flex-wrap: wrap; gap: 7px; margin: 14px 0 4px; }
.tag {
  font-size: 12px; font-weight: 600;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 10px;
  border-radius: 999px;
}

.divider { height: 1px; background: var(--border); margin: 22px 0; }

/* -------------------- Formulario -------------------- */
.form-heading { font-size: 17px; font-weight: 700; margin: 0 0 4px; }
.form-sub { font-size: 13.5px; color: var(--text-soft); margin: 0 0 16px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 10px;
  font-size: 14.5px;
  font-family: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent);
}
.field input.invalid { border-color: var(--parts); }
.field .error { font-size: 12px; color: var(--parts); margin-top: 5px; display: none; }
.field .error.show { display: block; }
.btn-submit { width: 100%; margin-top: 4px; padding: 13px; font-size: 15px; }
.btn-submit .spinner {
  display: inline-block;
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
  vertical-align: -2px;
  margin-right: 7px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.success-box {
  text-align: center;
  padding: 20px 10px;
}
.success-box .check {
  width: 60px; height: 60px;
  margin: 0 auto 14px;
  background: var(--ok-bg);
  color: var(--ok);
  border-radius: 50%;
  display: grid; place-items: center;
  font-size: 30px;
  animation: pop .3s cubic-bezier(.2,.9,.3,1.4);
}
.success-box h3 { font-size: 19px; margin: 0 0 6px; }
.success-box p { color: var(--text-soft); font-size: 14.5px; margin: 0; }

/* -------------------- Toast -------------------- */
.toast {
  position: fixed;
  bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg-elev);
  padding: 13px 20px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  z-index: 200;
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* -------------------- Responsive -------------------- */
@media (max-width: 640px) {
  /* Cabecera compacta: [logo + BuyIT] a la izquierda, acciones a la derecha (se ajustan) */
  .header-inner { display: flex; align-items: center; gap: 10px; }
  .brand-center { grid-column: auto; justify-self: auto; order: 0; }
  .header-side-left { grid-column: auto; justify-self: auto; order: 1; }
  .header-actions { grid-column: auto; justify-self: auto; order: 2; margin-left: auto; }
  .actions-row { flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
  .brand-logo-img { height: 24px; }
  .brand-title { font-size: 16px; }
  .brand-sub { display: none; }
  .user-name { display: none; }
  .btn-winners, .btn-sorteo { padding: 7px 12px; font-size: 13px; }
  .deadline-pill { font-size: 12px; padding: 5px 10px; }
  .rules-content { grid-template-columns: 1fr; }
  .rules-dates { grid-template-columns: 1fr 1fr; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  .spec-table { grid-template-columns: 1fr; }
  .modal-content { padding: 20px 18px 22px; }
  .modal-title { font-size: 20px; }
  .controls-inner { gap: 12px; }
  .filters { width: 100%; overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
}
@media (max-width: 420px) {
  .card-cta { flex-direction: column; }
  .rules-dates { grid-template-columns: 1fr; }
}

/* -------------------- Controles extra: orden / mis inscripciones -------------------- */
.controls-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.toggle-mine { } /* hereda .chip */
.sort-select {
  border: 1px solid var(--border);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  padding: 9px 12px;
  border-radius: 999px;
  cursor: pointer;
}
.sort-select:focus { outline: none; border-color: var(--accent); }

/* -------------------- Botón Sorteo (admin) -------------------- */
.btn-sorteo {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.btn-sorteo:hover { filter: brightness(1.08); }
.btn-sorteo[hidden] { display: none; }

/* -------------------- Aviso de cierre -------------------- */
.closed-banner {
  margin: 18px 0 0;
  background: var(--fair-bg);
  color: var(--fair);
  border: 1px solid color-mix(in srgb, var(--fair) 30%, transparent);
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 13.5px;
  font-weight: 600;
}
.closed-note {
  background: var(--bg-subtle);
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 14px;
  color: var(--text-soft);
  text-align: center;
  font-weight: 500;
}

/* Baja */
.btn-baja { width: 100%; margin-top: 12px; }
.btn-baja:hover { color: var(--parts); border-color: var(--parts); }

/* Ganador en el modal */
.winner-banner {
  background: var(--teal-soft);
  color: var(--teal);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13.5px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* -------------------- Panel de sorteo -------------------- */
.modal-wide { max-width: 640px; }
.sorteo-toolbar { margin: 4px 0 16px; }
.btn-sm { font-size: 13px; padding: 8px 13px; }
.sorteo-list { display: flex; flex-direction: column; gap: 8px; }
.sorteo-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
}
.sorteo-info { min-width: 0; }
.sorteo-model { font-size: 14.5px; font-weight: 700; }
.sorteo-ref { font-size: 12px; color: var(--text-faint); margin-top: 1px; }
.sorteo-action { flex-shrink: 0; display: flex; align-items: center; gap: 8px; }
.sorteo-empty { font-size: 12.5px; color: var(--text-faint); }
.sorteo-winner { font-size: 13.5px; font-weight: 700; color: var(--teal); }

@media (max-width: 640px) {
  .controls-right { width: 100%; }
  .sort-select { flex: 1; }
}

/* -------------------- Anuncio de ganador en la tarjeta -------------------- */
.card.is-won { border-color: var(--teal); }
.won-flag {
  position: absolute;
  bottom: 10px; left: 10px;
  font-size: 11.5px; font-weight: 700;
  color: #fff;
  background: var(--teal);
  padding: 4px 10px;
  border-radius: 999px;
  box-shadow: 0 2px 8px rgba(0,0,0,.18);
}
.card-winner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--teal-soft);
  color: var(--teal);
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 14px;
  font-size: 13.5px;
  min-height: 30px;
}
.card-winner svg { flex-shrink: 0; }
.card-winner strong { color: var(--text); }
.already-joined.won-me { background: var(--teal-soft); }
.already-joined.won-me .aj-check { background: var(--teal); }

/* -------------------- Botón Ganadores (cabecera) -------------------- */
.btn-winners {
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.btn-winners:hover { filter: brightness(1.06); }
.btn-winners[hidden] { display: none; }

/* -------------------- Pantalla de ganadores -------------------- */
.winners-head {
  text-align: center;
  padding: 8px 8px 22px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.wh-trophy {
  width: 64px; height: 64px;
  margin: 0 auto 12px;
  display: grid; place-items: center;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 50%;
}
.winners-head h2 { font-size: 24px; font-weight: 800; margin: 0 0 6px; letter-spacing: -.02em; }
.winners-head p { font-size: 14px; color: var(--text-soft); margin: 0; line-height: 1.5; }
.winners-head.win-mine h2 { color: var(--teal); }

.winners-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.winner-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--bg-elev);
}
.winner-item.mine { border-color: var(--teal); background: var(--teal-soft); }
.wn-thumb {
  width: 64px; height: 50px;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
  flex-shrink: 0;
  padding: 4px;
}
.wn-thumb-ph { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--text-faint); }
.wn-info { min-width: 0; flex: 1; }
.wn-model { font-size: 14px; font-weight: 700; line-height: 1.25; }
.wn-ref { font-size: 11.5px; color: var(--text-faint); margin: 1px 0 6px; }
.wn-person { display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; min-width: 0; }
.wn-person span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wn-avatar { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; background: var(--accent-soft); flex-shrink: 0; }
.wn-fallback { display: grid; place-items: center; font-size: 11px; font-weight: 700; color: var(--accent); }
.wn-badge { position: absolute; top: 8px; right: 8px; color: var(--teal); }

.confetti-canvas {
  position: fixed; inset: 0;
  z-index: 400;
  pointer-events: none;
}

@media (max-width: 560px) {
  .winners-grid { grid-template-columns: 1fr; }
}
