:root {
  --bg: #F5F4F0;
  --surface: #FFFFFF;
  --surface-2: #F1EFE8;
  --border: #E5E3DC;
  --border-strong: #D3D1C7;
  --text: #2C2C2A;
  --text-2: #5F5E5A;
  --text-3: #888780;
  --accent: #185FA5;
  --accent-bg: #E6F1FB;
  --success: #3B6D11;
  --success-bg: #EAF3DE;
  --warning: #854F0B;
  --warning-bg: #FAEEDA;
  --danger: #A32D2D;
  --danger-bg: #FCEBEB;
  --radius: 10px;
  --radius-lg: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

code, pre, .mono {
  font-family: Consolas, Monaco, "Courier New", monospace;
  font-size: 13px;
}

/* ---------- 布局 ---------- */

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

.sidebar {
  width: 216px;
  flex: 0 0 216px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 10px 18px;
}
.brand-mark {
  width: 28px; height: 28px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600;
  flex: 0 0 28px;
}
.brand-name { font-size: 15px; font-weight: 600; letter-spacing: .2px; }

.nav-group { margin-bottom: 14px; }
.nav-title {
  font-size: 11px;
  color: var(--text-3);
  padding: 6px 10px;
  letter-spacing: .6px;
  text-transform: uppercase;
}
.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 8px;
  color: var(--text-2);
  font-size: 13.5px;
  margin-bottom: 1px;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; color: var(--text); }
.nav-item.active { background: var(--accent-bg); color: var(--accent); font-weight: 500; }

.main { flex: 1; min-width: 0; padding: 24px 28px 60px; }
.main-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px; margin-bottom: 20px; flex-wrap: wrap;
}
.main-head h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
.main-head p { margin: 0; color: var(--text-2); font-size: 13px; }

/* ---------- 卡片 ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 14px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15px; font-weight: 600; margin: 0; }
.card-head .hint { font-size: 12.5px; color: var(--text-3); margin: 0; }

.grid { display: grid; gap: 12px; }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.metric {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.metric .label { font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.metric .value { font-size: 26px; font-weight: 600; line-height: 1.2; }
.metric .value.small { font-size: 18px; }
.metric .sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ---------- 表格 ---------- */

.table-wrap { overflow-x: auto; }
table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
table.data th {
  text-align: left;
  font-weight: 500;
  color: var(--text-2);
  font-size: 12.5px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  background: var(--surface-2);
}
table.data th:first-child { border-top-left-radius: 8px; }
table.data th:last-child { border-top-right-radius: 8px; }
table.data td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #FBFAF7; }
table.data td.nowrap { white-space: nowrap; }
table.data td.actions { white-space: nowrap; text-align: right; }

/* ---------- 表单 ---------- */

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 13px;
  color: var(--text-2);
  margin-bottom: 5px;
}
.field .desc { font-size: 12px; color: var(--text-3); margin-top: 4px; }

input[type=text], input[type=password], input[type=number], input[type=email],
select, textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(24,95,165,.12);
}
textarea { resize: vertical; min-height: 90px; }
textarea.mono { font-family: Consolas, Monaco, monospace; font-size: 13px; }

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 140px; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.check input { width: auto; }

/* ---------- 按钮 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: #0C447C; }
.btn-danger { color: var(--danger); border-color: #F09595; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 4px 10px; font-size: 12.5px; }
.btn-link {
  border: none; background: none; color: var(--accent);
  padding: 2px 4px; cursor: pointer; font-size: 12.5px; font-family: inherit;
}
.btn-link:hover { text-decoration: underline; background: none; }
.btn-link.danger { color: var(--danger); }

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

/* ---------- 标签 ---------- */

.tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1.7;
  white-space: nowrap;
}
.tag-info { background: var(--accent-bg); color: var(--accent); }
.tag-success { background: var(--success-bg); color: var(--success); }
.tag-warning { background: var(--warning-bg); color: var(--warning); }
.tag-danger { background: var(--danger-bg); color: var(--danger); }
.tag-gray { background: var(--surface-2); color: var(--text-2); }

