<script setup>
import { computed, nextTick, onBeforeUnmount, onMounted, ref } from 'vue'
import * as echarts from 'echarts'
import { Odometer, CircleCheckFilled, VideoCameraFilled, WarnTriangleFilled } from '@element-plus/icons-vue'

const nowText = ref('2025/12/31 12:59:59')
const weekText = ref('星期三')
const mapError = ref('')

const baseCards = computed(() => [
  { label: '监测点总数', value: 18, unit: '个', icon: Odometer, color: '#60b8ff' },
  { label: '在线监测点', value: 16, unit: '个', icon: CircleCheckFilled, color: '#52e0a8' },
  { label: '离线监测点', value: 2, unit: '个', icon: VideoCameraFilled, color: '#ff8e8e' },
  { label: '当日预警点', value: 3, unit: '个', icon: WarnTriangleFilled, color: '#ffb54d' }
])

const operationSummary = [
  { label: '管网总长度', value: '128.6km' },
  { label: '重点管段', value: '12段' },
  { label: '调压站', value: '6座' }
]

const repairRecords = [
  { month: '1月', value: 3 },
  { month: '2月', value: 5 },
  { month: '3月', value: 4 },
  { month: '4月', value: 6 },
  { month: '5月', value: 4 },
  { month: '6月', value: 7 }
]

const pointRows = [
  { id: 1, name: '辰州路阀井A-01', time: '12:59', value: '0.22MPa', status: '在线' },
  { id: 2, name: '古城路调压箱B-02', time: '12:59', value: '0.24MPa', status: '在线' },
  { id: 3, name: '迎宾路阀室C-03', time: '12:59', value: '0.18MPa', status: '预警' },
  { id: 4, name: '建设路阀井D-04', time: '12:59', value: '0.21MPa', status: '在线' },
  { id: 5, name: '滨江路管点E-05', time: '12:59', value: '0.23MPa', status: '在线' },
  { id: 6, name: '天宁路调压站F-06', time: '12:59', value: '0.19MPa', status: '离线' },
  { id: 7, name: '鸳鸯路阀井G-07', time: '12:59', value: '0.25MPa', status: '在线' },
  { id: 8, name: '消防巷支线H-08', time: '12:59', value: '0.20MPa', status: '在线' }
]

const equipmentRows = [
  { id: 1, name: '调压柜A', code: 'RQ-001', location: '辰州路', status: '正常' },
  { id: 2, name: '阀门井B', code: 'RQ-002', location: '古城路', status: '正常' },
  { id: 3, name: '流量计C', code: 'RQ-003', location: '迎宾路', status: '检修中' },
  { id: 4, name: '压力表D', code: 'RQ-004', location: '建设路', status: '正常' },
  { id: 5, name: '调压箱E', code: 'RQ-005', location: '滨江路', status: '正常' }
]

const warningRows = [
  { level: '高', title: '压力波动偏高', code: '辰州路阀井A-01', time: '12:59:59', desc: '建议复核上游调压状态', tag: '压力异常' },
  { level: '中', title: '疑似泄漏趋势', code: '迎宾路阀室C-03', time: '12:58:40', desc: '瞬时流量较近30分钟均值偏高', tag: '流量异常' },
  { level: '高', title: '通信中断', code: '天宁路调压站F-06', time: '12:57:12', desc: '采集设备离线超过15分钟', tag: '设备离线' },
  { level: '中', title: '设备开盖异常', code: '古城路调压箱B-02', time: '12:56:22', desc: '巡检确认现场状态', tag: '巡检关注' },
  { level: '中', title: '阀门状态异常', code: '滨江路管点E-05', time: '12:54:16', desc: '阀门开度反馈与设定值存在偏差', tag: '阀门异常' },
  { level: '高', title: '瞬时流量突增', code: '鸳鸯路阀井G-07', time: '12:52:48', desc: '短时流量连续3次超出阈值上限', tag: '流量异常' },
  { level: '中', title: '电池电量偏低', code: '消防巷支线H-08', time: '12:49:05', desc: '建议尽快安排现场更换电池', tag: '设备维护' },
  { level: '高', title: '站点离线恢复失败', code: '天宁路调压站F-06', time: '12:45:31', desc: '自动重连3次未成功，请人工排查', tag: '设备离线' }
]

