/* ================= 灵山高速数智养护系统 - 扁平清新风格 ================= */
:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --ink: #1c2b3a;
  --ink-2: #5a6b7f;
  --ink-3: #93a3b5;
  --brand: #1668dc;
  --brand-2: #0e4fb3;
  --brand-soft: #e8f1fe;
  --green: #16a34a; --green-bg: #e8f8ee;
  --yellow: #d97706; --yellow-bg: #fef3e2; --yellow-solid: #f59e0b;
  --orange: #ea580c; --orange-bg: #fdeae0; --orange-solid: #f97316;
  --red: #dc2626; --red-bg: #fdeaea; --red-solid: #ef4444;
  --blue: #2563eb; --blue-bg: #e9f0fe;
  --line: #e7edf5;
  --shadow: 0 1px 3px rgba(23, 43, 77, .06);
  --radius: 14px;
  --sidebar-w: 232px;
  font-size: 15px;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg); color: var(--ink); overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------------- 布局 ---------------- */
#app { display: flex; height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column;
  background: linear-gradient(180deg, #0d2b57 0%, #123a72 55%, #0d2b57 100%);
  color: #cfe0f7;
}
.brand { display: flex; gap: 10px; align-items: center; padding: 18px 16px 14px; }
.brand-logo { font-size: 30px; line-height: 1; filter: drop-shadow(0 2px 4px rgba(0,0,0,.3)); }
.brand-name { font-size: 16.5px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.brand-sub { font-size: 12px; color: #8fb1e0; margin-top: 3px; }
.nav { flex: 1; padding: 8px 10px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 11px; padding: 12px 14px; margin-bottom: 4px;
  border-radius: 11px; cursor: pointer; font-size: 15px; color: #cfe0f7;
  transition: background .15s, color .15s; user-select: none;
}
.nav-item .ico { font-size: 18px; width: 22px; text-align: center; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, #1c7bff, #1668dc); color: #fff; font-weight: 600; box-shadow: 0 4px 12px rgba(22,104,220,.4); }
.nav-item .badge { margin-left: auto; }
.sidebar-foot { padding: 12px 16px 16px; font-size: 12px; color: #7d9dcb; }
.live-dot { display: flex; align-items: center; gap: 7px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 6px #22c55e; animation: pulse 2s infinite; }
.dot.warn { background: #f59e0b; box-shadow: 0 0 6px #f59e0b; }
@keyframes pulse { 50% { opacity: .4; } }
.upstream { margin-top: 8px; opacity: .85; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 58px; display: flex; align-items: center; gap: 18px; padding: 0 22px;
  background: var(--panel); box-shadow: var(--shadow); position: relative; z-index: 5;
}
.crumb { font-size: 17px; font-weight: 700; white-space: nowrap; }
.tabs { display: flex; gap: 6px; flex: 1; overflow-x: auto; }
.tab {
  display: flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 9px;
  background: var(--bg); color: var(--ink-2); cursor: pointer; font-size: 13.5px; white-space: nowrap;
  transition: all .15s;
}
.tab.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.tab .x { padding: 0 2px; opacity: .5; } .tab .x:hover { opacity: 1; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.env-chip { font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.clock { font-size: 14px; font-weight: 600; color: var(--brand); font-variant-numeric: tabular-nums; white-space: nowrap; }
.user { font-size: 13.5px; color: var(--ink-2); white-space: nowrap; }
.content { flex: 1; overflow-y: auto; padding: 18px 22px 26px; }

/* ---------------- 通用组件 ---------------- */
.card { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card-title { display: flex; align-items: center; gap: 9px; font-size: 15.5px; font-weight: 700; margin-bottom: 14px; }
.card-title::before { content: ""; width: 4px; height: 16px; border-radius: 2px; background: var(--brand); }
.card-title .more { margin-left: auto; font-size: 13px; color: var(--brand); cursor: pointer; font-weight: 500; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: 1fr 1fr; } .g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); } .g5 { grid-template-columns: repeat(5, 1fr); }
.g23 { grid-template-columns: 2fr 3fr; } .g32 { grid-template-columns: 3fr 2fr; }

/* 徽章 */
.lv { display: inline-flex; align-items: center; gap: 6px; padding: 3px 11px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.6; }
.lv-yellow { background: var(--yellow-bg); color: var(--yellow); }
.lv-orange { background: var(--orange-bg); color: var(--orange); }
.lv-red { background: var(--red-bg); color: var(--red); }
.lv-normal, .lv-green { background: var(--green-bg); color: var(--green); }
.lv-blue { background: var(--blue-bg); color: var(--blue); }
.lv-gray { background: #eef2f7; color: var(--ink-3); }
.lv::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.lv-solid-yellow { background: var(--yellow-solid); color: #fff; }
.lv-solid-orange { background: var(--orange-solid); color: #fff; }
.lv-solid-red { background: var(--red-solid); color: #fff; animation: blink 1.2s infinite; }
.lv-solid-green { background: var(--green); color: #fff; }
@keyframes blink { 50% { opacity: .65; } }

/* 统计块 */
.stat { background: var(--panel); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 6px; position: relative; overflow: hidden; }
.stat .k { font-size: 13.5px; color: var(--ink-2); }
.stat .v { font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .v small { font-size: 13px; font-weight: 500; color: var(--ink-3); margin-left: 4px; }
.stat .sub { font-size: 12.5px; color: var(--ink-3); }
.stat.c-yellow .v { color: var(--yellow-solid); } .stat.c-orange .v { color: var(--orange-solid); }
.stat.c-red .v { color: var(--red-solid); } .stat.c-green .v { color: var(--green); }
.stat.c-blue .v { color: var(--brand); }
.stat .trend-up { color: var(--red); font-size: 12.5px; } .stat .trend-down { color: var(--green); font-size: 12.5px; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; padding: 10px 12px; color: var(--ink-3); font-weight: 600; font-size: 13px; background: #f8fafd; position: sticky; top: 0; }
.table td { padding: 11px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:hover td { background: #f7faff; }
.table tr.clickable { cursor: pointer; }
.mono { font-family: "SF Mono", Consolas, monospace; font-size: 13px; color: var(--ink-2); }
.table-wrap { overflow: auto; border-radius: 10px; }

/* 按钮 */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: 9px; border: none; cursor: pointer; font-size: 13.5px;
  background: var(--brand); color: #fff; transition: filter .15s; white-space: nowrap;
}
.btn:hover { filter: brightness(1.08); }
.btn.ghost { background: var(--brand-soft); color: var(--brand); }
.btn.gray { background: #eef2f7; color: var(--ink-2); }
.btn.danger { background: var(--red); }
.btn.sm { padding: 5px 11px; font-size: 12.5px; border-radius: 7px; }

/* 筛选条 */
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters select, .filters input {
  padding: 8px 12px; border-radius: 9px; border: 1px solid var(--line); background: #fff;
  font-size: 13.5px; color: var(--ink); outline: none; min-width: 120px;
}
.filters select:focus, .filters input:focus { border-color: var(--brand); }

/* 分页 */
.pager { display: flex; align-items: center; gap: 8px; justify-content: flex-end; margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.pager button { padding: 6px 12px; border-radius: 8px; border: none; background: #eef2f7; cursor: pointer; font-size: 13px; }
.pager button:disabled { opacity: .4; cursor: default; }
.pager button.cur { background: var(--brand); color: #fff; }

/* AI结论条 */
.ai-bar { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 12px; background: linear-gradient(90deg, #f0f6ff, #f7fbff); }
.ai-bar .ai-ico { font-size: 22px; }
.ai-bar .ai-text { font-size: 14px; line-height: 1.75; }
.ai-bar .ai-text b { color: var(--brand-2); }
.ai-bar.lv-bg-yellow { background: linear-gradient(90deg, #fff8ec, #fffdf7); }
.ai-bar.lv-bg-orange { background: linear-gradient(90deg, #fff1e8, #fffaf6); }
.ai-bar.lv-bg-red { background: linear-gradient(90deg, #feecec, #fff7f7); }

/* 弹层 */
.modal-mask { position: fixed; inset: 0; background: rgba(13, 32, 56, .45); backdrop-filter: blur(3px); z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-mask[hidden] { display: none; }
.modal { background: #fff; border-radius: 16px; width: min(860px, 92vw); max-height: 86vh; display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(13,32,56,.3); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 22px; font-size: 16px; font-weight: 700; border-bottom: 1px solid var(--line); }
.modal-close { border: none; background: none; font-size: 22px; color: var(--ink-3); cursor: pointer; line-height: 1; }
.modal-body { padding: 18px 22px; overflow-y: auto; }

/* Toast */
.toast-wrap { position: fixed; top: 70px; right: 22px; z-index: 200; display: flex; flex-direction: column; gap: 10px; }
.toast { background: #123a72; color: #fff; padding: 12px 18px; border-radius: 11px; font-size: 14px; box-shadow: 0 8px 24px rgba(13,32,56,.3); animation: slidein .25s; }
.toast.ok::before { content: "✓ "; color: #4ade80; } .toast.err::before { content: "✕ "; color: #f87171; }
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }

/* 进度条 */
.bar { height: 9px; background: #edf1f7; border-radius: 5px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 5px; background: linear-gradient(90deg, #1c7bff, #1668dc); transition: width .4s; }
.bar i.warn { background: linear-gradient(90deg, #fbbf24, #f59e0b); }
.bar i.danger { background: linear-gradient(90deg, #fb923c, #f97316); }

/* ================= 驾驶舱（深色） ================= */
.cockpit {
  background: radial-gradient(1200px 500px at 70% -10%, #14356b 0%, #0b1f42 55%, #081733 100%);
  border-radius: 16px; padding: 20px; color: #d7e6ff; margin-bottom: 16px;
}
.cockpit .card { background: rgba(255,255,255,.045); box-shadow: none; margin-bottom: 0; }
.cockpit .card-title { color: #eaf3ff; }
.cockpit .card-title::before { background: #3b8bff; }
.cockpit .table th { background: rgba(255,255,255,.05); color: #8fb1e0; }
.cockpit .table td { border-bottom: 1px solid rgba(255,255,255,.07); color: #d7e6ff; }
.cockpit .table tr:hover td { background: rgba(255,255,255,.05); }
.cockpit-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.cockpit-title { font-size: 21px; font-weight: 800; letter-spacing: 2px; color: #fff; }
.cockpit-title small { font-size: 12.5px; font-weight: 400; color: #7d9dcb; margin-left: 12px; letter-spacing: 1px; }
.cockpit-sub { font-size: 13px; color: #8fb1e0; display: flex; gap: 16px; flex-wrap: wrap; }
.cockpit .lv { background: rgba(255,255,255,.1); }

/* 态势图 */
.map-wrap { position: relative; height: 420px; border-radius: 12px; overflow: hidden; background: linear-gradient(180deg, rgba(9,25,52,.6), rgba(7,19,42,.8)); }
.map-canvas { position: absolute; inset: 0; }
.map-tip {
  position: absolute; z-index: 10; background: rgba(8,22,48,.95); border: 1px solid rgba(59,139,255,.4);
  border-radius: 10px; padding: 12px 14px; font-size: 12.5px; color: #cfe2ff; max-width: 260px;
  box-shadow: 0 8px 24px rgba(0,0,0,.4); pointer-events: none; line-height: 1.7;
}

/* 滚动预警栏 */
.roll-list { max-height: 300px; overflow-y: auto; }
.roll-item { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px dashed rgba(255,255,255,.08); font-size: 13.5px; cursor: pointer; }
.roll-item:hover { background: rgba(255,255,255,.05); }
.roll-item .t { margin-left: auto; color: #7d9dcb; font-size: 12px; white-space: nowrap; }

/* 摄像头卡片 */
.cam-card { background: #0c1f3f; border-radius: 12px; overflow: hidden; position: relative; aspect-ratio: 16/9; }
.cam-card img, .cam-card .cam-ph { width: 100%; height: 100%; object-fit: cover; display: block; }
.cam-ph { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: #5b7ba8; font-size: 12.5px; background: repeating-linear-gradient(45deg, #0a1b38 0 12px, #0c2044 12px 24px); }
.cam-ph .cam-ico { font-size: 30px; opacity: .6; }
.cam-off .cam-ph { background: repeating-linear-gradient(45deg, #1a1f2b 0 12px, #232937 12px 24px); }
.cam-info { position: absolute; left: 0; right: 0; bottom: 0; padding: 8px 12px; background: linear-gradient(transparent, rgba(4,12,28,.9)); font-size: 12.5px; color: #dbe8ff; display: flex; justify-content: space-between; align-items: center; }
.cam-tag { position: absolute; top: 8px; left: 8px; display: flex; gap: 6px; }
.cam-live { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(220,38,38,.85); color: #fff; }
.cam-live.on { background: rgba(22,163,74,.85); }
.cam-detect { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: rgba(59,139,255,.85); color: #fff; }

/* 事件流 */
.evt-item { display: flex; gap: 12px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.evt-item .evt-ico { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.evt-item .evt-main { flex: 1; min-width: 0; }
.evt-item .evt-name { font-size: 14px; font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.evt-item .evt-desc { font-size: 12.5px; color: var(--ink-2); margin-top: 3px; line-height: 1.6; }
.evt-item .evt-meta { font-size: 12px; color: var(--ink-3); margin-top: 4px; display: flex; gap: 12px; flex-wrap: wrap; }

/* 时间线 */
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--line); }
.tl-item { position: relative; padding: 0 0 16px 12px; }
.tl-item::before { content: ""; position: absolute; left: -21px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.tl-item .tl-time { font-size: 12px; color: var(--ink-3); }
.tl-item .tl-text { font-size: 13.5px; margin-top: 2px; }

/* KV 描述 */
.kv { display: grid; grid-template-columns: 110px 1fr; gap: 8px 14px; font-size: 13.5px; }
.kv .k { color: var(--ink-3); }
.kv .v { color: var(--ink); word-break: break-all; }

/* 图表容器 */
.chart { width: 100%; height: 260px; }
.chart-sm { width: 100%; height: 200px; }
.chart-lg { width: 100%; height: 320px; }

/* 报告 */
.report-doc { background: #fff; border-radius: 12px; padding: 30px 36px; line-height: 2; font-size: 14.5px; }
.report-doc h2 { text-align: center; font-size: 20px; margin-bottom: 4px; }
.report-doc .rsub { text-align: center; color: var(--ink-3); font-size: 12.5px; margin-bottom: 18px; }
.report-doc h3 { font-size: 16px; margin: 18px 0 8px; color: var(--brand-2); }
.report-doc ul { padding-left: 22px; }

/* 空状态 */
.empty { text-align: center; color: var(--ink-3); padding: 40px 0; font-size: 13.5px; }

@media (max-width: 1200px) {
  .g4, .g5 { grid-template-columns: repeat(2, 1fr); }
  .g3 { grid-template-columns: 1fr 1fr; }
  .g23, .g32 { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  :root { --sidebar-w: 64px; }
  .brand-text, .nav-item span.lbl, .sidebar-foot { display: none; }
  .g2, .g3 { grid-template-columns: 1fr; }
}
