.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 12% 82%, rgba(165, 198, 211, .34), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(229, 180, 164, .28), transparent 25%),
    var(--bg);
}

.workspace-pending .app-shell,
.auth-pending .app-shell,
.auth-signed-out .app-shell,
.auth-change-password .app-shell,
.auth-error .app-shell { visibility: hidden; }
.workspace-pending::before {
  content: "正在载入工作台…";
  position: fixed;
  inset: 50% auto auto 50%;
  z-index: 999;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 13px;
}
.auth-pending.workspace-pending::before { display: none; }
.auth-ready .auth-gate { display: none; }

.auth-panel {
  width: min(430px, 100%);
  padding: 34px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--glass-strong);
  box-shadow: var(--shadow);
  backdrop-filter: blur(26px) saturate(110%);
  -webkit-backdrop-filter: blur(26px) saturate(110%);
}

.auth-logo {
  display: block;
  width: 126px;
  height: 52px;
  object-fit: contain;
  object-position: left center;
  margin-bottom: 42px;
}

html[data-theme="night"] .auth-logo { content: url("./assets/jinyue-logo-white.png"); }
.auth-panel h1 { margin: 0; color: var(--text); font-size: 30px; letter-spacing: -.04em; }
.auth-panel > p { margin: 9px 0 28px; color: var(--muted); font-size: 14px; }
.auth-form { display: grid; gap: 16px; }
.auth-change-form { display: none; }
.auth-change-password #authForm { display: none; }
.auth-change-password .auth-change-form { display: grid; }
.auth-form label { display: grid; gap: 7px; color: var(--text-soft); font-size: 12px; }
.auth-form input { width: 100%; height: 46px; padding: 0 14px; border-radius: 12px; }
.auth-form .btn { min-height: 46px; margin-top: 4px; }
.auth-status {
  display: none;
  margin: 2px 0 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, #c9785f 35%, transparent);
  border-radius: 10px;
  color: #9f4e39;
  background: color-mix(in srgb, #e8a48d 14%, transparent);
  font-size: 12px;
  line-height: 1.55;
}
.auth-status.visible { display: block; }
.auth-error .auth-form { display: none; }
.auth-retry { display: none; width: 100%; margin-top: 18px; }
.auth-error .auth-retry { display: inline-flex; }

.auth-account {
  padding: 11px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  color: var(--muted);
  background: color-mix(in srgb, var(--glass-strong) 78%, transparent);
  font-size: 12px;
}
.auth-account strong { color: var(--text); font-weight: 650; }
.auth-password-tip { margin-top: -5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.auth-cancel-change { margin-top: -5px; }

.user-identity {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 176px;
  height: 42px;
  padding: 4px 7px 4px 5px;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  color: var(--text);
  background: var(--field);
}
.user-badge {
  display: grid;
  flex: 0 0 31px;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 10px;
  color: #234b47;
  background: var(--cyan-soft);
  font-size: 14px;
  font-weight: 800;
}
.user-copy { min-width: 0; text-align: left; }
.user-copy strong,
.user-copy small { display: block; overflow: hidden; max-width: 118px; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { font-size: 12px; }
.user-copy small { margin-top: 1px; color: var(--muted); font-size: 9px; }
.user-identity .sign-out {
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  font-size: 15px;
  cursor: pointer;
}
.user-identity .sign-out:hover { color: var(--text); background: var(--glass-strong); }
.operator-field { display: none !important; }

.permission-note {
  display: none;
  margin-top: 10px;
  padding: 9px 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  color: var(--muted);
  background: var(--field);
  font-size: 10px;
  line-height: 1.5;
}
body[data-user-role="branch_admin"] .permission-note,
body[data-user-role="viewer"] .permission-note { display: block; }

[data-permission-disabled="true"] { opacity: .48 !important; cursor: not-allowed !important; }

@media (max-width: 900px) {
  .user-identity { min-width: 42px; width: 42px; padding: 4px; }
  .user-copy, .user-identity .sign-out { display: none; }
}

@media (max-width: 660px) {
  .auth-panel { padding: 26px 22px; border-radius: 22px; }
  .auth-logo { margin-bottom: 30px; }
}
