/* Portal del cliente de JAMC. Mismo aspecto que el panel; claro y oscuro según el sistema; fuentes del sistema. */
:root {
  --fondo: #f4f6f9;
  --superficie: #ffffff;
  --superficie-2: #f0f3f7;
  --borde: #dde3ea;
  --texto: #18202b;
  --tenue: #5d6876;
  --primario: #1f5fbf;
  --primario-texto: #ffffff;
  --primario-suave: #e5eefb;
  --peligro: #b42318;
  --verde: #12703c;
  --verde-suave: #e3f4ea;
  --ambar: #8a5300;
  --ambar-suave: #fdf1dc;
  --rojo: #b42318;
  --rojo-suave: #fdecea;
  --gris: #5d6876;
  --gris-suave: #eceff3;
  --morado: #6b3fb5;
  --morado-suave: #efe8fb;
  --sombra: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --sombra-alta: 0 12px 32px rgba(16, 24, 40, 0.18);
  --radio: 12px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fondo: #0f141a;
    --superficie: #171e26;
    --superficie-2: #1e2731;
    --borde: #2c3845;
    --texto: #e6ebf1;
    --tenue: #9aa6b4;
    --primario: #5b9bff;
    --primario-texto: #0b1220;
    --primario-suave: #1a2c47;
    --peligro: #ff7a6e;
    --verde: #5fd394;
    --verde-suave: #16301f;
    --ambar: #f2b45a;
    --ambar-suave: #352812;
    --rojo: #ff7a6e;
    --rojo-suave: #3a1d1b;
    --gris: #9aa6b4;
    --gris-suave: #232c36;
    --morado: #c3a6ff;
    --morado-suave: #2a2140;
    --sombra: 0 1px 2px rgba(0, 0, 0, 0.4);
    --sombra-alta: 0 12px 32px rgba(0, 0, 0, 0.55);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--fondo);
  color: var(--texto);
  font: 15px/1.5 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
h1,
h2,
h3 {
  line-height: 1.25;
  margin: 0 0 0.5rem;
}
h1 {
  font-size: 1.5rem;
}
h2 {
  font-size: 1.2rem;
}
h3 {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--tenue);
  font-weight: 650;
  margin: 0 0 0.25rem;
}
p {
  margin: 0 0 0.6rem;
}
.tenue {
  color: var(--tenue);
}
.cargando {
  color: var(--tenue);
  padding: 2rem 1rem;
  text-align: center;
}
.icono {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: none;
}

/* ---------- Botones y campos ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  min-height: 40px;
  padding: 0.45rem 0.95rem;
  border: 1px solid var(--borde);
  border-radius: 8px;
  background: var(--superficie);
  color: var(--texto);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover:not(:disabled) {
  background: var(--superficie-2);
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-primario {
  background: var(--primario);
  border-color: var(--primario);
  color: var(--primario-texto);
}
.btn-primario:hover:not(:disabled) {
  background: var(--primario);
  filter: brightness(1.08);
}
.btn-ingreso {
  width: 100%;
  min-height: 46px;
}
.btn-icono {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--tenue);
  cursor: pointer;
}
.btn-icono:hover:not(:disabled) {
  background: var(--superficie-2);
  color: var(--texto);
}
.campo {
  width: 100%;
  min-height: 40px;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--borde);
  border-radius: 8px;
  background: var(--superficie);
  color: var(--texto);
  font: inherit;
}
.campo-codigo {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.campo-etiquetado {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.etiqueta {
  font-weight: 600;
  font-size: 0.9rem;
}
.ayuda {
  color: var(--tenue);
  font-size: 0.82rem;
}
.acciones {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.pila {
  display: grid;
  gap: 0.6rem;
}

/* ---------- Barra ---------- */
.barra {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1.25rem;
  background: var(--superficie);
  border-bottom: 1px solid var(--borde);
}
.marca {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}
.marca-logo {
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--primario);
  font-size: 1.15rem;
}
.marca-sub {
  color: var(--tenue);
  font-size: 0.9rem;
}
.marca-grande .marca-logo {
  font-size: 1.8rem;
}
.marca-grande .marca-sub {
  font-size: 1.05rem;
}
.menu-usuario {
  position: relative;
}
.menu-usuario summary {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  list-style: none;
  cursor: pointer;
  padding: 0.25rem 0.4rem;
  border-radius: 8px;
}
.menu-usuario summary::-webkit-details-marker {
  display: none;
}
.menu-usuario summary:hover {
  background: var(--superficie-2);
}
.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--primario-suave);
  color: var(--primario);
  font-weight: 700;
}
.nombre-usuario {
  max-width: 14rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu-lista {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 240px;
  padding: 0.35rem;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 10px;
  box-shadow: var(--sombra-alta);
}
.menu-lista p {
  margin: 0;
  padding: 0.45rem 0.7rem 0.55rem;
  border-bottom: 1px solid var(--borde);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}
.menu-lista button {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.55rem 0.7rem;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--texto);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.menu-lista button:hover {
  background: var(--superficie-2);
}

/* ---------- Contenido ---------- */
.contenido {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 1.5rem 1.25rem 2.5rem;
}
.encabezado {
  margin-bottom: 1.25rem;
}
.productos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(420px, 100%), 1fr));
  gap: 1rem;
  align-items: start;
}
.tarjeta {
  padding: 1.25rem;
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: var(--radio);
  box-shadow: var(--sombra);
}
.producto-cabecera {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.producto-cabecera h2 {
  margin: 0;
}
.producto-cabecera p {
  margin: 0;
}
.datos {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem 1.25rem;
  margin: 0 0 1.1rem;
}
.datos > div {
  min-width: 0;
}
.datos dt {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--tenue);
}
.datos dd {
  margin: 0;
}
.datos .ancho {
  grid-column: 1 / -1;
}
.dato-grande {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}
.lista-equipos {
  margin: 0.25rem 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.88rem;
}
.lista-equipos li {
  padding: 0.15rem 0;
  overflow-wrap: anywhere;
}
.tarjeta-futura {
  border-style: dashed;
  box-shadow: none;
  background: transparent;
}
.nota {
  padding: 0.65rem 0.85rem;
  border-radius: 8px;
  background: var(--primario-suave);
}
.nota-alerta {
  background: var(--ambar-suave);
}
.nota-renovacion {
  background: var(--morado-suave);
}
.nota p:last-child {
  margin: 0;
}
.pie-producto {
  margin: 0.9rem 0 0;
  color: var(--tenue);
  font-size: 0.82rem;
}
.vincular {
  margin-top: 1.5rem;
}
.vincular summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primario);
}
.vincular form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem 1rem;
  margin-top: 0.9rem;
}
.vincular form .acciones,
.vincular form .ayuda {
  grid-column: 1 / -1;
}
.pie {
  margin-top: 2rem;
  color: var(--tenue);
  font-size: 0.82rem;
}