/* ---------- 提示条 ---------- */

.alert {
  padding: 11px 14px;
  border-radius: var(--radius);
  font-size: 13.5px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-info { background: var(--accent-bg); color: #0C447C; border-color: #B5D4F4; }
.alert-success { background: var(--success-bg); color: var(--success); border-color: #C0DD97; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: #FAC775; }
.alert-danger { background: var(--danger-bg); color: var(--danger); border-color: #F09595; }

/* ---------- 弹层 ---------- */

.modal-mask {
  position: fixed; inset: 0;
  background: rgba(44,44,42,.42);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 48px 16px;
  z-index: 50;
  overflow-y: auto;
}
.modal-mask.open { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 620px;
  padding: 22px 24px;
  border: 1px solid var(--border);
}
.modal h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.modal .modal-sub { margin: 0 0 18px; font-size: 13px; color: var(--text-2); }
.modal-foot {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border);
}

/* ---------- 空状态 ---------- */

.empty {
  text-align: center;
  padding: 42px 20px;
  color: var(--text-3);
  font-size: 13.5px;
}
.empty strong { display: block; color: var(--text-2); font-size: 14px; margin-bottom: 4px; font-weight: 500; }

/* ---------- 日志详情 ---------- */

.detail-block {
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 12px;
  overflow-x: auto;
}
.detail-block .k { font-size: 12.5px; color: var(--text-2); margin-bottom: 6px; }
.detail-block pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text);
  max-height: 260px;
  overflow-y: auto;
}

.kv { display: flex; gap: 10px; font-size: 13px; padding: 5px 0; }
.kv .k { color: var(--text-2); flex: 0 0 92px; }
.kv .v { color: var(--text); word-break: break-all; }

/* ---------- 登录页 ---------- */

.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.login-box {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 30px 30px 26px;
}
.login-box h1 { font-size: 19px; font-weight: 600; margin: 0 0 6px; }
.login-box .sub { font-size: 13px; color: var(--text-2); margin: 0 0 22px; }

/* ---------- 代码块 ---------- */

.code-box {
  background: #2C2C2A;
  color: #F1EFE8;
  border-radius: var(--radius);
  padding: 13px 15px;
  font-family: Consolas, Monaco, monospace;
  font-size: 12.5px;
  line-height: 1.65;
  overflow-x: auto;
  white-space: pre;
  margin: 0;
}
.code-box .c { color: #B4B2A9; }

.copy-row { display: flex; gap: 8px; align-items: stretch; }
.copy-row input { flex: 1; font-family: Consolas, Monaco, monospace; font-size: 12.5px; }

/* ---------- 分页 ---------- */

.pager {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-top: 14px; font-size: 13px; color: var(--text-2);
  flex-wrap: wrap;
}

/* ---------- 预览 ---------- */

.preview-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; }
.preview-tab {
  padding: 5px 12px; border-radius: 999px; font-size: 13px;
  border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; color: var(--text-2); font-family: inherit;
}
.preview-tab.active { background: var(--accent-bg); color: var(--accent); border-color: #B5D4F4; font-weight: 500; }
.preview-meta { margin-bottom: 10px; min-height: 0; }
.preview-meta code {
  font-family: Consolas, Monaco, monospace; font-size: 12px;
  background: var(--surface-2); padding: 1px 5px; border-radius: 4px; color: var(--text-2);
}
.preview-body {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--surface);
  min-height: 120px;
  max-height: 460px;
  overflow: auto;
}
.preview-body iframe { width: 100%; height: 420px; border: none; }

.spinner {
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

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

@media (max-width: 860px) {
  .layout { flex-direction: column; }
  .sidebar {
    width: 100%; flex: none; height: auto; position: static;
    border-right: none; border-bottom: 1px solid var(--border);
    display: flex; flex-wrap: wrap; gap: 6px; padding: 12px;
  }
  .brand { width: 100%; padding-bottom: 10px; }
  .nav-group { margin-bottom: 0; }
  .nav-title { display: none; }
  .nav-item { padding: 6px 10px; }
  .main { padding: 18px 14px 50px; }
}
