@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;600;700&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg: #0c0e12;
  --surface: #14171e;
  --surface2: #1a1e28;
  --border: #252a35;
  --border-light: #333a48;
  --text: #d4d8e0;
  --dim: #6b7280;
  --accent: #c9a55a;
  --accent-dim: #9e7c34;
  --danger: #e05252;
  --radius: 6px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Serif SC', serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 600px 400px at 20% 30%, rgba(201,165,90,.06), transparent),
    radial-gradient(ellipse 500px 500px at 80% 70%, rgba(100,120,180,.05), transparent);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.6;
}

.hidden { display: none !important; }
.mono { font-family: 'JetBrains Mono', monospace; }
.dim { color: var(--dim); }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(12,14,18,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner {
  max-width: 860px; margin: 0 auto; padding: 14px 24px;
  display: flex; align-items: center; justify-content: space-between;
}
.brand { font-size: 17px; font-weight: 700; color: var(--accent); letter-spacing: .05em; }
.brand-dim { color: var(--dim); font-weight: 400; font-size: 13px; margin-left: 10px; letter-spacing: .1em; }

/* ---------- 布局 ---------- */
.container { max-width: 860px; margin: 0 auto; padding: 28px 24px 64px; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  transition: border-color .2s;
}
.card:hover { border-color: var(--border-light); }
.card-head {
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.card-head h2 { font-size: 15px; font-weight: 600; color: var(--accent); letter-spacing: .06em; }
.card-body { padding: 18px 20px 22px; }

/* ---------- 概览 ---------- */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 20px; margin-bottom: 20px;
}
.stat { padding: 18px; margin-bottom: 0; text-align: center; }
.stat-num {
  font-size: 30px; font-weight: 700; color: var(--accent);
  line-height: 1.2; font-variant-numeric: tabular-nums;
}
.stat-num.stat-dim { color: var(--dim); }
.stat-unit { font-size: 13px; font-weight: 400; margin-left: 2px; }
.stat-label { font-size: 12.5px; color: var(--dim); margin-top: 6px; letter-spacing: .05em; }

/* ---------- 按钮 ---------- */
.btn, .btn-primary, .btn-danger {
  font-family: inherit; font-size: 14px; cursor: pointer;
  border-radius: var(--radius); padding: 8px 18px;
  transition: background .18s, border-color .18s, color .18s;
  letter-spacing: .04em;
}
.btn {
  background: transparent; color: var(--text);
  border: 1px solid var(--border-light);
}
.btn:hover { border-color: var(--accent-dim); color: var(--accent); }
.btn-primary {
  background: var(--accent); color: #14130d;
  border: 1px solid var(--accent); font-weight: 600;
}
.btn-primary:hover { background: var(--accent-dim); border-color: var(--accent-dim); }
.btn-danger {
  background: transparent; color: var(--danger);
  border: 1px solid var(--danger);
}
.btn-danger:hover { background: rgba(224,82,82,.12); }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn:disabled, .btn-primary:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .btn-primary:focus-visible, .btn-danger:focus-visible,
.input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- 输入 ---------- */
.input {
  width: 100%; padding: 10px 12px; font-size: 14px;
  font-family: inherit; color: var(--text);
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius); transition: border-color .18s;
}
.input:focus { outline: none; border-color: var(--accent); }
.input::placeholder { color: var(--dim); }

/* ---------- 登录 ---------- */
.login-wrap { display: flex; justify-content: center; padding-top: 9vh; }
.login-card { width: 360px; padding: 32px; text-align: center; margin-bottom: 0; }
.login-title { font-size: 19px; font-weight: 700; color: var(--accent); letter-spacing: .1em; }
.login-hint { color: var(--dim); font-size: 13px; margin: 10px 0 22px; }
.code-input {
  text-align: center; font-size: 22px; letter-spacing: .45em;
  padding: 12px; margin-bottom: 16px;
}
.form-error { color: var(--danger); font-size: 13px; margin-top: 12px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
  text-align: left; color: var(--dim); font-weight: 400;
  font-size: 12px; letter-spacing: .08em;
  padding: 8px 10px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 10px; border-bottom: 1px solid var(--border);
  vertical-align: middle; white-space: nowrap;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.015); }
.th-actions { text-align: right; }
.td-actions { text-align: right; }
.td-actions .btn-sm { margin-left: 6px; }
.td-query {
  max-width: 220px; overflow: hidden; text-overflow: ellipsis;
  color: var(--dim);
}
.key-prefix { font-family: 'JetBrains Mono', monospace; font-size: 12.5px; color: var(--accent); }

.badge {
  display: inline-block; padding: 2px 10px; border-radius: 10px;
  font-size: 12px; letter-spacing: .05em;
}
.badge-on  { color: var(--accent); border: 1px solid var(--accent-dim); }
.badge-off { color: var(--dim); border: 1px solid var(--border-light); }
.badge-ok  { color: #7dba6a; }
.badge-err { color: var(--danger); }
.badge-local { color: var(--dim); }

.empty { color: var(--dim); text-align: center; padding: 18px 0 6px; font-size: 13.5px; }
.load-more-wrap { text-align: center; margin-top: 14px; }

/* ---------- 模态框 ---------- */
.modal {
  display: none; position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  align-items: center; justify-content: center; padding: 24px;
}
.modal.active { display: flex; }
.modal-box {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 32px;
  width: 100%; max-width: 440px;
  box-shadow: 0 24px 64px rgba(0,0,0,.6);
}
.modal-box h3 { font-size: 17px; color: var(--accent); font-weight: 700; margin-bottom: 10px; letter-spacing: .06em; }
.modal-desc { color: var(--dim); font-size: 13.5px; margin-bottom: 18px; }
.warn-text { color: var(--accent); }
.modal-actions {
  display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px;
}
.key-reveal {
  background: var(--bg); border: 1px solid var(--accent-dim);
  border-radius: var(--radius); padding: 14px;
  font-size: 13px; word-break: break-all; user-select: all;
  color: var(--accent);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 28px; left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--surface2); border: 1px solid var(--accent-dim);
  color: var(--text); padding: 10px 22px;
  border-radius: var(--radius); font-size: 13.5px;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 200;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

@media (max-width: 640px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .container { padding: 20px 16px 48px; }
  .modal-box { padding: 24px; }
}
