body.auth-required {
  overflow: hidden;
  background: #edf3ff;
}

body.auth-required .app-shell {
  visibility: hidden;
}

.auth-password-change {
  min-height: 28px;
  margin-left: 4px;
  padding: 0 9px;
  color: #205dce;
  border: 1px solid #cddcff;
  border-radius: 4px;
  background: #fff;
  font: inherit;
  cursor: pointer;
}

.auth-password-change:hover {
  color: #fff;
  border-color: #2f6fe4;
  background: #2f6fe4;
}

.auth-gate {
  width: min(1080px, calc(100vw - 32px));
  max-width: none;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 38px 100px rgba(31, 61, 128, .22);
  overflow: hidden;
}

/*
 * Safari can keep an author-styled <dialog> in normal document flow after
 * close(). Chromium's user-agent sheet hides it, but WebKit needs an explicit
 * closed-state rule whenever the dialog itself declares display/layout styles.
 */
dialog:not([open]) {
  display: none !important;
}

.auth-gate[open] {
  display: block;
}

.auth-gate-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(430px, 470px);
  align-items: stretch;
  width: 100%;
  height: min(744px, calc(100dvh - 32px));
}

.auth-gate::backdrop {
  background:
    radial-gradient(circle at 78% 22%, rgba(47, 111, 228, .28), transparent 32%),
    linear-gradient(135deg, #e7efff 0%, #f7f9ff 54%, #dce8ff 100%);
}

.auth-gate .auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  margin: 0;
  padding: 34px 38px 28px;
  border: 1px solid rgba(155, 177, 218, .55);
  border-left: 0;
  border-top: 5px solid #2f6fe4;
  border-radius: 0;
  background: rgba(255, 255, 255, .97);
  box-shadow: none;
  overflow-y: auto;
}

.auth-gate .auth-card::before {
  display: none;
}

.auth-video-panel {
  position: relative;
  min-width: 0;
  /*
   * Do not use percentage min-height here. Safari resolves 100% against the
   * modal containing block while the grid row itself is still auto-sized,
   * creating a height cycle that stretches the login dialog to the viewport.
   * The form now defines the row height and the video simply stretches to it.
   */
  min-height: 0;
  align-self: stretch;
  overflow: hidden;
  border: 1px solid rgba(155, 177, 218, .55);
  border-right: 0;
  border-top: 5px solid #2f6fe4;
  background: #0c1a33 url("./assets/media/auth-entry-poster.jpg?v=1.1.5") center / cover no-repeat;
  isolation: isolate;
}

.auth-video-panel video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: transparent;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 34px;
  padding-bottom: 20px;
  border-bottom: 1px solid #e2e9f6;
}

.auth-brand img {
  width: 116px;
  height: auto;
}

.auth-brand div {
  display: grid;
  gap: 4px;
  padding-left: 14px;
  border-left: 1px solid #d5dfef;
}

.auth-brand span {
  color: #5c6b89;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .09em;
}

.auth-brand strong {
  color: #142043;
  font-size: 13px;
}

.auth-gate .auth-heading {
  display: block;
  padding: 0;
  margin-bottom: 22px;
  color: #111b3d;
  background: transparent;
}

.auth-gate .auth-heading .eyebrow {
  color: #2f6fe4;
}

.auth-gate .auth-heading h2 {
  margin: 6px 0 8px;
  color: #111b3d;
  font-size: clamp(27px, 4vw, 34px);
  line-height: 1.18;
}

.auth-gate .auth-heading p {
  margin: 0;
  min-height: 44.1875px;
  color: #68748d;
  font-size: 13px;
  line-height: 1.7;
}

.auth-field {
  margin-top: 14px;
}

.auth-field input {
  min-height: 48px;
  padding-inline: 14px;
  font-size: 15px;
}

.auth-gate .auth-mode-note {
  margin-top: 16px;
  padding: 11px 13px;
  border-left: 3px solid #2f6fe4;
  border-radius: 4px;
  background: #f1f5fd;
  color: #53627e;
  font-size: 11px;
  line-height: 1.65;
}

.auth-gate .auth-security-note {
  min-height: 35.1875px;
  margin: 13px 0 18px;
  color: #5f6c84;
  font-size: 11px;
  line-height: 1.6;
}

.auth-submit {
  width: 100%;
  min-height: 48px;
  font-size: 14px;
  box-shadow: 0 10px 20px rgba(47, 111, 228, .2);
}

.auth-footer-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  margin-top: 18px;
}

.auth-footer {
  display: block;
  margin: 0;
  color: #66728a;
  font-size: 10px;
  text-align: center;
}

.auth-admin-entry {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 0;
  border: 0;
  border-bottom: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #66728a;
  font: inherit;
  font-size: 10px;
  line-height: 1;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease;
}

.auth-admin-entry svg {
  width: 11px;
  height: 11px;
  fill: currentColor;
}

.auth-admin-entry:hover,
.auth-admin-entry:focus-visible {
  border-bottom-color: currentColor;
  color: #526681;
  outline: none;
}

