:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --text: #162033;
  --muted: #667085;
  --line: #e4e8f0;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --green: #0f9f6e;
  --green-bg: #e8f7f0;
  --amber: #b45309;
  --amber-bg: #fdf3e3;
  --red: #c0392b;
  --red-bg: #fdecea;
  --shadow: 0 12px 32px rgba(21, 35, 61, 0.08);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

button, input { font: inherit; }
button { cursor: pointer; }

[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 20%, rgba(37, 99, 235, 0.18), transparent 34%),
    radial-gradient(circle at 85% 75%, rgba(15, 159, 110, 0.16), transparent 36%),
    var(--bg);
}

.login-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 36px 32px 28px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #2563eb, #0f9f6e);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-bottom: 18px;
}

.brand-mark.small {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  margin: 0;
  font-size: 12px;
}

.login-card h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.muted { color: var(--muted); }
.login-card .muted { margin: 0 0 24px; }

label {
  display: block;
  font-weight: 600;
  color: #344054;
  margin-bottom: 14px;
}

.login-card label { font-size: 13px; }

input[type="text"],
input[type="password"],
input[type="search"],
input[type="number"] {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

select {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
}

select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.toolbar .filter-select {
  width: 132px;
  margin: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 7px 14px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: #fff;
  color: var(--text);
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

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

.btn.ghost {
  border-color: var(--line);
  color: #344054;
}

.btn.ghost:hover { background: #f2f5fa; }

.btn.danger {
  background: var(--red-bg);
  border-color: #f5c6c0;
  color: var(--red);
}

.btn.danger:hover { background: #fbdcd8; }

.btn.small {
  min-height: 30px;
  padding: 4px 10px;
  font-size: 12px;
  border-radius: 7px;
}

.btn.block { width: 100%; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

.error-text {
  min-height: 20px;
  margin-top: 10px;
  color: var(--red);
  font-size: 13px;
}

.topbar {
  height: 64px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar-title { display: flex; align-items: center; gap: 12px; }
.topbar-title div { display: flex; flex-direction: column; line-height: 1.3; }
.topbar-title .muted { font-size: 12px; }
.topbar-actions { display: flex; gap: 8px; }

.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 26px 28px 60px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px 18px;
  box-shadow: 0 4px 14px rgba(21, 35, 61, 0.04);
}

.stat-card .label { color: var(--muted); font-size: 12px; }
.stat-card .value { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.stat-card .note { color: var(--muted); font-size: 12px; }

/* 运行状况一行：进程指标 + 数据库体积，异常时由 JS 追加高亮类。 */
.runtime-line {
  margin: -10px 0 18px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}
.runtime-line.warn { color: #b45309; }

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 18px;
}

.tab {
  padding: 10px 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--muted);
  font-weight: 600;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab.has-pending:not(.active) { color: var(--amber); }

.panel { animation: fade 0.18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.toolbar input[type="search"] { max-width: 360px; margin: 0; }
.toolbar .muted { margin-left: auto; font-size: 12px; }

.table-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: auto;
  box-shadow: 0 4px 14px rgba(21, 35, 61, 0.04);
}

table { width: 100%; border-collapse: collapse; min-width: 900px; }

th, td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

th {
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

tbody tr:hover { background: #fbfcfe; }
tbody tr:last-child td { border-bottom: 0; }

th.right, td.right { text-align: right; }
td.actions { white-space: nowrap; }
td.actions .btn { margin-left: 4px; }

code.device-code {
  font-family: "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
  background: #f2f5fa;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 3px 7px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.chip.active { color: var(--green); background: var(--green-bg); }
.chip.pending { color: var(--amber); background: var(--amber-bg); }
.chip.blocked { color: var(--red); background: var(--red-bg); }

.cell-main { font-weight: 600; }
.cell-sub { color: var(--muted); font-size: 12px; }
.empty { padding: 40px; text-align: center; color: var(--muted); }

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.vault-grid {
  display: grid;
  grid-template-columns: minmax(320px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.users-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

textarea {
  width: 100%;
  margin-top: 6px;
  padding: 10px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 9px;
  background: #fff;
  color: var(--text);
  outline: none;
  resize: vertical;
  font-family: "Cascadia Mono", Consolas, "Microsoft YaHei UI", monospace;
  font-size: 13px;
  line-height: 1.5;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.vault-dialog {
  width: min(760px, 92vw);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 22px;
  box-shadow: var(--shadow);
  background: var(--surface);
  color: var(--text);
}

.vault-dialog::backdrop {
  background: rgba(10, 20, 40, 0.45);
}

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

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

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 4px 14px rgba(21, 35, 61, 0.04);
}

.card h2 { margin: 0 0 6px; font-size: 16px; letter-spacing: -0.01em; }
.card .hint { color: var(--muted); font-size: 12px; margin: 0 0 16px; }
.card label { font-size: 13px; }
.card .btn { margin-top: 4px; }

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 14px;
}

.switch {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 6px;
  cursor: pointer;
}

.switch input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
}

.danger-card { border-color: #f5c6c0; background: #fffafa; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #162033;
  color: #fff;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: 80vw;
  font-size: 13px;
}

.toast.error { background: var(--red); }

@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .settings-grid { grid-template-columns: 1fr; }
  .vault-grid { grid-template-columns: 1fr; }
  .users-grid { grid-template-columns: 1fr; }
  .topbar { padding: 0 16px; }
  .page { padding: 20px 16px 48px; }
}

@media (max-width: 560px) {
  .stats { grid-template-columns: 1fr; }
  .field-grid { grid-template-columns: 1fr; }
  .topbar-title strong { font-size: 13px; }
}

/* ---------- 用户详情弹窗：登录历史 / 操作日志 / 网盘 / API ---------- */
.user-detail-dialog {
  width: min(1180px, 96vw);
  max-height: 90vh;
  border: 0;
  border-radius: 18px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.user-detail-dialog::backdrop { background: rgba(15, 23, 42, 0.48); }

.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--line);
}

.detail-head h2 { margin: 0 0 4px; font-size: 20px; }
.detail-head p { margin: 0; }
.detail-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.detail-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  padding: 14px 24px;
  background: #f8fafc;
  border-bottom: 1px solid var(--line);
}

.detail-stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.detail-stat .label { color: var(--muted); font-size: 12px; }
.detail-stat .value { font-size: 18px; font-weight: 700; margin-top: 2px; }
.detail-stat .note { color: #94a3b8; font-size: 11px; margin-top: 2px; }

.detail-tabs { margin: 0; padding: 0 24px; }
.detail-body { padding: 16px 24px 24px; max-height: 52vh; overflow: auto; }
.detail-section + .detail-section { margin-top: 18px; }
.detail-section h3 { margin: 0 0 10px; font-size: 15px; }
.detail-table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.detail-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.detail-table th, .detail-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #eef2f7;
  vertical-align: top;
}
.detail-table th {
  color: var(--muted);
  font-weight: 600;
  font-size: 12px;
  background: #f8fafc;
  white-space: nowrap;
}
.detail-table tbody tr:last-child td { border-bottom: 0; }
.detail-table code { font-size: 12px; word-break: break-all; }
.detail-empty { color: #94a3b8; padding: 28px; text-align: center; }

@media (max-width: 720px) {
  .detail-head { flex-direction: column; }
  .detail-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-body { max-height: 58vh; padding: 14px 16px 20px; }
  .detail-head { padding: 16px; }
  .detail-tabs { padding: 0 16px; overflow-x: auto; }
}

.detail-search {
  width: 230px;
  max-width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
}

@media (max-width: 720px) {
  .detail-search { width: 100%; }
}

.activity-pager {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 12px;
}

.ui-version { margin-left: 6px; font-size: 11px; }

.detail-notice {
  padding: 10px 24px;
  background: #fff8e6;
  border-bottom: 1px solid #f3e1b5;
  color: #8a5a00;
  font-size: 13px;
}

.onboarding-hint {
  margin: 0 0 16px;
  padding: 12px 16px;
  background: #eef6ff;
  border: 1px solid #cfe3ff;
  color: #1d4ed8;
  border-radius: 12px;
  font-size: 13px;
}
