:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --panel-2: #fafbfc;
  --border: #e3e6ea;
  --text: #1f2328;
  --text-2: #6b7280;
  --brand: #1f6feb;
  --brand-2: #0ea5a5;
  --danger: #d1242f;
  --ok: #1a7f37;
  --shadow: 0 6px 24px rgba(16, 24, 40, .08);
  --radius: 10px;
}

[data-theme="dark"] {
  --bg: #14161a;
  --panel: #1c1f24;
  --panel-2: #22262c;
  --border: #2e333a;
  --text: #e6e8eb;
  --text-2: #9aa3ad;
  --brand: #4d8dff;
  --brand-2: #2fd4c4;
  --shadow: 0 6px 24px rgba(0, 0, 0, .4);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app { height: 100%; display: flex; flex-direction: column; }

/* ---------- 顶栏 ---------- */
header.top {
  height: 54px;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 1200;
}

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .3px; }
.brand .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--brand-2); box-shadow: 0 0 0 4px rgba(14, 165, 165, .16); }
.brand small { color: var(--text-2); font-weight: 400; }

.stat { display: flex; align-items: baseline; gap: 5px; color: var(--text-2); white-space: nowrap; }
.stat b { color: var(--text); font-size: 15px; }

.spacer { flex: 1 1 auto; }

.btn {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 13px;
  white-space: nowrap;
  transition: .15s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.icon { width: 32px; text-align: center; padding: 6px 0; }

/* ---------- 主体 ---------- */
main { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }

aside.side {
  width: 320px;
  flex: 0 0 auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  z-index: 1100;
}
aside.side.hide { display: none; }

.sec { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.sec h4 { margin: 0 0 8px; font-size: 12px; color: var(--text-2); font-weight: 600; letter-spacing: .5px; }

input.search {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  outline: none;
}
input.search:focus { border-color: var(--brand); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }

.list { overflow: auto; flex: 1 1 auto; min-height: 0; }
.list .row {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; cursor: pointer; border-bottom: 1px solid var(--border);
}
.list .row:hover { background: var(--panel-2); }
.list .row.sel { background: rgba(31, 111, 235, .1); }
.list .row .c { font-weight: 600; font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; font-size: 13px; }
.list .row .m { color: var(--text-2); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 auto; }
.list .row .t { color: var(--text-2); font-size: 12px; white-space: nowrap; }

#map { flex: 1 1 auto; min-width: 0; height: 100%; background: var(--bg); }

/* ---------- 台站标记 ---------- */
.mk {
  width: 22px; height: 22px; margin: -11px 0 0 -11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; line-height: 1;
  border-radius: 50%;
  background: rgba(255, 255, 255, .92);
  border: 1.5px solid var(--brand);
  box-shadow: 0 1px 4px rgba(0, 0, 0, .3);
}
[data-theme="dark"] .mk { background: rgba(20, 22, 26, .9); }
.mk.k1 { border-color: #b07d00; }
.mk.k2 { border-color: var(--brand-2); }
.mk.k4 { border-color: #8b5cf6; }
.mk.fresh { animation: pop .5s ease-out; }
@keyframes pop { from { box-shadow: 0 0 0 0 rgba(31, 111, 235, .7); } to { box-shadow: 0 0 0 14px rgba(31, 111, 235, 0); } }
.mk .arw { position: absolute; top: -7px; left: 50%; margin-left: -3px; width: 0; height: 0; border-left: 3px solid transparent; border-right: 3px solid transparent; border-bottom: 7px solid var(--brand); }

.lbl {
  background: transparent; border: 0; box-shadow: none;
  color: var(--text); font-size: 11px; font-weight: 600; white-space: nowrap;
  text-shadow: 0 0 3px var(--panel), 0 0 3px var(--panel), 0 0 3px var(--panel), 0 0 3px var(--panel);
}

/* ---------- 详情面板 ---------- */
.detail {
  width: 340px; flex: 0 0 auto;
  background: var(--panel); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; min-height: 0; z-index: 1100;
}
.detail .hd { padding: 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.detail .hd .c { font-size: 17px; font-weight: 700; font-family: ui-monospace, Menlo, Consolas, monospace; }
.detail .bd { overflow: auto; padding: 12px; }
.kv { display: grid; grid-template-columns: 78px 1fr; gap: 6px 10px; font-size: 13px; }
.kv .k { color: var(--text-2); }
.kv .v { word-break: break-all; }
.pk { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11.5px; padding: 4px 0; border-bottom: 1px dashed var(--border); word-break: break-all; }
.pk time { color: var(--text-2); margin-right: 6px; }

/* ---------- 报文抽屉 ---------- */
.drawer {
  position: absolute; right: 0; bottom: 0; width: 420px; max-width: 100%;
  height: 260px; background: var(--panel); border-left: 1px solid var(--border);
  border-top: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; flex-direction: column; z-index: 1150;
  transform: translateY(100%); transition: transform .2s;
}
.drawer.open { transform: none; }
.drawer .hd { padding: 8px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.drawer .bd { overflow: auto; padding: 6px 12px; }

.legend {
  position: absolute; left: 344px; bottom: 22px; z-index: 1100;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; box-shadow: var(--shadow);
}
aside.side.hide ~ .legend { left: 12px; }
.legend span { display: inline-flex; align-items: center; gap: 4px; margin-right: 10px; }
.legend i.lg { width: 10px; height: 10px; border-radius: 50%; border: 1.5px solid var(--brand); display: inline-block; }
.legend i.lg.k1 { border-color: #b07d00; }
.legend i.lg.k2 { border-color: var(--brand-2); }
.legend i.lg.k4 { border-color: #8b5cf6; }

@media (max-width: 820px) {
  aside.side { position: absolute; top: 0; bottom: 0; left: 0; width: 82%; }
  aside.side.hide { display: none; }
  .detail { position: absolute; top: 0; right: 0; bottom: 0; width: 86%; }
  .legend { display: none; }
  header.top .stat.opt { display: none; }
}
