/*
 * Portal auth - carbon + oro (misma linea que axions.es / dashboard)
 */
.portal-auth-body {
  --auth-ink: var(--text-primary, #0b1220);
  --auth-gold: var(--ax-brand, #b89b6a);
  --auth-gold-hover: var(--ax-brand-hover, #a88f4a);
  --auth-muted: rgba(255, 255, 255, 0.58);
  --auth-line: rgba(255, 255, 255, 0.12);
  --auth-paper: #0b1220;
  margin: 0;
  min-height: 100dvh;
  font-family: var(--ax-font-sans, "Plus Jakarta Sans", system-ui, sans-serif);
  color: #fff;
  background:
    radial-gradient(ellipse 80% 55% at 70% 0%, rgba(184, 155, 106, 0.16), transparent 55%),
    radial-gradient(ellipse 50% 40% at 10% 90%, rgba(61, 143, 209, 0.08), transparent 50%),
    linear-gradient(165deg, #06080d 0%, #0b1220 55%, #0b1220 100%);
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

/* Continuidad void → portal (sin fade a papel crema) */
.portal-auth-body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3.5rem;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(6, 8, 13, 0.35) 100%
  );
  pointer-events: none;
  z-index: 0;
}

.portal-auth-shell {
  position: relative;
  z-index: 1;
  max-width: 420px;
  margin: 0 auto;
  padding: max(2rem, env(safe-area-inset-top)) max(1.15rem, env(safe-area-inset-right)) max(2.5rem, env(safe-area-inset-bottom)) max(1.15rem, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  justify-content: center;
  gap: 0;
}

.portal-auth-brand {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  width: 100%;
  margin-bottom: clamp(1rem, 2.5vh, 1.65rem);
  line-height: 0;
  text-decoration: none;
  gap: 0.65rem;
  color: #e8d5a3;
}

a.portal-auth-brand:link,
a.portal-auth-brand:visited,
a.portal-auth-brand:hover,
a.portal-auth-brand:active,
a.portal-auth-brand:focus-visible {
  color: #e8d5a3;
}

/* Mark nítido, tamaño contenido (sin fatiga visual) */
.portal-auth-brand .ax-auth-mark {
  display: block;
  width: min(100%, 8.75rem);
  height: auto;
  max-height: min(10.5rem, 28vh);
  margin-inline: auto;
  object-fit: contain;
  object-position: center;
  filter: none;
}

.portal-auth-brand__word {
  display: block;
  margin: 0;
  padding: 0;
  color: #e8d5a3;
  line-height: 0;
  text-shadow: none;
}

.portal-auth-brand__word.ax-wordmark,
.portal-auth-brand .ax-wordmark--auth .ax-wordmark__svg {
  color: #e8d5a3;
}

.portal-auth-brand .ax-wordmark--auth .ax-wordmark__svg {
  height: 1.05rem;
}

.portal-auth-card {
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--auth-line);
  border-radius: var(--ax-radius-card, 0.5rem);
  padding: 1.75rem 1.4rem 1.6rem;
  box-shadow: none;
  backdrop-filter: blur(8px);
}

.portal-auth-card--wide { max-width: 100%; }

.portal-auth-card h1 {
  margin: 0 0 0.5rem;
  font-family: var(--ax-font-display, "Fraunces", Georgia, serif);
  font-size: clamp(1.75rem, 5vw, 2.2rem);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: #fff;
  line-height: 1.12;
}

.portal-auth-lead--muted {
  margin-top: -0.35rem;
  font-size: 0.82rem;
  color: #78716c;
}

.portal-auth-lead {
  margin: 0 0 1.35rem;
  color: var(--auth-muted);
  font-size: 0.9375rem;
  line-height: 1.55;
}

.portal-auth-lead strong {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
}

.portal-auth-lead a {
  color: rgba(255, 255, 255, 0.9);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.portal-auth-lead a:hover {
  color: var(--auth-gold);
}

.portal-auth-form label {
  display: block;
  margin-bottom: 1rem;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.42);
}

.portal-auth-form input[type="email"],
.portal-auth-form input[type="password"],
.portal-auth-form input[type="text"],
.portal-auth-form .portal-input {
  display: block;
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.9rem 1rem;
  border: 1px solid var(--auth-line);
  border-radius: var(--ax-radius-btn, 0.35rem);
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
  color: #fff;
  background: rgba(0, 0, 0, 0.35);
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
  outline: none;
  transition: border-color 0.2s ease;
}

.portal-auth-form input::placeholder {
  color: rgba(255, 255, 255, 0.28);
}

.portal-auth-form input:focus {
  border-color: rgba(255, 255, 255, 0.35);
  outline: none !important;
}

.portal-auth-form input:focus-visible {
  border-color: color-mix(in srgb, var(--auth-gold) 50%, rgba(255, 255, 255, 0.4));
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--auth-gold) 32%, transparent);
  outline: none !important;
}

.portal-auth-btn {
  display: block;
  width: 100%;
  margin-top: 0.65rem;
  padding: 0.95rem 1rem;
  min-height: 48px;
  border: 1px solid var(--auth-gold);
  border-radius: var(--ax-radius-btn, 0.35rem);
  background: var(--auth-gold);
  color: #0b1220;
  font-family: inherit;
  font-weight: 600;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.portal-auth-btn:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 3px;
}

.portal-auth-btn:hover {
  background: var(--auth-gold-hover);
  border-color: var(--auth-gold-hover);
  color: #0b1220;
}

.portal-auth-btn:disabled,
.portal-auth-btn.is-loading {
  opacity: 0.65;
  cursor: wait;
}

.portal-auth-btn.is-loading {
  position: relative;
  pointer-events: none;
}

.portal-btn-spinner {
  display: inline-block;
  width: 0.95rem;
  height: 0.95rem;
  margin-right: 0.45rem;
  vertical-align: -0.15em;
  border: 2px solid rgba(11, 18, 32, 0.22);
  border-top-color: #0b1220;
  border-radius: 999px;
  animation: portal-auth-spin 0.7s linear infinite;
}

@keyframes portal-auth-spin {
  to { transform: rotate(360deg); }
}

.portal-field-error {
  display: block;
  margin: 0.35rem 0 0;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #fecaca;
  line-height: 1.35;
}

.portal-auth-form label:has(.portal-field-error) input,
.portal-auth-form input[aria-invalid="true"] {
  border-color: rgba(248, 113, 113, 0.55);
}

.portal-auth-btn--inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  padding-left: 1.5rem;
  padding-right: 1.5rem;
  text-decoration: none;
  text-align: center;
}

