:root {
  --bg: #f5f6f8;
  --panel: #fff;
  --line: #e3e6eb;
  --text: #1f2329;
  --muted: #8a9099;
  --primary: #2f6fed;
  --primary-d: #2258c4;
  --high: #e5484d;
  --mid: #e08a00;
  --low: #2f9e63;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--text);
  background: var(--bg);
}

/* ------------------------------------------------ top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  height: 56px;
  background: #0a121f;   /* 深海蓝 */
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-size: 16px; font-weight: 600; white-space: nowrap; }
.brand .sub { font-size: 12px; font-weight: 400; color: #9aa4b2; margin-left: 8px; }
.tabs { display: flex; gap: 4px; flex: 1; }
.tab {
  color: #c7ced8;
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 14px;
}
.tab:hover { background: #16243a; color: #fff; }
.tab.active { background: var(--primary); color: #fff; }
.topright { display: flex; align-items: center; gap: 16px; }
.actor { font-size: 12px; color: #9aa4b2; display: flex; align-items: center; gap: 6px; }
.actor input {
  width: 110px;
  padding: 4px 8px;
  border: 1px solid #26364f;
  border-radius: 5px;
  background: #16243a;
  color: #fff;
  font-size: 13px;
}
.health { font-size: 12px; color: #9aa4b2; }
.health.ok { color: #4cc38a; }
.health.bad { color: #ff7b72; }

/* ------------------------------------------------ layout */
.view { max-width: 1200px; margin: 0 auto; padding: 20px; }
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.card h2 { margin: 0 0 12px; font-size: 15px; }
.card h2 .hint { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row + .row { margin-top: 10px; }
.spacer { flex: 1; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h1 { font-size: 18px; margin: 0; }

/* ------------------------------------------------ form controls */
input, select, textarea, button { font: inherit; }
input[type="text"], input:not([type]), select, textarea, input[type="date"] {
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
}
textarea { width: 100%; min-height: 70px; resize: vertical; }
button {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
button:hover { border-color: #c6ccd5; }
button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
button.primary:hover { background: var(--primary-d); }
button.danger { color: var(--high); border-color: #f0c2c4; }
button.sm { padding: 3px 9px; font-size: 12px; }
button:disabled { opacity: .5; cursor: not-allowed; }

/* ------------------------------------------------ table */
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--muted); font-weight: 500; background: #fafbfc; white-space: nowrap; }
tbody tr:hover { background: #f8fafd; }
td.num { white-space: nowrap; }
.empty { color: var(--muted); padding: 24px; text-align: center; }
.clamp { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; max-width: 380px; }

/* ------------------------------------------------ tags */
.tag {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 12px;
  white-space: nowrap;
  border: 1px solid transparent;
}
.tag.gray { background: #eef0f3; color: #5c636d; }
.tag.blue { background: #e8f0fe; color: #2258c4; }
.tag.green { background: #e6f4ec; color: var(--low); }
.tag.amber { background: #fdf1dc; color: var(--mid); }
.tag.red { background: #fdeaea; color: var(--high); }
.risk-high { color: var(--high); font-weight: 600; }
.risk-mid { color: var(--mid); font-weight: 600; }
.risk-low { color: var(--low); font-weight: 600; }
.warn { color: var(--high); font-weight: 600; }

/* ------------------------------------------------ 概览页 */
.ov-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}
.ov-card {
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  padding: 14px 16px;
  cursor: pointer;
  background: #fff;
}
.ov-card:hover { background: #f8fafd; border-color: #c6ccd5; }
.ov-card.red { border-left-color: var(--high); }
.ov-card.amber { border-left-color: var(--mid); }
.ov-card.green { border-left-color: var(--low); }
.ov-card .ov-num { font-size: 26px; font-weight: 600; line-height: 1.2; }
.ov-card.red .ov-num { color: var(--high); }
.ov-card.amber .ov-num { color: var(--mid); }
.ov-card.green .ov-num { color: var(--low); }
.ov-card .ov-label { font-size: 13px; margin-top: 2px; }
.ov-card .hint { font-size: 12px; }

.ov-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.ov-row:last-child { border-bottom: none; }
.ov-block {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.ov-block:last-child { border-bottom: none; }
.ov-block b { color: var(--high); font-size: 16px; }
.ov-block .hint { display: block; font-size: 12px; }

/* ------------------------------------------------ 分组筛选条 */
.grp-bar { gap: 8px; }
button.grp {
  background: #fff;
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 14px;
}
button.grp b { margin-left: 4px; }
button.grp:hover { border-color: #c6ccd5; }
button.grp.on { background: var(--primary); border-color: var(--primary); color: #fff; }
button.grp.on b { color: #fff; }

/* ------------------------------------------------ 条件预警卡片 */
.alert {
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
  background: #fff;
}
.alert:last-child { margin-bottom: 0; }
.alert.high { border-left-color: var(--high); }
.alert.mid { border-left-color: var(--mid); }
.alert.low { border-left-color: var(--low); }
.alert .ahead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert .ahead b { font-size: 13px; }
.alert .abody { margin-top: 6px; font-size: 12px; color: #55606c; line-height: 1.7; }
.alert .asugg { margin-top: 6px; font-size: 12px; color: var(--primary); line-height: 1.6; }

/* ------------------------------------------------ kv list */
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 20px; }
.kv div { font-size: 13px; }
.kv .k { color: var(--muted); margin-right: 6px; }

/* ------------------------------------------------ modal */
.modal {
  border: none;
  border-radius: 10px;
  padding: 0;
  width: min(760px, 92vw);
  max-height: 88vh;
}
.modal::backdrop { background: rgba(16, 21, 28, .45); }
.modal .mhead {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--line);
}
.modal .mhead h3 { margin: 0; font-size: 15px; }
.modal .mbody { padding: 18px; overflow: auto; max-height: 74vh; }
.modal .mbody section + section { margin-top: 18px; }
.modal .mbody h4 { margin: 0 0 8px; font-size: 13px; color: var(--muted); }
.danger-list { margin: 0 0 12px; padding-left: 20px; }
.danger-list li + li { margin-top: 5px; }
.modal .close { border: none; background: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }

/* ------------------------------------------------ toast */
.toast {
  position: fixed; left: 50%; bottom: 32px; transform: translateX(-50%) translateY(20px);
  background: #0a121f; color: #fff; padding: 10px 18px; border-radius: 8px;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .22s; z-index: 99;
  max-width: 80vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--high); }

.spin { color: var(--muted); padding: 24px; text-align: center; }

/* ------------------------------------------------ topbar 用户 */
.topbar .who { font-size: 12px; color: #c7ced8; }
.topbar .logout {
  padding: 4px 12px;
  font-size: 12px;
  background: #16243a;
  border: 1px solid #26364f;
  color: #c7ced8;
  border-radius: 5px;
  cursor: pointer;
}
.topbar .logout:hover { background: #1d2c45; color: #fff; }

/* ------------------------------------------------ 登录页 */
.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #0a121f;
}
.auth-card {
  width: min(360px, 92vw);
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}
.auth-brand { font-size: 18px; font-weight: 600; margin-bottom: 18px; }
.auth-brand span { font-size: 12px; font-weight: 400; color: var(--muted); margin-left: 8px; }
.auth-tabs { display: flex; gap: 6px; margin-bottom: 18px; }
.atab {
  padding: 6px 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  color: var(--text);
}
.atab.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.auth-card input {
  width: 100%;
  padding: 9px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}
#authBtn { width: 100%; padding: 9px; }
.auth-msg { color: var(--high); font-size: 12px; min-height: 18px; margin-bottom: 6px; }
.auth-foot { margin-top: 14px; font-size: 12px; color: var(--muted); }