/* ========== Shared theme tokens ========== */
:root {
  color-scheme: light;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --auth-surface: #ffffff;
  --auth-primary: var(--primary-color, #663399);
  --auth-primary-dark: var(--primary-color-darker, #52267a);
  --auth-primary-light: var(--primary-color-lighter, #8a5cb8);
  --auth-primary-soft: var(--primary-color-soft, rgba(102, 51, 153, 0.12));
  --auth-primary-rgb: var(--primary-rgb, 102, 51, 153);
  --auth-text: #0f172a;
  --auth-text-muted: #64748b;
  --auth-border: #e2e8f0;
  --auth-danger: #ef4444;
  --auth-danger-soft: rgba(239, 68, 68, 0.1);
  --auth-danger-border: rgba(239, 68, 68, 0.35);
  --auth-success: #16a34a;
  --auth-success-soft: rgba(22, 163, 74, 0.1);
  --auth-success-border: rgba(22, 163, 74, 0.35);
  --auth-page-bg: #f3f5fa;
}

/* ========== Login (marketing + card) ========== */
.auth-login {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100dvh;
  color: var(--auth-text);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  background-color: var(--auth-page-bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 12% -10%, rgba(var(--auth-primary-rgb), 0.12), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 110%, rgba(var(--auth-primary-rgb), 0.08), transparent 50%);
  overflow-x: hidden;
}

.auth-login *,
.auth-login *::before,
.auth-login *::after {
  box-sizing: border-box;
}

.auth-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
}

.auth-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  order: -1;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: auto;
  padding:
    max(1rem, env(safe-area-inset-top, 0px) + 1rem)
    max(0.85rem, env(safe-area-inset-right, 0px) + 0.85rem)
    0.75rem
    max(0.85rem, env(safe-area-inset-left, 0px) + 0.85rem);
}

/* ---------- Left: brand + features + preview ---------- */
.auth-marketing {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "copy"
    "preview"
    "stats";
  gap: 1.25rem;
  align-content: start;
  align-items: start;
  min-width: 0;
  min-height: auto;
  padding:
    0.5rem
    max(0.85rem, env(safe-area-inset-right, 0px) + 0.85rem)
    max(1.25rem, env(safe-area-inset-bottom, 0px) + 1.25rem)
    max(0.85rem, env(safe-area-inset-left, 0px) + 0.85rem);
}

.auth-marketing::before {
  content: "";
  position: absolute;
  inset: auto -8% -18% -12%;
  height: 55%;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(var(--auth-primary-rgb), 0.08), transparent 55%),
    repeating-linear-gradient(
      -12deg,
      transparent 0 18px,
      rgba(var(--auth-primary-rgb), 0.035) 18px 19px
    );
  pointer-events: none;
  z-index: 0;
  mask-image: linear-gradient(to top, black 20%, transparent 90%);
}

.marketing-copy {
  grid-area: copy;
  position: relative;
  z-index: 1;
  min-width: 0;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 1.75rem;
}

.brand-mark,
.panel-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--auth-primary);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1.15rem;
  flex: 0 0 auto;
  overflow: hidden;
  box-shadow: 0 8px 18px -10px rgba(var(--auth-primary-rgb), 0.7);
}

.brand-mark img,
.panel-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.hero-brand-name {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-page .hero-title {
  font-size: clamp(1.85rem, 3.4vw, 3.1rem);
  font-weight: 800;
  line-height: 1.18;
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
  color: #111827;
  overflow-wrap: anywhere;
}

.hero-title-accent {
  color: var(--auth-primary);
}

.auth-page .hero-subtitle {
  font-size: clamp(0.95rem, 1.15vw, 1.08rem);
  color: var(--auth-text-muted);
  line-height: 1.65;
  margin: 0 0 1.6rem;
  max-width: 42rem;
}

.hero-features {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem 1.25rem;
  max-width: 46rem;
}

.hero-features li {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--auth-text-muted);
}

.hero-features strong {
  display: block;
  color: #1e293b;
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 0.12rem;
}