const hazardSummary = [
  { label: '一般隐患', value: 14, color: '#f3e64d' },
  { label: '较大隐患', value: 5, color: '#ff9f1a' },
  { label: '重大隐患', value: 2, color: '#ff3030' }
]

const mapKpis = [
  { label: '在线率', value: '88.9%' },
  { label: '压力均值', value: '0.21MPa' },
  { label: '今日告警', value: '4条' }
]

const pipelineLines = [
  {
    name: '辰州路主干线',
    color: '#39f5ff',
    flow: '瞬时流量 0.52m³/min',
    points: [
      [110.3855, 28.4696],
      [110.3873, 28.4668],
      [110.3894, 28.4633],
      [110.3922, 28.4598],
      [110.3978, 28.4568],
      [110.4058, 28.4558],
      [110.4148, 28.4551]
    ]
  },
  {
    name: '古城路支线',
    color: '#14d8ff',
    flow: '瞬时流量 0.38m³/min',
    points: [
      [110.3892, 28.4728],
      [110.3928, 28.4704],
      [110.3964, 28.4683],
      [110.4011, 28.4672],
      [110.4072, 28.4669]
    ]
  }
]

const pipePoints = [
  { name: 'A点', value: '0.22MPa', lng: 110.3872, lat: 28.4669 },
  { name: 'B点', value: '0.24MPa', lng: 110.3894, lat: 28.4633 },
  { name: 'C点', value: '0.18MPa', lng: 110.3922, lat: 28.4598 },
  { name: 'D点', value: '0.23MPa', lng: 110.3978, lat: 28.4568 },
  { name: 'E点', value: '0.25MPa', lng: 110.4058, lat: 28.4558 },
  { name: 'F点', value: '0.19MPa', lng: 110.3892, lat: 28.4728 },
  { name: 'G点', value: '0.21MPa', lng: 110.4011, lat: 28.4672 }
]

const mapWrapRef = ref(null)
const repairChartRef = ref(null)
const hazardChartRef = ref(null)
let mapInstance = null
let repairChart = null
let hazardChart = null
let clockTimer = null

function formatWeek(day) {
  return ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六'][day]
}

function pad(value) {
  return String(value).padStart(2, '0')
}

function updateClock() {
  const now = new Date()
  nowText.value = `${now.getFullYear()}/${pad(now.getMonth() + 1)}/${pad(now.getDate())} ${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}`
  weekText.value = formatWeek(now.getDay())
}

function initRepairChart() {
  if (!repairChartRef.value) return
  repairChart?.dispose()
  repairChart = echarts.init(repairChartRef.value)
  repairChart.setOption({
    grid: { left: 30, right: 12, top: 20, bottom: 24, containLabel: true },
    xAxis: {
      type: 'category',
      data: repairRecords.map(item => item.month),
      axisLine: { lineStyle: { color: 'rgba(91, 167, 219, 0.8)' } },
      axisLabel: { color: '#d2efff' }
    },
    yAxis: {
      type: 'value',
      splitLine: { lineStyle: { color: 'rgba(91, 167, 219, 0.18)' } },
      axisLine: { show: false },
      axisLabel: { color: '#d2efff' }
    },
    tooltip: { trigger: 'axis' },
    series: [{
      type: 'bar',
      barWidth: 24,
      data: repairRecords.map(item => item.value),
      itemStyle: {
        borderRadius: [6, 6, 0, 0],
        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
          { offset: 0, color: '#38d8ff' },
          { offset: 1, color: '#166dff' }
        ])
      }
    }]
  })
}

