* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; font-family: "Microsoft YaHei", "PingFang SC", Arial, sans-serif; background: #0b1320; color: #d8e2ef; overflow: hidden; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.app { display: grid; grid-template-columns: 380px 1fr 400px; height: calc(100vh - 48px); min-width: 1100px; }

/* Panels */
.panel { background: #101b2b; overflow: auto; }
.left { border-right: 1px solid #263950; }
.right { border-left: 1px solid #263950; }

.section { padding: 14px 16px; border-bottom: 1px solid #263950; }
.section h2 { margin: 0 0 10px; font-size: 14px; color: #8cc8ff; font-weight: 700; }
.hint { font-size: 12px; color: #8293a7; line-height: 1.6; margin-bottom: 8px; }

textarea {
  width: 100%; min-height: 100px; resize: vertical;
  background: #0b1422; border: 1px solid #33506e; border-radius: 6px;
  color: #eaf2ff; padding: 10px; line-height: 1.6; outline: none; font-size: 13px;
}
textarea:focus, input:focus { border-color: #5aa7ff; }

.patch-input { min-height: 60px !important; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.btn {
  border: 1px solid #33506e; background: #17263a; color: #c9d8ea;
  border-radius: 6px; padding: 7px 10px; font-size: 12px; white-space: nowrap;
}
.btn:hover { border-color: #5aa7ff; background: #1c314c; }
.primary { background: #1267c4; border-color: #2588f2; color: #fff; font-weight: 700; }
.primary:hover { background: #1578e0; }
.ghost { background: transparent; border-color: transparent; }
.preset { padding: 4px 8px; font-size: 11px; }

.parse {
  display: none; margin-top: 10px; background: #0c1726;
  border: 1px solid #264e75; border-radius: 6px; padding: 10px;
  font-size: 12px; line-height: 1.7;
}
.parse b { color: #f6c96b; }
.warn { color: #ff9b7d; }

.file-input {
  width: 100%; padding: 9px; background: #0b1422;
  border: 1px dashed #38628a; border-radius: 6px; color: #cfe2f5; font-size: 12px;
}

.upload-list { max-height: 200px; overflow: auto; margin-top: 10px; }
.upload-card {
  border: 1px solid #263950; background: #0c1726; border-radius: 6px;
  padding: 9px; margin-bottom: 8px; font-size: 12px; line-height: 1.5;
}
.upload-card b { color: #f0f6ff; }
.upload-card small { display: block; color: #8293a7; margin-top: 3px; }

.stream-list { max-height: 160px; overflow: auto; margin-top: 8px; }
.stream-item {
  display: grid; grid-template-columns: 60px 1fr auto; gap: 8px;
  align-items: start; border-bottom: 1px solid rgba(255,255,255,.06);
  padding: 6px 0; font-size: 12px;
}
.stream-item b { color: #8cc8ff; }
.stream-item span { color: #b7c8da; line-height: 1.45; }
.stream-item em { font-style: normal; color: #67d391; font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.metric { background: #0c1726; border: 1px solid #263950; border-radius: 6px; padding: 10px; }
.metric strong { display: block; font-size: 22px; color: #79bdff; }
.metric span { font-size: 11px; color: #8293a7; }

.history-list { max-height: 300px; overflow: auto; }
.history-card {
  border: 1px solid #263950; background: #0c1726; border-radius: 6px;
  padding: 10px; margin-bottom: 8px; font-size: 12px; line-height: 1.6;
}
.history-card h3 { margin: 0 0 4px; color: #f0f6ff; font-size: 13px; }
.history-card .meta { color: #8cc8ff; margin-bottom: 4px; }
.history-card .source { color: #91a5ba; font-size: 11px; }

/* Center - Graph */
.main { position: relative; background: radial-gradient(circle at 55% 45%, #17283f 0%, #0b1320 68%); overflow: hidden; }
.toolbar {
  position: absolute; top: 12px; left: 12px; right: 12px; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: rgba(9,18,31,.9); border: 1px solid #263950; border-radius: 8px; padding: 8px 12px;
}
.toolbar .title { font-size: 14px; font-weight: 700; color: #fff; white-space: nowrap; }
.search-input {
  width: 180px; background: #0b1422; border: 1px solid #33506e;
  border-radius: 6px; color: #eaf2ff; padding: 6px 10px; font-size: 12px; outline: none;
}
.search-input:focus { border-color: #5aa7ff; }

#kgCanvas { width: 100%; height: 100%; display: block; cursor: grab; }
#kgCanvas.dragging { cursor: grabbing; }

.tooltip {
  position: absolute; z-index: 10; max-width: 260px;
  padding: 8px 10px; border: 1px solid #33506e; border-radius: 6px;
  background: rgba(12,23,38,.95); color: #eaf2ff; font-size: 12px; line-height: 1.5;
  pointer-events: none; opacity: 0; transition: opacity 120ms;
}
.tooltip.visible { opacity: 1; }

.map-panel {
  position: absolute; left: 12px; bottom: 100px; width: 280px; height: 200px;
  background: rgba(9,18,31,.9); border: 1px solid #263950; border-radius: 8px; z-index: 4;
}
.map-panel header { height: 28px; padding: 6px 10px; font-size: 12px; color: #a8c3df; border-bottom: 1px solid #263950; }
#mapCanvas { width: 100%; height: 172px; display: block; }

.timeline {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 5;
  background: rgba(9,18,31,.9); border: 1px solid #263950; border-radius: 8px; padding: 10px;
}
.steps { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.step { border: 1px solid #2c425c; border-radius: 6px; padding: 6px; text-align: center; font-size: 12px; color: #8293a7; }
.step.done { border-color: #3ca66b; color: #b7f1cf; }
.step.active { border-color: #5aa7ff; background: #173456; color: #fff; }

/* Right Panel - Decision */
.tabs { display: flex; gap: 5px; margin-bottom: 10px; }
.tab {
  flex: 1; padding: 6px 4px; border: 1px solid #2c425c; background: #0c1726;
  color: #8ea2b8; border-radius: 6px; font-size: 12px; text-align: center;
}
.tab.active { border-color: #5aa7ff; background: #173456; color: #e7f2ff; }

.output { font-size: 12px; line-height: 1.7; }
.item {
  border: 1px solid #263950; background: #0c1726; border-radius: 6px;
  padding: 10px; margin-bottom: 8px;
}
.item h3 { margin: 0 0 4px; font-size: 13px; color: #f0f6ff; }
.tag {
  display: inline-block; border-radius: 4px; padding: 1px 6px;
  margin-left: 6px; font-size: 10px; color: #fff;
}
.tag.red { background: #c64d4d; }
.tag.blue { background: #347dc4; }
.tag.green { background: #21965f; }
.tag.yellow { background: #b8871b; }
.tag.purple { background: #7c3aed; }

.empty { padding: 24px 0; text-align: center; color: #65788d; }
.muted { color: #8293a7; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #2c425c; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #3d5a7a; }

@media (max-width: 1200px) {
  .app { grid-template-columns: 340px 1fr 360px; }
  .map-panel { width: 240px; height: 180px; }
}

/* ============================
   Site navigation
   ============================ */
.site-nav {
  height: 48px; display: flex; align-items: center; gap: 18px;
  padding: 0 16px; background: #0e1a2b; border-bottom: 1px solid #263950;
  position: relative; z-index: 50;
}
.site-nav .brand { font-size: 14px; font-weight: 700; color: #eaf2ff; white-space: nowrap; }
.site-nav .brand em { font-style: normal; color: #5aa7ff; }
.site-nav nav { display: flex; gap: 4px; flex: 1; }
.site-nav nav a {
  padding: 6px 12px; border-radius: 6px; font-size: 13px;
  color: #93a8bf; text-decoration: none; border: 1px solid transparent; white-space: nowrap;
}
.site-nav nav a:hover { color: #dceaf9; background: #16283e; }
.site-nav nav a.active { color: #fff; background: #173456; border-color: #3d7fc4; }
.nav-status { display: flex; align-items: center; gap: 10px; font-size: 11px; color: #8293a7; white-space: nowrap; }
.nav-status .dot { width: 7px; height: 7px; border-radius: 50%; background: #3ca66b; display: inline-block; }
.nav-status .dot.offline { background: #c64d4d; }

/* ============================
   Page shell
   ============================ */
.page { height: calc(100vh - 48px); overflow: auto; padding: 18px 22px 40px; }
.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 18px; color: #f0f6ff; margin-bottom: 6px; }
.page-head p { font-size: 12px; color: #8293a7; line-height: 1.7; max-width: 900px; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.side { grid-template-columns: minmax(0, 1fr) 360px; align-items: start; }
@media (max-width: 1200px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.side { grid-template-columns: minmax(0, 1fr); }
}

.card {
  background: #101b2b; border: 1px solid #263950; border-radius: 8px;
  padding: 14px 16px; margin-bottom: 14px;
}
.card > h2 { font-size: 14px; color: #8cc8ff; margin-bottom: 10px; font-weight: 700; }
.card > h3 { font-size: 13px; color: #f0f6ff; margin-bottom: 8px; }
.card .sub { font-size: 11px; color: #7d8fa4; margin: -6px 0 10px; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 4px 10px; font-size: 12px; line-height: 1.7; }
.kv dt { color: #8293a7; }
.kv dd { color: #dbe7f5; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.stat { background: #0c1726; border: 1px solid #263950; border-radius: 6px; padding: 10px 12px; }
.stat strong { display: block; font-size: 20px; color: #79bdff; line-height: 1.3; }
.stat span { font-size: 11px; color: #8293a7; }

table.data { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data th, table.data td { text-align: left; padding: 7px 9px; border-bottom: 1px solid #1e3048; }
table.data th { color: #8cc8ff; font-weight: 700; background: #0c1726; position: sticky; top: 0; }
table.data td { color: #c8d7e8; }
table.data tr:hover td { background: #132338; }
.table-wrap { max-height: 420px; overflow: auto; border: 1px solid #263950; border-radius: 6px; }

.badge {
  display: inline-block; padding: 1px 7px; border-radius: 10px;
  font-size: 10px; border: 1px solid #33506e; color: #a8c3df; background: #0c1726;
}
.badge.ok { border-color: #2f7d55; color: #8fe0b4; }
.badge.warn { border-color: #8a6a1f; color: #f0cd7a; }
.badge.bad { border-color: #8a3b3b; color: #ffa8a8; }
.badge.info { border-color: #2f5f8a; color: #93c8f5; }
.badge.est { border-color: #6b4fa0; color: #cdb4f5; }

.notice {
  border: 1px solid #6b5a2a; background: #231f11; color: #e8cf94;
  border-radius: 6px; padding: 9px 12px; font-size: 12px; line-height: 1.65; margin-bottom: 12px;
}
.notice.info { border-color: #2f5f8a; background: #101f30; color: #a9cdf0; }
.notice.bad { border-color: #8a3b3b; background: #251414; color: #f0b0b0; }
.notice ul { margin: 4px 0 0 18px; }

.select, .input {
  background: #0b1422; border: 1px solid #33506e; border-radius: 6px;
  color: #eaf2ff; padding: 6px 9px; font-size: 12px; outline: none;
}
.select:focus, .input:focus { border-color: #5aa7ff; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 11px; color: #8293a7; }

/* ============================
   Five-stage player
   ============================ */
.stage-bar { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-bottom: 10px; }
.stage-btn {
  border: 1px solid #2c425c; background: #0c1726; color: #8ea2b8;
  border-radius: 6px; padding: 9px 6px; font-size: 12px; text-align: center; line-height: 1.5;
}
.stage-btn small { display: block; font-size: 10px; color: #65788d; margin-top: 2px; }
.stage-btn:hover { border-color: #4d7fb5; color: #dceaf9; }
.stage-btn.active { border-color: #5aa7ff; background: #173456; color: #fff; }
.stage-btn.active small { color: #a9cdf0; }
.stage-btn.done { border-color: #2f7d55; color: #9fdcb9; }

.progress { height: 5px; background: #16283e; border-radius: 3px; overflow: hidden; margin-bottom: 12px; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(90deg, #2f7d55, #5aa7ff); transition: width 320ms ease; }

.stage-panel { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.stage-card { background: #0c1726; border: 1px solid #263950; border-radius: 6px; padding: 10px 12px; font-size: 12px; line-height: 1.65; }
.stage-card h4 { font-size: 12px; color: #8cc8ff; margin-bottom: 5px; }
.stage-card .chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.chip { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: #16283e; color: #a8c3df; border: 1px solid #2c425c; }
.chip.on { background: #173456; border-color: #3d7fc4; color: #dceaf9; }

.canvas-wrap { position: relative; background: radial-gradient(circle at 55% 45%, #17283f 0%, #0b1320 68%); border: 1px solid #263950; border-radius: 8px; overflow: hidden; }
.canvas-wrap canvas { width: 100%; display: block; cursor: grab; }
.canvas-wrap canvas.dragging { cursor: grabbing; }
.canvas-wrap.tall canvas { height: 620px; }
.canvas-wrap.mid canvas { height: 460px; }
.canvas-tools {
  position: absolute; top: 10px; left: 10px; right: 10px; z-index: 5;
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  background: rgba(9,18,31,.88); border: 1px solid #263950; border-radius: 8px; padding: 7px 10px;
}
.legend { position: absolute; left: 10px; bottom: 10px; z-index: 5; display: flex; flex-wrap: wrap; gap: 6px; max-width: 70%;
  background: rgba(9,18,31,.85); border: 1px solid #263950; border-radius: 6px; padding: 6px 8px; }
.legend span { font-size: 10px; color: #a8c3df; display: inline-flex; align-items: center; gap: 4px; }
.legend i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }

/* ============================
   Route planner / road map
   ============================ */
#roadCanvas { width: 100%; height: 420px; display: block; }
.route-steps { counter-reset: seg; font-size: 12px; }
.route-seg {
  display: grid; grid-template-columns: 22px 1fr auto; gap: 8px; align-items: center;
  padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,.06);
}
.route-seg .idx { color: #5aa7ff; font-weight: 700; text-align: center; }
.route-seg .road { color: #c8d7e8; }
.route-seg .road small { display: block; color: #7d8fa4; font-size: 11px; }
.route-seg .km { color: #f6c96b; white-space: nowrap; }
.route-seg .km.unknown { color: #8a6a1f; }

/* ============================
   Case cards
   ============================ */
.case-card { background: #101b2b; border: 1px solid #263950; border-radius: 8px; padding: 14px 16px; }
.case-card h3 { font-size: 14px; color: #f0f6ff; margin-bottom: 6px; }
.case-card .meta { font-size: 11px; color: #8cc8ff; margin-bottom: 8px; }
.case-card .body { font-size: 12px; line-height: 1.75; color: #c8d7e8; }
.case-card .body + .body { margin-top: 8px; }
.case-card .src { font-size: 11px; color: #7d8fa4; margin-top: 8px; word-break: break-all; }
.case-card .foot { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.mag { font-size: 26px; font-weight: 700; color: #ff9b7d; line-height: 1; }

/* ============================
   Node detail / lists
   ============================ */
.rel-list { font-size: 12px; max-height: 340px; overflow: auto; }
.rel-row { display: grid; grid-template-columns: 34px 92px 1fr; gap: 8px; padding: 5px 0; border-bottom: 1px solid rgba(255,255,255,.06); align-items: baseline; }
.rel-row .dir { color: #5aa7ff; font-size: 11px; }
.rel-row .rel { color: #f6c96b; font-size: 11px; }
.rel-row .peer { color: #c8d7e8; cursor: pointer; }
.rel-row .peer:hover { color: #79bdff; text-decoration: underline; }

.run-item { border: 1px solid #263950; background: #0c1726; border-radius: 6px; padding: 9px 11px; margin-bottom: 8px; font-size: 12px; line-height: 1.6; }
.run-item .head { display: flex; justify-content: space-between; gap: 8px; color: #8cc8ff; }
.run-item .head em { font-style: normal; color: #67d391; font-size: 11px; }


/* 按钮选中态：标签/动态层等开关型按钮复用 .btn，需要一个 active 变体 */
.btn.active { border-color: #3d7fc4; background: #173456; color: #e7f2ff; }

.rel-row .peer small { display: block; color: #7d8fa4; font-size: 11px; margin-top: 1px; }
