/* Scope every override to the user dialog; other modal layouts are untouched. */
dialog:has(#user-form) {
  width: min(660px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  overflow: hidden;
  border-radius: 16px;
  background: #fff;
}

dialog[open]:has(#user-form) { display: flex; flex-direction: column; }
dialog:has(#user-form) .modal-head { padding: 20px 26px; flex: none; }
dialog:has(#user-form) .modal-head h2 { font-size: 21px; letter-spacing: -.5px; }
dialog:has(#user-form) .modal-head button {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #63758d;
}
dialog:has(#user-form) .modal-head button:hover { background: #f0f4fa; }
dialog:has(#user-form) .users-form { display: flex; flex-direction: column; min-height: 0; }
dialog:has(#user-form) .users-body { padding: 18px 26px 22px; overflow-y: auto; overscroll-behavior: contain; }
dialog:has(#user-form) .users-intro { margin: 0 0 20px; color: #607188; font-size: 12px; line-height: 1.5; }
dialog:has(#user-form) .users-section + .users-section { margin-top: 20px; padding-top: 18px; border-top: 1px solid #e7edf5; }
dialog:has(#user-form) h3 { margin: 0 0 12px; font-size: 13px; font-weight: 650; color: #243b5a; }
dialog:has(#user-form) .users-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
dialog:has(#user-form) .users-wide { grid-column: 1 / -1; min-width: 0; }
dialog:has(#user-form) .field { margin: 0; gap: 7px; }
dialog:has(#user-form) .field label { color: #475c76; font-size: 11px; line-height: 1.4; }
dialog:has(#user-form) .field input { height: 41px; padding: 10px 12px; font-size: 13px; border-radius: 8px; }
dialog:has(#user-form) .users-help { margin: 7px 0 0; color: #607188; font-size: 11px; line-height: 1.5; }
dialog:has(#user-form) .users-grid > .users-help { margin: -5px 0 0; }
dialog:has(#user-form) .users-roles { margin: 0 0 14px; padding: 0; border: 0; min-width: 0; }
dialog:has(#user-form) .users-roles legend { padding: 0; margin-bottom: 8px; color: #475c76; font-size: 11px; font-weight: 600; }
dialog:has(#user-form) .users-role {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px;
  border: 1px solid #dfe6f0;
  border-radius: 10px;
  cursor: pointer;
  background: #fff;
}
dialog:has(#user-form) .users-role:has(input:checked) { background: #f1f6ff; border-color: #5484e7; box-shadow: inset 0 0 0 1px #5484e7; }
dialog:has(#user-form) .users-role:hover { border-color: #799bd6; }
dialog:has(#user-form) .users-role input,
dialog:has(#user-form) .users-disable input { width: 16px; height: 16px; margin: 1px 0 0; flex: none; accent-color: #2863da; }
dialog:has(#user-form) .users-role-copy { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
dialog:has(#user-form) .users-role-copy strong { font-size: 12px; color: #243b5a; }
dialog:has(#user-form) .users-role-copy > span { color: #566c87; font-size: 11px; line-height: 1.5; }
dialog:has(#user-form) .users-password { position: relative; min-width: 0; }
dialog:has(#user-form) .users-password input { padding-right: 64px; }
dialog:has(#user-form) .users-toggle { position: absolute; right: 3px; bottom: 2px; min-width: 55px; height: 37px; padding: 0 9px; border-radius: 6px; color: #335fb0; font-size: 11px; font-weight: 600; }
dialog:has(#user-form) .users-toggle:hover { background: #edf3ff; }
dialog:has(#user-form) .users-status { display: flex; align-items: center; gap: 7px; margin: 12px 0 0; font-size: 11px; font-weight: 600; color: #34765b; }
dialog:has(#user-form) .users-status > span { width: 6px; height: 6px; border-radius: 50%; background: #38956d; }
dialog:has(#user-form) .users-disable { display: flex; align-items: flex-start; gap: 9px; margin-top: 14px; cursor: pointer; }
dialog:has(#user-form) .users-disable strong { display: block; font-size: 11px; color: #475c76; }
dialog:has(#user-form) .users-disable span span { display: block; margin-top: 3px; font-size: 11px; color: #607188; }
dialog:has(#user-form) .users-verify { margin-top: 18px; padding: 16px; border: 1px solid #e1e8f1; border-radius: 11px; background: #f8fafd; }
dialog:has(#user-form) .users-verify-heading { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 14px; }
dialog:has(#user-form) .users-verify-heading h3 { margin: 0; font-size: 12px; }
dialog:has(#user-form) .users-verify-heading .users-help { margin-top: 4px; }
dialog:has(#user-form) .users-lock { display: grid; place-items: center; width: 30px; height: 30px; background: #e9eff8; border-radius: 8px; color: #54729c; flex: none; }
dialog:has(#user-form) .users-lock svg { width: 18px; height: 18px; }
dialog:has(#user-form) .users-verify .users-grid { align-items: end; }
dialog:has(#user-form) .error:empty { display: none; }
dialog:has(#user-form) .users-footer { padding: 15px 26px; background: #fff; flex: none; }
dialog:has(#user-form) .users-footer .btn { min-height: 40px; border-radius: 8px; }
dialog:has(#user-form) button:focus-visible,
dialog:has(#user-form) input:focus-visible { outline: 2px solid #3773db; outline-offset: 3px; }
dialog:has(#user-form) .users-role:has(input:focus-visible) { outline: 2px solid #3773db; outline-offset: 3px; }

@media (max-width: 520px) {
  dialog:has(#user-form) { width: calc(100% - 20px); max-height: calc(100dvh - 20px); border-radius: 12px; }
  dialog:has(#user-form) .modal-head { padding: 15px 18px; }
  dialog:has(#user-form) .users-body { padding: 16px 18px 18px; }
  dialog:has(#user-form) .users-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  dialog:has(#user-form) .users-roles .users-grid { gap: 8px; }
  dialog:has(#user-form) .field input { font-size: 16px; }
  dialog:has(#user-form) .users-verify { padding: 13px; }
  dialog:has(#user-form) .users-footer { padding: 12px 18px; }
  dialog:has(#user-form) .users-footer .btn { flex: 1; justify-content: center; }
}
