:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #1b2733;
  --muted: #6c7a89;
  --line: #e3e8ee;
  --brand: #1f4e79;
  --brand-soft: #eaf1f8;
  --ok: #18a058;
  --warn: #d97706;
  --err: #c0392b;
  --radius: 10px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.6 "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.topbar {
  background: var(--brand);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar-inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 0 20px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.brand { display: flex; align-items: center; gap: 10px; color: #fff; font-weight: 600; font-size: 16px; }
.brand:hover { text-decoration: none; }
.logo {
  width: 14px; height: 14px; border-radius: 3px;
  background: #f0b429;
  box-shadow: 0 0 0 4px rgba(240, 180, 41, .25);
}
.nav { display: flex; gap: 6px; margin-left: auto; }
.nav-link {
  color: rgba(255,255,255,.85);
  padding: 6px 12px;
  border-radius: 6px;
}
.nav-link:hover { background: rgba(255,255,255,.14); color: #fff; text-decoration: none; }
.clock { color: rgba(255,255,255,.8); font-variant-numeric: tabular-nums; }

.wrap { max-width: 1240px; margin: 0 auto; padding: 24px 20px 40px; }
.foot { text-align: center; color: var(--muted); font-size: 12px; padding: 0 0 28px; }

h1.page-title { font-size: 22px; margin: 0 0 8px; }
h2 { font-size: 15px; margin: 0; font-weight: 600; }
.muted { color: var(--muted); font-weight: 400; font-size: 14px; }
.title-row { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.page-head { margin-bottom: 6px; }
.back { font-size: 13px; color: var(--muted); }
.meta-row { color: var(--muted); font-size: 13px; margin: 8px 0 18px; display: flex; gap: 16px; flex-wrap: wrap; }
.tag {
  display: inline-block; padding: 1px 8px; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 12px;
}

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px;
}
.kpi .kpi-label { color: var(--muted); font-size: 13px; }
.kpi .kpi-value { font-size: 26px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .kpi-value small { font-size: 13px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.kpi.skeleton { min-height: 84px; background: linear-gradient(90deg, #eef1f5 25%, #f7f9fb 37%, #eef1f5 63%); background-size: 400% 100%; animation: shine 1.4s infinite; }
@keyframes shine { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 16px;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.hint { color: var(--muted); font-size: 12px; }
.ok { color: #7ee2a8; }
.warn { color: #ffb37a; }
.bad { color: #ff8a8a; }
button.btn.small { padding: 4px 10px; font-size: 12px; }

.meter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.meter-card {
  display: block; border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px;
  color: inherit; background: #fcfdfe; transition: border-color .15s, box-shadow .15s;
}
.meter-card:hover { text-decoration: none; border-color: #b9cfe4; box-shadow: 0 4px 14px rgba(31,78,121,.08); }
.card-head { display: flex; align-items: center; gap: 8px; }
.card-title { font-weight: 600; }
.card-head .tag { margin-left: auto; }
.card-value { font-size: 24px; font-weight: 600; margin-top: 12px; font-variant-numeric: tabular-nums; }
.card-value span { font-size: 12px; color: var(--muted); font-weight: 400; margin-left: 4px; }
.card-label { color: var(--muted); font-size: 12px; }
.card-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 12px; }
.card-grid div { background: #f5f8fb; border-radius: 6px; padding: 6px 8px; }
.card-grid b { display: block; font-size: 14px; font-weight: 600; font-variant-numeric: tabular-nums; }
.card-grid span { color: var(--muted); font-size: 12px; }
.card-foot { margin-top: 10px; color: var(--muted); font-size: 12px; display: flex; justify-content: space-between; gap: 8px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: #b6c1cc; display: inline-block; flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px rgba(24,160,88,.15); }
.dot.off { background: var(--err); box-shadow: 0 0 0 3px rgba(192,57,43,.12); }
.dot.warn { background: var(--warn); }

.empty { color: var(--muted); font-size: 13px; padding: 10px 2px; }

.alert-list { display: flex; flex-direction: column; gap: 8px; }
.alert-item { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: 8px; background: #fbfaf7; border: 1px solid #f0e6d8; font-size: 13px; }
.alert-item.error { background: #fdf5f4; border-color: #f2d9d6; }
.alert-item .alert-time { color: var(--muted); font-variant-numeric: tabular-nums; flex: none; }
.alert-item .alert-meta { margin-left: auto; color: var(--muted); font-size: 12px; flex: none; }
.resolved { color: var(--ok); }

.controls { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
select, button.btn {
  border: 1px solid #cdd7e2; background: #fff; border-radius: 6px;
  padding: 5px 10px; font-size: 13px; color: var(--ink); cursor: pointer;
}
button.btn:hover { border-color: var(--brand); color: var(--brand); }

.chart { width: 100%; height: 320px; }
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data-table th { background: #f5f8fb; color: var(--muted); font-weight: 500; }
.data-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.data-table tbody tr:hover { background: #fafcfe; }

.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }

@media (max-width: 640px) {
  .topbar-inner { gap: 12px; padding: 0 12px; }
  .brand span:last-child { font-size: 14px; }
  .nav-link { padding: 6px 8px; font-size: 13px; }
  .clock { display: none; }
  .wrap { padding: 16px 12px 32px; }
  .kpi .kpi-value { font-size: 22px; }
  .chart { height: 260px; }
}
/* ============ 组织树节点内联新增 ============ */
.fx-add, .org-plus {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%; cursor: pointer;
  font-size: 13px; line-height: 1; color: #8ef0ff; flex: 0 0 auto;
  border: 1px solid rgba(34, 211, 238, .45); background: rgba(34, 211, 238, .12);
  margin-right: 6px; transition: background .15s, box-shadow .15s;
}
.fx-add:hover, .org-plus:hover { background: rgba(34, 211, 238, .32); box-shadow: 0 0 10px rgba(34, 211, 238, .45); }
.fx-inline, .org-inline {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 8px 10px; margin: 4px 0 6px 12px;
  background: rgba(34, 211, 238, .06);
  border: 1px dashed rgba(34, 211, 238, .38); border-radius: 8px;
}
.fx-inline select, .fx-inline input, .org-inline select, .org-inline input {
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .16);
  color: #eaf8ff; border-radius: 6px; padding: 5px 8px; font-size: 12px; min-width: 96px;
}
.fx-inline .btn, .org-inline .btn { padding: 5px 12px; font-size: 12px; }

/* ---------------- 顶栏与移动端适配 ---------------- */
.nav-toggle {
  display: none; margin-left: auto; padding: 6px 10px; font-size: 18px; line-height: 1;
  color: #fff; background: rgba(255, 255, 255, .12); border: 1px solid rgba(255, 255, 255, .22);
  border-radius: 8px; cursor: pointer;
}
.mobile-note {
  margin: 10px auto 0; max-width: 1240px; padding: 8px 14px; font-size: 12px;
  color: #7a5313; background: #fff7e6; border: 1px solid #ffe0a3; border-radius: 8px;
}
.login-wx {
  display: block; text-align: center; padding: 11px; margin-bottom: 6px;
  border-radius: 9px; font-size: 14px; font-weight: 600; letter-spacing: 1px;
  color: #06283d; background: linear-gradient(120deg, #56d9a3, #2bb673);
  text-decoration: none;
}
.login-wx:hover { text-decoration: none; filter: brightness(1.05); }
.login-or { text-align: center; font-size: 11px; color: #5d7b98; margin: 10px 0; position: relative; }
.login-or::before, .login-or::after {
  content: ""; position: absolute; top: 50%; width: 34%; height: 1px; background: rgba(255, 255, 255, .14);
}
.login-or::before { left: 0; } .login-or::after { right: 0; }
.login-wx-hint { font-size: 12px; line-height: 1.7; color: #7b8ba3; margin: 0 0 12px; }
.login-err {
  font-size: 12px; color: #ffb1b1; background: rgba(248, 113, 113, .12);
  border: 1px solid rgba(248, 113, 113, .3); border-radius: 8px;
  padding: 8px 10px; margin: 0 0 12px; line-height: 1.6;
}

@media (max-width: 1100px) {
  .topbar-inner { gap: 14px; padding: 0 14px; }
  .nav { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .nav-link { padding: 6px 10px; white-space: nowrap; }
  .clock { display: none; }
}

@media (max-width: 900px) {
  .topbar-inner { height: 54px; flex-wrap: nowrap; }
  .nav-toggle { display: inline-block; }
  .nav {
    position: absolute; top: 54px; right: 10px; left: 10px; z-index: 30;
    flex-direction: column; gap: 2px; padding: 10px; border-radius: 12px;
    background: var(--brand); box-shadow: 0 18px 40px rgba(0, 0, 0, .28);
    display: none;
  }
  .nav.open { display: flex; }
  .nav-link { padding: 10px 12px; border-radius: 8px; }
  .user-chip { margin-left: auto; }
  .wrap { padding: 16px 12px 32px; }
  .panel { padding: 14px; overflow-x: auto; }
  .kpis, .ems-kpis, .meter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
  .ems-grid { display: block !important; }
  .ems-grid > section { margin-bottom: 14px; }
  .chart { height: 220px; }
  .foot { padding-bottom: 18px; }
  table, .ems-table, .smart-table, .admin-table { font-size: 12px; }
  .ems-table th, .ems-table td { padding: 6px 8px; white-space: nowrap; }
  .screen-entry { flex-direction: column; align-items: flex-start; gap: 14px; padding: 16px; }
  .entry-btn { width: 100%; justify-content: center; }
  .admin-wrap { padding: 12px 12px 32px; }
  .admin-form input, .admin-form select, .admin-form textarea { min-width: 0; width: 100%; }
  .admin-form label { flex: 1 1 100%; }
  .admin-cols { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .kpis, .ems-kpis, .meter-grid { grid-template-columns: 1fr !important; }
  .brand { font-size: 14px; }
  .chart { height: 200px; }
  .panel-head { flex-wrap: wrap; gap: 6px; }
}
