/* ==========================================================================
   v3 导航轨道：左侧图标坞（默认图标，可展开名称）
   替换原 300px 侧栏与底部玻璃停靠栏；保留 v2.1 苔原余烬视觉。
   ========================================================================== */

:root {
  --rail-w: 84px;
  --rail-w-expanded: 260px;
}

/* 主内容跟随轨道宽度，展开/收起丝滑过渡 */
.main {
  margin-left: var(--rail-w);
  transition: margin-left 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}
body.rail-expanded .main { margin-left: var(--rail-w-expanded); }

/* 轨道本体 */
.rail {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--rail-w);
  z-index: 60;
  display: flex;
  flex-direction: column;
  padding: 18px 12px 16px;
  background: linear-gradient(180deg, rgba(15, 27, 21, 0.96), rgba(30, 49, 38, 0.93));
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 12px 0 40px rgba(12, 25, 17, 0.2);
  backdrop-filter: blur(28px) saturate(140%);
  -webkit-backdrop-filter: blur(28px) saturate(140%);
  transition: width 0.4s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.4s ease;
  overflow: visible;
}
body.rail-expanded .rail {
  width: var(--rail-w-expanded);
  box-shadow: 24px 0 70px rgba(10, 22, 15, 0.32);
}

.rail-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 44px;
  padding: 0 6px;
  color: #f7fbf6;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  flex: none;
}
.rail-brand:hover { text-decoration: none; }
.rail-mark {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 251, 246, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
}
.rail-mark svg { width: 22px; height: 22px; color: #ffb39c; }
.rail-name {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.02em;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transform: translateX(-8px);
  transition: opacity 0.22s ease, transform 0.3s ease, max-width 0.3s ease;
}
.rail.expanded .rail-name { opacity: 1; max-width: 170px; transform: none; transition-delay: 0.08s; }

.rail-toggle {
  position: absolute;
  top: 24px;
  right: -14px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(21, 34, 27, 0.96);
  color: #f7fbf6;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 3;
  box-shadow: 0 8px 20px rgba(10, 22, 15, 0.28);
  transition: background 0.2s ease, transform 0.3s ease;
}
.rail-toggle svg { width: 15px; height: 15px; transition: transform 0.3s ease; }
.rail-toggle:hover { background: #2d4a3a; }
.rail.expanded .rail-toggle svg { transform: rotate(180deg); }

.rail-nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 18px;
  flex: 1;
  overflow: visible;
  padding: 2px 0;
}
.rail-nav::-webkit-scrollbar { width: 6px; }

.rail-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 0 28px 0 12px;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #dbe7dd;
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  overflow: visible;
}
.rail-item:hover { color: #fff; text-decoration: none; }
.rail-item:not([aria-current="page"]):hover { background: rgba(255, 255, 255, 0.12); }
.rail-icon {
  width: 24px;
  height: 24px;
  flex: none;
  transition: transform 0.28s cubic-bezier(0.18, 1.3, 0.35, 1), color 0.2s ease;
}
.rail-item:hover .rail-icon, .rail-item.hot .rail-icon { transform: scale(1.24); }
.rail-item.near .rail-icon { transform: scale(1.1); }

.rail-label {
  font-size: 15px;
  font-weight: 500;
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transform: translateX(-6px);
  transition: opacity 0.2s ease, transform 0.28s ease, max-width 0.3s ease;
}
.rail.expanded .rail-label {
  opacity: 1;
  max-width: 160px;
  transform: none;
  transition-delay: 0.06s;
}

.rail-item[aria-current="page"] {
  background: rgba(255, 251, 246, 0.94);
  color: #1b2a22;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 10px 26px rgba(8, 20, 13, 0.22);
}
.rail-item[aria-current="page"] .rail-label { color: #1b2a22; }
.rail-item[aria-current="page"] .rail-dot { background: #b23a2a; }
.rail-dot {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #ffb39c;
  flex: none;
}

/* 悬停 1.5 秒后浮出的名称提示（展开时由文字直接显示） */
.rail-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(100% + 14px);
  top: 50%;
  z-index: 80;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(14, 25, 19, 0.97);
  border: 1px solid rgba(255, 255, 255, 0.16);
  color: #f7fbf6;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 12px 30px rgba(8, 18, 12, 0.3);
  opacity: 0;
  transform: translate(-6px, -50%);
  pointer-events: none;
  transition: opacity 0.12s ease 0.2s, transform 0.12s ease 0.2s;
}
.rail-item:hover::after { opacity: 1; transform: translate(0, -50%); }
.rail.expanded .rail-item::after { display: none; }

.rail-foot {
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.rail-cmd { min-height: 44px; }
.rail-status {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 12px;
  color: #c7d8cb;
  font-size: 11.5px;
  white-space: nowrap;
  overflow: hidden;
}
.rail-status .dot { background: #6fd18f; }
.rail-status-text {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
  white-space: nowrap;
  transform: translateX(-6px);
  transition: opacity 0.2s ease, transform 0.28s ease, max-width 0.3s ease;
}
.rail-status-meta { display: block; color: #8fa697; font-size: 10.5px; line-height: 1.5; }
.rail.expanded .rail-status-text { opacity: 1; max-width: 170px; transform: none; transition-delay: 0.06s; }

/* 移动端：图标轨道常驻，展开为覆盖式抽屉 */
.rail-scrim {
  position: fixed;
  inset: 0;
  z-index: 55;
  background: rgba(12, 24, 17, 0.32);
  backdrop-filter: blur(4px);
  display: none;
}
body.rail-expanded .rail-scrim { display: block; }

@media (min-width: 1024px) {
  body.rail-expanded .rail-scrim { display: none; }
}

@media (max-width: 1023px) {
  :root { --rail-w: 76px; }
  .main { margin-left: var(--rail-w); padding-top: 0; }
  body.rail-expanded .main { margin-left: var(--rail-w); }
  body.rail-expanded .rail { width: 250px; }
  .rail { width: var(--rail-w); padding: 14px 10px 14px; }
  .rail-toggle { top: 20px; right: -12px; }
  .rail-nav { margin-top: 14px; }
  .rail-item { min-height: 50px; padding: 0 10px; }
  .page { padding-top: 24px; }
}

/* 饼图：参考“大环 + 中心大数字 + 图例” */
.donut-figure { position: relative; }
.donut-center {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  pointer-events: none;
  color: #2b1712;
}
.donut-center span { font-size: 12px; color: #65443a; }
.donut-center strong {
  font-family: var(--font-mono);
  font-size: 34px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 767px) {
  .donut-center strong { font-size: 28px; }
}

/* 320px 极窄屏：内容单列，避免图表最小内容把页面撑宽 */
@media (max-width: 480px) {
  .kpi-stack { grid-template-columns: 1fr; }
  .stats-3, .stats-4 { grid-template-columns: 1fr; }
  .toolbar .field { min-width: 0 !important; width: 100%; }
  .area-group { width: 100%; }
  .area-btn { flex: 1 1 auto; }
  .grid-12, .monitor-grid { gap: 8px; }
  .page { padding-left: 12px; padding-right: 12px; }
  .alert, .alert * { overflow-wrap: anywhere; }
}


/* ---------- 参考图式数据看板 ---------- */
.dashboard-top { margin-top: 32px; }
.dashboard-top .card { height: 100%; display: flex; flex-direction: column; }
.dashboard-top .card-head { flex: none; }
.dashboard-top .card > figure { flex: 1; }
.summary-list { display: flex; flex: 1; flex-direction: column; justify-content: space-between; gap: 10px; margin-top: 4px; }
.summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.36);
  border: 1px solid rgba(255, 255, 255, 0.42);
}
.summary-label { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #4a2e26; }
.summary-label .dot { width: 8px; height: 8px; }
.summary-value {
  font-family: var(--font-mono);
  font-size: 21px;
  font-weight: 700;
  color: #2b1712;
  font-variant-numeric: tabular-nums;
}
.recent-alarms-card .table-wrap { overflow-x: auto; }
.table.compact { min-width: 0; font-size: 13px; }
.table.compact th { padding: 8px 6px; font-size: 12px; }
.table.compact td { padding: 9px 6px; font-size: 13px; }
.table.compact .pill { transform: scale(0.92); transform-origin: left center; }
.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-width: 230px;
  height: 42px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.48);
  color: #65443a;
  font-size: 13px;
  cursor: pointer;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.search-trigger svg { width: 17px; height: 17px; flex: none; color: #7d5b4f; }
.search-trigger:hover { background: rgba(255, 255, 255, 0.66); }
.search-trigger .search-kbd {
  margin-left: auto;
  padding: 2px 7px;
  border-radius: 6px;
  border: 1px solid rgba(90, 45, 30, 0.16);
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #7d5b4f;
}

@media (max-width: 767px) {
  .search-trigger { min-width: 0; width: 42px; padding: 0; justify-content: center; }
  .search-trigger .search-text, .search-trigger .search-kbd { display: none; }
  .summary-row { min-height: 44px; }
  .summary-value { font-size: 18px; }
}


/* 摘要卡三列（大屏与参考图 3/3/6 比例对应） */
.span-3 { grid-column: span 12; }
@media (min-width: 1280px) {
  .span-3 { grid-column: span 3; }
}
@media (max-width: 1279px) {
  .span-6 { grid-column: span 12; }
}


/* 手机端：KPI 2×2，最近告警表隐藏类别列以完整显示状态 */
@media (max-width: 767px) {
  .kpi-row.stats-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi-row .kpi { padding: 18px 16px; }
}
@media (max-width: 480px) {
  .recent-alarms-card th:nth-child(3),
  .recent-alarms-card td:nth-child(3) { display: none; }
}


/* 监控占位：连接中 / 错误 / 演示入口 */
.video-placeholder.vp-error .vp-title { color: #ffb39c; }
.video-placeholder.vp-error .vp-hint { color: #e4c8ba; max-width: 86%; line-height: 1.6; }
.vp-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 10px; }
.vp-actions[hidden] { display: none; }
.vp-actions .btn-secondary {
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
}
.vp-actions .btn-secondary:hover { background: rgba(255, 255, 255, 0.22); }


/* 告警工单：批量选择 / 编辑 / 删除 */
.alarm-toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 12px 20px;
  border-bottom: 1px solid rgba(90, 45, 30, 0.08);
  background: rgba(255, 255, 255, 0.24);
}
.check-label { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: #4a2e26; cursor: pointer; }
.check-col { width: 38px; text-align: center; }
.check-col input[type="checkbox"] { width: 16px; height: 16px; accent-color: #9a3412; cursor: pointer; vertical-align: middle; }
.table .cell-actions { white-space: normal; min-width: 220px; }
.table .cell-actions .btn { margin: 2px 4px 2px 0; white-space: nowrap; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
#edit-modal .modal { max-width: 460px; }
#frame-wall[hidden], #frame-empty[hidden] { display: none !important; }


/* 确认工单弹窗：大图 + 完整信息 */
#confirm-modal .modal { max-width: 760px; }
.confirm-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(220px, 0.75fr);
  gap: 22px;
  align-items: start;
  margin-top: 14px;
}
.confirm-img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 16px;
  background: #0b0b0d;
}
.confirm-img[hidden] { display: none !important; }
.confirm-noimg {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.35);
  color: #65443a;
  font-size: 13px;
}
.confirm-noimg[hidden] { display: none !important; }
.confirm-meta { margin: 0; }
.confirm-meta .row { min-height: 32px; }
.confirm-meta dd { max-width: 62%; text-align: right; overflow-wrap: anywhere; }
@media (max-width: 640px) {
  .confirm-grid { grid-template-columns: 1fr; }
}


/* 告警工单：默认只显示「编辑」；进入编辑模式后才出现勾选与删除 */
#alarm-list-container .check-col { display: none; }
#alarm-list-container.selection-mode .check-col { display: table-cell; }
#alarm-list-container .alarm-delete { display: none; }
#alarm-list-container.selection-mode .alarm-delete { display: inline-flex; }
.selection-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.selection-tools[hidden] { display: none !important; }
.table .cell-actions { min-width: 170px; }
#alarm-list-container:not(.selection-mode) tbody tr[data-id] { cursor: pointer; }
tbody tr[data-id]:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}


/* ---------- 趋势图：自绘 SVG，滚轮缩放动画自己控制 ---------- */
#trend-chart {
  position: relative;
  height: 360px;
  min-height: 360px;
  overflow: visible;
  cursor: grab;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
#trend-chart.is-panning { cursor: grabbing; }
#trend-chart .trend-svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
}
#trend-chart .trend-plot { overflow: hidden; }
#trend-chart .trend-grid line {
  stroke: rgba(90, 45, 30, 0.085);
  stroke-width: 1;
  shape-rendering: crispEdges;
}
#trend-chart .trend-axis text {
  fill: #65443a;
  font-family: var(--font-sans);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}
#trend-chart .trend-yaxis text { text-anchor: end; dominant-baseline: middle; }
#trend-chart .trend-xaxis text { text-anchor: middle; }
#trend-chart .trend-xaxis { transition: opacity 0.12s ease; }
#trend-chart.is-zooming .trend-xaxis { opacity: 0; }
#trend-chart .trend-line {
  fill: none;
  stroke: #9a3412;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#trend-chart .trend-area {
  fill: rgba(154, 52, 18, 0.10);
  stroke: none;
}
#trend-chart .trend-hover-line {
  stroke: rgba(154, 52, 18, 0.35);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}