function initHazardChart() {
  if (!hazardChartRef.value) return
  hazardChart?.dispose()
  hazardChart = echarts.init(hazardChartRef.value)
  hazardChart.setOption({
    grid: { left: 18, right: 18, top: 10, bottom: 10, containLabel: true },
    xAxis: {
      type: 'value',
      splitLine: { show: false },
      axisLine: { show: false },
      axisTick: { show: false },
      axisLabel: { show: false }
    },
    yAxis: {
      type: 'category',
      data: hazardSummary.map(item => item.label),
      axisLine: { show: false },
      axisTick: { show: false },
      axisLabel: { color: '#d2efff', fontSize: 13 }
    },
    tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } },
    series: [{
      type: 'bar',
      data: hazardSummary.map(item => ({ value: item.value, itemStyle: { color: item.color, borderRadius: 10 } })),
      barWidth: 14,
      label: { show: true, position: 'right', color: '#fff', fontWeight: 'bold' },
      showBackground: true,
      backgroundStyle: { color: 'rgba(255,255,255,0.08)', borderRadius: 10 }
    }]
  })
}

function waitForBMapGL() {
  return new Promise((resolve, reject) => {
    if (window.BMapGL) {
      resolve(window.BMapGL)
      return
    }
    let attempts = 0
    const timer = setInterval(() => {
      attempts += 1
      if (window.BMapGL) {
        clearInterval(timer)
        resolve(window.BMapGL)
        return
      }
      if (attempts >= 100) {
        clearInterval(timer)
        reject(new Error('百度地图加载超时'))
      }
    }, 200)
  })
}

function createFlowLabel(BMapGL, text) {
  const label = new BMapGL.Label(text, { offset: new BMapGL.Size(-46, -18) })
  label.setStyle({
    color: '#fff36a',
    background: 'rgba(255, 230, 0, 0.22)',
    border: '1px solid rgba(255, 230, 0, 0.55)',
    borderRadius: '8px',
    padding: '5px 8px',
    fontSize: '12px',
    boxShadow: '0 0 12px rgba(255, 230, 0, 0.22)'
  })
  return label
}

function addPipeLine(BMapGL, pipe) {
  const bmapPoints = pipe.points.map(([lng, lat]) => new BMapGL.Point(lng, lat))
  const polyline = new BMapGL.Polyline(bmapPoints, {
    strokeColor: pipe.color,
    strokeWeight: 4,
    strokeOpacity: 0.95
  })
  mapInstance.addOverlay(polyline)

  bmapPoints.forEach((point, index) => {
    const ring = new BMapGL.Circle(point, 14, {
      strokeColor: '#39f5ff',
      strokeWeight: 2,
      strokeOpacity: 0.7,
      fillColor: 'rgba(57,245,255,0.08)',
      fillOpacity: 0.18
    })
    mapInstance.addOverlay(ring)
    if (index < bmapPoints.length - 1 && index % 2 === 0) {
      const label = createFlowLabel(BMapGL, pipe.flow)
      const current = pipe.points[index]
      const next = pipe.points[index + 1]
      label.setPosition(new BMapGL.Point((current[0] + next[0]) / 2, (current[1] + next[1]) / 2))
      mapInstance.addOverlay(label)
    }
  })
}

function addPipePoint(BMapGL, point) {
  const markerPoint = new BMapGL.Point(point.lng, point.lat)
  const marker = new BMapGL.Marker(markerPoint)
  mapInstance.addOverlay(marker)
  const label = new BMapGL.Label(`${point.name} ${point.value}`, { offset: new BMapGL.Size(-42, -40) })
  label.setPosition(markerPoint)
  label.setStyle({
    color: '#d8faff',
    background: 'rgba(18, 68, 112, 0.75)',
    border: '1px solid rgba(57, 245, 255, 0.55)',
    borderRadius: '8px',
    padding: '5px 8px',
    fontSize: '12px'
  })
  mapInstance.addOverlay(label)
}

