/* ---------------- 基础 ---------------- */
:root {
  --primary: #1769e0;
  --primary-dark: #1257bd;
  --bg: #f5f7fa;
  --card: #ffffff;
  --text: #1f2329;
  --text-sub: #646a73;
  --text-muted: #8a919c;
  --border: #e9edf2;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --sidebar: #101a2c;
  --sidebar-2: #16233a;
  --radius: 12px;
}

* { box-sizing: border-box; }

/*
 * 关键兜底：hidden 属性的 display:none 来自浏览器默认样式（UA 样式），
 * 优先级低于作者写的 .modal-mask{display:flex} 之类，导致 hidden 完全失效。
 * 必须显式声明，否则弹窗/视图切换全部失灵。
 */
[hidden] { display: none !important; }

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

h1, h2, h3, h4 { margin: 0; font-weight: 700; }
p { margin: 0; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ---------------- 登录页 ---------------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(135deg, #1b3a6b 0%, #1769e0 55%, #4a90e2 100%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  padding: 36px 32px 28px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(10, 30, 60, 0.28);
}

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

.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, #4a90e2, #1769e0);
  color: #fff;
  font-weight: 800;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 1px;
}

.login-brand h1 { font-size: 20px; }
.login-brand p { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  color: var(--text-sub);
  font-weight: 500;
}
.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fafbfc;
  outline: none;
  transition: border-color .15s, background .15s;
}
.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--primary);
  background: #fff;
}

.form-error {
  margin-bottom: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  background: #fff1f0;
  color: var(--danger);
  font-size: 13px;
}

.login-hint {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.9;
}
.login-hint b { color: var(--text-sub); }

