/* =========================================================
 * 后台登录门 / 账号与权限界面
 * 在 theme.css 之后引入
 * ========================================================= */

[hidden] { display: none !important; }
body.locked { overflow: hidden; }
body.locked .app-shell { display: none; }

/* ---------- 登录门 ---------- */
.auth-gate {
  position: fixed; inset: 0; z-index: 9999; overflow-y: auto;
  display: flex; align-items: center; justify-content: center; padding: 32px 20px;
  background:
    radial-gradient(900px 520px at 15% 5%, rgba(199,169,109,.16), transparent 65%),
    radial-gradient(700px 500px at 90% 95%, rgba(58,139,112,.22), transparent 70%),
    linear-gradient(135deg, #0a201a 0%, #0d2b23 48%, #071a15 100%);
}
.auth-wrap {
  width: 100%; max-width: 960px;
  display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 420px);
  background: var(--card); border: 1px solid rgba(199,169,109,.36);
  border-radius: 12px; overflow: hidden; box-shadow: 0 40px 100px rgba(0,0,0,.48);
}
.auth-visual {
  position: relative; padding: 58px 46px 46px; color: #fff;
  background: linear-gradient(150deg, #0d2c24 0%, #164536 58%, #0b241d 100%);
  display: flex; flex-direction: column;
}
.auth-visual::before { content: ''; position: absolute; left: 0; right: 0; top: 0; height: 3px; background: linear-gradient(90deg, var(--gold-500), rgba(199,169,109,.1)); }
.auth-visual::after {
  content: ''; position: absolute; right: -90px; bottom: -110px; width: 320px; height: 320px;
  border: 1px solid rgba(199,169,109,.22); border-radius: 50%; pointer-events: none;
}
.av-eyebrow { font-size: 10.5px; letter-spacing: 3.4px; color: var(--gold-500); text-transform: uppercase; }
.av-title { font-family: var(--serif); font-size: 38px; line-height: 1.35; letter-spacing: 3px; font-weight: 600; margin-top: 22px; }
.av-title em { font-style: normal; color: var(--gold-300); }
.av-rule { width: 46px; height: 1px; background: var(--gold-500); margin: 24px 0 20px; }
.av-desc { font-size: 13px; line-height: 1.9; color: rgba(255,255,255,.72); max-width: 330px; }
.av-list { margin-top: auto; padding-top: 42px; display: grid; gap: 13px; }
.av-list div { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: rgba(255,255,255,.82); }
.av-list i { width: 5px; height: 5px; border-radius: 50%; background: var(--gold-500); flex: none; }
.av-foot { margin-top: 30px; font-size: 10px; letter-spacing: 2.2px; color: rgba(199,169,109,.55); }

.auth-panel { padding: 46px 40px 36px; min-width: 0; }
.ap-head { display: flex; align-items: center; gap: 12px; margin-bottom: 30px; }
.ap-mark {
  width: 42px; height: 42px; flex: none; border: 1px solid var(--gold-500); border-radius: 5px;
  background: linear-gradient(150deg, #123c31, #0b2820); color: var(--gold-300);
  display: grid; place-items: center; font-family: var(--serif); font-size: 22px;
}
.ap-brand b { display: block; font-family: var(--serif); font-size: 16px; letter-spacing: 2.5px; }
.ap-brand span { display: block; font-size: 9px; letter-spacing: 2.4px; color: var(--gold-700); margin-top: 2px; }
.ap-title { font-family: var(--serif); font-size: 25px; letter-spacing: 1.5px; }
.ap-sub { font-size: 12.5px; color: var(--ink-500); margin-top: 7px; line-height: 1.8; }

.auth-form { margin-top: 26px; display: grid; gap: 16px; }
.auth-form .field { min-width: 0; }
.auth-form .field > label { display: block; font-size: 12px; color: var(--ink-700); font-weight: 500; margin-bottom: 7px; letter-spacing: .3px; }
.auth-form input[type=text], .auth-form input[type=password] {
  width: 100%; height: 44px; padding: 0 13px; border: 1px solid var(--line-2);
  border-radius: 6px; background: #fff; font-size: 14px; outline: none;
}
.auth-form input:focus { border-color: var(--gold-500); box-shadow: 0 0 0 3px rgba(199,169,109,.16); }
.auth-form .hint { display: block; font-size: 11px; color: var(--ink-400); margin-top: 5px; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 62px !important; }
.pw-toggle { position: absolute; right: 6px; top: 6px; height: 32px; padding: 0 10px; border: 0; background: transparent; color: var(--ink-500); font-size: 11.5px; }
.pw-toggle:hover { color: var(--green-700); }

.auth-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12px; color: var(--ink-500); }
.auth-row label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.auth-row input[type=checkbox] { accent-color: var(--green-700); }
.auth-msg { min-height: 20px; font-size: 12px; line-height: 1.6; }
.auth-msg.err { color: var(--red); }
.auth-msg.warn { color: var(--amber); }
.auth-msg.ok { color: var(--green-600); }
.auth-submit { width: 100%; height: 46px; font-size: 14px; letter-spacing: 2px; }
.auth-submit:disabled { opacity: .6; cursor: not-allowed; }
.auth-note {
  margin-top: 22px; padding: 13px 14px; border: 1px solid var(--line);
  border-left: 2px solid var(--gold-500); border-radius: 4px;
  background: var(--gold-100); font-size: 11.5px; line-height: 1.8; color: var(--ink-700);
}
.auth-foot { margin-top: 20px; text-align: center; font-size: 10.5px; color: var(--ink-400); letter-spacing: .5px; }
.auth-setup-badge {
  display: inline-block; padding: 3px 9px; border-radius: 999px; margin-bottom: 12px;
  background: var(--gold-100); color: var(--gold-700); font-size: 10.5px; letter-spacing: 1px;
}

@media (max-width: 860px) {
  .auth-gate { padding: 20px 14px; align-items: flex-start; }
  .auth-wrap { grid-template-columns: minmax(0, 1fr); max-width: 440px; margin: auto; }
  .auth-visual { display: none; }
  .auth-panel { padding: 34px 24px 26px; }
  .ap-title { font-size: 22px; }
}

/* ---------- 顶栏当前用户 ---------- */
.user-chip { position: relative; flex: none; }
.user-btn {
  height: 38px; display: inline-flex; align-items: center; gap: 9px;
  padding: 0 10px 0 6px; border: 1px solid var(--line-2); border-radius: 7px;
  background: var(--card); color: var(--ink-900);
}
.user-btn:hover { border-color: var(--gold-500); }
.user-av {
  width: 27px; height: 27px; border-radius: 5px; flex: none; color: #fff;
  display: grid; place-items: center; font-family: var(--serif); font-size: 13px;
  background: linear-gradient(140deg, #1b4a3c, #0f3028);
}
.user-txt { text-align: left; line-height: 1.25; }
.user-txt b { display: block; font-size: 12px; font-weight: 600; }
.user-txt small { display: block; font-size: 10px; color: var(--ink-400); }
.user-btn .icon { width: 13px; height: 13px; color: var(--ink-400); transform: rotate(90deg); }
.user-menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 200;
  width: 208px; background: var(--card); border: 1px solid var(--line-2);
  border-radius: 8px; box-shadow: var(--shadow-l); padding: 6px;
}
.um-head { padding: 9px 10px 11px; border-bottom: 1px solid var(--line); margin-bottom: 5px; }
.um-head b { display: block; font-size: 12.5px; }
.um-head span { display: block; font-size: 10.5px; color: var(--ink-400); margin-top: 2px; }
.user-menu button {
  width: 100%; display: flex; align-items: center; gap: 9px; padding: 8px 10px;
  border: 0; border-radius: 5px; background: transparent; color: var(--ink-700);
  font-size: 12.5px; text-align: left;
}
.user-menu button:hover { background: var(--green-50); color: var(--green-700); }
.user-menu button.danger { color: var(--red); }
.user-menu button.danger:hover { background: var(--red-50); }
.user-menu .icon { width: 15px; height: 15px; }

/* ---------- 管理员与权限页 ---------- */
.role-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.role-card { padding: 17px 18px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.role-card.owner { border-top: 2px solid var(--gold-500); }
.role-card.admin { border-top: 2px solid var(--green-600); }
.role-card.staff { border-top: 2px solid var(--ink-400); }
.role-card b { display: block; font-family: var(--serif); font-size: 15px; letter-spacing: 1px; }
.role-card p { font-size: 11.5px; line-height: 1.8; color: var(--ink-500); margin-top: 7px; }
.role-card .rc-count { display: block; font-size: 10.5px; color: var(--gold-700); margin-top: 10px; letter-spacing: .5px; }
.perm-box { border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; background: var(--card); }
.perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 18px; }
.perm-item { display: flex; align-items: flex-start; gap: 8px; font-size: 12.5px; cursor: pointer; }
.perm-item input { margin-top: 3px; accent-color: var(--green-700); flex: none; }
.perm-item span b { display: block; font-weight: 600; }
.perm-item span small { display: block; font-size: 10.5px; color: var(--ink-400); line-height: 1.5; }
.role-badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 11px; letter-spacing: .5px; }
.role-badge.owner { background: var(--gold-100); color: var(--gold-700); }
.role-badge.admin { background: var(--green-50); color: var(--green-700); }
.role-badge.staff { background: #eef0ed; color: var(--ink-500); }
.acct-perm { font-size: 11px; color: var(--ink-500); max-width: 280px; line-height: 1.6; }
.acct-note { margin-top: 16px; }

@media (max-width: 720px) {
  .role-cards { grid-template-columns: minmax(0, 1fr); }
  .perm-grid { grid-template-columns: minmax(0, 1fr); }
  .user-txt { display: none; }
  .user-btn { padding: 0 8px; }
  /* 窄屏顶栏：标题区占满剩余空间，副标题与刷新隐藏，新增按钮只留图标 */
  .topbar { gap: 10px; }
  .topbar > div:nth-child(2) { flex: 1; min-width: 0; }
  .topbar .sub { display: none; }
  .topbar h1 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #btnRefresh { display: none; }
  #btnQuickAdd { font-size: 0 !important; padding: 0 11px; }
  #btnQuickAdd .icon { width: 17px; height: 17px; }
}
@media (max-width: 400px) {
  .topbar h1 { font-size: 15px !important; }
}
