/* 工业网络流量防护与预警验证系统 - 原型样式 */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0b1426;
  --panel: #111e36;
  --panel-2: #16264a;
  --border: #22375f;
  --text: #d6e2f5;
  --muted: #7f93b5;
  --primary: #2f8cff;
  --cyan: #19d3da;
  --green: #22c55e;
  --yellow: #f5b83d;
  --orange: #ff8a3d;
  --red: #ff4d5e;
}
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  overflow: hidden;
}
a { color: var(--primary); text-decoration: none; }
button { font-family: inherit; }

/* ---------- 布局 ---------- */
.layout { display: flex; height: 100vh; }
.sidebar {
  width: 216px; flex-shrink: 0;
  background: #0d1a31;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
}
.brand {
  padding: 18px 16px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.brand-logo {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--primary), var(--cyan));
  display: grid; place-items: center; font-weight: 700; color: #fff;
}
.brand-title { font-size: 14px; font-weight: 700; line-height: 1.3; }
.brand-sub { font-size: 11px; color: var(--muted); }
.nav { list-style: none; padding: 10px 0; flex: 1; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 20px; color: var(--muted);
  border-left: 3px solid transparent;
}
.nav a:hover { color: var(--text); background: rgba(47,140,255,.08); }
.nav a.active {
  color: #fff; background: rgba(47,140,255,.16);
  border-left-color: var(--primary);
}
.nav-icon { width: 18px; text-align: center; }
.sidebar-foot { padding: 12px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; border-bottom: 1px solid var(--border); background: #0d1a31;
}
.page-title { font-size: 17px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 18px; color: var(--muted); font-size: 13px; }
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 6px; box-shadow: 0 0 6px var(--green); }
.content { flex: 1; overflow-y: auto; padding: 16px 20px 24px; }

/* ---------- 通用组件 ---------- */
.grid { display: grid; gap: 14px; }
.g-4 { grid-template-columns: repeat(4, 1fr); }
.g-3 { grid-template-columns: repeat(3, 1fr); }
.g-2 { grid-template-columns: repeat(2, 1fr); }
.g-21 { grid-template-columns: 2fr 1fr; }
.g-12 { grid-template-columns: 1fr 2fr; }
.mt { margin-top: 14px; }

