:root {
  --bg: #0e1621;
  --card: #13202f;
  --field: #16273a;
  --border: #243a52;
  --text: #eaf2ff;
  --muted: #8fa3b8;
  --accent: #2f81f7;
  --accent-hover: #4c93ff;
  --danger: #ff7a7a;
  --success: #3ddc97;
  --warning: #f5b545;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei UI", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.glow {
  position: fixed;
  inset: -40% -10% auto -10%;
  height: 70vh;
  background: radial-gradient(closest-side, rgba(47, 129, 247, 0.16), transparent 70%);
  pointer-events: none;
  z-index: 0;
}

button,
input,
select {
  font: inherit;
}

[hidden] {
  display: none !important;
}

/* ---------- 登录 ---------- */
.login-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 20px;
}

.login-card {
  width: min(440px, 100%);
  padding: 44px 40px 34px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.login-logo {
  display: block;
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
}

.eyebrow {
  margin: 20px 0 30px;
  text-align: center;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.22em;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  height: 44px;
  padding: 0 13px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 129, 247, 0.18);
}

input::placeholder {
  color: #5d7289;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 19px, calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

button {
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  padding: 0 18px;
  height: 42px;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.primary {
  width: 100%;
  height: 46px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.primary:hover {
  background: var(--accent-hover);
}

.primary:disabled,
.ghost:disabled {
  opacity: 0.55;
  cursor: default;
}

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  height: 36px;
  padding: 0 14px;
}

.ghost:hover {
  border-color: #35516f;
  color: var(--text);
}

.ghost.small {
  height: 34px;
  flex: 0 0 auto;
  font-size: 12px;
}

.ghost.danger {
  color: var(--danger);
  border-color: rgba(255, 122, 122, 0.35);
}

.ghost.danger:hover {
  border-color: var(--danger);
  color: #ffa0a0;
}

.form-error {
  min-height: 18px;
  margin: 4px 0 10px;
  color: var(--danger);
  font-size: 12px;
  line-height: 1.5;
}

.login-hint {
  margin: 24px 0 0;
  text-align: center;
  color: #4e647d;
  font-size: 11px;
}

/* ---------- 管理 ---------- */
.admin-view {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 34px;
  border-bottom: 1px solid rgba(36, 58, 82, 0.7);
  background: rgba(14, 22, 33, 0.72);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.brand img {
  width: 176px;
  display: block;
}

.brand .divider {
  width: 1px;
  height: 22px;
  background: var(--border);
}

.section-title {
  color: var(--muted);
  font-size: 13px;
}

.account {
  display: flex;
  align-items: center;
  gap: 14px;
}

.current-email {
  color: var(--muted);
  font-size: 12px;
}

.content {
  max-width: 1080px;
  margin: 0 auto;
  padding: 30px 24px 60px;
  display: grid;
  gap: 22px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px 26px;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.card-sub {
  color: var(--muted);
  font-size: 12px;
}

.create-form {
  display: grid;
  grid-template-columns: 1.3fr 1.3fr 0.7fr auto;
  gap: 14px;
  align-items: end;
}

.create-form .field {
  margin-bottom: 0;
}

.password-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.password-row input {
  min-width: 0;
}

.create-submit {
  width: auto;
  height: 44px;
  padding: 0 26px;
  white-space: nowrap;
}

.create-card .form-error {
  margin-bottom: 0;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  padding: 0 12px 11px;
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 13px 12px;
  border-bottom: 1px solid rgba(36, 58, 82, 0.55);
  vertical-align: middle;
  white-space: nowrap;
}

tbody tr:last-child td {
  border-bottom: 0;
}

td.email {
  color: var(--text);
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role-badge,
.status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  border: 1px solid transparent;
}

.role-badge.admin {
  color: #9ec5ff;
  border-color: rgba(47, 129, 247, 0.45);
  background: rgba(47, 129, 247, 0.12);
}

.role-badge.user {
  color: var(--muted);
  border-color: var(--border);
}

.status-badge.active {
  color: var(--success);
  background: rgba(61, 220, 151, 0.1);
  border-color: rgba(61, 220, 151, 0.3);
}

.status-badge.disabled {
  color: var(--danger);
  background: rgba(255, 122, 122, 0.1);
  border-color: rgba(255, 122, 122, 0.3);
}

.status-badge.self {
  color: var(--warning);
  background: rgba(245, 181, 69, 0.1);
  border-color: rgba(245, 181, 69, 0.3);
}

.actions-col {
  text-align: right;
}

td.actions {
  text-align: right;
}

td.actions .ghost {
  height: 30px;
  padding: 0 11px;
  font-size: 12px;
  margin-left: 6px;
}

.muted-cell {
  color: var(--muted);
}

.footnote {
  margin: 18px 0 0;
  color: #5d7289;
  font-size: 11px;
  line-height: 1.7;
}

/* ---------- 弹窗 / 提示 ---------- */
.dialog {
  width: min(420px, calc(100vw - 32px));
  padding: 26px;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}

.dialog::backdrop {
  background: rgba(6, 11, 17, 0.7);
  backdrop-filter: blur(3px);
}

.dialog h2 {
  margin: 0 0 4px;
  font-size: 16px;
}

.dialog-sub {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 8px;
}

.dialog-actions .primary {
  width: auto;
  padding: 0 22px;
  height: 40px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  z-index: 20;
  padding: 11px 20px;
  background: #1b2c40;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font-size: 13px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.toast.error {
  border-color: rgba(255, 122, 122, 0.5);
  color: #ffb3b3;
}

.toast.success {
  border-color: rgba(61, 220, 151, 0.5);
  color: #9df0c8;
}

@media (max-width: 860px) {
  .create-form {
    grid-template-columns: 1fr 1fr;
  }

  .create-submit {
    grid-column: 1 / -1;
    width: 100%;
  }

  .topbar {
    padding: 14px 18px;
  }

  .brand img {
    width: 130px;
  }

  .current-email {
    display: none;
  }
}

@media (max-width: 560px) {
  .create-form {
    grid-template-columns: 1fr;
  }

  .login-card {
    padding: 34px 26px 28px;
  }

  .card {
    padding: 20px 18px;
  }
}