#trend-chart .trend-hover-dot { fill: #9a3412; stroke: #fffaf6; stroke-width: 2; }
.trend-tip {
  position: absolute;
  z-index: 3;
  padding: 7px 10px;
  border-radius: 9px;
  background: rgba(255, 252, 248, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 8px 22px rgba(70, 30, 18, 0.16);
  color: #2b1712;
  font-size: 12px;
  line-height: 1.5;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, -100%);
}
.trend-tip[hidden] { display: none !important; }
@media (max-width: 1279px) {
  #trend-chart { height: 320px; min-height: 320px; }
}
@media (max-width: 767px) {
  #trend-chart { height: 270px; min-height: 270px; }
}




/* ---------- 实时监控视频全屏 ---------- */
.video-shell {
  user-select: none;
  -webkit-user-select: none;
}
.video-fs-btn {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 4;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  background: rgba(10, 11, 10, 0.46);
  color: #fff;
  cursor: pointer;
  opacity: 0.58;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.16s ease, background 0.16s ease, transform 0.16s ease;
}
.video-fs-btn:hover,
.video-fs-btn:focus-visible {
  opacity: 1;
  background: rgba(10, 11, 10, 0.72);
  transform: translateY(-1px);
}
.video-fs-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.85);
  outline-offset: 2px;
}
.video-fs-btn svg { width: 19px; height: 19px; }
.video-fs-btn svg[hidden] { display: none !important; }
.video-shell:fullscreen,
.video-shell:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0 !important;
  border: 0;
  border-radius: 0;
  aspect-ratio: auto;
  background: #000;
}
.video-shell:fullscreen img,
.video-shell:-webkit-full-screen img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.video-shell:fullscreen .video-fs-btn,
.video-shell:-webkit-full-screen .video-fs-btn {
  right: 22px;
  bottom: 22px;
  opacity: 0.85;
}
.video-shell:fullscreen .video-fs-btn:hover,
.video-shell:-webkit-full-screen .video-fs-btn:hover { opacity: 1; }
@media (hover: none), (pointer: coarse) {
  .video-fs-btn { opacity: 0.9; }
}
