:root {
  --bg: #f4f6f9;
  --panel: #ffffff;
  --border: #e3e8ef;
  --border-strong: #d0d7e2;
  --text: #1c2430;
  --text-2: #5b6675;
  --text-3: #8a94a3;
  --primary: #1f5fd4;
  --primary-light: #eaf1fd;
  --primary-dark: #17489f;
  --green: #12805c;
  --green-bg: #e6f6ef;
  --red: #c0392b;
  --red-bg: #fdeceb;
  --amber: #9a6700;
  --amber-bg: #fdf5e2;
  --blue: #1f5fd4;
  --blue-bg: #eaf1fd;
  --gray-bg: #eef1f5;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}

a {
  color: var(--primary);
  text-decoration: none;
}

/* ---------- 登录 ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(1200px 600px at 20% 0%, #e8f0fe 0%, #f4f6f9 45%, #eef1f6 100%);
}

.login-card {
  width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow-lg);
  padding: 36px 34px 30px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.login-brand .mark {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 15px;
}

.login-brand h1 {
  font-size: 18px;
  margin: 0;
  font-weight: 600;
}

.login-sub {
  color: var(--text-3);
  font-size: 12.5px;
  margin: 0 0 24px;
}

/* ---------- 布局 ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  padding: 18px 18px 14px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-bottom: 1px solid var(--border);
}

.side-brand .mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
}

.side-brand .t1 {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
}

.side-brand .t2 {
  font-size: 11px;
  color: var(--text-3);
}

.nav {
  padding: 10px 10px 20px;
  overflow-y: auto;
  flex: 1;
}

.nav-group {
  font-size: 11px;
  color: var(--text-3);
  padding: 12px 10px 6px;
  letter-spacing: 0.04em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-2);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 2px;
  transition: background 0.12s, color 0.12s;
}

.nav-item:hover {
  background: #f6f8fb;
  color: var(--text);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-item svg {
  width: 15px;
  height: 15px;
  flex: 0 0 15px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.7;
}

.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  border-radius: 9px;
  font-size: 10.5px;
  padding: 0 6px;
  line-height: 16px;
  font-weight: 600;
}

.side-foot {
  border-top: 1px solid var(--border);
  padding: 10px 14px;
  font-size: 11.5px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 58px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar h2 {
  font-size: 15.5px;
  margin: 0;
  font-weight: 600;
}

.topbar .crumb {
  color: var(--text-3);
  font-size: 12px;
}

.topbar .spacer {
  flex: 1;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--text-2);
}

.avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary);
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 12px;
}

.content {
  padding: 20px 22px 40px;
  flex: 1;
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}

.card-head h3 {
  margin: 0;
  font-size: 13.5px;
  font-weight: 600;
}

.card-head .sub {
  color: var(--text-3);
  font-size: 12px;
}

.card-body {
  padding: 16px;
}

.card-body.tight {
  padding: 0;
}

/* ---------- 统计卡 ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.stat {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.stat .label {
  color: var(--text-3);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat .value {
  font-size: 25px;
  font-weight: 650;
  margin-top: 4px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.stat .value small {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-3);
  margin-left: 4px;
}

.stat .foot {
  font-size: 11.5px;
  color: var(--text-3);
  margin-top: 2px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
}

/* ---------- 工具条 ---------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.toolbar .grow {
  flex: 1;
}

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

.field label {
  font-size: 12px;
  color: var(--text-2);
}

.field .hint {
  font-size: 11.5px;
  color: var(--text-3);
}

input[type="text"],
input[type="number"],
input[type="password"],
input[type="datetime-local"],
input[type="date"],
select,
textarea {
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  background: #fff;
  padding: 0 9px;
  outline: none;
  transition: border-color 0.12s, box-shadow 0.12s;
  min-width: 0;
}

textarea {
  height: auto;
  padding: 7px 9px;
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(31, 95, 212, 0.12);
}

select {
  padding-right: 6px;
  cursor: pointer;
}

.btn {
  height: 32px;
  padding: 0 13px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  background: #fff;
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s, opacity 0.12s;
}

.btn:hover {
  background: #f7f9fc;
  border-color: #bcc6d4;
}

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

.btn.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn.danger {
  color: var(--red);
  border-color: #eccac6;
}

.btn.danger:hover {
  background: var(--red-bg);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
  color: var(--primary);
  padding: 0 6px;
  height: 26px;
}

.btn.ghost:hover {
  background: var(--primary-light);
}

.btn.sm {
  height: 26px;
  font-size: 12px;
  padding: 0 9px;
  border-radius: 6px;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link {
  color: var(--primary);
  cursor: pointer;
  font-size: 12.5px;
}

.link.danger {
  color: var(--red);
}

.link.muted {
  color: var(--text-2);
}

/* ---------- 表格 ---------- */
.table-wrap {
  overflow-x: auto;
}

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

thead th {
  text-align: left;
  font-weight: 600;
  color: var(--text-2);
  background: #f8fafc;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 12px;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid #f1f4f8;
  vertical-align: middle;
}

tbody tr:hover {
  background: #fafbfd;
}

tbody tr:last-child td {
  border-bottom: none;
}

td.mono,
.mono {
  font-family: "JetBrains Mono", Consolas, "Courier New", monospace;
  font-size: 12px;
}

td.actions {
  white-space: nowrap;
  text-align: right;
}

.empty {
  padding: 40px 0;
  text-align: center;
  color: var(--text-3);
  font-size: 12.5px;
}

/* ---------- 徽标 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 500;
  background: var(--gray-bg);
  color: var(--text-2);
  white-space: nowrap;
}

.badge.green {
  background: var(--green-bg);
  color: var(--green);
}

.badge.red {
  background: var(--red-bg);
  color: var(--red);
}

.badge.amber {
  background: var(--amber-bg);
  color: var(--amber);
}

.badge.blue {
  background: var(--blue-bg);
  color: var(--blue);
}

.badge.gray {
  background: var(--gray-bg);
  color: var(--text-2);
}

.badge.outline {
  background: #fff;
  border: 1px solid var(--border-strong);
  color: var(--text-2);
}

/* ---------- 分页 ---------- */
.pager {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 12.5px;
  color: var(--text-2);
}

.pager .spacer {
  flex: 1;
}

/* ---------- 弹层 ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 28, 40, 0.35);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal {
  background: #fff;
  border-radius: 12px;
  width: 560px;
  max-width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  animation: pop 0.14s ease-out;
}

.modal.wide {
  width: 860px;
}

@keyframes pop {
  from {
    transform: translateY(-6px);
    opacity: 0.6;
  }
  to {
    transform: none;
    opacity: 1;
  }
}

.modal-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-head h3 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.modal-head .close {
  margin-left: auto;
  cursor: pointer;
  color: var(--text-3);
  font-size: 18px;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 6px;
}

.modal-head .close:hover {
  background: #f2f5f9;
  color: var(--text);
}

.modal-body {
  padding: 18px;
  max-height: 66vh;
  overflow-y: auto;
}

.modal-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  background: #fbfcfe;
  border-radius: 0 0 12px 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px 14px;
}

.form-grid .full {
  grid-column: 1 / -1;
}

/* ---------- 提示 ---------- */
.toasts {
  position: fixed;
  right: 20px;
  bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 300;
}

.toast {
  background: #1c2430;
  color: #fff;
  padding: 9px 14px;
  border-radius: 8px;
  font-size: 12.8px;
  box-shadow: var(--shadow-lg);
  animation: pop 0.16s ease-out;
  max-width: 380px;
}

.toast.error {
  background: #a5342a;
}

.toast.ok {
  background: #146a4f;
}

/* ---------- 图表 ---------- */
.chart {
  width: 100%;
  height: 180px;
}

.legend {
  display: flex;
  gap: 14px;
  font-size: 11.5px;
  color: var(--text-2);
  align-items: center;
}

/* ---------- 适配器卡 ---------- */
.adapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

.adapter-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  background: #fff;
}

