/* Shared authentication and first-run surfaces. */
*,
*::before,
*::after {
  box-sizing: border-box;
}

body.auth-body {
  min-height: 100dvh;
  margin: 0;
  padding: clamp(16px, 4vw, 48px);
  display: grid;
  place-items: center;
  overflow-x: hidden;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

.auth-shell {
  width: min(100%, 1040px);
  min-height: min(720px, calc(100dvh - 64px));
  display: grid;
  grid-template-columns: minmax(290px, 0.82fr) minmax(420px, 1.18fr);
  overflow: hidden;
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background: var(--bg-card);
  box-shadow: var(--shadow-modal);
}

.auth-context {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  padding: clamp(28px, 4vw, 52px);
  background: #171a1f;
  color: #ffffff;
}

.auth-context::after {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
}

.auth-brand,
.auth-brand-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.auth-brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 1rem;
}

.auth-brand-name {
  min-width: 0;
  color: inherit;
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}

.auth-context-copy {
  max-width: 350px;
}

.auth-context-copy h1 {
  margin: 0 0 14px;
  color: #ffffff;
  font-size: clamp(1.65rem, 3vw, 2.35rem);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: 0;
}

.auth-context-copy p {
  margin: 0;
  color: #cbd1da;
  font-size: 0.92rem;
  line-height: 1.65;
}

.auth-trust-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 20px;
  color: #aeb7c3;
  font-size: 0.76rem;
}

.auth-trust-row span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.auth-trust-row i {
  color: #86efac;
}

.auth-panel {
  position: relative;
  display: grid;
  align-items: center;
  padding: clamp(30px, 5vw, 64px);
  background: var(--bg-card);
}

.auth-form-wrap {
  width: min(100%, 440px);
  margin: 0 auto;
}

.auth-brand-inline {
  display: none;
  margin-bottom: 28px;
  color: var(--text-primary);
}

.auth-heading {
  margin: 0 0 6px;
  color: var(--text-primary);
  font-size: 1.45rem;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: 0;
}

.auth-subtitle {
  margin: 0 0 26px;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.5;
}

.auth-label {
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
}

.auth-control {
  min-height: 44px;
  border: 1px solid var(--border-input);
  border-radius: 7px;
  background: var(--bg-input);
  color: var(--text-primary);
  padding: 10px 12px;
}

.auth-control:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px var(--accent-soft);
  background: var(--bg-input-focus);
  color: var(--text-primary);
}

.auth-control::placeholder {
  color: var(--text-muted);
}

.auth-password {
  position: relative;
}

.auth-password .auth-control {
  padding-right: 46px;
}

.auth-icon-button {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 34px;
  height: 34px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
}

.auth-icon-button:hover,
.auth-icon-button:focus-visible {
  background: var(--accent-soft);
  color: var(--accent);
  outline: 0;
}

.auth-check {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 2px 0 20px;
  color: var(--text-secondary);
  font-size: 0.8rem;
}

.auth-check input {
  width: 17px;
  height: 17px;
  margin: 0;
  accent-color: var(--accent);
}

.auth-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  font-size: 0.8rem;
}

.auth-links a,
.auth-back-link {
  color: var(--accent);
  text-decoration: none;
}

.auth-links a:hover,
.auth-back-link:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.auth-primary,
.auth-secondary {
  width: 100%;
  min-height: 44px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  border-radius: 7px;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
}

.auth-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.auth-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: #ffffff;
}

.auth-secondary {
  border: 1px solid var(--border-input);
  background: var(--bg-card);
  color: var(--text-primary);
}

.auth-secondary:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  height: 1px;
  flex: 1;
  background: var(--border-card);
}

.auth-status {
  min-height: 36px;
  margin-top: 9px;
  color: var(--text-muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.auth-actions {
  display: grid;
  gap: 10px;
}

.auth-install-link {
  min-height: 42px;
}

.auth-version {
  margin-top: 22px;
  color: var(--text-muted);
  font-size: 0.66rem;
  text-align: center;
}

.auth-alert {
  margin-bottom: 18px;
  padding: 11px 12px;
  border: 1px solid var(--border-card);
  border-radius: 7px;
  background: var(--bg-table-stripe);
  color: var(--text-secondary);
  font-size: 0.82rem;
  line-height: 1.45;
}

.auth-alert.is-error {
  border-color: color-mix(in srgb, var(--kpi-negative) 32%, var(--border-card));
  background: var(--kpi-negative-bg);
  color: var(--badge-unpaid-text);
}

.auth-theme-toggle {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 10;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-card);
  border-radius: 7px;
  background: var(--bg-card);
  color: var(--text-secondary);
  box-shadow: var(--shadow-card);
}

.auth-theme-toggle:hover,
.auth-theme-toggle:focus-visible {
  border-color: var(--accent);
  color: var(--accent);
  outline: 0;
}

.auth-back-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 18px;
  font-size: 0.82rem;
}

