/* Auth owns its foreground, surface and controls independently of the app shell.
   The light gate remains legible even when the operating system uses dark mode. */
.auth-dialog {
  --auth-text: #14263a;
  --auth-muted: #4c6277;
  --auth-accent: #0f725a;
  --auth-field-surface: #f7fafc;
  --auth-field-border: #9eb4c6;
  --auth-focus: #139a66;
  --auth-primary-from: #139a66;
  --auth-primary-to: #0f8156;
  --auth-gate-bg: #f3f7f5;
  --auth-gate-card: #ffffff;
  --auth-line: #dbe6e8;
  --auth-aura-one: rgb(73 226 170 / 12%);
  --auth-aura-two: rgb(19 154 102 / 10%);
  color-scheme: light;
  color: var(--auth-text);
  background: var(--auth-gate-card);
}

.auth-card {
  display: grid;
  gap: 0.65rem;
}

.auth-identity {
  overflow-wrap: anywhere;
}

.auth-launch {
  width: 100%;
}

.auth-dialog {
  width: min(94vw, 560px);
  max-height: min(88vh, 760px);
  padding: 0;
  border: 0;
  border-radius: 18px;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.28);
}

.auth-dialog::backdrop {
  background: rgb(16 24 40 / 0.58);
}

.auth-dialog-shell {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--auth-gate-card);
  color: var(--auth-text);
}

.auth-dialog-header,
.auth-account-summary,
.auth-factor-row,
.auth-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.auth-dialog-heading-wrap {
  display: grid;
  gap: 0.28rem;
  min-width: 0;
}

.auth-brand-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.7rem;
}

.auth-brand-mark {
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgb(19 154 102 / 0.18);
}

.auth-brand-copy strong,
.auth-brand-copy span {
  display: block;
}

.auth-brand-copy strong {
  color: var(--auth-text);
  font-size: 1.14rem;
  letter-spacing: 0.06em;
}

.auth-brand-copy span {
  margin-top: 0.1rem;
  color: var(--auth-muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.auth-eyebrow {
  color: var(--auth-accent);
  letter-spacing: 0.14em;
}

.auth-dialog-header h2 {
  margin: 0.2rem 0 0;
}

.auth-dialog-body,
.auth-form,
.auth-enrollment,
.auth-factor-list,
.auth-secret-box,
.auth-loading {
  display: grid;
  gap: 0.85rem;
}

.auth-login-copy {
  margin-top: 0;
  line-height: 1.55;
}

.auth-field {
  display: grid;
  gap: 0.35rem;
  font-weight: 600;
}

.auth-field input,
.auth-field select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--auth-field-border);
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
  background: var(--auth-field-surface);
  color: var(--auth-text);
  caret-color: var(--auth-focus);
  font: inherit;
}

.auth-field input::placeholder {
  color: var(--auth-muted);
  opacity: 1;
}

.auth-field input:focus,
.auth-field select:focus {
  outline: 3px solid color-mix(in srgb, var(--auth-focus) 35%, transparent);
  outline-offset: 2px;
  border-color: var(--auth-focus);
}

/* Browser/password-manager autofill must not reintroduce invisible text. */
.auth-field input:-webkit-autofill,
.auth-field input:-webkit-autofill:hover,
.auth-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--auth-text);
  -webkit-box-shadow: 0 0 0 1000px var(--auth-field-surface) inset;
  caret-color: var(--auth-focus);
}

.auth-dialog-body .button-primary {
  border-color: var(--auth-primary-to);
  background: linear-gradient(135deg, var(--auth-primary-from), var(--auth-primary-to));
  color: #ffffff;
  box-shadow: 0 9px 22px rgb(19 154 102 / 0.16);
}

.auth-qr {
  width: min(100%, 280px);
  aspect-ratio: 1;
  justify-self: center;
  object-fit: contain;
  background: #fff;
  border: 1px solid rgb(0 0 0 / 0.08);
  border-radius: 12px;
  padding: 0.75rem;
}

.auth-secret-box {
  padding: 0.8rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--auth-accent) 11%, var(--auth-gate-card));
  border: 1px solid var(--auth-line);
}

.auth-secret-box code {
  user-select: all;
  overflow-wrap: anywhere;
  font-size: 0.94rem;
}

.auth-factor-row {
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--auth-line);
}