.adapter-card h4 {
  margin: 0 0 2px;
  font-size: 13.5px;
}

.adapter-card .type {
  font-family: Consolas, monospace;
  font-size: 11px;
  color: var(--text-3);
}

.adapter-card .caps {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.kv {
  display: grid;
  grid-template-columns: 96px 1fr;
  gap: 7px 12px;
  font-size: 12.5px;
}

.kv dt {
  color: var(--text-3);
}

.kv dd {
  margin: 0;
  word-break: break-all;
}

pre.code {
  background: #0f1720;
  color: #d6e2f0;
  padding: 12px;
  border-radius: 8px;
  font-family: Consolas, "Courier New", monospace;
  font-size: 11.8px;
  line-height: 1.55;
  overflow: auto;
  max-height: 260px;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 14px;
}

.tab {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-2);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}

.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.section-title {
  font-size: 13px;
  font-weight: 600;
  margin: 4px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title .line {
  flex: 1;
  height: 1px;
  background: var(--border);
}

.notice {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  padding: 9px 12px;
  font-size: 12.3px;
  color: var(--text-2);
  margin-bottom: 12px;
}

.copy {
  cursor: pointer;
  color: var(--text-3);
  font-size: 11.5px;
  margin-left: 4px;
}

.copy:hover {
  color: var(--primary);
}

.spin {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(0, 0, 0, 0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 900px) {
  .sidebar {
    display: none;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
