:root {
  --page-bg: #f6f7fa;
  --page-shadow: rgba(44, 57, 79, 0.12);
  --surface: #ffffff;
  --surface-subtle: #f6f8fb;
  --surface-muted: #edf1f6;
  --text: #17223a;
  --text-muted: #55657f;
  --text-soft: #6e7c92;
  --line: #ccd5e2;
  --line-strong: #b6c2d3;
  --brand: #1c2740;
  --brand-strong: #121b2d;
  --danger: #8f3a35;
  --success: #235843;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 18% 42%, rgba(145, 167, 199, 0.16), transparent 32%),
    radial-gradient(circle at 82% 58%, rgba(155, 172, 197, 0.18), transparent 26%),
    linear-gradient(180deg, #f7f8fb 0%, #f2f4f8 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at center, transparent 48%, rgba(255, 255, 255, 0.75) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.3), rgba(214, 222, 233, 0.08));
}

button,
input {
  font: inherit;
}

h1,
h2 {
  margin: 0;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  letter-spacing: -0.04em;
}

.auth-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  max-width: 1240px;
  margin: 0 auto;
  padding: 44px 32px 34px;
  display: flex;
  align-items: center;
}

.auth-layout {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(320px, 1.05fr) minmax(420px, 500px);
  gap: 72px;
  align-items: center;
}

.auth-brand {
  min-height: 640px;
  padding: 18px 8px 18px 10px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-brand__content {
  display: grid;
  gap: 92px;
  align-content: center;
}

.auth-brand__logo {
  display: inline-block;
  text-decoration: none;
}

.auth-brand__logo img {
  display: block;
  width: min(100%, 270px);
  height: auto;
}

.auth-brand__copy {
  max-width: 500px;
}

.auth-brand__copy h2 {
  max-width: 460px;
  font-size: clamp(3.3rem, 6vw, 4.85rem);
  font-weight: 500;
  line-height: 0.98;
}

.auth-brand__copy p,
.auth-brand__panel p {
  margin: 24px 0 0;
  max-width: 470px;
  color: var(--text-muted);
  font-size: 1.08rem;
  line-height: 1.72;
}

.auth-brand__panel {
  display: none;
}

.auth-brand__admin-link {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.auth-brand__pill,
.auth-badge {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid #d5dce7;
  border-radius: 2px;
  background: var(--surface-subtle);
  color: #43516a;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.auth-brand__pill {
  display: none;
}

.auth-panel {
  display: flex;
  justify-content: flex-end;
}

.auth-card {
  width: 100%;
  padding: 38px 38px 34px;
  border: 1px solid rgba(208, 216, 226, 0.96);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 26px 62px var(--page-shadow);
}

.auth-card__header {
  margin-bottom: 28px;
}

.auth-card__header h1 {
  margin-top: 18px;
  font-size: clamp(2.65rem, 5vw, 3.6rem);
  font-weight: 600;
  line-height: 0.98;
  color: var(--text);
}

.auth-card__header p {
  margin: 16px 0 0;
  color: var(--text-muted);
  font-size: 1.02rem;
  line-height: 1.72;
}

.auth-form {
  display: grid;
  gap: 18px;
}

.form-group {
  display: grid;
  gap: 10px;
}

.auth-label {
  color: #33415c;
  font-size: 0.98rem;
  font-weight: 700;
}

.auth-input {
  display: flex;
  align-items: center;
  min-height: 58px;
  border: 1px solid var(--line);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.auth-input:focus-within {
  border-color: #72829b;
  box-shadow: 0 0 0 3px rgba(110, 124, 146, 0.14);
}

.auth-input__icon {
  flex: 0 0 46px;
  align-self: stretch;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid #dbe2ec;
  background: #f8fafe;
  color: var(--text-soft);
}

.auth-input__icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.auth-input--iconless .form-control {
  padding-left: 16px;
}

.form-control {
  width: 100%;
  min-height: 56px;
  padding: 0 16px;
  border: 0;
  background: #fffef9;
  color: var(--text);
  outline: 0;
}

.auth-input--with-action .form-control {
  padding-right: 12px;
}

.auth-input__action {
  align-self: stretch;
  padding: 0 18px;
  border: 0;
  border-left: 1px solid #dbe2ec;
  background: var(--surface-subtle);
  color: #3d4c65;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.auth-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 14px;
  flex-wrap: wrap;
}

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

.auth-checkbox {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.96rem;
}

.auth-checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--brand);
}

.auth-link {
  border: 0;
  padding: 0;
  background: transparent;
  color: #495a76;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
}

.auth-link:hover,
.auth-link:focus-visible,
.auth-brand__admin-link:hover,
.auth-brand__admin-link:focus-visible {
  color: var(--brand);
  outline: none;
}

.auth-link--inline {
  justify-self: start;
}

.auth-link--center {
  justify-self: center;
  margin-top: 4px;
}

.btn {
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid transparent;
  background: var(--surface);
  cursor: pointer;
  font-weight: 700;
}

.auth-submit-btn {
  color: #ffffff;
  background: var(--brand);
}

.auth-submit-btn:hover,
.auth-submit-btn:focus-visible {
  background: var(--brand-strong);
  outline: none;
}

.auth-secondary-btn {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-subtle);
}