.auth-admin-entry:active {
  color: #2f6fe4;
}

.auth-mode-identity {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 9px;
  padding: 7px 10px;
  border: 1px solid rgba(192, 145, 54, .34);
  border-radius: 4px;
  background: #fff7e5;
  color: #8d6115;
  font-size: 10px;
  font-weight: 850;
  letter-spacing: .08em;
  visibility: hidden;
}

.auth-mode-identity.is-visible {
  visibility: visible;
}

.auth-mode-identity svg {
  width: 15px;
  height: 15px;
  fill: currentColor;
}

.auth-gate.is-admin-mode {
  box-shadow: 0 42px 110px rgba(8, 22, 49, .32);
}

.auth-gate.is-admin-mode::backdrop {
  background:
    radial-gradient(circle at 76% 20%, rgba(196, 147, 52, .18), transparent 29%),
    linear-gradient(135deg, #dce4f1 0%, #eef1f5 50%, #cbd5e4 100%);
}

.auth-gate.is-admin-mode .auth-card,
.auth-gate.is-admin-mode .auth-video-panel {
  border-top-color: #bd8b31;
}

.auth-gate.is-admin-mode .auth-card {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, .98), rgba(248, 246, 240, .98));
}

.auth-gate.is-admin-mode .auth-video-panel video {
  filter: none;
}

.auth-gate.is-admin-mode .auth-brand {
  border-bottom-color: #ddd5c3;
}

.auth-gate.is-admin-mode .auth-brand div {
  border-left-color: #d7ccb4;
}

.auth-gate.is-admin-mode .auth-brand span,
.auth-gate.is-admin-mode .auth-heading .eyebrow {
  color: #9a6a18;
}

.auth-gate.is-admin-mode .auth-heading h2 {
  color: #15233f;
}

.auth-gate.is-admin-mode .auth-field input {
  border-color: #c9b98f;
  background: #fffdf8;
}

.auth-gate.is-admin-mode #auth-username[readonly] {
  color: #6f531e;
  background: #f4eddd;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  letter-spacing: .08em;
  cursor: default;
}

.auth-gate.is-admin-mode .auth-mode-note {
  border-left-color: #bd8b31;
  background: #f8f1e3;
  color: #6c5d42;
}

.auth-gate.is-admin-mode .auth-mode-note b {
  color: #8a6019;
}

.auth-gate.is-admin-mode .auth-submit {
  border-color: #172d51;
  background: #172d51;
  box-shadow: 0 10px 22px rgba(18, 43, 81, .24);
}

.auth-gate.is-admin-mode .auth-submit:hover,
.auth-gate.is-admin-mode .auth-submit:focus-visible {
  border-color: #bd8b31;
  background: #233d68;
}

.auth-admin-entry.is-return {
  color: #7d6334;
}

.auth-admin-entry.is-return:hover,
.auth-admin-entry.is-return:focus-visible {
  color: #172d51;
}

.password-change-modal::backdrop {
  background: rgba(16, 30, 67, .58);
  backdrop-filter: blur(8px);
}

.password-change-card {
  width: min(480px, calc(100vw - 28px));
  border-top: 4px solid #2f6fe4;
}

.password-account-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 13px 14px;
  border-left: 3px solid #2f6fe4;
  border-radius: 5px;
  background: #edf3ff;
}

.password-account-card span,
.password-rule {
  color: #6d7890;
  font-size: 11px;
}

.password-account-card strong {
  color: #205dce;
  font-size: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.password-rule {
  margin: 10px 0 18px;
  line-height: 1.6;
}

.password-change-feedback {
  margin: -6px 0 14px;
  padding: 10px 12px;
  border-left: 3px solid #d74343;
  border-radius: 4px;
  background: #fff1f1;
  color: #9f2626;
  font-size: 12px;
  line-height: 1.55;
}

.password-change-feedback[hidden] {
  display: none;
}

.password-change-card > .button {
  width: 100%;
}

.email-binding-modal::backdrop {
  background: rgba(16, 30, 67, .58);
  backdrop-filter: blur(8px);
}

.email-binding-card {
  width: min(520px, calc(100vw - 28px));
  border-top: 4px solid #2f6fe4;
}

.email-binding-status-card {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  padding: 13px 14px;
  border-left: 3px solid #2f6fe4;
  border-radius: 5px;
  background: #edf3ff;
}

.email-binding-status-card span,
.email-binding-status-card small {
  color: #6d7890;
  font-size: 11px;
}

.email-binding-status-card strong {
  color: #174fae;
  font-size: 14px;
  overflow-wrap: anywhere;
}

.email-binding-feedback {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid #d74343;
  border-radius: 4px;
  background: #fff1f1;
  color: #9f2626;
  font-size: 12px;
  line-height: 1.55;
}

.email-binding-feedback[hidden] {
  display: none;
}

.email-binding-actions {
  justify-content: space-between;
}

.user-management-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
  padding: 24px 26px;
  border: 1px solid #dce4f2;
  border-top: 4px solid #2f6fe4;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(45, 62, 115, .08);
}