async function initMap() {
  if (!mapWrapRef.value) return
  try {
    const BMapGL = await waitForBMapGL()
    mapInstance = new BMapGL.Map(mapWrapRef.value, { enableMapClick: true })
    const center = new BMapGL.Point(110.3965, 28.4638)
    mapInstance.centerAndZoom(center, 15)
    mapInstance.enableScrollWheelZoom(true)
    mapInstance.setMapStyleV2({ styleId: 'a0f4e6e6f9e7a6c5d8e7f7e7f7e7f7e5' })

    pipelineLines.forEach(pipe => addPipeLine(BMapGL, pipe))
    pipePoints.forEach(point => addPipePoint(BMapGL, point))
  } catch (error) {
    mapError.value = '百度地图加载失败，请检查地图脚本或网络连接。'
  }
}

function handleResize() {
  repairChart?.resize()
  hazardChart?.resize()
}

onMounted(async () => {
  updateClock()
  clockTimer = window.setInterval(updateClock, 1000)
  await nextTick()
  initRepairChart()
  initHazardChart()
  initMap()
  window.addEventListener('resize', handleResize)
})

onBeforeUnmount(() => {
  if (clockTimer) window.clearInterval(clockTimer)
  window.removeEventListener('resize', handleResize)
  repairChart?.dispose()
  hazardChart?.dispose()
  mapInstance = null
})
</script>