.auth-toggle-group {
  display: inline-flex;
  width: fit-content;
  border: 1px solid var(--line);
  background: var(--surface-subtle);
}

.auth-toggle {
  border: 0;
  padding: 12px 16px;
  background: transparent;
  color: var(--text-soft);
  font-weight: 700;
  cursor: pointer;
}

.auth-toggle.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--line);
}

.auth-twofa-panel {
  display: none;
  gap: 16px;
}

.auth-twofa-panel.is-active {
  display: grid;
}

.auth-support-copy {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.65;
}

.auth-qr-wrap {
  margin-top: 12px;
  display: inline-flex;
  padding: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.auth-qr-image {
  display: block;
  width: 220px;
  max-width: 100%;
  height: auto;
}

.auth-notice {
  display: grid;
  gap: 8px;
  margin-bottom: 22px;
  padding: 14px 16px;
  border: 1px solid rgba(143, 58, 53, 0.22);
  background: rgba(143, 58, 53, 0.08);
  color: var(--danger);
}

.auth-notice.is-success {
  border-color: rgba(35, 88, 67, 0.2);
  background: rgba(35, 88, 67, 0.08);
  color: var(--success);
}

.auth-notice.is-hidden,
.auth-form.is-hidden {
  display: none;
}

.instance-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.instance-modal.is-hidden {
  display: none;
}

.instance-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 32, 51, 0.44);
  backdrop-filter: blur(4px);
}

.instance-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  padding: 30px;
  border: 1px solid rgba(208, 216, 226, 0.96);
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 68px rgba(20, 32, 51, 0.18);
}

.instance-modal__close {
  position: absolute;
  top: 10px;
  right: 14px;
  border: 0;
  background: transparent;
  color: var(--text-soft);
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
}

.instance-modal__header h2 {
  margin-top: 18px;
  font-size: clamp(2rem, 4vw, 2.8rem);
  font-weight: 600;
  line-height: 1;
}

.instance-modal__header p {
  margin: 14px 0 0;
  color: var(--text-muted);
  line-height: 1.68;
}

.instance-modal__list {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.instance-option {
  display: grid;
  gap: 10px;
  width: 100%;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.instance-option:hover,
.instance-option:focus-visible {
  border-color: #7c8ca4;
  box-shadow: 0 14px 28px rgba(20, 32, 51, 0.08);
  transform: translateY(-1px);
  outline: none;
}

.instance-option__title {
  font-size: 1.1rem;
  font-weight: 700;
}

.instance-option__meta {
  color: var(--text-muted);
  line-height: 1.58;
}

.instance-option__hint {
  color: var(--brand);
  font-size: 0.94rem;
  font-weight: 700;
}

.auth-footer {
  color: var(--text-muted);
  font-size: 0.94rem;
}

@media (max-width: 1080px) {
  .auth-shell {
    padding: 34px 24px 28px;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    gap: 32px;
  }

  .auth-brand {
    min-height: auto;
    padding: 0;
    gap: 36px;
  }

  .auth-brand__content {
    gap: 40px;
  }

  .auth-panel {
    justify-content: flex-start;
  }
}

@media (max-width: 640px) {
  .auth-shell {
    padding: 22px 16px;
  }

  .auth-brand__content {
    gap: 28px;
  }

  .auth-brand__logo img {
    width: min(100%, 220px);
  }

  .auth-brand__copy h2 {
    font-size: 2.7rem;
  }

  .auth-brand__copy p {
    margin-top: 18px;
    font-size: 1rem;
  }

  .auth-card {
    padding: 28px 20px 24px;
  }

  .auth-card__header h1,
  .instance-modal__header h2 {
    font-size: 2.25rem;
  }

  .auth-actions,
  .auth-row {
    align-items: stretch;
  }

  .btn,
  .auth-submit-btn,
  .auth-secondary-btn {
    width: 100%;
  }

  .instance-modal {
    padding: 16px;
  }

  .instance-modal__dialog {
    padding: 24px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .auth-input,
  .btn,
  .auth-toggle,
  .instance-option {
    transition: none;
  }
}
