:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1b2230;
  --panel-3: #212a3a;
  --border: #2b3444;
  --border-strong: #3a4658;
  --text: #e6edf3;
  --muted: #8b98a9;
  --primary: #4f8cff;
  --primary-dim: #2f5fb8;
  --ok: #3fb950;
  --warn: #d29922;
  --danger: #f85149;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 system-ui, -apple-system, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--primary); }

/* ── 布局 ─────────────────────────────────────────── */

.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 224px;
  flex: 0 0 224px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  background: var(--panel);
  border-right: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
  font-weight: 650;
  font-size: 15px;
  letter-spacing: .2px;
}

.brand .logo {
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 9px;
  background: linear-gradient(135deg, #2f6feb, #20b2aa);
  font-size: 16px;
}

.nav { display: flex; flex-direction: column; gap: 4px; overflow-y: auto; }

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  cursor: pointer;
  transition: background .15s, color .15s;
}

.nav button:hover { background: var(--panel-2); color: var(--text); }

.nav button.active {
  background: rgba(79, 140, 255, .14);
  color: #9dc0ff;
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--ok);
  margin-right: 6px;
  box-shadow: 0 0 0 3px rgba(63, 185, 80, .15);
}

.main {
  flex: 1;
  min-width: 0;
  padding: 26px 32px 130px;
  max-width: 1200px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head h1 {
  margin: 0 0 4px;
  font-size: 21px;
  font-weight: 650;
}

.page-head .sub { color: var(--muted); font-size: 13px; max-width: 720px; }

/* ── 卡片 ─────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  margin-bottom: 16px;
}

.card-title {
  margin: 0 0 14px;
  font-size: 14px;
  font-weight: 650;
  letter-spacing: .3px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-title .count {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
}

.subcard {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--panel-2);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.subcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.subcard-head strong { font-size: 13.5px; overflow-wrap: anywhere; }

.empty {
  color: var(--muted);
  font-size: 13px;
  padding: 10px 0;
}

/* ── 表单 ─────────────────────────────────────────── */

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px 16px;
}

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }

.field-label {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: .2px;
}

.field-hint { font-size: 11.5px; color: #6e7d90; }

/* 字段说明角标：悬停 / 聚焦显示气泡 */
.doc-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  margin-left: 4px;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  font-size: 9px;
  font-style: italic;
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1;
  cursor: help;
  user-select: none;
  flex: none;
}

.doc-badge:hover,
.doc-badge:focus {
  border-color: var(--primary);
  color: #9dc0ff;
  outline: none;
}

.doc-pop {
  display: none;
  position: absolute;
  top: calc(100% + 7px);
  left: 0;
  z-index: 40;
  width: max-content;
  max-width: min(300px, calc(100vw - 56px));
  padding: 9px 11px;
  background: #0b0f15;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .55);
  color: var(--text);
  font-size: 12px;
  font-style: normal;
  font-weight: 400;
  line-height: 1.55;
  text-align: left;
  white-space: normal;
  pointer-events: none;
}

.doc-badge:hover .doc-pop,
.doc-badge:focus .doc-pop { display: block; }

@media (max-width: 640px) {
  .doc-pop { left: auto; right: 0; }
}

input[type="text"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 8px 10px;
  background: #0f141c;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary-dim);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, .16);
}

textarea.code {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  resize: vertical;
  min-height: 120px;
  white-space: pre;
  tab-size: 2;
}

textarea.invalid, input.invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(248, 81, 73, .14);
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
}

.check input { width: 15px; height: 15px; accent-color: var(--primary); }

.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }

.muted { color: var(--muted); font-size: 12.5px; }

/* ── 按钮 ─────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
  transition: background .15s, border-color .15s, opacity .15s;
  white-space: nowrap;
}

.btn:hover { background: var(--panel-3); border-color: #4a586d; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  font-weight: 600;
}
.btn.primary:hover { background: #3f7df2; }

.btn.ghost { background: transparent; }

.btn.danger { color: var(--danger); border-color: rgba(248, 81, 73, .4); background: transparent; }
.btn.danger:hover { background: rgba(248, 81, 73, .12); color: #ff7b72; border-color: var(--danger); }

.btn.tiny { padding: 3px 9px; font-size: 12px; border-radius: 6px; }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 状态元素 ─────────────────────────────────────── */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  white-space: nowrap;
}

