/* ============== 泰源环境数据平台 看板样式 ============== */
:root {
  --bg: #0b1220;
  --panel: #121c2e;
  --panel-2: #17243b;
  --border: #23334d;
  --text: #e2e8f0;
  --muted: #8aa0bd;
  --accent: #22d3ee;
  --green: #22c55e;
  --red: #ef4444;
  --amber: #f59e0b;
  --blue: #3b82f6;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Microsoft YaHei", "PingFang SC", Segoe UI, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: var(--accent); text-decoration: none; }

/* ---------------- 登录页 ---------------- */
.login-body {
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0f2027 0%, #203a43 45%, #2c5364 100%);
}
.login-card {
  width: 400px; background: rgba(255,255,255,.97);
  border-radius: 14px; padding: 40px 36px 32px;
  box-shadow: 0 24px 60px rgba(0,0,0,.45);
  color: #1e293b;
}
.login-logo {
  width: 56px; height: 56px; margin: 0 auto 14px;
  display: flex; align-items: center; justify-content: center;
}
.login-logo img { display: block; }
.login-card h1 { font-size: 20px; text-align: center; margin-bottom: 4px; }
.login-card .sub { text-align: center; color: #64748b; font-size: 13px; margin-bottom: 26px; }
.login-tips {
  margin-top: 18px; padding: 10px 12px; border-radius: 8px;
  background: #f1f5f9; font-size: 12px; color: #475569; line-height: 1.9;
}

/* ---------------- 通用控件 ---------------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; color: #475569; margin-bottom: 6px; font-weight: 600; }
.input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1;
  border-radius: 8px; font-size: 14px; outline: none; background: #fff; color: #0f172a;
}
.input:focus, select:focus, textarea:focus { border-color: #0ea5e9; box-shadow: 0 0 0 3px rgba(14,165,233,.15); }
textarea { resize: vertical; min-height: 64px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1px solid transparent; border-radius: 8px;
  cursor: pointer; font-size: 13px; font-weight: 600;
  background: var(--panel-2); color: var(--text);
  border-color: var(--border);
  transition: all .15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: #0ea5e9; color: #fff; border-color: #0ea5e9; }
.btn-primary:hover { background: #0284c7; color: #fff; }
.btn-danger { color: #fecaca; border-color: #7f1d1d; }
.btn-danger:hover { background: #7f1d1d; color: #fff; }
.btn-success { color: #bbf7d0; border-color: #166534; }
.btn-success:hover { background: #166534; color: #fff; }
.btn-warn { color: #fde68a; border-color: #92400e; }
.btn-warn:hover { background: #92400e; color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { width: 100%; justify-content: center; padding: 11px; }

.dark .input, .dark select, .dark textarea {
  background: #0d1728; border-color: var(--border); color: var(--text);
}
.dark select option { background: #0d1728; }

/* ---------------- 整体布局 ---------------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 210px; flex-shrink: 0; background: #0e1828;
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  transition: margin-left .22s ease;
}
/* PC：菜单栏隐藏（状态记忆在 localStorage） */
body.sb-off .sidebar { margin-left: -211px; }
/* 移动端遮罩（仅小屏显示时出现） */
.sb-backdrop {
  display: none; position: fixed; inset: 0; z-index: 55;
  background: rgba(0,0,0,.5);
}
body.sb-on .sb-backdrop { display: block; }
.sidebar .brand {
  padding: 20px 18px; font-size: 16px; font-weight: 700;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.sidebar .brand .dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--green);
  box-shadow: 0 0 8px var(--green);
}
.nav { flex: 1; padding: 10px 0; overflow-y: auto; }
.nav-item {
  padding: 11px 20px 11px 17px; cursor: pointer; color: var(--muted);
  display: flex; align-items: center; justify-content: flex-start; gap: 10px;
  font-size: 14px; text-align: left; border-left: 3px solid transparent;
}
.nav-icon {
  width: 22px; height: 18px; flex: 0 0 22px;
  line-height: 18px; text-align: center;
}
.nav-label { line-height: 18px; text-align: left; white-space: nowrap; }
.nav-item:hover { color: var(--text); background: #13203a; }
.nav-item.active { color: var(--accent); background: #13203a; border-left-color: var(--accent); }
.nav-item[hidden] { display: none; }
.nav-group { padding: 14px 20px 4px; font-size: 11px; color: #56688a; letter-spacing: 2px; }
.sidebar-qr { text-align: center; padding: 12px 0 4px; border-top: 1px solid var(--border); }
.sidebar .user-box {
  padding: 14px 18px; border-top: 1px solid var(--border);
  font-size: 12px; color: var(--muted);
}
.sidebar .user-box b { color: var(--text); font-size: 13px; }
.sidebar .user-box .role {
  display: inline-block; margin-top: 6px; padding: 1px 8px;
  border-radius: 10px; background: #1e3a5f; color: #7dd3fc; font-size: 11px;
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; background: #0e1828;
}
.topbar h2 { font-size: 17px; }
.topbar-left { display: flex; align-items: center; gap: 12px; }
.sb-toggle {
  width: 34px; height: 34px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 8px;
  font-size: 17px; line-height: 1; cursor: pointer; transition: all .15s;
}
.sb-toggle:hover { border-color: var(--accent); color: var(--accent); }
.topbar .right { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--muted); }
.content { padding: 20px 24px; flex: 1; overflow-y: auto; }

/* 小屏：侧栏改为浮层抽屉，汉堡按钮唤出，点遮罩/菜单项收起 */
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; z-index: 60;
    margin-left: 0 !important;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: 0 0 32px rgba(0,0,0,.5);
  }
  body.sb-on .sidebar { transform: translateX(0); }
  .content { padding: 14px; }
  .topbar { padding: 0 14px; }
}

/* ---------------- KPI 卡片 ---------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 16px; margin-bottom: 18px; }
.kpi {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px;
  position: relative; overflow: hidden;
}
.kpi .label { color: var(--muted); font-size: 13px; margin-bottom: 10px; }
.kpi .num { font-size: 30px; font-weight: 700; font-family: Consolas, monospace; }
.kpi .num.red { color: var(--red); }
.kpi .num.green { color: var(--green); }
.kpi .num.amber { color: var(--amber); }
.kpi .num.cyan { color: var(--accent); }
.kpi::after {
  content: ""; position: absolute; right: -18px; top: -18px;
  width: 70px; height: 70px; border-radius: 50%;
  background: rgba(34,211,238,.08);
}

/* ---------------- 态势示意图 ---------------- */
.map-box {
  position: relative; width: 100%; height: 420px;
  background: radial-gradient(circle at 50% 50%, #0d1a2e 0%, #070d18 100%);
  border-radius: 10px; overflow: hidden; border: 1px solid var(--border);
}
.map-box svg { width: 100%; height: 100%; display: block; }
.map-grid line { stroke: rgba(80,120,170,.08); stroke-width: 1; }
.map-mark { cursor: pointer; transition: transform .15s; transform-origin: center; transform-box: fill-box; }
.map-mark:hover { transform: scale(1.25); }
.map-pop {
  position: absolute; z-index: 10; min-width: 220px;
  background: var(--panel-2); border: 1px solid var(--accent);
  border-radius: 10px; padding: 12px 14px; font-size: 13px;
  box-shadow: 0 12px 32px rgba(0,0,0,.5); pointer-events: auto;
}
.map-pop h4 { font-size: 14px; margin-bottom: 6px; color: var(--accent); }
.map-pop .row { display: flex; justify-content: space-between; gap: 12px; margin: 3px 0; }
.map-pop .btns { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.map-pop .btns button { font-size: 12px; padding: 4px 10px; }
.map-legend {
  position: absolute; left: 12px; bottom: 12px; z-index: 5;
  background: rgba(13,23,40,.85); border: 1px solid var(--border);
  border-radius: 8px; padding: 8px 12px; font-size: 12px;
}
.map-legend .lg-row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.map-legend .lg-shape { width: 14px; height: 14px; display: inline-block; }
.map-legend .lg-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.map-hint { position: absolute; right: 12px; top: 12px; z-index: 5; color: var(--muted); font-size: 12px; }

/* ---------------- 面板/表格 ---------------- */
.panel {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; margin-bottom: 18px;
}
.panel-head {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
}
.panel-head h3 { font-size: 15px; }
.panel-body { padding: 16px 18px; }
.panel-body.no-pad { padding: 0; }

.factor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.factor-grid .panel { margin-bottom: 0; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.filter-bar .fg { display: flex; flex-direction: column; gap: 5px; }
.filter-bar label { font-size: 12px; color: var(--muted); }
.filter-bar input, .filter-bar select {
  width: auto; min-width: 130px; padding: 7px 10px;
  background: #0d1728; border: 1px solid var(--border); color: var(--text);
  border-radius: 7px; font-size: 13px;
}

.table-wrap { overflow-x: auto; }
/* 空气参数页：表体独立滚动，表头（分析仪/参数/高值/低值）固定不随滚动 */
.table-wrap.bpa-scroll { max-height: calc(100vh - 250px); overflow: auto; }
.bpa-scroll thead th { position: sticky; top: 0; z-index: 2; background: var(--panel-2); box-shadow: 0 1px 0 var(--border); }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 11px 14px; color: var(--muted);
  font-weight: 600; white-space: nowrap; border-bottom: 1px solid var(--border);
  background: #101b2e;
}
table.data td { padding: 10px 14px; border-bottom: 1px solid #1a2740; white-space: nowrap; }
table.data td.ledger-wrap { white-space: normal; min-width: 260px; max-width: 420px; line-height: 1.55; }
table.data td.ledger-remark { white-space: normal; min-width: 200px; max-width: 340px; line-height: 1.55; }
.ledger-table { min-width: 1420px; }
.ledger-meta { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; font-size: 13px; }
table.data tr:hover td { background: #14213a; }
table.data tr.row-muted td { color: #8296b5; opacity: .82; }
/* 可显示但不可接单：暗色行，只能看站点与告警 */
table.data tr.row-readonly td { background: rgba(2, 6, 23, .55); }
table.data tr.row-readonly:hover td { background: #0d1728; }
table.data tr.flash td { animation: flashRow 1.2s; }
@keyframes flashRow { 0% { background: rgba(34,211,238,.25); } 100% { background: transparent; } }

/* 实时监控：整行故障/离线 站点淡红底；单元格故障值更深红 */
table.data tr.row-fault td { background: rgba(239,68,68,.08); }
table.data tr.row-fault:hover td { background: rgba(239,68,68,.15); }
table.data td.fault { background: rgba(239,68,68,.22); color: #fecaca; }
table.data td.fault b { color: #fca5a5; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: 12px; }
.tag-green { background: rgba(34,197,94,.15); color: #86efac; }
.tag-red { background: rgba(239,68,68,.15); color: #fca5a5; }
.tag-amber { background: rgba(245,158,11,.15); color: #fcd34d; }
.tag-blue { background: rgba(59,130,246,.15); color: #93c5fd;
}
.tag-gray { background: rgba(148,163,184,.15); color: #cbd5e1; }
.tag-orange { background: rgba(249,115,22,.18); color: #fdba74; }

/* 历史数据桶表：按数据标识给数值单元格着底色（N 正常不上色） */
.flag-cell { font-weight: 600; }
.flag-F { background: rgba(148,163,184,.20); color: #e2e8f0; }
.flag-M { background: rgba(234,179,8,.18); color: #fde68a; }
.flag-D, .flag-B { background: rgba(239,68,68,.22); color: #fecaca; }
.flag-C { background: rgba(59,130,246,.20); color: #bfdbfe; }
.flag-T { background: rgba(249,115,22,.22); color: #fed7aa; }
tr:hover td.flag-F, tr:hover td.flag-M, tr:hover td.flag-D,
tr:hover td.flag-B, tr:hover td.flag-C, tr:hover td.flag-T { filter: brightness(1.25); }

/* 用户权限多选（区县+点位） */
.scope-box { border: 1px solid rgba(148,163,184,.25); border-radius: 8px; padding: 10px 12px; max-height: 260px; overflow-y: auto; }
.scope-group { padding: 6px 0; border-bottom: 1px dashed rgba(148,163,184,.18); }
.scope-group:last-child { border-bottom: none; }
.scope-devices { display: flex; flex-wrap: wrap; gap: 6px 12px; padding: 6px 0 2px 22px; }
.scope-dev-item { display: inline-flex; align-items: center; gap: 10px; padding: 3px 8px; border-radius: 6px; border: 1px solid transparent; }
/* 可显示但不可接单：暗色背景，只能看站点与告警、看不到工单 */
.scope-dev-item.ro { background: #070c16; border-color: rgba(148,163,184,.18); }
.chk-accept-label { font-size: 12px; color: var(--muted); }
.scope-dev-item.ro .chk-accept-label { color: #64748b; }
.scope-ro-tip { color: #cbd5e1; background: #070c16; border-radius: 4px; padding: 0 4px; }
.chk-inline { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: normal; cursor: pointer; }
.chk-inline input, .chk-district-wrap input { cursor: pointer; }
.chk-district-wrap { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.dot-status { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot-on { background: var(--green); box-shadow: 0 0 6px var(--green); }
.dot-off { background: var(--red); }

.muted { color: var(--muted); }
.text-red { color: var(--red); }
.text-amber { color: var(--amber); }
.text-green { color: var(--green); }
.text-cyan { color: var(--accent); }
.fw-bold { font-weight: 700; }
.mono { font-family: Consolas, monospace; }
.nowrap { white-space: nowrap; }
.mt2 { margin-top: 12px; }
.text-right { text-align: right; }

/* 分页 */
.pager { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding: 12px 18px; }

/* ---------------- 实时监控设备列表 ---------------- */
.device-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 7px 14px; border-radius: 18px; border: 1px solid var(--border);
  cursor: pointer; font-size: 13px; background: #0d1728;
}
.chip.active { border-color: var(--accent); color: var(--accent); background: rgba(34,211,238,.08); }
.chip .dot-status { margin-right: 4px; }

/* ---------------- 图表 ---------------- */
.chart-box { position: relative; width: 100%; height: 360px; }
.legend { display: flex; gap: 18px; flex-wrap: wrap; margin-bottom: 8px; font-size: 12px; }
.legend .li { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.legend .sw { width: 16px; height: 3px; border-radius: 2px; }

/* ---------------- 弹窗/告警 ---------------- */
.modal-mask {
  position: fixed; inset: 0; background: rgba(3,8,16,.65);
  display: none; align-items: center; justify-content: center; z-index: 100;
}
.modal-mask.show { display: flex; }
.modal {
  background: var(--panel); border: 1px solid var(--border);
  border-radius: 12px; width: 520px; max-width: 94vw; max-height: 88vh;
  display: flex; flex-direction: column;
}
.modal.modal-lg { width: 760px; }
.modal.modal-xl { width: 1300px; max-width: 96vw; }
.modal-head {
  padding: 15px 20px; border-bottom: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center; font-weight: 700;
}
.modal-close { cursor: pointer; color: var(--muted); font-size: 20px; line-height: 1; }
.modal-body { padding: 20px; overflow-y: auto; }
.modal-foot { padding: 13px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }
.modal .input, .modal select, .modal textarea {
  background: #0d1728; border-color: var(--border); color: var(--text); width: 100%;
  padding: 9px 11px; border-radius: 7px; border-style: solid; border-width: 1px;
}
.modal select option { background: #0d1728; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }

/* 告警弹窗（右上角） */
.alarm-stack { position: fixed; right: 18px; top: 70px; z-index: 200; display: flex; flex-direction: column; gap: 12px; width: 380px; }
.alarm-pop {
  background: linear-gradient(135deg, #3b0d0d, #2a0f1f);
  border: 1px solid var(--red); border-radius: 12px; padding: 14px 16px;
  box-shadow: 0 10px 40px rgba(239,68,68,.35);
  animation: alarmBlink 1s infinite;
}
.alarm-pop h4 { display: flex; align-items: center; gap: 8px; color: #fca5a5; margin-bottom: 8px; font-size: 15px; }
.alarm-pop .meta { font-size: 12px; color: #fda4af; line-height: 1.9; }
.alarm-pop .acts { margin-top: 10px; display: flex; justify-content: flex-end; gap: 8px; }
@keyframes alarmBlink {
  0%, 100% { box-shadow: 0 10px 40px rgba(239,68,68,.25); }
  50% { box-shadow: 0 10px 50px rgba(239,68,68,.6); }
}

/* 超级管理员告警声静音开关（顶栏"实时监控"标题后） */
#btnAlarmMute { margin-left: 2px; padding: 5px 12px; letter-spacing: .5px; white-space: nowrap; }
#btnAlarmMute[hidden] { display: none; }
#btnAlarmTest { margin-left: 6px; padding: 5px 12px; letter-spacing: .5px; white-space: nowrap; }
#btnAlarmTest[hidden] { display: none; }

/* 工单级别弹窗 */
.ticket-pop.lvl-1 { border-color: #ef4444; }
.ticket-pop.lvl-2 {
  border-color: #f97316;
  animation: alarmBlinkFast .55s infinite;
}
.ticket-pop.lvl-3 { border-color: #f59e0b; }
.ticket-pop.lvl-4 { border-color: #d946ef; box-shadow: 0 10px 40px rgba(217,70,239,.3); }
.ticket-pop.accepted { animation: none; opacity: .85; }
.ticket-pop h4 { flex-wrap: wrap; gap: 6px; }
.ticket-pop .lvl-badge {
  display: inline-block; padding: 1px 9px; border-radius: 6px; font-size: 12px;
  background: #ef4444; color: #fff;
}
.ticket-pop.lvl-2 .lvl-badge { background: #f97316; }
.ticket-pop.lvl-3 .lvl-badge { background: #f59e0b; color: #1f2937; }
.ticket-pop.lvl-4 .lvl-badge { background: #d946ef; }
.ticket-pop .loop-tag {
  font-size: 11px; color: #fdba74; border: 1px solid #f97316; border-radius: 6px; padding: 0 7px;
}
.ticket-pop .acked-tag {
  font-size: 12px; color: #86efac; border: 1px solid #166534; border-radius: 6px; padding: 0 7px;
}
.alarm-list { margin: 6px 0 4px; padding-left: 18px; font-size: 12px; color: #fda4af; line-height: 1.8; }
.alarm-list .muted { color: #fca5a5aa; list-style: none; margin-left: -14px; }
@keyframes alarmBlinkFast {
  0%, 100% { box-shadow: 0 10px 40px rgba(249,115,22,.25); }
  50% { box-shadow: 0 10px 50px rgba(249,115,22,.7); }
}

/* toast */
.toast-stack { position: fixed; left: 50%; top: 22px; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 10px 22px; border-radius: 8px; font-size: 13px;
  background: #1e293b; border: 1px solid var(--border); box-shadow: 0 6px 24px rgba(0,0,0,.4);
}
.toast.ok { border-color: #166534; color: #86efac; }
.toast.err { border-color: #7f1d1d; color: #fca5a5; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab { padding: 9px 18px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab .badge {
  display: inline-block; margin-left: 5px; background: var(--red); color: #fff;
  border-radius: 9px; font-size: 11px; padding: 0 7px;
}
.empty { text-align: center; color: var(--muted); padding: 44px 0; }
.login-error { color: #b91c1c; font-size: 13px; min-height: 18px; margin-bottom: 10px; text-align: center; }

/* 报文监视终端窗口 */
.frames-view {
  background: #0d1117; border: 1px solid #30363d; border-radius: 8px;
  height: 62vh; overflow-y: auto; padding: 10px 12px;
  font-family: Consolas, "Courier New", monospace; font-size: 12.5px; line-height: 1.7;
}
.frames-view .fl { white-space: pre-wrap; word-break: break-all; border-bottom: 1px dashed #21262d; padding: 3px 0; }
.frames-view .fl:last-child { border-bottom: none; }
.fl-ts { color: #8b949e; margin-right: 10px; }
.fl-dir { display: inline-block; min-width: 40px; margin-right: 10px; font-weight: 600; }
.fl-cn { display: inline-block; min-width: 44px; margin-right: 10px; color: #d29922; }
.fl-in .fl-dir { color: #3fb950; }
.fl-in .fl-raw { color: #c9d1d9; }
.fl-out .fl-dir { color: #58a6ff; }
.fl-out .fl-raw { color: #79c0ff; }

.frames-view .fl-gap { height: 10px; border-bottom: none; }

/* 报文监视：组间分隔加大 + 相邻组交替背景 */
.frames-view .fl-gap { height: 16px; border-bottom: 1px solid #30363d; margin-bottom: 6px; }
.frames-view .fl { padding: 3px 6px; }
.frames-view .fl-g0 { background: rgba(88, 166, 255, .06); }
.frames-view .fl-g1 { background: rgba(63, 185, 80, .05); }