<template>
  <div class="gas-home-screen">
    <div class="screen-header">
      <div class="header-time">{{ nowText }} {{ weekText }}</div>
      <div class="header-title-wrap">
        <div class="header-title">燃气管网安全运行监测系统</div>
        <div class="header-subtitle">Gas Pipeline Operation Dashboard</div>
      </div>
      <div class="header-tags">
        <span class="header-tag">实时监测</span>
        <span class="header-tag">管网运行</span>
        <span class="header-tag">隐患预警</span>
      </div>
    </div>

    <div class="screen-body">
      <div class="side-panel left-panel">
        <section class="panel-card base-card">
          <div class="panel-title">基础概况</div>
          <div class="base-grid">
            <div v-for="item in baseCards" :key="item.label" class="base-item">
              <div class="base-icon" :style="{ background: item.color }">
                <component :is="item.icon" class="base-icon-svg" />
              </div>
              <div class="base-text">
                <div class="base-label">{{ item.label }}</div>
                <div class="base-value">{{ item.value }}<span>{{ item.unit }}</span></div>
              </div>
            </div>
          </div>
        </section>

        <section class="panel-card">
          <div class="panel-title">维修趋势</div>
          <div ref="repairChartRef" class="chart-box repair-chart"></div>
        </section>

        <section class="panel-card table-card">
          <div class="panel-title">监测点数据</div>
          <div class="table-wrap">
            <table class="data-table">
              <thead>
                <tr>
                  <th>序号</th>
                  <th>监测点</th>
                  <th>时间</th>
                  <th>数值</th>
                  <th>状态</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="row in pointRows" :key="row.id">
                  <td>{{ row.id }}</td>
                  <td>{{ row.name }}</td>
                  <td>{{ row.time }}</td>
                  <td>{{ row.value }}</td>
                  <td :class="['status-cell', row.status === '在线' ? 'ok' : row.status === '预警' ? 'warn' : 'off']">{{ row.status }}</td>
                </tr>
              </tbody>
            </table>
          </div>
        </section>
      </div>

      <div class="center-panel">
        <div class="map-stage">
          <div class="map-stage-top">
            <div class="summary-strip">
              <div v-for="item in operationSummary" :key="item.label" class="summary-item">
                <span class="summary-label">{{ item.label }}</span>
                <strong class="summary-value">{{ item.value }}</strong>
              </div>
            </div>
            <div class="map-kpis">
              <div v-for="item in mapKpis" :key="item.label" class="map-kpi">
                <span>{{ item.label }}</span>
                <strong>{{ item.value }}</strong>
              </div>
            </div>
          </div>

          <div ref="mapWrapRef" class="map-view"></div>
          <div v-if="mapError" class="map-error">{{ mapError }}</div>

          <div class="map-panel info-panel">
            <div class="mini-title">当前管网信息</div>
            <div class="mini-row"><span>主干线</span><strong>2条</strong></div>
            <div class="mini-row"><span>支线</span><strong>4条</strong></div>
            <div class="mini-row"><span>重点巡检</span><strong>3段</strong></div>
          </div>

          <div class="map-panel point-panel">
            <div class="mini-title">当前管点信息</div>
            <div class="mini-row"><span>在线采集</span><strong>16个</strong></div>
            <div class="mini-row"><span>预警点位</span><strong>3个</strong></div>
            <div class="mini-row"><span>离线点位</span><strong>2个</strong></div>
          </div>
        </div>
      </div>

      <div class="side-panel right-panel">
        <section class="panel-card">
          <div class="panel-title">设备运行</div>
          <div class="table-wrap equipment-wrap">
            <table class="data-table compact-table">
              <thead>
                <tr>
                  <th>序号</th>
                  <th>设备名称</th>
                  <th>设备编号</th>
                  <th>位置</th>
                  <th>状态</th>
                </tr>
              </thead>
              <tbody>
                <tr v-for="row in equipmentRows" :key="row.id">
                  <td>{{ row.id }}</td>
                  <td>{{ row.name }}</td>
                  <td>{{ row.code }}</td>
                  <td>{{ row.location }}</td>
                  <td>{{ row.status }}</td>
                </tr>
              </tbody>
            </table>
          </div>
        </section>

        <section class="panel-card warning-card">
          <div class="panel-title">告警动态</div>
          <div class="warning-scroll">
            <div class="warning-list">
              <div v-for="(item, index) in warningRows" :key="index" class="warning-item" :class="item.level === '高' ? 'danger' : 'notice'">
                <div class="warning-side">
                  <div class="warning-badge">{{ item.level }}</div>
                  <div class="warning-tag">{{ item.tag }}</div>
                </div>
                <div class="warning-main">
                  <div class="warning-title-row">
                    <span class="warning-title">{{ item.title }}</span>
                    <span class="warning-time">{{ item.time }}</span>
                  </div>
                  <div class="warning-code">{{ item.code }}</div>
                  <div class="warning-desc">{{ item.desc }}</div>
                </div>
              </div>
            </div>
          </div>
        </section>

        <section class="panel-card hazard-card">
          <div class="panel-title">隐患统计</div>
          <div class="hazard-summary three-col">
            <div v-for="item in hazardSummary" :key="item.label" class="hazard-summary-item">
              <span class="hazard-dot" :style="{ background: item.color }"></span>
              <span>{{ item.label }}</span>
              <strong :style="{ color: item.color }">{{ item.value }}项</strong>
            </div>
          </div>
          <div ref="hazardChartRef" class="chart-box hazard-chart"></div>
        </section>
      </div>
    </div>
  </div>
</template>

<style scoped lang="scss">
.gas-home-screen {
  min-height: 100vh;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(14, 42, 70, 0.96), rgba(8, 20, 37, 1)),
    radial-gradient(circle at center, rgba(36, 122, 184, 0.18), transparent 58%),
    #081425;
}

.screen-header {
  height: 72px;
  padding: 0 18px;
  display: grid;
  grid-template-columns: 320px 1fr 320px;
  align-items: center;
  border-bottom: 1px solid rgba(93, 194, 255, 0.28);
  background: linear-gradient(90deg, rgba(27, 98, 155, 0.95), rgba(18, 53, 98, 0.95));
}

