:root {
  --bg-base: #070b12;
  --bg-surface: #0f172a;
  --bg-card: #131c31;
  --border-line: #1e293b;
  --border-hi: #334155;
  --text-main: #f8fafc;
  --text-sub: #94a3b8;
  --text-dim: #64748b;
  --accent: #38bdf8;
  --ok: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
}
* { box-sizing: border-box; margin: 0; padding: 0; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif; }
body { background: var(--bg-base); color: var(--text-main); height: 100vh; width: 100vw; overflow: hidden; display: flex; flex-direction: column; }
.mono { font-family: "Consolas", "SFMono-Regular", monospace; font-variant-numeric: tabular-nums; }

/* 细滚动条美化 */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1e293b; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #334155; }

#login-screen {
  position: fixed; inset: 0; z-index: 9999; background: rgba(6, 10, 16, 0.96);
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px);
}
.login-box {
  width: 370px; max-width: calc(100vw - 32px); background: var(--bg-surface); border: 1px solid var(--border-hi);
  border-radius: 6px; padding: 30px; box-shadow: 0 24px 48px rgba(0,0,0,0.75);
}
.login-box h2 { font-size: 17px; font-weight: 600; margin-bottom: 4px; }
.login-box p { font-size: 12px; color: var(--text-sub); margin-bottom: 22px; padding-bottom: 14px; border-bottom: 1px solid var(--border-line); }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-sub); margin-bottom: 5px; }
.field input {
  width: 100%; padding: 8px 11px; background: #070b12; border: 1px solid var(--border-hi);
  border-radius: 4px; color: #fff; font-size: 13px; outline: none; transition: border-color 0.15s;
}
.field input:focus { border-color: var(--accent); }
.btn-login {
  width: 100%; padding: 10px; background: #0284c7; border: none; border-radius: 4px;
  color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; margin-top: 6px; transition: background 0.15s;
}
.btn-login:hover { background: #0369a1; }

header {
  min-height: 50px; background: var(--bg-surface); border-bottom: 1px solid var(--border-line);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 18px; flex-shrink: 0; z-index: 100;
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-tag {
  font-size: 11px; font-weight: 700; padding: 2px 6px; border-radius: 3px; flex-shrink: 0;
  background: rgba(56, 189, 248, 0.12); color: var(--accent); border: 1px solid rgba(56, 189, 248, 0.3);
}
.brand h1 { font-size: 14px; font-weight: 600; letter-spacing: 0.3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.nav-tabs { display: flex; height: 50px; gap: 2px; flex-shrink: 0; }
.nav-tab {
  height: 100%; padding: 0 14px; background: transparent; border: none; border-bottom: 2px solid transparent;
  color: var(--text-sub); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: color 0.15s, background 0.15s;
}
.nav-tab:hover { color: var(--text-main); }
.nav-tab.active { color: var(--accent); border-bottom-color: var(--accent); background: rgba(56, 189, 248, 0.05); }

.hdr-right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.btn-top {
  padding: 5px 10px; font-size: 12px; border-radius: 4px; cursor: pointer; white-space: nowrap;
  background: var(--bg-card); border: 1px solid var(--border-hi); color: var(--text-main);
  transition: border-color 0.15s, background 0.15s;
}
.btn-top:hover { border-color: var(--accent); }
.btn-top.active { background: #0284c7; border-color: #0284c7; color: #fff; }
.btn-top.active:hover { background: #0369a1; }
.gw-status {
  display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-sub); white-space: nowrap;
  background: #070b12; padding: 4px 11px; border-radius: 4px; border: 1px solid var(--border-line);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--danger); flex-shrink: 0; }
.dot.online { background: var(--ok); box-shadow: 0 0 6px rgba(16, 185, 129, 0.65); }

main { flex: 1; position: relative; overflow: hidden; }
.view-page { position: absolute; inset: 0; display: none; overflow-y: auto; }
.view-page.active { display: block; }

#webgl-wrap { position: absolute; inset: 0; cursor: grab; }
#webgl-wrap:active { cursor: grabbing; }
#css2d-wrap { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 15; }

/* 3D 空间实时悬浮标注牌（使用 GPU translate3d 定位） */
.callout-3d {
  position: absolute;
  left: 0; top: 0;
  background: rgba(11, 18, 32, 0.92);
  border: 1px solid rgba(56, 189, 248, 0.65);
  border-left: 3px solid #38bdf8;
  border-radius: 4px;
  padding: 6px 10px;
  color: #f8fafc;
  font-size: 11px;
  line-height: 1.45;
  box-shadow: 0 8px 20px rgba(0,0,0,0.65);
  white-space: nowrap;
  margin-top: -14px;
  will-change: transform, opacity;
}
.callout-3d.warn {
  border-color: rgba(245, 158, 11, 0.85);
  border-left-color: #f59e0b;
  background: rgba(34, 24, 8, 0.94);
}
.callout-3d.danger {
  border-color: rgba(239, 68, 68, 0.85);
  border-left-color: #ef4444;
  background: rgba(34, 10, 14, 0.94);
}
.callout-3d .c-hd { font-weight: 700; font-size: 11px; color: #38bdf8; display: flex; justify-content: space-between; gap: 10px; margin-bottom: 2px; }
.callout-3d.warn .c-hd { color: #fbbf24; }
.callout-3d.danger .c-hd { color: #f87171; }
.callout-3d .c-stem {
  position: absolute; left: 50%; bottom: -14px; width: 1px; height: 14px; background: rgba(56, 189, 248, 0.85);
}
.callout-3d.warn .c-stem { background: rgba(245, 158, 11, 0.9); }
.callout-3d.danger .c-stem { background: rgba(239, 68, 68, 0.9); }

/* 混凝土板层右侧工程引线标注 */
.layer-pin {
  position: absolute;
  left: 0; top: 0;
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: #cbd5e1; white-space: nowrap;
  will-change: transform, opacity;
}
.layer-pin .pin-line { width: 20px; height: 1px; background: #64748b; }
.layer-pin .pin-box {
  background: rgba(15, 23, 42, 0.88); border: 1px solid #334155;
  padding: 2px 7px; border-radius: 3px;
}

.side-hud {
  position: absolute; top: 14px; bottom: 14px; width: 296px; z-index: 30;
  display: flex; flex-direction: column; gap: 10px; pointer-events: none;
  overflow-y: auto; overflow-x: hidden; transition: opacity 0.2s, transform 0.2s;
}
.hud-l { left: 14px; }
.hud-r { right: 14px; }
.hud-hidden .side-hud { opacity: 0; pointer-events: none; transform: translateY(8px); }
.hud-hidden .side-hud .card { pointer-events: none; }

.card {
  background: rgba(15, 23, 42, 0.88); border: 1px solid var(--border-line);
  border-radius: 6px; padding: 12px 14px; pointer-events: auto; backdrop-filter: blur(8px);
}
.card-chart { flex: 1; display: flex; flex-direction: column; min-height: 170px; }
.ec-mini-box { flex: 1; width: 100%; min-height: 120px; }
.card-hd {
  font-size: 12px; font-weight: 600; color: var(--text-main); padding-bottom: 7px; margin-bottom: 9px;
  border-bottom: 1px solid var(--border-line); display: flex; justify-content: space-between; align-items: center; gap: 8px;
}
.card-hd span { font-size: 11px; color: var(--text-dim); font-weight: 400; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.stat-box { background: #090e1a; border: 1px solid #1e293b; border-radius: 4px; padding: 7px 9px; }
.stat-box .k { font-size: 11px; color: var(--text-sub); margin-bottom: 2px; }
.stat-box .v { font-size: 16px; font-weight: 700; white-space: nowrap; }
.stat-box .v small { font-size: 11px; color: var(--text-dim); font-weight: 400; margin-left: 2px; }

.diag-panel {
  padding: 9px 11px; border-radius: 4px; font-size: 12px; line-height: 1.5;
  background: rgba(16, 185, 129, 0.08); border-left: 3px solid var(--ok);
  transition: background 0.2s, border-color 0.2s;
}
.diag-panel.warn { background: rgba(245, 158, 11, 0.12); border-left-color: var(--warn); }
.diag-panel.danger { background: rgba(239, 68, 68, 0.14); border-left-color: var(--danger); }
.diag-panel .dt { font-weight: 600; color: var(--ok); margin-bottom: 2px; }
.diag-panel.warn .dt { color: var(--warn); }
.diag-panel.danger .dt { color: var(--danger); }

.layer-ctrl { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; cursor: pointer; gap: 8px; }
.ctrl-tip { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--border-line); font-size: 11px; color: var(--text-dim); text-align: center; }

.viewport-bar {
  position: absolute; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 35;
  background: rgba(15, 23, 42, 0.92); border: 1px solid var(--border-hi);
  border-radius: 6px; padding: 6px 10px; display: flex; gap: 6px; align-items: center; flex-wrap: nowrap;
  max-width: calc(100vw - 24px); overflow-x: auto;
}
.v-sep { color: #334155; }
.v-btn {
  padding: 4px 10px; font-size: 12px; background: #1e293b; border: 1px solid #334155; white-space: nowrap;
  color: var(--text-main); border-radius: 4px; cursor: pointer; transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.v-btn:hover { border-color: var(--accent); color: var(--accent); }
.v-btn.active { background: #0284c7; border-color: #0284c7; color: #fff; }

.ana-container { padding: 18px 22px; max-width: 1580px; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.kpi-strip { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; }
.kpi-tile { background: var(--bg-surface); border: 1px solid var(--border-line); border-radius: 6px; padding: 13px 15px; }
.kpi-tile .t-lbl { font-size: 12px; color: var(--text-sub); margin-bottom: 5px; }
.kpi-tile .t-val { font-size: 21px; font-weight: 700; }
.kpi-tile .t-sub { font-size: 11px; color: var(--text-dim); margin-top: 3px; }
.ana-row-1 { display: grid; grid-template-columns: 1.35fr 1fr; gap: 14px; }
.ana-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.chart-box { background: var(--bg-surface); border: 1px solid var(--border-line); border-radius: 6px; padding: 14px 16px; }
.chart-box h3 { font-size: 13px; font-weight: 600; margin-bottom: 10px; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.chart-box h3 span { font-size: 11px; color: var(--text-dim); font-weight: 400; }
.ec-div { width: 100%; height: 265px; }

.page-pad { padding: 18px 22px; max-width: 1500px; margin: 0 auto; }
.bar-top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 12px;
  background: var(--bg-surface); padding: 11px 15px; border-radius: 6px; border: 1px solid var(--border-line);
}
.bar-sub { font-size: 12px; color: var(--text-dim); margin-left: 10px; }
.bar-actions { display: flex; gap: 8px; }
.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; min-width: 760px; border-collapse: collapse; background: var(--bg-surface); border: 1px solid var(--border-line); font-size: 13px; }
th, td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border-line); }
th { background: #0b1120; color: var(--text-sub); font-size: 12px; }
tbody tr:hover { background: rgba(56, 189, 248, 0.04); }
.badge { padding: 2px 7px; border-radius: 3px; font-size: 11px; font-weight: 600; display: inline-block; }
.b-danger { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.b-warn { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }

.ops-layout { display: grid; grid-template-columns: 1fr 1.4fr; gap: 14px; align-items: start; }
.cfg-group { margin: 14px 0; }
.cfg-label { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.cfg-range { width: 100%; accent-color: var(--accent); cursor: pointer; }
.mqtt-cfg { margin-top: 18px; padding-top: 10px; border-top: 1px solid var(--border-line); }
.console-meta { display: inline-flex; align-items: center; gap: 8px; }
.btn-mini {
  padding: 2px 7px; font-size: 11px; background: #1e293b; border: 1px solid #334155;
  color: var(--text-sub); border-radius: 3px; cursor: pointer;
}
.btn-mini:hover { color: var(--text-main); border-color: var(--accent); }
.console {
  background: #05080f; border: 1px solid var(--border-line); border-radius: 6px; padding: 12px;
  height: 440px; overflow-y: auto; font-family: "Consolas", monospace; font-size: 12px; line-height: 1.6; color: #38bdf8;
}
.c-line { border-bottom: 1px solid #0f172a; padding: 3px 0; word-break: break-all; }
.c-line.c-sys { color: #94a3b8; }
.c-line.c-sim { color: #34d399; }

/* 响应式适配：常见笔记本 1366/1280 与窄屏 */
@media (max-width: 1380px) {
  .brand h1 { font-size: 13px; }
  .nav-tab { padding: 0 10px; font-size: 12px; }
  .side-hud { width: 264px; }
  .stat-box .v { font-size: 15px; }
}

@media (max-width: 1120px) {
  header { flex-wrap: wrap; padding: 8px 14px; }
  .nav-tabs { order: 3; width: 100%; height: 38px; overflow-x: auto; border-top: 1px solid var(--border-line); }
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .ana-row-1, .ana-row-2, .ops-layout { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .kpi-strip { grid-template-columns: repeat(2, 1fr); }
  .side-hud { width: 230px; }
  .brand h1 { display: none; }
}
