/* ============ 设计令牌 ============ */
:root {
  --primary: #6d4af3;
  --primary-strong: #5b34e6;
  --primary-soft: #efeaff;
  --primary-line: #d9ccfb;
  --grad-from: #4318a0;
  --grad-to: #7b3ff2;
  --bg: #f5f6fa;
  --card: #ffffff;
  --text: #1f2430;
  --text-2: #6b7280;
  --text-3: #9aa0ab;
  --border: #ececf1;
  --green: #16b587;
  --green-soft: #e6f8f1;
  --blue: #3b82f6;
  --purple: #7c3aed;
  --orange: #f59e0b;
  --red: #ef4444;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 6px 22px rgba(31, 36, 48, 0.06);
  --shadow-soft: 0 2px 10px rgba(31, 36, 48, 0.04);
  --sidebar-w: 232px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.55;
}
a { color: inherit; text-decoration: none; }
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;
  background: linear-gradient(135deg, #efeaff 0%, #f7f5ff 55%, #e9e2ff 100%);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 18px;
  padding: 40px 36px 32px;
  box-shadow: 0 18px 50px rgba(76, 27, 149, 0.14);
}
.login-logo {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: #fff;
}
.login-title { text-align: center; font-size: 20px; font-weight: 700; margin: 0 0 4px; }
.login-sub { text-align: center; color: var(--text-2); margin: 0 0 28px; font-size: 13px; }
.field { margin-bottom: 18px; }
.field label { display: block; margin-bottom: 7px; color: var(--text-2); font-weight: 500; }
.input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109, 74, 243, .12); }
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-weight: 600;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.btn-primary { background: var(--primary); color: #fff; width: 100%; justify-content: center; padding: 12px; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.btn-outline {
  background: #fff;
  color: var(--primary);
  border-color: var(--primary-line);
}
.btn-outline:hover { background: var(--primary-soft); }
.btn-ghost { background: transparent; color: var(--text-2); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; width: auto; }
.btn-danger {
  background: #fff;
  color: var(--red);
  border-color: rgba(220, 38, 38, .35);
}
.btn-danger:hover { background: #fef2f2; }
.row-actions { display: flex; gap: 8px; flex-wrap: nowrap; }
.login-err {
  background: #fef2f2;
  color: var(--red);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.login-err.show { display: block; }

/* ============ 主框架 ============ */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 20;
}
.side-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 18px 18px 16px;
}
.side-brand .logo {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.side-brand .b-name { font-weight: 700; font-size: 15px; line-height: 1.2; }
.side-brand .b-sub { font-size: 11px; color: var(--text-3); }
.side-nav { flex: 1; overflow-y: auto; padding: 8px 12px; }
.nav-group { margin-bottom: 12px; }
.nav-group-title {
  font-size: 11px;
  color: var(--text-3);
  padding: 8px 12px 5px;
  letter-spacing: .5px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-weight: 500;
  margin-bottom: 2px;
  position: relative;
}
.nav-item:hover { background: var(--bg); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-item .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--red);
  margin-left: auto;
}
.side-foot {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.side-foot .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.side-foot .u-name { font-weight: 600; font-size: 13px; }
.side-foot .u-role { font-size: 11px; color: var(--text-3); }
.side-foot .logout { margin-left: auto; color: var(--text-3); border: none; background: none; }
.side-foot .logout:hover { color: var(--red); }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; }
.topbar {
  height: 60px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .menu-btn { border: none; background: var(--primary-soft); color: var(--primary); width: 36px; height: 36px; border-radius: 10px; }
.topbar h1 { font-size: 18px; margin: 0; font-weight: 700; }
.content { padding: 26px; }

/* ============ 横幅 ============ */
.hero {
  background: linear-gradient(120deg, var(--grad-from) 0%, var(--grad-to) 100%);
  border-radius: var(--radius);
  color: #fff;
  padding: 26px 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 22px;
  position: relative;
  overflow: hidden;
}
.hero .h-date { font-size: 13px; opacity: .85; margin-bottom: 8px; }
.hero h2 { font-size: 28px; margin: 0 0 10px; font-weight: 700; }
.hero p { margin: 0; opacity: .88; font-size: 13px; max-width: 620px; }
.hero-right { display: flex; align-items: center; gap: 14px; flex: none; }
.hero-badge {
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  text-align: center;
}
.hero-badge .n { font-size: 24px; font-weight: 700; }
.hero-badge .t { font-size: 11px; opacity: .85; }
.hero-shield {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .16);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============ 统计卡片 ============ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: var(--shadow-soft);
}
.stat-ico { width: 48px; height: 48px; border-radius: 13px; display: flex; align-items: center; justify-content: center; color: #fff; flex: none; }
.stat-ico.blue { background: linear-gradient(135deg, #4f93ff, #2f6fed); }
.stat-ico.purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-ico.green { background: linear-gradient(135deg, #22c19a, #0e9f73); }
.stat-ico.orange { background: linear-gradient(135deg, #fbb03b, #f08a06); }
.stat-meta .s-label { color: var(--text-2); font-size: 13px; }
.stat-meta .s-num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.stat-meta .s-desc { color: var(--text-3); font-size: 11px; }

/* ============ 状态条 ============ */
.status-bar {
  background: var(--green-soft);
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
  color: #0b8a66;
}
.status-bar.warn { background: #fff7e8; color: #b9760a; }
.status-bar.bad { background: #fef2f2; color: var(--red); }
.status-bar .s-dot { width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.status-bar .updated { margin-left: auto; font-size: 12px; color: inherit; opacity: .8; }

/* ============ 面板/卡片 ============ */
.panel-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 18px; }
.panel {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
  box-shadow: var(--shadow-soft);
}
.panel-head { display: flex; align-items: center; gap: 9px; margin-bottom: 16px; }
.panel-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.panel-head .bar { width: 4px; height: 16px; border-radius: 3px; background: var(--primary); }
.panel-head .legend { margin-left: auto; font-size: 12px; color: var(--text-2); display: flex; align-items: center; gap: 6px; }
.panel-head .legend i { width: 11px; height: 11px; border-radius: 3px; background: var(--primary); display: inline-block; }

/* 服务列表 */
.svc-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.svc-row:last-child { border-bottom: none; }
.svc-row .s-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); flex: none; }
.svc-row .s-dot.off { background: var(--red); }
.svc-row .s-info .n { font-weight: 600; }
.svc-row .s-info .d { font-size: 12px; color: var(--text-3); }
.badge { margin-left: auto; font-size: 12px; padding: 3px 11px; border-radius: 20px; font-weight: 600; }
.badge.ok { background: var(--green-soft); color: #0b8a66; }
.badge.off { background: #fef2f2; color: var(--red); }

/* ============ 内页卡片与表格 ============ */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 18px;
}
.card-title { font-size: 15px; font-weight: 700; margin: 0 0 16px; display: flex; align-items: center; gap: 8px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }
.table-wrap { border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
table.data { width: 100%; border-collapse: collapse; }
table.data th {
  background: #fafbfe;
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  color: var(--text-2);
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}
table.data td { padding: 12px 16px; border-bottom: 1px solid var(--border); }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #fcfbff; }
.empty { text-align: center; color: var(--text-3); padding: 30px 0 !important; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 16px; }
.pagination .total { color: var(--text-2); font-size: 13px; }

/* 风险/角色标签 */
.tag { font-size: 12px; padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.tag.low { background: #e6f8f1; color: #0b8a66; }
.tag.medium { background: #fff7e8; color: #b9760a; }
.tag.high { background: #ffedd5; color: #ea580c; }
.tag.critical { background: #fef2f2; color: var(--red); }
.tag.role { background: var(--primary-soft); color: var(--primary); }

/* 弹窗 */
.modal-mask { position: fixed; inset: 0; background: rgba(31,36,48,.45); display: none; align-items: center; justify-content: center; z-index: 50; }
.modal-mask.show { display: flex; }
.modal { background: #fff; border-radius: 16px; width: 480px; max-width: calc(100vw - 40px); padding: 24px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h3 { margin: 0 0 18px; font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 20px; }
.form-actions { display: flex; justify-content: flex-end; margin-top: 8px; }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.verify-bar {
  margin: 16px 4px 4px; padding: 12px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
}
.verify-bar.ok { background: var(--green-soft); color: #0b8a66; }
.verify-bar.bad { background: #fef2f2; color: var(--red); }
@media (max-width: 900px) { .form-grid { grid-template-columns: 1fr; } }

/* 提示 toast */
.toast {
  position: fixed;
  top: 22px;
  left: 50%;
  transform: translateX(-50%);
  background: #1f2430;
  color: #fff;
  padding: 10px 20px;
  border-radius: 10px;
  font-size: 13px;
  z-index: 100;
  opacity: 0;
  transition: opacity .2s;
  pointer-events: none;
}
.toast.show { opacity: .95; }

.sidebar { transition: transform .22s ease; }
.sidebar.collapsed { transform: translateX(-100%); }
.sidebar.collapsed ~ .main { margin-left: 0; }
.main { transition: margin-left .22s ease; }

@media (max-width: 1180px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .panel-grid { grid-template-columns: 1fr; }
}