.header-time {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #ddf6ff;
}

.header-title-wrap {
  text-align: center;
}

.header-title {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: 2px;
}

.header-subtitle {
  margin-top: 4px;
  color: rgba(196, 234, 255, 0.78);
  font-size: 12px;
  letter-spacing: 1px;
}

.header-tags {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.header-tag {
  padding: 7px 12px;
  border: 1px solid rgba(117, 206, 255, 0.4);
  border-radius: 16px;
  color: #d8f5ff;
  background: rgba(13, 77, 128, 0.45);
  font-size: 12px;
}

.screen-body {
  height: calc(100vh - 72px);
  padding: 12px;
  display: grid;
  grid-template-columns: 360px 1fr 360px;
  gap: 12px;
}

.side-panel,
.center-panel {
  min-height: 0;
}

.left-panel,
.right-panel {
  display: grid;
  gap: 12px;
}

.left-panel {
  grid-template-rows: 220px 220px 1fr;
}

.right-panel {
  grid-template-rows: 250px 260px 1fr;
}

.panel-card {
  min-height: 0;
  padding: 12px;
  background: linear-gradient(180deg, rgba(13, 33, 56, 0.88), rgba(10, 25, 42, 0.88));
  border: 1px solid rgba(65, 158, 219, 0.28);
  border-radius: 10px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03);
}

.panel-title {
  position: relative;
  padding-left: 14px;
  margin-bottom: 12px;
  color: #8fe5ff;
  font-size: 18px;
  font-weight: 800;
}

.panel-title::before {
  content: '';
  position: absolute;
  left: 0;
  top: 4px;
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: linear-gradient(180deg, #28d7ff, #1776ff);
}

.base-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.base-card {
  background: linear-gradient(180deg, rgba(10, 30, 53, 0.95), rgba(9, 24, 42, 0.95));
}

.base-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.base-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 12px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(20, 57, 89, 0.55), rgba(18, 44, 72, 0.45));
  border: 1px solid rgba(97, 190, 255, 0.16);
}

.base-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 48px;
}

.base-icon-svg {
  width: 26px;
  height: 26px;
  color: #fff;
}

.base-text {
  min-width: 0;
}

.base-label {
  color: #d6efff;
  font-size: 13px;
  letter-spacing: 0.5px;
}

.base-value {
  margin-top: 4px;
  color: #fff;
  font-size: 30px;
  font-weight: 800;
  line-height: 1;
}

.base-value span {
  margin-left: 4px;
  color: #90d9ff;
  font-size: 12px;
  font-weight: 500;
}

.chart-box {
  width: 100%;
  height: calc(100% - 36px);
}

.table-card,
.warning-card,
.hazard-card {
  overflow: hidden;
}

