:root {
  --bg-deep: #07133a;
  --bg-mid: #0c2a78;
  --bg-accent: #1d56d6;
  --glass: rgba(24, 42, 92, 0.58);
  --glass-strong: rgba(20, 36, 82, 0.82);
  --border: rgba(148, 180, 255, 0.24);
  --border-strong: rgba(148, 180, 255, 0.45);
  --text: #eaf0ff;
  --muted: #9db1e6;
  --primary: #3b82f6;
  --primary-light: #60a5fa;
  --danger: #f87171;
  --success: #34d399;
  --warn-bg: rgba(251, 191, 36, 0.14);
  --warn-border: rgba(251, 191, 36, 0.4);
  --warn-text: #ffe3a3;
  --radius: 12px;
  --shadow: 0 8px 28px rgba(3, 8, 30, 0.5);
  --glow-blue: 0 6px 18px rgba(59, 130, 246, 0.45);
  --glow-cyan: 0 0 22px rgba(34, 211, 238, 0.35);
}

* { box-sizing: border-box; }

html { min-height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  line-height: 1.55;
  background:
    radial-gradient(900px 480px at 12% -8%, rgba(59, 130, 246, 0.42), transparent 60%),
    radial-gradient(820px 460px at 88% 108%, rgba(34, 211, 238, 0.28), transparent 60%),
    radial-gradient(700px 420px at 82% -6%, rgba(139, 92, 246, 0.22), transparent 55%),
    linear-gradient(158deg, var(--bg-deep) 0%, var(--bg-mid) 48%, #0a2f8f 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 46%, rgba(96, 165, 250, 0.06) 47% 48%, transparent 49% 100%),
    linear-gradient(65deg, transparent 0 62%, rgba(34, 211, 238, 0.05) 63% 64%, transparent 65% 100%);
  background-size: 90px 90px, 120px 120px;
  opacity: 0.55;
}

::selection { background: rgba(59, 130, 246, 0.55); color: #fff; }

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(8, 18, 52, 0.72);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 24px rgba(3, 8, 30, 0.35);
}
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.brand {
  font-size: 19px;
  font-weight: 800;
  color: #fff;
  text-decoration: none;
  letter-spacing: 0.5px;
  text-shadow: 0 0 18px rgba(96, 165, 250, 0.65);
}
.brand-sub { color: var(--muted); font-size: 13px; }
.user-name { font-size: 14px; font-weight: 600; color: #fff; }
.tenant-tag {
  font-size: 12px;
  color: #bcd3ff;
  background: rgba(96, 165, 250, 0.16);
  border: 1px solid rgba(96, 165, 250, 0.4);
  border-radius: 999px;
  padding: 2px 10px;
}

main.container { padding-top: 26px; padding-bottom: 40px; }

/* ---------- 卡片 ---------- */
.card {
  position: relative;
  background: var(--glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px 24px;
  margin-bottom: 22px;
}
.card h2 { margin: 0 0 10px; font-size: 17px; color: #fff; }

.muted { color: var(--muted); }
.empty { text-align: center; padding: 28px 0; }

.legacy-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: var(--warn-bg);
  border-color: var(--warn-border);
  backdrop-filter: none;
  color: var(--warn-text);
}
.legacy-banner[hidden] { display: none; }
.legacy-banner strong { color: #ffe3a3; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.18s, border-color 0.18s, box-shadow 0.18s, color 0.18s, transform 0.08s;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #fff;
  border-color: rgba(96, 165, 250, 0.55);
  box-shadow: var(--glow-blue);
}
.btn-primary:hover { filter: brightness(1.1); box-shadow: 0 6px 24px rgba(59, 130, 246, 0.65); }
.btn-outline {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(163, 191, 255, 0.38);
  color: #dbe7ff;
}
.btn-outline:hover { background: rgba(59, 130, 246, 0.28); border-color: #7aa2ff; box-shadow: 0 0 14px rgba(59, 130, 246, 0.35); color: #fff; }
.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  color: #ffb4b4;
  border-color: rgba(248, 113, 113, 0.4);
}
.btn-danger:hover { background: rgba(248, 113, 113, 0.26); border-color: #f87171; box-shadow: 0 0 14px rgba(248, 113, 113, 0.4); color: #fff; }
.btn-small { padding: 5px 10px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; filter: none; box-shadow: none; }

.status { margin-top: 12px; font-size: 14px; min-height: 20px; }
.status.success { color: var(--success); text-shadow: 0 0 12px rgba(52, 211, 153, 0.45); }
.status.error { color: var(--danger); text-shadow: 0 0 12px rgba(248, 113, 113, 0.45); }

/* ---------- 上传 ---------- */
.upload-buttons { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 6px; }
.file-pick { cursor: pointer; user-select: none; }
.file-summary {
  margin: 10px 0;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px dashed rgba(163, 191, 255, 0.4);
  border-radius: 8px;
  font-size: 13px;
  word-break: break-all;
}

/* ---------- 表单 ---------- */
.field { margin: 14px 0; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: #cfe0ff; }
.field input[type="text"],
.field input[type="password"],
.field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.field input:focus, .field textarea:focus, .filter-bar input:focus {
  outline: none;
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.35), 0 0 16px rgba(59, 130, 246, 0.35);
}
.field input::placeholder, .field textarea::placeholder, .filter-bar input::placeholder {
  color: rgba(157, 177, 230, 0.65);
}
.readonly { background: rgba(0, 0, 0, 0.2) !important; color: var(--muted); }
.check-line { display: flex; align-items: center; gap: 8px; font-weight: 400 !important; cursor: pointer; }
.check-line input[type="checkbox"] { accent-color: var(--primary); width: 15px; height: 15px; }

/* ---------- 列表 ---------- */
.list-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.list-head h2 { margin: 0; }
.filter-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filter-bar input[type="text"] {
  width: 230px;
  padding: 7px 11px;
  border: 1px solid var(--border);
  border-radius: 9px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}
.table-wrap { overflow-x: auto; }
.report-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-table th, .report-table td {
  text-align: left;
  padding: 11px 12px;
  border-bottom: 1px solid rgba(148, 180, 255, 0.16);
  vertical-align: middle;
}
.report-table th {
  font-size: 12.5px;
  color: #a9c3ff;
  font-weight: 600;
  white-space: nowrap;
  background: rgba(96, 165, 250, 0.12);
}
.report-table tr:hover td { background: rgba(96, 165, 250, 0.1); }

.desc-cell { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.actions { display: flex; gap: 6px; white-space: nowrap; }

.list-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 14px;
  font-size: 13px;
}
.pagination { display: flex; gap: 5px; flex-wrap: wrap; }
.page-btn {
  min-width: 30px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.07);
  border-radius: 7px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  color: #dbe7ff;
  transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.page-btn:hover:not(:disabled) { border-color: #7aa2ff; color: #fff; box-shadow: 0 0 12px rgba(59, 130, 246, 0.4); }
.page-btn.active {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  border-color: rgba(96, 165, 250, 0.6);
  color: #fff;
  box-shadow: var(--glow-blue);
}
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- 令牌 ---------- */
.token-list { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.token-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 9px;
  font-size: 13px;
}
.token-value {
  flex: 0 0 50%;
  max-width: 50%;
  font-family: Consolas, "Courier New", monospace;
  font-size: 12px;
  color: #cfe2ff;
  word-break: break-all;
  line-height: 1.5;
}
.token-time { margin-right: auto; white-space: nowrap; font-size: 12px; }
.token-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ---------- 徽标 ---------- */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge.on { background: rgba(251, 191, 36, 0.16); color: #ffd98a; border: 1px solid rgba(251, 191, 36, 0.4); }
.badge.off { background: rgba(157, 177, 230, 0.14); color: var(--muted); border: 1px solid rgba(157, 177, 230, 0.3); }

/* ---------- 提示 ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 48px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(10, 20, 52, 0.9);
  backdrop-filter: blur(10px);
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 14px;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  border: 1px solid rgba(96, 165, 250, 0.4);
  box-shadow: var(--glow-blue);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 弹窗 ---------- */
.dialog {
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--glass-strong);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 16px 50px rgba(3, 8, 30, 0.7);
  color: var(--text);
  padding: 24px;
  width: min(460px, 92vw);
}
.dialog::backdrop { background: rgba(4, 10, 32, 0.6); backdrop-filter: blur(4px); }
.dialog h3 { margin: 0 0 4px; color: #fff; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------- 登录 / 注册 / 密码门 / 错误页 ---------- */
.login-card, .gate-card, .error-card { max-width: 440px; margin: 50px auto; text-align: center; }
.login-logo { font-size: 42px; filter: drop-shadow(0 0 14px rgba(96, 165, 250, 0.7)); }
.gate-icon { font-size: 38px; filter: drop-shadow(0 0 14px rgba(96, 165, 250, 0.7)); }
.error-code {
  font-size: 46px;
  font-weight: 800;
  color: var(--danger);
  text-shadow: 0 0 22px rgba(248, 113, 113, 0.6);
}
.auth-form { margin-top: 18px; text-align: left; }
.auth-switch { margin-top: 16px; font-size: 14px; }
.auth-switch a { color: #7db0ff; text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; text-shadow: 0 0 10px rgba(96, 165, 250, 0.5); }
.notice {
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  color: var(--warn-text);
  border-radius: 9px;
  padding: 10px 12px;
  font-size: 13px;
  margin-top: 12px;
  text-align: left;
}
.notice a { color: #7db0ff; }

.footer {
  color: rgba(220, 235, 255, 0.65);
  font-size: 13px;
  padding: 18px 0 30px;
  text-align: center;
  text-shadow: 0 1px 6px rgba(3, 8, 30, 0.6);
}

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: rgba(96, 165, 250, 0.35); border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: rgba(96, 165, 250, 0.55); }
::-webkit-scrollbar-track { background: rgba(255, 255, 255, 0.04); }