.feature-ico,
.stat-ico {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--auth-primary-soft);
  color: var(--auth-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.feature-ico svg,
.stat-ico svg {
  width: 18px;
  height: 18px;
}

.dash-preview {
  grid-area: preview;
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
  justify-self: end;
}

.dash-window {
  background: #fff;
  border: 1px solid #e8ecf3;
  border-radius: 16px;
  box-shadow:
    0 24px 50px -28px rgba(15, 23, 42, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.8);
  display: grid;
  grid-template-columns: 42px 1fr;
  overflow: hidden;
  min-height: 250px;
  width: 100%;
}

.dash-sidebar {
  background: #f8f7fb;
  border-right: 1px solid #eef1f6;
  padding: 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dash-sidebar span:not(.dash-dot) {
  width: 18px;
  height: 4px;
  border-radius: 99px;
  background: #d8d6e5;
}

.dash-sidebar .dash-dot {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: var(--auth-primary);
  margin-bottom: 4px;
}

.dash-main {
  padding: 12px 12px 10px;
  display: grid;
  gap: 10px;
}

.dash-kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dash-kpis div,
.dash-chart,
.dash-lists > div {
  background: #f8fafc;
  border-radius: 10px;
  padding: 8px 10px;
}

.dash-kpis small,
.dash-chart small,
.dash-lists small {
  display: block;
  font-size: 0.62rem;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.dash-kpis strong {
  display: block;
  margin-top: 2px;
  font-size: 0.72rem;
  color: #0f172a;
}

.dash-chart svg {
  display: block;
  width: 100%;
  height: 58px;
  margin-top: 4px;
}

.dash-lists {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dash-lists span {
  display: block;
  height: 6px;
  border-radius: 99px;
  background: #e2e8f0;
  margin-top: 7px;
}

.dash-lists span:nth-child(2) { width: 88%; }
.dash-lists span:nth-child(3) { width: 64%; }
.dash-lists span:nth-child(4) { width: 76%; }

.hero-stats {
  grid-area: stats;
  position: relative;
  z-index: 1;
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0.9rem 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.75rem;
  border-top: 1px solid #e8ecf3;
}

.hero-stats li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--auth-text-muted);
}

.hero-stats strong {
  display: block;
  color: #1e293b;
  font-size: 0.82rem;
}

.stat-ico {
  width: 30px;
  height: 30px;
}

.stat-ico svg {
  width: 14px;
  height: 14px;
}

/* ---------- Login card ---------- */
.auth-panel-inner {
  background: var(--auth-surface);
  border-radius: 24px;
  width: 100%;
  max-width: 480px;
  min-width: 0;
  padding: clamp(1.35rem, 4vw, 2.6rem) clamp(1.1rem, 4vw, 2.4rem);
  box-shadow:
    0 24px 60px -28px rgba(15, 23, 42, 0.28),
    0 0 0 1px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  overflow: hidden;
}

.panel-mark {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 1.35rem;
  margin: 0 auto;
}

.auth-page .panel-title {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-align: center;
  margin: 0 0 0.3rem;
}

.auth-page .panel-subtitle {
  font-size: 0.88rem;
  color: var(--auth-text-muted);
  line-height: 1.5;
  text-align: center;
  margin: 0;
}

.auth-page .auth-panel-inner form {
  display: grid;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.auth-page .field {
  display: grid;
  gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.auth-page .field label {
  font-size: 0.8rem;
  font-weight: 600;
  color: #334155;
}

.auth-page .input-shell {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 48px;
  border: 1.5px solid var(--auth-border);
  border-radius: 12px;
  padding: 0 0.75rem;
  background: #fff;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.auth-page .input-shell:focus-within {
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 4px rgba(var(--auth-primary-rgb), 0.14);
}

.auth-page .input-addon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  flex: 0 0 auto;
}

.auth-page .input-shell:focus-within .input-addon {
  color: var(--auth-primary);
}

.auth-page .input-addon svg,
.auth-page .toggle-password svg {
  width: 19px;
  height: 19px;
}

.auth-page .input-shell input {
  flex: 1 1 0%;
  width: 0;
  min-width: 0;
  max-width: 100%;
  border: none;
  background: transparent;
  padding: 0.85rem 0;
  font-size: 1rem;
  color: var(--auth-text);
  font-family: inherit;
}

.auth-page .input-shell input::placeholder {
  color: #b6c0cf;
}

.auth-page .input-shell input:focus {
  outline: none;
}

.auth-page .toggle-password {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  padding: 0.35rem;
  min-width: 40px;
  min-height: 40px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}

.auth-page .toggle-password:hover,
.auth-page .toggle-password:focus-visible {
  color: var(--auth-primary);
  background: var(--auth-primary-soft);
  outline: none;
}

.auth-page .toggle-password .icon-eye-off {
  display: none;
}

.auth-page .toggle-password.is-visible .icon-eye {
  display: none;
}

.auth-page .toggle-password.is-visible .icon-eye-off {
  display: block;
}

.auth-page .form-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  font-size: 0.85rem;
  gap: 0.5rem;
}

.auth-page .remember {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 44px;
  color: #475569;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
}

.auth-page .remember input {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin: 0;
  border: 1.5px solid #cbd5e1;
  border-radius: 5px;
  background: #fff;
  display: grid;
  place-content: center;
  cursor: pointer;
  flex: 0 0 auto;
}

.auth-page .remember input::after {
  content: "";
  width: 9px;
  height: 5px;
  border: 2px solid #fff;
  border-top: 0;
  border-right: 0;
  transform: rotate(-45deg) scale(0);
  margin-top: -1px;
}

.auth-page .remember input:checked {
  background: var(--auth-primary);
  border-color: var(--auth-primary);
}

.auth-page .remember input:checked::after {
  transform: rotate(-45deg) scale(1);
}

.auth-page .remember input:focus-visible {
  outline: 2px solid var(--auth-primary);
  outline-offset: 2px;
}

.auth-page .auth-btn {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  min-height: 48px;
  padding: 0.95rem 1rem;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, var(--auth-primary), var(--auth-primary-dark));
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 14px 26px -12px rgba(var(--auth-primary-rgb), 0.7);
  transition: transform 0.12s ease, box-shadow 0.18s ease, opacity 0.15s ease;
}

.auth-page .auth-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px -12px rgba(var(--auth-primary-rgb), 0.8);
}

