:root {
  --brand: #2563eb;
  --brand-dark: #1d4ed8;
  --brand-soft: #eff4ff;
  --sidebar-bg: #1c2534;
  --sidebar-bg-2: #151c28;
  --sidebar-active: #2563eb;
  --text: #1f2937;
  --text-2: #5b6779;
  --text-3: #8b97a8;
  --line: #e5e9f0;
  --bg: #f4f6fa;
  --card: #ffffff;
  --danger: #d64545;
  --warn: #d98407;
  --ok: #16a34a;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 6px 18px rgba(16, 24, 40, .06);
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
button { font-family: inherit; }
.boot { display: flex; height: 100vh; align-items: center; justify-content: center; color: var(--text-3); }

/* ---------------- 登录 ---------------- */
.login-wrap {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  height: 100vh;
  min-height: 620px;
}
.login-art {
  position: relative;
  background: linear-gradient(150deg, #16233c 0%, #1b3a6b 55%, #2563eb 100%);
  color: #fff;
  padding: 56px 60px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.login-art::after {
  content: "";
  position: absolute;
  inset: auto -160px -220px auto;
  width: 620px; height: 620px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,.16), transparent 65%);
}
.login-art h1 { font-size: 30px; line-height: 1.4; margin: 0 0 14px; font-weight: 650; letter-spacing: .5px; }
.login-art .sub { color: rgba(255,255,255,.72); font-size: 14px; line-height: 1.9; max-width: 460px; }
.login-brand { display: flex; align-items: center; gap: 12px; font-size: 17px; font-weight: 600; letter-spacing: 1px; }
.login-brand .logo {
  width: 38px; height: 38px; border-radius: 10px;
  background: rgba(255,255,255,.14);
  display: grid; place-items: center;
  border: 1px solid rgba(255,255,255,.22);
}
.login-points { display: flex; gap: 26px; position: relative; z-index: 2; }
.login-points div { font-size: 12px; color: rgba(255,255,255,.6); }
.login-points strong { display: block; font-size: 26px; color: #fff; font-weight: 600; margin-bottom: 2px; }
.login-panel { display: flex; align-items: center; justify-content: center; background: #fff; padding: 40px; }
.login-form { width: 100%; max-width: 340px; }
.login-form h2 { margin: 0 0 6px; font-size: 22px; }
.login-form .hint { color: var(--text-3); font-size: 13px; margin-bottom: 28px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 7px; }
.input, select.input, textarea.input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid #d8dee9; border-radius: 8px;
  font-size: 14px; color: var(--text); background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
textarea.input { height: auto; padding: 10px 12px; line-height: 1.6; resize: vertical; }
.input:focus, select.input:focus, textarea.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37,99,235,.12); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 36px; padding: 0 16px; border-radius: 8px; border: 1px solid #d8dee9;
  background: #fff; color: var(--text); font-size: 13px; cursor: pointer;
  transition: all .15s; white-space: nowrap;
}
.btn:hover { border-color: #b9c4d4; background: #fafbfc; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.btn.danger { color: var(--danger); border-color: #f0c9c9; background: #fdf4f4; }
.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.block { width: 100%; height: 42px; font-size: 15px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12px; border-radius: 6px; }
.login-hint {
  margin-top: 22px; padding: 12px 14px; border-radius: 8px;
  background: #f7f9fc; border: 1px solid var(--line);
  font-size: 12px; color: var(--text-3); line-height: 1.9;
}
.login-hint b { color: var(--text-2); font-weight: 600; }
.login-error { color: var(--danger); font-size: 13px; margin-bottom: 12px; min-height: 18px; }

/* ---------------- 布局 ---------------- */
.layout { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: 224px; flex: 0 0 224px;
  background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-bg-2) 100%);
  color: #c7d0de;
  display: flex; flex-direction: column;
  transition: width .18s ease;
}
.sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px; color: #fff;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar .brand .logo {
  width: 30px; height: 30px; border-radius: 8px; flex: 0 0 30px;
  background: var(--brand); display: grid; place-items: center;
}
.sidebar .brand .t1 { font-size: 14px; font-weight: 600; letter-spacing: .5px; }
.sidebar .brand .t2 { font-size: 11px; color: rgba(255,255,255,.45); letter-spacing: 1.2px; }
.nav { flex: 1; overflow-y: auto; padding: 10px 0 20px; }
.nav-group { padding: 14px 20px 6px; font-size: 11px; color: rgba(255,255,255,.32); letter-spacing: 1px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 18px; margin: 2px 10px;
  border-radius: 7px; cursor: pointer; font-size: 13.5px;
  color: #b6c2d4; transition: all .14s; position: relative;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--sidebar-active); color: #fff; font-weight: 500; box-shadow: 0 4px 12px rgba(37,99,235,.35); }
.nav-item .ico { width: 16px; height: 16px; flex: 0 0 16px; opacity: .9; }
.nav-item .badge {
  margin-left: auto; background: rgba(255,255,255,.18); color: #fff;
  font-size: 11px; padding: 1px 6px; border-radius: 9px; min-width: 18px; text-align: center;
}
.nav-item.active .badge { background: rgba(255,255,255,.28); }
.sidebar-foot {
  padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.07);
  font-size: 11px; color: rgba(255,255,255,.35); line-height: 1.7;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; flex: 0 0 58px; background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; padding: 0 22px; gap: 16px;
}
.crumb { font-size: 13px; color: var(--text-3); display: flex; align-items: center; gap: 7px; }
.crumb b { color: var(--text); font-weight: 600; font-size: 15px; }
.topbar .spacer { flex: 1; }
.scope-tag {
  font-size: 12px; padding: 4px 10px; border-radius: 20px;
  background: var(--brand-soft); color: var(--brand-dark); border: 1px solid #dbe6ff;
}
.user-chip { display: flex; align-items: center; gap: 9px; cursor: pointer; padding: 4px 8px; border-radius: 8px; }
.user-chip:hover { background: #f5f7fa; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--brand-soft);
  color: var(--brand-dark); display: grid; place-items: center; font-size: 12px; font-weight: 600;
}
.user-chip .nm { font-size: 13px; line-height: 1.2; }
.user-chip .rl { font-size: 11px; color: var(--text-3); }
.content { flex: 1; overflow-y: auto; padding: 20px 22px 40px; }

