:root {
  color-scheme: dark;
  --bg: #0e1116;
  --bg-soft: #151a21;
  --bg-raised: #1b222b;
  --line: #26303b;
  --text: #e6edf3;
  --muted: #8b98a5;
  --accent: #4f8cff;
  --accent-soft: rgba(79, 140, 255, 0.14);
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 20% -10%, #16202c 0%, var(--bg) 60%);
  color: var(--text);
  font: 14px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  min-height: 100vh;
}

h1, h2 { margin: 0; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 17px; }
h2 { font-size: 15px; }

a { color: var(--accent); }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
code { background: var(--bg-raised); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.dim { opacity: 0.55; }
.num { text-align: right; font-variant-numeric: tabular-nums; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(14, 17, 22, 0.85);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand p { margin: 2px 0 0; font-size: 12px; }
.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: linear-gradient(160deg, #4f8cff, #2b5fd9);
  font: 700 12px/1 var(--mono);
  color: #fff;
  letter-spacing: 0.5px;
}

.topbar-side { display: flex; align-items: center; gap: 8px; }

.chip {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-soft);
  font-size: 12px;
  color: var(--muted);
}
.chip.ok { color: var(--ok); border-color: rgba(63, 185, 80, 0.3); }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-raised);
  color: var(--text);
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover { background: #232c37; border-color: #34404d; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3f7bf0; }
.btn.ghost { background: transparent; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.block { width: 100%; justify-content: center; }
.btn.link {
  background: none;
  border: none;
  padding: 2px 6px;
  color: var(--accent);
  font-size: 13px;
}
.btn.link:hover { text-decoration: underline; background: none; }
.btn.link.danger { color: var(--danger); }

.banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 24px;
  background: rgba(210, 153, 34, 0.12);
  border-bottom: 1px solid rgba(210, 153, 34, 0.35);
  color: #e3b341;
  font-size: 13px;
}

.container { max-width: 1080px; margin: 0 auto; padding: 22px 24px 64px; }

.tabs { display: flex; gap: 4px; margin-bottom: 14px; }
.tab {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.tab:hover { color: var(--text); }
.tab.active { background: var(--accent-soft); color: #9cc0ff; }

.panel {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.hint { font-size: 12.5px; margin: 12px 2px 0; }

.table-wrap { overflow-x: auto; }
.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th {
  text-align: left;
  font-weight: 500;
  font-size: 12px;
  color: var(--muted);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.grid td { padding: 10px; border-bottom: 1px solid rgba(38, 48, 59, 0.6); vertical-align: middle; }
.grid tr:last-child td { border-bottom: none; }
.grid .actions { text-align: right; white-space: nowrap; }
.grid .empty { text-align: center; color: var(--muted); padding: 24px; }

.name-cell { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.status { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; background: #4b5563; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(63, 185, 80, 0.16); }

.badge {
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--bg-raised);
}
.badge.site { color: #d2a8ff; border-color: rgba(210, 168, 255, 0.3); }
.badge.psk { color: #7ee787; border-color: rgba(126, 231, 135, 0.25); }
.badge.off { color: var(--danger); border-color: rgba(248, 81, 73, 0.3); }

/* auth page */
.auth-page { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.auth-card { width: min(380px, 100%); padding: 26px; }
.auth-card .brand { margin-bottom: 22px; }
.auth-lang { display: flex; justify-content: flex-end; margin-bottom: -14px; }

html[lang^="zh"] [data-lang="en"] { display: none; }
html[lang^="en"] [data-lang="zh"] { display: none; }

.docs h3 { margin: 24px 0 8px; font-size: 15px; }
.docs h3:first-child { margin-top: 4px; }
.docs p, .docs li { color: var(--muted); font-size: 13px; line-height: 1.75; }
.docs ul, .docs ol { padding-left: 20px; margin: 6px 0; }
.docs code { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; font-size: 12px; }
.docs pre { background: var(--bg-raised); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow-x: auto; }
.docs pre code { background: none; border: 0; padding: 0; font-size: 12px; line-height: 1.65; }
.docs table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 13px; }
.docs th, .docs td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.docs th { color: var(--text); font-weight: 600; }
.docs a { color: var(--accent); }
.nokey-body p { color: var(--muted); font-size: 13px; line-height: 1.7; }
.card {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.field input, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 11px;
  font: inherit;
}
.field input:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 14px; }
.checkbox input { accent-color: var(--accent); }

.error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 10px 0 0; }

/* dialogs */
.modal {
  border: 1px solid var(--line);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 14px;
  padding: 22px;
  width: min(440px, calc(100vw - 32px));
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
}
.modal::backdrop { background: rgba(3, 6, 10, 0.72); backdrop-filter: blur(2px); }
.modal h2 { margin-bottom: 16px; }
.modal.wide { width: min(880px, calc(100vw - 32px)); }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.detail-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.detail-grid { display: grid; grid-template-columns: 1fr 240px; gap: 18px; align-items: start; }
.detail-grid textarea {
  font-family: var(--mono);
  font-size: 12px;
  height: 340px;
  resize: vertical;
  line-height: 1.6;
}
.detail-actions { display: flex; gap: 8px; margin-top: 10px; }
.qr-box {
  background: #fff;
  border-radius: 10px;
  padding: 10px;
  display: grid;
  place-items: center;
  min-height: 240px;
}
.qr-box img { width: 100%; height: auto; display: block; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; padding: 12px 16px; }
  .container { padding: 16px 12px 48px; }
  .detail-grid { grid-template-columns: 1fr; }
  .qr-box { max-width: 240px; margin: 0 auto; }
}