textarea.auth-control {
  min-height: 92px;
  resize: vertical;
}


/* Compact security steps: reset, activation, 2FA, and device approval. */
body.auth-body.auth-compact-page {
  padding: clamp(16px, 4vw, 40px);
}

.auth-compact-page .auth-card,
.auth-compact-page .card-box {
  width: min(100%, 460px);
  padding: clamp(24px, 5vw, 38px);
  border: 1px solid var(--border-card);
  border-radius: 8px;
  background: var(--bg-card);
  color: var(--text-primary);
  box-shadow: var(--shadow-modal);
}

.auth-compact-page .auth-card > .d-flex:first-child > i {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--border-card));
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 1.05rem;
}

.auth-compact-page .auth-card > .d-flex:first-child .fw-bold {
  color: var(--text-primary);
  font-size: 1.12rem;
  line-height: 1.3;
}

.auth-compact-page .form-label {
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: .78rem;
  font-weight: 700;
}

.auth-compact-page .form-control {
  min-height: 44px;
  border: 1px solid var(--border-input);
  border-radius: 7px;
  background: var(--bg-input);
  color: var(--text-primary);
  padding: 10px 12px;
  letter-spacing: 0;
}

.auth-compact-page input[name="code"] {
  min-height: 58px;
  border-width: 2px;
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  text-align: center;
  caret-color: var(--accent);
  background: var(--bg-input-focus);
  color: var(--text-primary);
  text-shadow: none;
}

.auth-compact-page input[name="code"]::selection {
  background: var(--accent);
  color: #ffffff;
}

.auth-compact-page input[name="code"]::placeholder {
  color: var(--text-muted);
  opacity: .62;
}

.auth-compact-page .form-control:focus {
  border-color: var(--accent);
  outline: 0;
  background: var(--bg-input-focus);
  color: var(--text-primary);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.auth-compact-page .btn {
  min-height: 44px;
  border-radius: 7px;
  font-size: .86rem;
  font-weight: 700;
}

.auth-compact-page .text-muted {
  color: var(--text-muted);
}

.auth-compact-page .alert {
  border-radius: 7px;
  font-size: .82rem;
}

.auth-compact-page .device-box,
.auth-compact-page .resend-box {
  padding: 13px;
  border: 1px solid var(--border-card);
  border-radius: 7px;
  background: var(--bg-table-stripe);
}

.auth-compact-page .device-box {
  margin-bottom: 16px;
}

.auth-compact-page .resend-box {
  margin-top: 14px;
}

.auth-compact-page .card-box {
  text-align: center;
}

.auth-compact-page .card-box dl {
  border-color: var(--border-card);
  border-radius: 7px;
  background: var(--bg-table-stripe);
}

.auth-compact-page code {
  overflow-wrap: anywhere;
}

@media (max-width: 540px) {
  body.auth-body.auth-compact-page {
    padding: 0;
  }

  .auth-compact-page .auth-card,
  .auth-compact-page .card-box {
    width: 100%;
    min-height: 100dvh;
    padding: max(72px, env(safe-area-inset-top)) 20px max(30px, env(safe-area-inset-bottom));
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (max-width: 840px) {
  body.auth-body {
    padding: 0;
    place-items: stretch;
  }

  .auth-shell {
    width: 100%;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-context {
    display: none;
  }

  .auth-panel {
    min-height: 100dvh;
    padding: max(28px, env(safe-area-inset-top)) 20px max(32px, env(safe-area-inset-bottom));
  }

  .auth-brand-inline {
    display: flex;
  }

  .auth-form-wrap {
    max-width: 500px;
  }
}

@media (max-width: 420px) {
  .auth-panel {
    align-items: start;
    padding-top: max(30px, env(safe-area-inset-top));
  }

  .auth-links {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .auth-heading {
    font-size: 1.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-primary,
  .auth-secondary,
  .auth-icon-button,
  .auth-theme-toggle {
    transition: none;
  }
}