.auth-page .auth-btn:active {
  transform: translateY(0);
}

.auth-page .auth-btn:disabled {
  opacity: 0.75;
  cursor: not-allowed;
  transform: none;
}

.auth-page .auth-btn.auth-is-loading .btn-text {
  display: none;
}

.auth-page .auth-btn .btn-loading {
  display: none;
  align-items: center;
  gap: 0.4rem;
}

.auth-page .auth-btn.auth-is-loading .btn-loading {
  display: inline-flex;
}

.auth-page .auth-link {
  color: var(--auth-primary);
  text-decoration: none;
  font-weight: 600;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.auth-page .auth-link:hover {
  text-decoration: underline;
}

.panel-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0.15rem 0 0;
  font-size: 0.75rem;
  color: #94a3b8;
}

.panel-secure svg {
  width: 14px;
  height: 14px;
}

.auth-page .auth-alert {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid var(--auth-border);
  font-size: 0.9rem;
  line-height: 1.5;
  background: #fff;
  margin: 0;
}

.auth-page .auth-alert ul {
  margin: 0;
  padding-left: 1.1rem;
}

.auth-page .auth-alert.error {
  background: var(--auth-danger-soft);
  border-color: var(--auth-danger-border);
  color: #991b1b;
}

.auth-page .auth-alert.success {
  background: var(--auth-success-soft);
  border-color: var(--auth-success-border);
  color: #065f46;
}

