body.auth-pending > .app-sticky-shell,
body.auth-pending > main,
body.auth-pending > dialog,
body.auth-pending > #toast,
body.auth-login > .app-sticky-shell,
body.auth-login > main,
body.auth-login > dialog,
body.auth-login > #toast {
  display: none !important;
}

.login-screen {
  display: none;
  min-height: 100vh;
  place-items: center;
  padding: 1.25rem;
  background:
    radial-gradient(circle at 18% 20%, rgba(35, 97, 91, 0.12), transparent 34%),
    radial-gradient(circle at 84% 76%, rgba(201, 120, 36, 0.14), transparent 30%),
    var(--bg);
}

body.auth-pending .login-screen,
body.auth-login .login-screen {
  display: grid;
}

body.auth-ready .login-screen {
  display: none;
}

body.auth-login #loginPending {
  display: none;
}

.login-card {
  width: min(100%, 420px);
  display: grid;
  gap: 1rem;
  padding: 2rem;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 18px 55px rgba(27, 39, 36, 0.14);
}

.login-brand {
  width: 220px;
  height: 76px;
  margin-bottom: 0.2rem;
  background: url("/static/sheng-logo-transparent.webp") left center / contain no-repeat;
}

.login-card h1,
.login-card p {
  margin: 0;
}

.login-form {
  display: grid;
  gap: 1rem;
}

.login-form button {
  min-height: 46px;
}

.login-status {
  min-height: 1.3rem;
  color: var(--danger);
  font-size: 0.88rem;
}

.account-security-note {
  color: var(--muted);
  line-height: 1.45;
}

.site-access-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.45rem;
  padding: 0.16rem 0.55rem;
  border: 1px solid #9bc8b5;
  border-radius: 999px;
  background: #edf8f3;
  color: #175c46;
  font-size: 0.68rem;
  font-weight: 750;
  line-height: 1;
  white-space: nowrap;
}

.site-access-badge--viewer {
  border-color: #d8c894;
  background: #fff8df;
  color: #715b16;
}

body.site-readonly #openLocationEntry,
body.site-readonly #openResultEntry,
body.site-readonly #locationForm,
body.site-readonly #resultForm,
body.site-readonly #actionForm,
body.site-readonly #scheduleItemForm,
body.site-readonly #scheduleBuilder .schedule-zone-counts,
body.site-readonly #scheduleBuilder .schedule-total,
body.site-readonly #scheduleBuilder .schedule-pool,
body.site-readonly #scheduleBuilder .schedule-area-filter,
body.site-readonly #scheduleBuilder .schedule-builder-actions,
body.site-readonly #openScheduleItemAdd,
body.site-readonly #startScheduleLock,
body.site-readonly #startScheduleDelete,
body.site-readonly [data-edit-location],
body.site-readonly [data-edit-result],
body.site-readonly [data-edit-action],
body.site-readonly .schedule-actions-column button {
  display: none !important;
}

.user-management-panel {
  max-width: 1180px;
  margin: 0 auto;
}

.user-management-heading {
  align-items: center;
}

.user-security-note {
  margin-bottom: 1rem;
  padding: 0.8rem 0.95rem;
  border: 1px solid #d7e6df;
  border-radius: 8px;
  background: #f4faf7;
  color: var(--muted);
  line-height: 1.45;
}

.user-table-wrap {
  margin-top: 0.7rem;
}

.user-table {
  min-width: 1040px;
}

.user-table td {
  vertical-align: middle;
}

.user-table td:first-child strong,
.user-username {
  display: block;
}

.user-username {
  margin-top: 0.18rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.user-disabled-row {
  opacity: 0.68;
}

.access-chip-list,
.user-row-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.access-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.52rem;
  border: 1px solid #cedbd5;
  border-radius: 999px;
  background: #f5f8f6;
  color: #2e4b42;
  font-size: 0.76rem;
  font-weight: 700;
}

.access-chip small {
  color: var(--muted);
  font-weight: 650;
}

.access-chip--editor,
.access-chip--admin {
  border-color: #9bc8b5;
  background: #edf8f3;
  color: #175c46;
}

.user-row-actions {
  justify-content: flex-end;
  min-width: 150px;
}

.user-row-actions button {
  padding: 0.42rem 0.62rem;
  font-size: 0.76rem;
}

.user-dialog {
  width: min(760px, calc(100vw - 2rem));
}

.user-reset-dialog {
  width: min(580px, calc(100vw - 2rem));
}

.user-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
  margin: 1rem 0;
}

.user-site-permissions {
  display: grid;
  gap: 0.7rem;
  margin-top: 1rem;
  padding: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #f8faf8;
}

.user-site-permissions h3,
.user-site-permissions p {
  margin: 0;
}

.user-site-permission-list {
  display: grid;
  gap: 0.55rem;
}

