/* 认证相关页面样式 —— 复用 style.css 里的 CSS 变量，保证视觉一致
 *
 * ⚠️ 关键点：登录相关元素刻意**不使用 .links 这个 class**。
 *    style.css 在 @media (max-width:640px) 里写了 `.links { display: none }`，
 *    一旦复用就会导致手机上看不到登录/注册按钮（这是实际发生过的 bug）。
 *    这里统一用 .auth-links / .auth-btn，并在窄屏下保持可见。
 */

.auth-slot { display: flex; align-items: center; gap: 8px; margin-left: auto; flex: 0 0 auto; }
/* 只在 .links 真正可见的宽屏下取消自动外边距。
   窄屏时 style.css 把 .links 设为 display:none，但它仍在 DOM 中，
   兄弟选择器照样匹配 —— 会让登录区丢掉 margin-left:auto 贴到品牌名旁边，
   这就是「手机上个人信息被挡住 / 位置偏左」的原因。 */
@media (min-width: 641px) {
  .nav-inner > .links + .auth-slot { margin-left: 6px; }
}

.auth-links { display: flex; align-items: center; gap: 6px; }

.auth-btn {
  display: inline-flex; align-items: center;
  padding: 6px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .18s, transform .18s, background .18s;
}
.auth-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.auth-btn.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #fff;
}

.who { display: flex; align-items: center; gap: 8px; font-size: 14.5px; color: var(--muted); }
.who b { color: var(--fg); font-weight: 600; }
.role-badge {
  font-size: 11.5px; padding: 2px 8px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); letter-spacing: .04em;
  white-space: nowrap;
}
.role-badge.owner { color: #ffd479; border-color: rgba(255, 212, 121, .45); }
.role-badge.admin { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.role-badge.user  { color: var(--accent-2); border-color: color-mix(in srgb, var(--accent-2) 45%, transparent); }

/* ---------------- 主页面 hero 里的登录状态 ---------------- */
.hero-auth {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin-top: 22px;
}
.hero-auth .auth-hint {
  display: inline-flex; align-items: center; gap: 7px;
  color: var(--muted); font-size: 14.5px;
}
.hero-auth .auth-hint b { color: var(--fg); font-weight: 600; }
.hero-auth .dot-online {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 10px color-mix(in srgb, var(--accent-2) 70%, transparent);
}

.auth-wrap {
  position: relative; z-index: 1;
  min-height: calc(100vh - 62px);
  display: flex; align-items: center; justify-content: center;
  padding: 48px 0 64px;
}

.auth-card {
  width: min(460px, 92vw);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow);
}
.auth-card.wide { width: min(920px, 94vw); }
.auth-card h1 { margin: 0 0 6px; font-size: 24px; letter-spacing: -.01em; }
.auth-card .sub { margin: 0 0 22px; color: var(--muted); font-size: 14.5px; }

.field { display: block; margin-bottom: 15px; }
.field > span { display: block; margin-bottom: 6px; font-size: 13.5px; color: var(--muted); }
.field input {
  width: 100%; box-sizing: border-box;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 60%, transparent);
  color: var(--fg);
  font-size: 15px;
  font-family: inherit;
  transition: border-color .18s, box-shadow .18s;
}
.field input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.field .hint { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

.check { display: flex; align-items: center; gap: 9px; margin: 4px 0 18px; font-size: 14px; color: var(--muted); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.btn.wide { width: 100%; justify-content: center; }
.btn.sm { padding: 7px 14px; font-size: 14px; border-radius: 10px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; transform: none !important; }
.btn.danger { border-color: rgba(255, 120, 120, .35); color: #ff9c9c; }

.alt { margin: 18px 0 0; font-size: 14px; color: var(--muted); text-align: center; }
.alt a { color: var(--accent); }

.msg { min-height: 20px; margin: 0 0 14px; font-size: 14px; }
.msg.err { color: #ff9c9c; }
.msg.ok  { color: var(--accent-2); }

.panel { margin-top: 22px; }
.panel h2 { margin: 0 0 14px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.panel h2 .tag { font-size: 12px; color: var(--muted); font-weight: 400; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
@media (max-width: 620px) { .grid2 { grid-template-columns: 1fr; } }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 660px; }
table.users th, table.users td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.users th { color: var(--muted); font-weight: 500; font-size: 13px; background: color-mix(in srgb, var(--bg) 50%, transparent); }
table.users tr:last-child td { border-bottom: none; }
table.users tr.me td { background: color-mix(in srgb, var(--accent) 7%, transparent); }
table.users .acts { display: flex; gap: 6px; flex-wrap: wrap; }
select.mini {
  padding: 5px 9px; border-radius: 8px; font-size: 13.5px; font-family: inherit;
  border: 1px solid var(--line); background: var(--bg-soft); color: var(--fg);
}
.muted { color: var(--muted); }
.hidden { display: none !important; }

.audit-list { margin: 0; padding: 0; list-style: none; font-size: 13.5px; max-height: 260px; overflow-y: auto; }
.audit-list li { padding: 7px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.audit-list li:last-child { border-bottom: none; }
.audit-list b { color: var(--fg); font-weight: 600; }
.audit-list .t { color: var(--muted); opacity: .75; margin-right: 10px; }

.notice {
  padding: 12px 14px; border-radius: 11px; font-size: 13.5px; margin-bottom: 20px;
  border: 1px solid color-mix(in srgb, #ffd479 35%, transparent);
  background: color-mix(in srgb, #ffd479 10%, transparent);
  color: var(--fg);
}

/* ---------------- 窄屏适配 ----------------
 * 注意：不能隐藏 .auth-links / .auth-btn，否则手机上就没有登录入口了。
 * 这里只做收缩：隐藏角色徽章、截断用户名、缩小按钮与留白。
 */
@media (max-width: 640px) {
  /* 导航栏布局：品牌名可收缩；用户名、角色、操作与主题按钮固定靠右且不被压缩 */
  .nav-inner { gap: 6px; }
  .brand { min-width: 0; gap: 6px; }
  .brand > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .auth-slot { margin-left: auto; flex: 0 0 auto; gap: 5px; }
  .auth-btn { padding: 5px 8px; font-size: 12.5px; border-radius: 8px; }
  .auth-links { gap: 4px; }
  /* 手机上同样显示用户名与角色徽章，只是整体压缩一档 */
  .who { font-size: 12.5px; gap: 4px; }
  .who b { max-width: 56px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .role-badge { font-size: 10.5px; padding: 2px 6px; }
  .hero-auth { gap: 8px; margin-top: 18px; }
  .hero-auth .auth-hint { font-size: 13.5px; }
}
@media (max-width: 400px) {
  /* 较窄屏：导航栏只让出「注册」这一个按钮，用户名和角色徽章保持可见。
     注册入口在主页 hero 区仍然保留，不会丢失。 */
  .auth-slot .auth-btn[href="register.html"] { display: none; }
}
@media (max-width: 348px) {
  /* 极窄屏兜底：先牺牲角色徽章，保证用户名和操作按钮不被挤掉 */
  .auth-slot .role-badge { display: none; }
  .who b { max-width: 44px; }
}