.portal-auth-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--ax-radius-btn, 0.35rem);
  font-size: 0.875rem;
  margin-bottom: 1rem;
  line-height: 1.45;
}

.portal-auth-alert--error {
  background: rgba(248, 113, 113, 0.12);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.28);
}

.portal-auth-alert--ok {
  background: rgba(52, 211, 153, 0.12);
  color: #a7f3d0;
  border: 1px solid rgba(52, 211, 153, 0.28);
}

.portal-auth-links {
  font-size: 0.875rem;
  text-align: center;
  margin-top: 1.35rem;
  line-height: 1.9;
  color: var(--auth-muted);
}

.portal-auth-links a {
  color: rgba(255, 255, 255, 0.82);
  text-decoration: none;
  font-weight: 500;
}

.portal-auth-links a:hover {
  color: #fff;
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.portal-auth-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.75rem;
  text-align: center;
  font-size: 0.8125rem;
  margin-top: 1.75rem;
  color: rgba(255, 255, 255, 0.38);
}

.portal-auth-foot a {
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.62);
  text-decoration: none;
}

.portal-auth-foot a:hover {
  color: #fff;
}

.portal-modules-pick {
  border: 1px solid var(--auth-line);
  border-radius: var(--ax-radius-card, 0.5rem);
  padding: 1rem;
  margin-bottom: 1rem;
  background: rgba(0, 0, 0, 0.2);
}

.portal-module-check,
.portal-terms-check {
  display: flex;
  gap: 0.65rem;
  align-items: flex-start;
  font-weight: 400;
  margin-bottom: 0.65rem;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.75);
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.875rem;
}

.portal-terms-check input[type="checkbox"] {
  width: 1.15rem;
  height: 1.15rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
  accent-color: var(--auth-gold);
}

.portal-terms-check a {
  color: rgba(255, 255, 255, 0.9);
  text-decoration: underline;
  text-underline-offset: 0.15em;
}

.portal-terms-text {
  font-size: 0.9rem;
  color: var(--auth-muted);
  line-height: 1.6;
  margin-bottom: 1.25rem;
}

@media (max-width: 640px) {
  .portal-auth-shell {
    padding-left: max(1rem, env(safe-area-inset-left));
    padding-right: max(1rem, env(safe-area-inset-right));
  }

  .portal-auth-card {
    padding: 1.45rem 1.15rem 1.35rem;
  }

  .portal-auth-card h1 {
    font-size: clamp(1.55rem, 7vw, 1.85rem);
  }

  .portal-auth-brand {
    margin-bottom: 1.15rem;
    gap: 0.55rem;
  }

  .portal-auth-brand .ax-auth-mark {
    width: min(42vw, 7.75rem);
    max-height: min(9.5rem, 26vh);
  }

  .portal-auth-brand .ax-wordmark--auth .ax-wordmark__svg {
    height: 0.98rem;
  }
}