.auth-factor-row > div {
  display: grid;
  gap: 0.15rem;
}

.auth-actions {
  flex-wrap: wrap;
  justify-content: flex-start;
}

.auth-status:empty {
  display: none;
}

.auth-dialog-gate {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  border-radius: 0;
  overflow: auto;
  background:
    radial-gradient(circle at 18% 14%, var(--auth-aura-one), transparent 32rem),
    radial-gradient(circle at 84% 84%, var(--auth-aura-two), transparent 34rem),
    var(--auth-gate-bg);
  box-shadow: none;
}

.auth-dialog-gate::backdrop {
  background: var(--auth-gate-bg);
}

.auth-dialog-gate .auth-dialog-shell {
  width: min(460px, calc(100vw - 32px));
  box-sizing: border-box;
  margin: max(28px, 8vh) auto;
  padding: 30px;
  border: 1px solid var(--auth-line);
  border-radius: 22px;
  background: var(--auth-gate-card);
  box-shadow: 0 24px 70px rgb(15 44 34 / 0.13);
}

.auth-dialog-gate .auth-dialog-header {
  align-items: flex-start;
}

.auth-dialog-gate .auth-dialog-header h2 {
  margin: 0.15rem 0 0;
  color: var(--auth-text);
  font-size: clamp(1.8rem, 5vw, 2.25rem);
  line-height: 1.08;
}

.auth-dialog-gate .auth-close {
  display: none;
}

.auth-dialog-gate .auth-form {
  gap: 0.9rem;
}

.auth-dialog-gate .auth-form > .button,
.auth-dialog-gate .auth-dialog-body > .button {
  width: 100%;
  min-height: 44px;
}

.auth-dialog-gate .auth-status {
  margin: 0;
  border-radius: 10px;
}

html.artemis-auth-gated,
html.artemis-auth-gated body {
  overflow: hidden;
}

@media (max-width: 520px) {
  .auth-dialog-shell {
    padding: 1rem;
  }

  .auth-account-summary,
  .auth-factor-row {
    align-items: stretch;
    flex-direction: column;
  }

  .auth-dialog-gate .auth-dialog-shell {
    width: min(100% - 24px, 460px);
    margin: 12px auto;
    padding: 22px;
    border-radius: 18px;
  }

  .auth-brand-mark {
    width: 44px;
    height: 44px;
  }
}

/* Deep navy Auth + MFA palette: consistent in gated and non-gated dialogs. */
/* The Auth top-layer tracks the same explicit theme. */
html[data-theme="dark"] .auth-dialog {
    --auth-text: #f4f8ff;
    --auth-muted: #b9cce6;
    --auth-accent: #9bc9ff;
    --auth-field-surface: #091b33;
    --auth-field-border: #637fa4;
    --auth-focus: #91c4ff;
    --auth-primary-from: #286abd;
    --auth-primary-to: #194c98;
    --auth-gate-bg: #061225;
    --auth-gate-card: #10223d;
    --auth-line: #3d5678;
    --auth-aura-one: rgb(66 135 238 / 22%);
    --auth-aura-two: rgb(35 89 179 / 18%);
    color-scheme: dark;
  }

html[data-theme="dark"] .auth-dialog-gate .auth-dialog-shell {
    box-shadow: 0 24px 80px rgb(0 4 15 / 47%);
  }

html[data-theme="dark"] .auth-brand-mark {
    box-shadow: 0 10px 28px rgb(32 93 190 / 26%);
  }

html[data-theme="dark"] .auth-dialog-body .button-primary {
    box-shadow: 0 9px 25px rgb(12 62 142 / 34%);
  }

html[data-theme="dark"] .auth-dialog .auth-close,
html[data-theme="dark"] .auth-dialog .button:not(.button-primary) {
    color: var(--auth-text);
    border-color: var(--auth-line);
  }

html[data-theme="dark"] .auth-dialog .auth-close {
    background: #192f50;
  }

html[data-theme="dark"] .auth-dialog .muted-copy,
html[data-theme="dark"] .auth-dialog .auth-login-copy {
    color: var(--auth-muted);
  }

html[data-theme="dark"] .auth-dialog-gate .auth-status {
    color: var(--auth-muted);
  }

  /* Keep the actual QR image light for reliable authenticator scanning. */
html[data-theme="dark"] .auth-qr {
    border-color: var(--auth-line);
  }