.table-wrap {
  height: calc(100% - 38px);
  overflow: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.data-table thead {
  background: rgba(24, 122, 198, 0.55);
}

.data-table th,
.data-table td {
  padding: 10px 6px;
  color: #f4fbff;
  text-align: center;
  font-size: 13px;
  border-bottom: 1px solid rgba(130, 194, 231, 0.12);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.data-table tbody tr:nth-child(odd) {
  background: rgba(133, 196, 242, 0.12);
}

.data-table tbody tr:nth-child(even) {
  background: rgba(133, 196, 242, 0.06);
}

.compact-table th,
.compact-table td {
  padding: 9px 4px;
}

.status-cell.ok {
  color: #6effc4;
}

.status-cell.warn {
  color: #ffe16a;
}

.status-cell.off {
  color: #ff8e8e;
}

.center-panel {
  position: relative;
}

.map-stage {
  position: relative;
  height: 100%;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid rgba(56, 159, 223, 0.2);
  background: rgba(8, 20, 37, 0.64);
}

.map-stage-top {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.summary-strip,
.map-kpis {
  display: flex;
  gap: 10px;
}

.summary-item,
.map-kpi {
  min-width: 110px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(8, 31, 54, 0.78);
  border: 1px solid rgba(79, 177, 238, 0.22);
}

.summary-label,
.map-kpi span {
  display: block;
  color: #91d7ff;
  font-size: 12px;
}

.summary-value,
.map-kpi strong {
  display: block;
  margin-top: 6px;
  color: #fff;
  font-size: 20px;
}

.map-view {
  width: 100%;
  height: 100%;
}

.map-error {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffd3d3;
  background: rgba(5, 10, 20, 0.72);
  z-index: 4;
}

.map-panel {
  position: absolute;
  z-index: 3;
  width: 190px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(8, 31, 54, 0.78);
  border: 1px solid rgba(79, 177, 238, 0.22);
}

.info-panel {
  left: 18px;
  bottom: 20px;
}

.point-panel {
  right: 18px;
  bottom: 20px;
}

.mini-title {
  margin-bottom: 10px;
  color: #8fe5ff;
  font-size: 14px;
  font-weight: 700;
}

.mini-row {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  color: #d6efff;
  font-size: 13px;
}

.warning-scroll {
  height: calc(100% - 38px);
  overflow-y: auto;
  padding-right: 4px;
}

.warning-scroll::-webkit-scrollbar {
  width: 6px;
}

.warning-scroll::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(96, 180, 235, 0.38);
}

.warning-scroll::-webkit-scrollbar-track {
  background: transparent;
}

.warning-list {
  display: grid;
  gap: 12px;
}

.warning-item {
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 108, 108, 0.1);
  background: linear-gradient(180deg, rgba(72, 24, 38, 0.48), rgba(49, 19, 31, 0.36));
}

.warning-item.notice {
  border-color: rgba(255, 201, 92, 0.1);
  background: linear-gradient(180deg, rgba(78, 63, 23, 0.34), rgba(48, 43, 20, 0.24));
}

.warning-side {
  width: 56px;
  flex: 0 0 56px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

.warning-badge {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 800;
  color: #fff;
}

.warning-tag {
  width: 100%;
  padding: 3px 0;
  border-radius: 999px;
  text-align: center;
  font-size: 11px;
  color: #dcefff;
  background: rgba(255, 255, 255, 0.08);
}

.warning-item.danger .warning-badge {
  background: rgba(255, 58, 58, 0.24);
  color: #ff8787;
}

.warning-item.danger .warning-title {
  color: #ffd8d8;
}

.warning-item.notice .warning-badge {
  background: rgba(255, 198, 53, 0.18);
  color: #ffd45d;
}

.warning-item.notice .warning-title {
  color: #fff2c4;
}

.warning-main {
  min-width: 0;
  flex: 1;
}

.warning-title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.warning-title {
  font-weight: 700;
  font-size: 16px;
  line-height: 1.2;
}

.warning-time,
.warning-code,
.warning-desc {
  color: #dcefff;
  font-size: 12px;
}

.warning-time {
  color: #b6dfff;
  white-space: nowrap;
}

.warning-code {
  margin: 6px 0 4px;
  color: #9ad8ff;
}

.warning-desc {
  line-height: 1.5;
}

.hazard-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
}

.hazard-summary.three-col {
  justify-content: space-between;
}

.hazard-summary-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.hazard-dot {
  width: 8px;
  height: 24px;
  display: inline-block;
  border-radius: 4px;
}

.hazard-chart {
  height: 160px;
}

.equipment-wrap {
  height: calc(100% - 38px);
}

:deep(.BMap_cpyCtrl),
:deep(.anchorBL) {
  display: none !important;
}

@media (max-width: 1500px) {
  .screen-body {
    grid-template-columns: 320px 1fr 320px;
  }

  .header-title {
    font-size: 24px;
  }

  .summary-item,
  .map-kpi {
    min-width: 96px;
  }
}
</style>