.card {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px 16px; min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.card-title { font-size: 14px; font-weight: 700; padding-left: 9px; border-left: 3px solid var(--primary); }
.card-extra { font-size: 12px; color: var(--muted); }
.chart { width: 100%; height: 260px; }
.chart.tall { height: 340px; }
.chart.short { height: 200px; }

.kpi { display: flex; flex-direction: column; gap: 6px; }
.kpi-label { color: var(--muted); font-size: 12px; }
.kpi-value { font-size: 26px; font-weight: 700; font-family: "DIN Alternate", "Segoe UI", sans-serif; }
.kpi-value small { font-size: 13px; color: var(--muted); margin-left: 4px; font-weight: 400; }
.kpi-trend { font-size: 12px; color: var(--muted); }
.up { color: var(--red); } .down { color: var(--green); }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 14px; border-radius: 5px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); cursor: pointer; font-size: 13px;
}
.btn:hover { border-color: var(--primary); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { filter: brightness(1.1); }
.btn.danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn.sm { padding: 3px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn:focus-visible, .nav a:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 1px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.toolbar label { color: var(--muted); font-size: 13px; display: flex; align-items: center; gap: 6px; }
select, input[type=text], input[type=number], input[type=datetime-local] {
  background: var(--panel-2); border: 1px solid var(--border); color: var(--text);
  padding: 6px 10px; border-radius: 5px; font-size: 13px; font-family: inherit;
}
.spacer { flex: 1; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab {
  padding: 8px 16px; cursor: pointer; color: var(--muted); border: none; background: none;
  border-bottom: 2px solid transparent; font-size: 14px;
}
.tab.active { color: #fff; border-bottom-color: var(--primary); }

table.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th, .tbl td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.tbl th { color: var(--muted); font-weight: 400; background: var(--panel-2); }
.tbl tbody tr:hover { background: rgba(47,140,255,.07); }
.tbl-wrap { overflow-x: auto; }
.mono { font-family: Consolas, "Courier New", monospace; }

.tag { display: inline-block; padding: 1px 8px; border-radius: 3px; font-size: 12px; border: 1px solid; }
.lv-1 { color: var(--red); border-color: var(--red); background: rgba(255,77,94,.12); }
.lv-2 { color: var(--orange); border-color: var(--orange); background: rgba(255,138,61,.12); }
.lv-3 { color: var(--yellow); border-color: var(--yellow); background: rgba(245,184,61,.12); }
.lv-4 { color: var(--cyan); border-color: var(--cyan); background: rgba(25,211,218,.1); }
.st-ok { color: var(--green); border-color: var(--green); background: rgba(34,197,94,.1); }
.st-run { color: var(--primary); border-color: var(--primary); background: rgba(47,140,255,.12); }
.st-wait { color: var(--muted); border-color: var(--muted); }

.pager { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 10px; color: var(--muted); font-size: 12px; }

.progress { height: 8px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(90deg, var(--primary), var(--cyan)); transition: width .3s; }

.list-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px dashed var(--border); font-size: 13px;
}
.list-item:last-child { border-bottom: none; }
.list-item .time { color: var(--muted); font-size: 12px; margin-left: auto; white-space: nowrap; }

.desc { display: grid; grid-template-columns: 110px 1fr; gap: 8px 12px; font-size: 13px; }
.desc dt { color: var(--muted); }
.desc dd { word-break: break-all; }

pre.hex {
  background: #08101f; border: 1px solid var(--border); border-radius: 5px;
  padding: 10px; font-family: Consolas, monospace; font-size: 12px; color: #9fd0ff;
  overflow-x: auto; line-height: 1.6;
}

.scene-card { cursor: pointer; transition: border-color .2s; position: relative; }
.scene-card:hover { border-color: var(--primary); }
.scene-card.selected { border-color: var(--cyan); box-shadow: 0 0 0 1px var(--cyan) inset; }
.scene-card .check { position: absolute; top: 10px; right: 12px; color: var(--cyan); font-weight: 700; display: none; }
.scene-card.selected .check { display: block; }
.scene-name { font-weight: 700; margin-bottom: 6px; }
.scene-meta { color: var(--muted); font-size: 12px; line-height: 1.7; }

.log-box {
  background: #08101f; border: 1px solid var(--border); border-radius: 5px;
  height: 220px; overflow-y: auto; padding: 8px 10px;
  font-family: Consolas, monospace; font-size: 12px; line-height: 1.7; color: #9fb4d6;
}
.log-box .ok { color: var(--green); } .log-box .warn { color: var(--yellow); } .log-box .err { color: var(--red); }

.metric-big { text-align: center; padding: 6px 0; }
.metric-big .v { font-size: 30px; font-weight: 700; }
.metric-big .l { color: var(--muted); font-size: 12px; margin-top: 4px; }
.metric-big .std { font-size: 11px; margin-top: 2px; }

/* ---------- 弹窗 ---------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  width: 760px; max-width: 94vw; max-height: 88vh; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 700; }
.modal-close { background: none; border: none; color: var(--muted); font-size: 20px; cursor: pointer; }
.modal-body { padding: 16px 18px; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: var(--panel-2); border: 1px solid var(--primary); color: var(--text);
  padding: 10px 20px; border-radius: 6px; z-index: 200; opacity: 0; transition: opacity .3s;
  pointer-events: none;
}
.toast.show { opacity: 1; }

.form-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.form-row > label { width: 90px; color: var(--muted); flex-shrink: 0; }
.form-row > input, .form-row > select { flex: 1; }

.report-preview { background: #fff; color: #222; padding: 30px 40px; border-radius: 4px; font-family: "SimSun", serif; line-height: 1.8; }
.report-preview h2 { text-align: center; margin-bottom: 16px; font-family: "SimHei", sans-serif; }
.report-preview h3 { margin: 14px 0 6px; font-family: "SimHei", sans-serif; font-size: 15px; }
.report-preview table { width: 100%; border-collapse: collapse; margin: 6px 0; font-size: 13px; }
.report-preview th, .report-preview td { border: 1px solid #999; padding: 4px 8px; }
.report-preview th { background: #e8eef8; }

.switch { position: relative; width: 36px; height: 20px; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: var(--panel-2); border: 1px solid var(--border); border-radius: 10px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 14px; height: 14px; left: 2px; top: 2px; background: var(--muted); border-radius: 50%; transition: .2s; }
.switch input:checked + span { background: var(--primary); border-color: var(--primary); }
.switch input:checked + span::before { transform: translateX(16px); background: #fff; }

@media (max-width: 1280px) {
  .g-4 { grid-template-columns: repeat(2, 1fr); }
  .g-21, .g-12, .g-3 { grid-template-columns: 1fr; }
}