.user-site-permission-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(190px, 0.8fr);
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem;
  border: 1px solid #dce5e0;
  border-radius: 7px;
  background: white;
}

.user-all-sites-row {
  border-color: #9bc8b5;
  background: #edf8f3;
}

.user-site-list-disabled {
  opacity: 0.48;
}

.user-site-check {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.user-site-check span,
.user-site-check small {
  display: block;
}

.user-site-check small {
  margin-top: 0.12rem;
  color: var(--muted);
}

.account-menu {
  position: relative;
  flex: 0 0 auto;
}

.account-menu-trigger {
  display: grid;
  grid-template-columns: 34px minmax(92px, 1fr) 18px;
  align-items: center;
  gap: 0.55rem;
  min-height: 48px;
  max-width: 230px;
  padding: 0.38rem 0.62rem;
  border: 1px solid rgba(35, 97, 91, 0.22);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
  color: #18213f;
  box-shadow: 0 4px 16px rgba(27, 39, 36, 0.08);
}

.account-menu-trigger:hover,
.account-menu-trigger[aria-expanded="true"] {
  border-color: rgba(35, 97, 91, 0.48);
  background: #fff;
  transform: none;
  box-shadow: 0 7px 20px rgba(27, 39, 36, 0.12);
}

.account-avatar {
  display: inline-grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--brand), var(--brand-strong));
  color: #fff;
}

.account-avatar svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.account-summary {
  display: grid;
  min-width: 0;
  text-align: left;
}

.account-summary strong,
.account-summary small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-summary strong {
  font-size: 0.8rem;
  line-height: 1.25;
}

.account-summary small {
  margin-top: 0.08rem;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 650;
}

.account-menu-chevron {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
  transition: transform 160ms ease;
}

.account-menu-trigger[aria-expanded="true"] .account-menu-chevron {
  transform: rotate(180deg);
}

.account-menu-panel {
  position: fixed;
  z-index: 80;
  width: min(370px, calc(100vw - 24px));
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  box-shadow: 0 18px 48px rgba(27, 39, 36, 0.2);
}

.account-menu-identity {
  display: grid;
  gap: 0.15rem;
  padding: 0 0.1rem 0.8rem;
  border-bottom: 1px solid var(--line);
}

.account-menu-identity strong {
  font-size: 1rem;
}

.account-menu-identity span {
  color: var(--brand-strong);
  font-size: 0.84rem;
  font-weight: 750;
}

.account-menu-identity small {
  color: var(--muted);
  font-size: 0.76rem;
}

.account-menu-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
  padding-top: 0.8rem;
}

.account-menu-actions button {
  width: 100%;
}

.account-action {
  display: inline-flex;
  min-height: 46px;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  border-radius: 8px;
  font-weight: 780;
  box-shadow: none;
}

.account-action svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.account-action-team {
  grid-column: 1 / -1;
  border: 1px solid #9ebbcf;
  background: #eef6fb;
  color: #245a78;
}

.account-action-team:hover {
  border-color: #5f91b2;
  background: #deedf7;
  color: #174963;
  transform: translateY(-1px);
  box-shadow: 0 5px 13px rgba(36, 90, 120, 0.14);
}

.account-action-password {
  border: 1px solid #8fc3ad;
  background: #eaf7f1;
  color: #155b45;
}

.account-action-password:hover {
  border-color: #4d9c7c;
  background: #d9f0e6;
  color: #0d4937;
  transform: translateY(-1px);
  box-shadow: 0 5px 13px rgba(21, 91, 69, 0.14);
}

.account-action-sign-out {
  border: 1px solid #ddb0aa;
  background: #fff5f3;
  color: #9d3028;
}

.account-action-sign-out:hover {
  border-color: #c96f65;
  background: #fde7e3;
  color: #81251f;
  transform: translateY(-1px);
  box-shadow: 0 5px 13px rgba(157, 48, 40, 0.13);
}

.header-actions .account-menu-panel label {
  min-width: 0;
  color: var(--ink);
}

.password-change-panel {
  margin-top: 0.8rem;
  padding-top: 0.9rem;
  border-top: 1px solid var(--line);
}

.password-change-form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.65rem;
}

.password-change-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.password-change-actions button {
  width: 100%;
}

.password-change-form .login-status {
  min-height: 0;
}

.account-security-note {
  margin: 0.85rem 0 0;
  font-size: 0.82rem;
}

@media (max-width: 920px) {
  .account-menu-trigger {
    max-width: none;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 1.35rem;
  }

  .login-brand {
    width: 190px;
    height: 66px;
  }

  .user-form-grid,
  .user-site-permission-row {
    grid-template-columns: 1fr;
  }

  .user-row-actions {
    justify-content: flex-start;
  }

  .account-menu {
    width: 100%;
  }
}