.user-management-heading h2 {
  margin: 5px 0 7px;
  color: #101a3a;
  font-size: clamp(24px, 2.5vw, 32px);
}

.user-management-heading p {
  margin: 0;
  color: #68738f;
  font-size: 13px;
}

.user-management-panel {
  padding: 20px;
  border: 1px solid #dce4f2;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(45, 62, 115, .07);
}

.user-management-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.user-management-summary div {
  display: grid;
  gap: 5px;
  padding: 13px 15px;
  border-left: 3px solid #2f6fe4;
  border-radius: 5px;
  background: #f2f6fd;
}

.user-management-summary span {
  color: #76829b;
  font-size: 11px;
}

.user-management-summary strong {
  color: #1e5fd5;
  font-size: 22px;
}

.user-table-wrap {
  overflow-x: auto;
  border: 1px solid #dfe6f2;
  border-radius: 6px;
}

.user-table {
  width: 100%;
  min-width: 900px;
  border-collapse: collapse;
  font-size: 12px;
}

.user-table th,
.user-table td {
  padding: 12px 13px;
  border-bottom: 1px solid #e7ecf5;
  text-align: left;
  vertical-align: middle;
}

.user-table th {
  color: #68738f;
  background: #f5f8fe;
  font-size: 11px;
  white-space: nowrap;
}

.user-table tbody tr:last-child td {
  border-bottom: 0;
}

.user-identity {
  display: grid;
  gap: 3px;
}

.user-identity strong {
  color: #17213f;
  font-size: 13px;
}

.user-identity span,
.user-last-login {
  color: #7b879f;
  font-size: 10px;
}

.user-account-code {
  color: #215fcf;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  font-weight: 700;
}

.user-email-state {
  display: grid;
  gap: 3px;
}

.user-email-state strong {
  color: #33415f;
  font-size: 11px;
  font-weight: 700;
}

.user-email-state small {
  color: #7b879f;
  font-size: 10px;
}

.user-status,
.user-password-status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border: 1px solid #cbe6da;
  border-radius: 4px;
  background: #edf9f4;
  color: #176b50;
  font-size: 10px;
  font-weight: 800;
}

.user-status.is-disabled {
  color: #8b4860;
  border-color: #ebced7;
  background: #fff1f4;
}

.user-password-status.is-temporary {
  color: #936000;
  border-color: #edd7a7;
  background: #fff7e6;
}

.user-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.user-actions button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 10px;
}

.user-security-note {
  margin: 13px 0 0;
  color: #7a859c;
  font-size: 11px;
}

.user-editor-card {
  width: min(520px, calc(100vw - 28px));
}

.user-editor-card .field small {
  color: #818da4;
  font-size: 10px;
  line-height: 1.5;
}

.user-temporary-password {
  display: grid;
  gap: 3px;
  margin-top: 12px;
  padding: 13px 14px;
  border-left: 3px solid #2f6fe4;
  border-radius: 5px;
  background: #edf3ff;
}

.user-temporary-password span,
.user-temporary-password small {
  color: #71809a;
  font-size: 10px;
}

.user-temporary-password strong {
  color: #193e8d;
  font-size: 13px;
}

@media (max-width: 820px) {
  .auth-gate {
    width: calc(100vw - 22px);
    box-shadow: 0 24px 60px rgba(31, 61, 128, .22);
  }

  .auth-gate[open] {
    display: block;
  }

  .auth-gate-layout {
    display: block;
    height: min(744px, calc(100dvh - 32px));
  }

  .auth-video-panel {
    display: none;
  }

  .auth-gate .auth-card {
    width: 100%;
    margin: 0;
    padding: 25px 22px 22px;
    border-left: 1px solid rgba(155, 177, 218, .55);
    box-shadow: none;
  }

  .auth-gate .auth-card::before {
    display: none;
  }

  .auth-brand {
    margin-bottom: 24px;
  }

  .auth-brand img {
    width: 92px;
  }

  .auth-brand div {
    padding-left: 10px;
  }

  .user-management-heading {
    align-items: stretch;
    flex-direction: column;
    padding: 19px;
  }

  .user-management-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .user-management-summary div {
    padding: 10px;
  }

  .user-table {
    min-width: 0;
  }

  .user-table thead {
    display: none;
  }

  .user-table tbody,
  .user-table tr,
  .user-table td {
    display: block;
  }

  .user-table tr {
    padding: 14px;
    border-bottom: 1px solid #dfe6f2;
  }

  .user-table tr:last-child {
    border-bottom: 0;
  }

  .user-table td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 7px 0;
    border: 0;
  }

  .user-table td::before {
    content: attr(data-label);
    flex: 0 0 78px;
    color: #7a859d;
    font-size: 10px;
  }

  .user-table td:first-child {
    align-items: flex-start;
    padding-top: 0;
  }

  .user-actions {
    justify-content: flex-end;
  }
}