/* ---------------- 按钮 ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: #f2f4f7;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  transition: opacity .15s, background .15s;
  white-space: nowrap;
}
.btn:hover { opacity: .88; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: #fff1f0; color: var(--danger); }
.btn-ghost { background: #fff; border-color: #d9dee5; }
.btn-sm { padding: 6px 11px; font-size: 12px; border-radius: 7px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; font-weight: 600; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- 后台骨架 ---------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: var(--sidebar);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 20;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.side-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4a90e2, #1769e0);
  color: #fff; font-weight: 800; font-size: 14px;
  display: flex; align-items: center; justify-content: center;
}
.side-brand-text { display: flex; flex-direction: column; line-height: 1.3; }
.side-brand-text strong { color: #fff; font-size: 14px; }
.side-brand-text span { font-size: 11px; color: #7c8ba1; }

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 3px;
  border-radius: 9px;
  color: #b3c0d1;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .15s, color .15s;
  user-select: none;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--primary); color: #fff; font-weight: 600; }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.side-foot {
  padding: 14px 16px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
}
.side-user { font-size: 12.5px; color: #9fb0c6; margin-bottom: 10px; line-height: 1.6; }
.side-user strong { color: #fff; display: block; font-size: 13px; }
.side-logout {
  width: 100%;
  padding: 8px;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 8px;
  background: transparent;
  color: #b3c0d1;
  font-size: 12.5px;
}
.side-logout:hover { background: rgba(255,255,255,.07); color: #fff; }

.main {
  flex: 1;
  margin-left: 232px;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h2 { font-size: 19px; }
.topbar-sub { color: var(--text-muted); font-size: 12.5px; margin-top: 3px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.content { padding: 24px 28px 48px; }

.badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  background: #eef4fe;
  color: var(--primary);
}
.badge-admin { background: #fff4e5; color: var(--warning); }
.badge-gray { background: #f2f4f7; color: var(--text-sub); }
.badge-danger { background: #fff1f0; color: var(--danger); }
.badge-success { background: #ecfdf5; color: var(--success); }

/* ---------------- 卡片 / 统计 ---------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(16, 26, 44, .05), 0 1px 2px rgba(16, 26, 44, .03);
  margin-bottom: 18px;
  overflow: hidden;
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-head h3 { font-size: 15px; }
.card-body { padding: 20px; }

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(16, 26, 44, .05);
}
.stat-label { color: var(--text-muted); font-size: 12.5px; }
.stat-value { font-size: 28px; font-weight: 700; margin-top: 6px; line-height: 1.15; }
.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger { color: var(--danger); }

/* ---------------- 表格 ---------------- */
.table-wrap { width: 100%; overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th {
  text-align: left;
  padding: 11px 14px;
  background: #fafbfc;
  color: var(--text-sub);
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f2f4f7;
  vertical-align: middle;
}
.table tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: #fafcff; }
.table .col-actions { white-space: nowrap; }
.cell-brief {
  max-width: 340px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------------- 工具条 ---------------- */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: #fff;
}
.toolbar input[type="text"],
.toolbar select {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: #fafbfc;
  outline: none;
}
.toolbar input[type="text"]:focus,
.toolbar select:focus { border-color: var(--primary); background: #fff; }
.toolbar .spacer { flex: 1; }

/* ---------------- 条形图 ---------------- */
.bar-row { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.bar-name { width: 76px; font-size: 12.5px; color: var(--text-sub); flex-shrink: 0; }
.bar-track { flex: 1; height: 10px; border-radius: 6px; background: #f0f3f7; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 6px; background: var(--primary); transition: width .35s; }
.bar-count { width: 44px; text-align: right; font-size: 12.5px; color: var(--text-muted); }

/* ---------------- 空态 ---------------- */
.empty {
  padding: 56px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}
.empty-icon { font-size: 34px; margin-bottom: 10px; opacity: .35; }

/* ---------------- 弹窗 ---------------- */
.modal-mask {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(16, 26, 44, .45);
}
.modal {
  width: 100%;
  max-width: 480px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 24px 60px rgba(10, 30, 60, .3);
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-head h3 { font-size: 16px; }
.modal-close {
  border: none; background: none;
  font-size: 22px; line-height: 1;
  color: var(--text-muted); padding: 0 4px;
}
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}

/* ---------------- Toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%);
  z-index: 2000;
  padding: 11px 20px;
  border-radius: 10px;
  background: rgba(16, 26, 44, .92);
  color: #fff;
  font-size: 13px;
  box-shadow: 0 8px 24px rgba(10, 30, 60, .25);
  max-width: 80vw;
}
.toast.error { background: rgba(180, 30, 30, .95); }

/* AI 配置：服务商能力提示 */
.ai-capability {
  margin: -2px 0 14px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.6;
}

.ai-capability.ok {
  background: #eef7f1;
  color: #0b6b45;
}

.ai-capability.warn {
  background: #fff7ed;
  color: #b45309;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
}

/* AI 配置：操作区与自检结果 */
.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ai-test-result {
  margin-top: 14px;
}

.ai-test-result:empty {
  display: none;
}

.ai-test-head {
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

.ai-test-head.ok {
  background: #eef7f1;
  color: #0b6b45;
}

.ai-test-head.bad {
  background: #fff1f0;
  color: #b42318;
}

.ai-test-line {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px dashed var(--border);
  font-size: 12px;
}

.ai-test-line:last-child {
  border-bottom: none;
}

.ai-test-line b {
  flex-shrink: 0;
}

.ai-test-line.ok b { color: var(--success); }
.ai-test-line.bad b { color: var(--danger); }
.ai-test-line.warn b { color: var(--warning); }

.ai-test-line span {
  color: var(--text-sub);
  line-height: 1.6;
}

.ai-test-ms {
  color: var(--text-muted);
  font-size: 11px;
}

/* ---------------- 详情块 ---------------- */
.detail-block { margin-bottom: 16px; }
.detail-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}
.detail-text {
  padding: 12px 14px;
  border-radius: 9px;
  background: #fafbfc;
  border: 1px solid var(--border);
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}
.kp-list { display: flex; flex-wrap: wrap; gap: 7px; }
.kp-tag {
  padding: 4px 11px;
  border-radius: 14px;
  background: #eef4fe;
  color: var(--primary);
  font-size: 12px;
}

/* ---------------- 响应式 ---------------- */
@media (max-width: 860px) {
  .sidebar { width: 64px; }
  .side-brand-text, .side-user, .side-logout, .nav-item span { display: none; }
  .side-brand { justify-content: center; padding: 18px 0; }
  .nav-item { justify-content: center; padding: 11px 0; }
  .main { margin-left: 64px; }
  .content { padding: 16px; }
  .topbar { padding: 14px 16px; }
}