.badge.ok { color: #6fdb82; border-color: rgba(63, 185, 80, .35); background: rgba(63, 185, 80, .1); }
.badge.warn { color: #e2b93b; border-color: rgba(210, 153, 34, .35); background: rgba(210, 153, 34, .1); }
.badge.danger { color: #ff7b72; border-color: rgba(248, 81, 73, .35); background: rgba(248, 81, 73, .1); }
.badge.info { color: #9dc0ff; border-color: rgba(79, 140, 255, .35); background: rgba(79, 140, 255, .1); }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
}

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .k { color: var(--muted); font-size: 11.5px; letter-spacing: .2px; }
.stat .v { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
.stat .v.mono { font-family: var(--mono); font-size: 13px; }

.domain-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.domain-row:last-child { border-bottom: 0; padding-bottom: 0; }
.domain-row:first-child { padding-top: 0; }

.domain-name { font-weight: 600; overflow-wrap: anywhere; }
.domain-meta { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 12px; }

.actions { display: flex; gap: 8px; flex-wrap: wrap; }

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

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th { color: var(--muted); font-weight: 500; font-size: 11.5px; letter-spacing: .3px; }
tr:last-child td { border-bottom: 0; }

td.mono, .mono { font-family: var(--mono); font-size: 12px; }

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

/* ── 折叠 / 校验 / 提示 ─────────────────────────────── */

details.details {
  border-top: 1px dashed var(--border);
  margin-top: 12px;
  padding-top: 10px;
}

details.details > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12.5px;
  user-select: none;
}

details.details > summary:hover { color: var(--text); }

.details-body { margin-top: 12px; display: flex; flex-direction: column; gap: 12px; }

.validation {
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 14px;
  font-size: 12.5px;
}

.validation.error { background: rgba(248, 81, 73, .08); border: 1px solid rgba(248, 81, 73, .35); }
.validation.warn { background: rgba(210, 153, 34, .08); border: 1px solid rgba(210, 153, 34, .3); }
.validation ul { margin: 6px 0 0; padding-left: 18px; }
.validation li { margin: 3px 0; }

/* ── 保存条 ───────────────────────────────────────── */

.save-bar {
  position: fixed;
  left: 224px;
  right: 0;
  bottom: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 32px;
  background: rgba(15, 20, 28, .94);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(8px);
  flex-wrap: wrap;
}

.save-bar .state { color: var(--muted); font-size: 12.5px; }
.save-bar .state.dirty { color: var(--warn); }

/* ── 登录 ─────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 26px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.login-card h1 { font-size: 18px; margin: 0 0 6px; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 12.5px; }
.login-card .btn { width: 100%; margin-top: 14px; }
.login-error { color: var(--danger); font-size: 12.5px; min-height: 18px; margin-top: 10px; }

/* ── 日志 ─────────────────────────────────────────── */

.log-box {
  background: #0b0f15;
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: calc(100vh - 320px);
  overflow: auto;
  margin: 0;
}

.log-toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.log-toolbar select { width: auto; }

/* ── toast ────────────────────────────────────────── */

.toasts {
  position: fixed;
  right: 20px;
  bottom: 84px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  min-width: 220px;
  max-width: 420px;
  padding: 10px 14px;
  border-radius: 8px;
  background: var(--panel-3);
  border: 1px solid var(--border-strong);
  font-size: 12.5px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  animation: toast-in .18s ease-out;
  pointer-events: auto;
}

.toast.ok { border-color: rgba(63, 185, 80, .5); }
.toast.error { border-color: rgba(248, 81, 73, .55); }
.toast.warn { border-color: rgba(210, 153, 34, .5); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── 其它 ─────────────────────────────────────────── */

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

.spacer { height: 8px; }

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; flex-direction: row; align-items: center; padding: 10px 14px; gap: 12px; overflow-x: auto; }
  .brand { padding: 0; white-space: nowrap; }
  .nav { flex-direction: row; }
  .nav button { width: auto; white-space: nowrap; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; flex-direction: row; align-items: center; }
  .main { padding: 20px 16px 140px; }
  .save-bar { left: 0; padding: 12px 16px; }
}