.auth-page .spinner {
  width: 1.05rem;
  height: 1.05rem;
  border: 2.5px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: auth-spin 0.65s linear infinite;
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

@media (min-width: 1101px) {
  .auth-page {
    grid-template-columns: minmax(0, 1fr) minmax(0, 560px);
    min-height: 100dvh;
  }

  .auth-panel {
    order: 0;
    min-height: 100dvh;
    padding:
      clamp(1.5rem, 4vh, 3rem)
      max(1.25rem, env(safe-area-inset-right, 0px) + clamp(1.25rem, 4vw, 3.5rem))
      clamp(1.5rem, 4vh, 3rem)
      clamp(1rem, 2.5vw, 2rem);
  }

  .auth-marketing {
    min-height: 100dvh;
    grid-template-columns: minmax(0, 1.15fr) minmax(260px, 38%);
    grid-template-areas:
      "copy preview"
      "stats stats";
    gap: clamp(1.25rem, 2.5vw, 2.25rem) clamp(1.25rem, 3vw, 2.5rem);
    align-content: center;
    align-items: center;
    padding:
      clamp(1.75rem, 5vh, 4rem)
      clamp(1.5rem, 5vw, 5.5rem)
      clamp(1.5rem, 4vh, 3rem)
      max(1.25rem, env(safe-area-inset-left, 0px) + clamp(1.25rem, 5vw, 5.5rem));
  }
}

/* Tablet and down: form first, marketing content underneath */
@media (max-width: 1100px) {
  .auth-page {
    min-height: auto;
  }

  .auth-panel {
    min-height: auto;
    align-items: flex-start;
    padding:
      max(1.15rem, env(safe-area-inset-top, 0px) + 1.15rem)
      max(1rem, env(safe-area-inset-right, 0px) + 1rem)
      0.75rem
      max(1rem, env(safe-area-inset-left, 0px) + 1rem);
  }

  .auth-panel-inner {
    max-width: 520px;
    margin: 0 auto;
  }

  .auth-marketing {
    min-height: auto;
    grid-template-columns: 1fr;
    grid-template-areas:
      "copy"
      "preview"
      "stats";
    gap: 1.25rem;
    padding:
      0.5rem
      max(1rem, env(safe-area-inset-right, 0px) + 1rem)
      max(1.5rem, env(safe-area-inset-bottom, 0px) + 1.5rem)
      max(1rem, env(safe-area-inset-left, 0px) + 1rem);
  }

  .hero-brand {
    margin-bottom: 1rem;
  }

  .auth-page .hero-title {
    font-size: clamp(1.55rem, 5.5vw, 2.15rem);
  }

  .auth-page .hero-subtitle {
    margin-bottom: 1rem;
    max-width: none;
  }

  .hero-features {
    grid-template-columns: 1fr 1fr;
    max-width: none;
  }

  .dash-preview {
    max-width: 420px;
    justify-self: start;
  }

  .hero-stats {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .hero-features {
    grid-template-columns: 1fr;
  }

  .hero-stats {
    grid-template-columns: 1fr 1fr;
    gap: 0.85rem;
  }

  .dash-preview {
    max-width: none;
    justify-self: stretch;
  }

  .auth-panel-inner {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .auth-page .form-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.1rem;
  }

  .auth-panel {
    padding:
      max(0.9rem, env(safe-area-inset-top, 0px) + 0.9rem)
      max(0.75rem, env(safe-area-inset-right, 0px) + 0.75rem)
      0.5rem
      max(0.75rem, env(safe-area-inset-left, 0px) + 0.75rem);
  }

  .auth-panel-inner {
    border-radius: 18px;
    padding: 1.35rem 1.1rem;
    gap: 1rem;
  }

  .auth-marketing {
    padding:
      0.35rem
      max(0.75rem, env(safe-area-inset-right, 0px) + 0.75rem)
      max(1.25rem, env(safe-area-inset-bottom, 0px) + 1.25rem)
      max(0.75rem, env(safe-area-inset-left, 0px) + 0.75rem);
  }

  .auth-page .panel-title {
    font-size: 1.35rem;
  }

  .hero-stats {
    grid-template-columns: 1fr;
  }

  .hero-features li,
  .hero-stats li {
    font-size: 0.86rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-page .auth-btn,
  .auth-page .spinner {
    transition: none;
    animation: none;
  }
}

/* ========== Simple card screens (verify, passwords) ========== */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--auth-primary-soft), #f8f7fb);
  padding: 24px;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.auth-wrapper .auth-card {
  width: 100%;
  max-width: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  padding: 28px;
}

.auth-wrapper.auth-card-narrow .auth-card {
  max-width: 480px;
}

.auth-wrapper .auth-brand {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
}

.auth-wrapper .auth-brand img {
  max-height: 56px;
}

.auth-wrapper .auth-title {
  margin: 10px 0 2px 0;
  font-size: 22px;
  line-height: 1.2;
  text-align: center;
}

.auth-wrapper .auth-subtitle {
  margin: 0 0 18px 0;
  color: #6b7280;
  text-align: center;
  font-size: 14px;
}

.auth-wrapper .form-group {
  margin-bottom: 14px;
}

.auth-wrapper .form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 13px;
  color: #374151;
}

.auth-wrapper .auth-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.auth-wrapper .auth-input:focus {
  border-color: var(--auth-primary);
  box-shadow: 0 0 0 3px rgba(var(--auth-primary-rgb), 0.15);
}

.auth-wrapper .form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 16px 0;
}

.auth-wrapper .remember {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #374151;
  font-size: 13px;
}

.auth-wrapper .auth-link {
  font-size: 13px;
  color: var(--auth-primary);
  text-decoration: none;
}

.auth-wrapper .auth-link:hover {
  color: var(--auth-primary-dark);
  text-decoration: underline;
}

.auth-wrapper .auth-btn {
  width: 100%;
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  background: var(--auth-primary);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s;
}

.auth-wrapper .auth-btn:hover {
  background: var(--auth-primary-dark);
}

.auth-wrapper .auth-alert {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-wrapper .auth-alert.success {
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.auth-wrapper .auth-alert.error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.auth-wrapper .auth-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.auth-wrapper .auth-actions--center {
  justify-content: center;
  margin-top: 10px;
}