/* ---------------- 通用块 ---------------- */
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.page-head h2 { font-size: 18px; margin: 0; font-weight: 600; }
.page-head .desc { color: var(--text-3); font-size: 12.5px; }
.page-head .spacer { flex: 1; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid rgba(16,24,40,.04); }
.card-head { padding: 15px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.card-head h3 { margin: 0; font-size: 14.5px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-head .sub { font-size: 12px; color: var(--text-3); }
.card-body { padding: 16px 18px; }
.card-body.tight { padding: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 16px; }
.stat {
  background: #fff; border-radius: var(--radius); padding: 16px 18px;
  border: 1px solid rgba(16,24,40,.05); box-shadow: var(--shadow);
  position: relative; overflow: hidden;
}
.stat .lbl { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 6px; }
.stat .val { font-size: 28px; font-weight: 650; margin: 8px 0 4px; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.stat .val small { font-size: 13px; font-weight: 500; color: var(--text-3); margin-left: 3px; }
.stat .ex { font-size: 12px; color: var(--text-3); }
.stat .ex .up { color: var(--ok); }
.stat .ex .down { color: var(--danger); }
.stat .bar { position: absolute; left: 0; top: 0; width: 3px; height: 100%; background: var(--brand); opacity: .85; }
.stat.warn .bar { background: var(--warn); }
.stat.danger .bar { background: var(--danger); }
.stat.ok .bar { background: var(--ok); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }

/* ---------------- 表格 ---------------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.toolbar .input, .toolbar select.input { width: auto; min-width: 150px; height: 34px; font-size: 13px; }
.toolbar .spacer { flex: 1; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font-weight: 600; color: var(--text-2); background: #fafbfd;
  padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; font-size: 12.5px;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid #f1f4f8; vertical-align: middle; }
table.data tbody tr:hover { background: #fafcff; }
table.data tbody tr:last-child td { border-bottom: none; }
table.data .num { font-variant-numeric: tabular-nums; }
.table-empty { padding: 48px; text-align: center; color: var(--text-3); font-size: 13px; }
.link { color: var(--brand); cursor: pointer; }
.link:hover { text-decoration: underline; }
.mono { font-family: var(--mono); font-size: 12px; letter-spacing: -.2px; }
.muted { color: var(--text-3); }
.nowrap { white-space: nowrap; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 5px; font-size: 12px; line-height: 18px;
  background: #f1f4f9; color: var(--text-2); white-space: nowrap;
}
.tag.blue { background: #eaf1ff; color: #1d4ed8; }
.tag.green { background: #e9f7ef; color: #15803d; }
.tag.orange { background: #fdf3e5; color: #b45309; }
.tag.red { background: #fdeeee; color: #b91c1c; }
.tag.gray { background: #f1f4f9; color: #5b6779; }
.tag.purple { background: #f2edfd; color: #6d28d9; }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; display: inline-block; }

.pager { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--text-2); }
.pager .spacer { flex: 1; }
.pager button {
  min-width: 30px; height: 30px; padding: 0 8px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; cursor: pointer; color: var(--text-2);
}
.pager button.cur { background: var(--brand); color: #fff; border-color: var(--brand); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- 抽屉 / 弹窗 ---------------- */
.mask {
  position: fixed; inset: 0; background: rgba(15, 23, 42, .42);
  z-index: 60; display: flex; justify-content: flex-end;
  animation: fade .16s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.drawer {
  width: 720px; max-width: 94vw; background: var(--bg); height: 100%;
  display: flex; flex-direction: column; box-shadow: -12px 0 40px rgba(15,23,42,.16);
  animation: slide .2s ease;
}
@keyframes slide { from { transform: translateX(30px); opacity: .6; } to { transform: none; opacity: 1; } }
.drawer-head { padding: 16px 20px; background: #fff; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
.drawer-head h3 { margin: 0; font-size: 16px; }
.drawer-head .spacer { flex: 1; }
.drawer-body { flex: 1; overflow-y: auto; padding: 18px 20px 30px; }
.drawer-foot { padding: 12px 20px; background: #fff; border-top: 1px solid var(--line); display: flex; gap: 10px; justify-content: flex-end; }

.modal-mask { position: fixed; inset: 0; background: rgba(15,23,42,.42); z-index: 70; display: grid; place-items: center; animation: fade .16s; }
.modal { width: 460px; max-width: 92vw; background: #fff; border-radius: 12px; box-shadow: 0 20px 60px rgba(15,23,42,.25); overflow: hidden; }
.modal h3 { margin: 0; padding: 18px 20px 0; font-size: 16px; }
.modal .mbody { padding: 14px 20px 20px; font-size: 13.5px; color: var(--text-2); line-height: 1.7; }
.modal .mfoot { padding: 12px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; background: #fafbfd; }

.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 18px; border-radius: 8px; background: #1f2937; color: #fff;
  font-size: 13px; box-shadow: 0 8px 24px rgba(15,23,42,.24); animation: drop .18s ease;
}
.toast.err { background: var(--danger); }
.toast.ok { background: #15803d; }
@keyframes drop { from { transform: translateY(-8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------------- 详情块 ---------------- */
.kv { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.kv > div { background: #fff; padding: 11px 14px; font-size: 13px; }
.kv .k { color: var(--text-3); font-size: 12px; display: block; margin-bottom: 3px; }
.kv .v { color: var(--text); font-weight: 500; word-break: break-all; }
.section-title { font-size: 13.5px; font-weight: 600; margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--brand); }
.section-title .spacer { flex: 1; }
.section-title .act { font-size: 12px; font-weight: 400; color: var(--brand); cursor: pointer; }

.timeline { position: relative; padding-left: 18px; }
.timeline::before { content: ""; position: absolute; left: 4px; top: 6px; bottom: 6px; width: 1px; background: var(--line); }
.tl-item { position: relative; padding-bottom: 16px; font-size: 13px; }
.tl-item::before {
  content: ""; position: absolute; left: -18px; top: 5px; width: 9px; height: 9px; border-radius: 50%;
  background: #fff; border: 2px solid var(--brand);
}
.tl-item .t { color: var(--text-3); font-size: 12px; margin-left: 8px; }
.tl-item .c { color: var(--text-2); margin-top: 3px; line-height: 1.7; }

.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.thumbs img { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 6px; border: 1px solid var(--line); cursor: zoom-in; background: #eef1f5; }
.empty { padding: 28px; text-align: center; color: var(--text-3); font-size: 13px; }

/* ---------------- 地图 ---------------- */
.map-layout { display: grid; grid-template-columns: 1fr 330px; gap: 16px; height: calc(100vh - 160px); min-height: 520px; }
.map-canvas { position: relative; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); background: #e8eef5; }
.map-canvas svg { display: block; width: 100%; height: 100%; }
.map-legend {
  position: absolute; left: 14px; bottom: 14px; background: rgba(255,255,255,.94);
  border-radius: 8px; padding: 10px 12px; font-size: 12px; color: var(--text-2);
  box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center;
}
.map-legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: 5px; }
.map-tip {
  position: absolute; right: 14px; top: 14px; background: rgba(28,37,52,.86); color: #fff;
  font-size: 11.5px; padding: 6px 11px; border-radius: 6px; letter-spacing: .3px;
}
.map-side { display: flex; flex-direction: column; gap: 0; overflow: hidden; }
.map-list { overflow-y: auto; flex: 1; }
.map-row { padding: 11px 14px; border-bottom: 1px solid #f1f4f8; cursor: pointer; }
.map-row:hover { background: #fafcff; }
.map-row .n { font-size: 13px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.map-row .a { font-size: 12px; color: var(--text-3); margin-top: 3px; }
.map-row.on { background: var(--brand-soft); }
.map-pin { cursor: pointer; }

/* ---------------- 监控 ---------------- */
.monitor-layout { display: grid; grid-template-columns: 1fr 320px; gap: 16px; }
.player {
  position: relative; background: #0b1220; border-radius: var(--radius); overflow: hidden;
  aspect-ratio: 16/9; box-shadow: var(--shadow);
}
.player canvas { display: block; width: 100%; height: 100%; }
.player .bar {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 14px;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(transparent, rgba(0,0,0,.62)); color: #fff; font-size: 12px;
}
.player .bar .spacer { flex: 1; }
.player .rec { position: absolute; left: 14px; top: 12px; font-size: 12px; color: #fff; display: flex; align-items: center; gap: 6px; }
.player .rec i { width: 7px; height: 7px; border-radius: 50%; background: #e5484d; animation: blink 1.4s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.player .offline {
  position: absolute; inset: 0; display: grid; place-items: center; color: #93a1b5; font-size: 13px;
  background: repeating-linear-gradient(45deg, #0b1220, #0b1220 10px, #0e1626 10px, #0e1626 20px);
}
.seg-list { max-height: 320px; overflow-y: auto; }
.seg { padding: 9px 14px; border-bottom: 1px solid #f1f4f8; font-size: 12.5px; display: flex; gap: 8px; align-items: center; }
.seg:hover { background: #fafcff; }
.seg .tm { font-family: var(--mono); font-size: 12px; }

/* ---------------- 其他 ---------------- */
.progress { height: 6px; background: #eef1f6; border-radius: 4px; overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--brand); border-radius: 4px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; font-size: 13px; border-bottom: 1px dashed #eef1f6; }
.rank-row:last-child { border-bottom: none; }
.rank-row .idx { width: 20px; height: 20px; border-radius: 5px; background: #f1f4f9; display: grid; place-items: center; font-size: 11px; color: var(--text-2); }
.rank-row .idx.top { background: var(--brand); color: #fff; }
.rank-row .nm { width: 74px; color: var(--text-2); }
.rank-row .bg { flex: 1; }
.rank-row .vl { width: 52px; text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); }
.legend-inline { display: flex; gap: 16px; font-size: 12px; color: var(--text-3); flex-wrap: wrap; }
.legend-inline i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; margin-right: 5px; }
.loading-line { height: 3px; background: linear-gradient(90deg, transparent, var(--brand), transparent); background-size: 40% 100%; animation: run 1.1s infinite linear; }
@keyframes run { from { background-position: -40% 0; } to { background-position: 140% 0; } }

@media (max-width: 1280px) {
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .map-layout, .monitor-layout { grid-template-columns: 1fr; height: auto; }
  .map-canvas { height: 460px; }
}