/* Shell legacy (upgrade / tier_gate cards) */
.portal-dash-body {
  margin: 0;
  background: var(--bg-page, #faf6f1);
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: var(--ax-font-body, "Plus Jakarta Sans", system-ui, sans-serif);
  color: var(--text-primary, #0b1220);
}

.portal-dash-top {
  display: flex;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: max(0.875rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) 0.875rem max(1rem, env(safe-area-inset-left));
  background: #fff;
  border-bottom: 1px solid rgba(18, 18, 18, 0.08);
  position: sticky;
  top: 0;
  z-index: 10;
}

.portal-dash-logout {
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 0.45rem 0.65rem;
  border: 1px solid var(--border, #e4dfd4);
  border-radius: var(--ax-radius-btn, 0.35rem);
  text-decoration: none;
  color: inherit;
}

.portal-dash-main {
  padding: 1.25rem max(1rem, env(safe-area-inset-right)) max(2rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  max-width: 960px;
  margin: 0 auto;
}

.portal-dash-main h1 {
  font-family: var(--ax-font-display, "Fraunces", Georgia, serif);
  font-size: clamp(1.35rem, 5vw, 1.75rem);
  margin: 0 0 0.5rem;
  line-height: 1.2;
  font-weight: 600;
}

.portal-dash-sub { color: var(--text-muted); margin-top: 0; font-size: 0.95rem; }

.portal-dash-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-top: 1rem;
}

.portal-dash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 112px;
  min-width: 0;
  padding: 1rem 0.65rem;
  background: #fff;
  border: 1px solid var(--border, #e4dfd4);
  border-radius: var(--ax-radius-card, 0.5rem);
  text-decoration: none;
  color: inherit;
  font-weight: 600;
  font-size: 0.82rem;
  text-align: center;
  line-height: 1.3;
}

.portal-dash-card svg,
.portal-dash-card i {
  width: 1.5rem;
  height: 1.5rem;
  color: var(--ax-brand, #b89b6a);
}

.portal-dash-card--locked {
  border-color: color-mix(in srgb, var(--ax-brand, #b89b6a) 35%, #e7e5e4);
  background: color-mix(in srgb, var(--ax-brand, #b89b6a) 6%, #fff);
  position: relative;
}

.portal-dash-card--contract {
  border-style: dashed;
}

.portal-dash-card small {
  font-size: 0.65rem;
  font-weight: 500;
  color: #5c564c;
}

@media (min-width: 768px) {
  .portal-dash-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
  }
}

/* Auth last — anula sombra/blur de axions-premium-v10 */
.portal-auth-body .portal-auth-card {
  background: rgba(18, 24, 38, 0.72) !important;
  border: 1px solid rgba(255, 255, 255, 0.1) !important;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35) !important;
  backdrop-filter: blur(10px) !important;
  -webkit-backdrop-filter: blur(10px) !important;
}

/* PWA install: pie discreto — no compite con la tarjeta de login */
@media (max-width: 719px) {
  .portal-auth-body .axions-home-install {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: auto;
    z-index: 40;
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom));
    background: rgba(6, 8, 13, 0.92);
    color: #e2e8f0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    border-bottom: 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    grid-template-columns: auto minmax(0, 1fr) auto;
    grid-template-areas: "mark copy actions";
    column-gap: 0.5rem;
    row-gap: 0;
    align-items: center;
  }

  .portal-auth-body .axions-home-install__mark {
    width: 1.85rem;
    height: 1.85rem;
    border-radius: 0.5rem;
  }

  .portal-auth-body .axions-home-install__title {
    font-size: 0.78rem;
    font-weight: 650;
    color: #f1f5f9;
    padding-right: 1.1rem;
  }

  .portal-auth-body .axions-home-install__lead {
    display: none;
  }

  .portal-auth-body .axions-home-install__x {
    position: absolute;
    top: 0.3rem;
    right: 0.4rem;
    grid-area: unset;
    font-size: 1.15rem;
    color: #94a3b8;
  }

  .portal-auth-body .axions-home-install__actions {
    grid-area: actions;
    width: auto;
    flex-wrap: nowrap;
    gap: 0.35rem;
  }

  .portal-auth-body .axions-home-install__cta,
  .portal-auth-body .axions-home-install__chrome {
    flex: 0 0 auto;
    padding: 0.45rem 0.6rem;
    font-size: 0.68rem;
    border-radius: 0.55rem;
    box-shadow: none;
  }

  .portal-auth-body .axions-home-install__chrome {
    background: rgba(255, 255, 255, 0.06);
    color: #dbeafe;
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .portal-auth-body .portal-auth-shell {
    padding-bottom: calc(4.5rem + env(safe-area-inset-bottom));
  }
}