/* Enlaces legales, en todas las pantallas */
.pie-legal {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 0 1.25rem 2rem;
  text-align: center;
  color: var(--tenue);
  font-size: 0.82rem;
}
.pie-legal a {
  color: inherit;
}
.pie-legal a:hover {
  color: var(--texto);
}

/* Código oculto con el ojo */
.visor {
  display: inline-flex;
  align-items: center;
  gap: 0.1rem;
  flex-wrap: wrap;
}
.codigo {
  font-family: ui-monospace, 'Cascadia Mono', Consolas, 'SF Mono', Menlo, monospace;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  white-space: nowrap;
  margin-right: 0.3rem;
}
.codigo.visible {
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: var(--ambar-suave);
}

/* Estados */
.pastilla {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 650;
  white-space: nowrap;
}
.p-activa {
  background: var(--verde-suave);
  color: var(--verde);
}
.p-por-vencer {
  background: var(--ambar-suave);
  color: var(--ambar);
}
.p-vencida {
  background: var(--rojo-suave);
  color: var(--rojo);
}
.p-anulada,
.p-pronto {
  background: var(--gris-suave);
  color: var(--gris);
}

/* ---------- Ingreso ---------- */
.ingreso {
  display: grid;
  place-items: center;
  /* Deja a la vista el pie con los enlaces legales */
  min-height: calc(100vh - 3.5rem);
  padding: 1.25rem;
}
.tarjeta-ingreso {
  width: min(440px, 100%);
  padding: 2rem 1.75rem;
}
.tarjeta-ingreso .marca {
  margin-bottom: 0.75rem;
}
.tarjeta-ingreso .nota {
  margin-bottom: 1rem;
}
.pie-ingreso {
  margin: 1.1rem 0 0;
  color: var(--tenue);
  font-size: 0.82rem;
}

/* ---------- Diálogo y avisos ---------- */
dialog {
  width: min(460px, calc(100% - 2rem));
  padding: 1.4rem;
  color: var(--texto);
  background: var(--superficie);
  border: 1px solid var(--borde);
  border-radius: 12px;
  box-shadow: var(--sombra-alta);
}
dialog::backdrop {
  background: rgba(10, 15, 22, 0.5);
}
dialog .acciones {
  justify-content: flex-end;
  margin-top: 1rem;
}
#avisos {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 50;
  display: grid;
  gap: 0.5rem;
  max-width: min(420px, calc(100% - 2rem));
}
.aviso {
  padding: 0.7rem 1rem;
  border-radius: 8px;
  background: var(--texto);
  color: var(--fondo);
  box-shadow: var(--sombra-alta);
  transition: opacity 0.4s, transform 0.4s;
}
.aviso-error {
  background: var(--peligro);
  color: #fff;
}
.aviso.saliendo {
  opacity: 0;
  transform: translateY(6px);
}

/* ---------- Teléfono ---------- */
@media (max-width: 560px) {
  .barra {
    padding: 0.55rem 1rem;
  }
  .nombre-usuario {
    display: none;
  }
  .contenido {
    padding: 1.1rem 1rem 2rem;
  }
  .tarjeta {
    padding: 1rem;
  }
  .vincular form {
    grid-template-columns: 1fr;
  }
  .acciones .btn {
    flex: 1 1 auto;
  }
  #avisos {
    left: 1rem;
    right: 1rem;
    max-width: none;
  }
}

/* Teléfono angosto: un dato por fila para que el código oculto no se salga de la tarjeta */
@media (max-width: 440px) {
  .datos {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aviso {
    transition: none;
  }
}
