/* Port-monitoring console — dark terminal style (sealed ops-console mockup language).
   Dependency-free, no external requests. */
:root {
  --bg: #060a14; --panel: rgba(16, 26, 46, .82); --panel2: rgba(10, 17, 32, .9);
  --line: rgba(94, 156, 255, .18); --ink: #dbe7ff; --dim: #8494b3; --faint: #5b6a87;
  --cyan: #38d6f5; --amber: #ffb454; --red: #ff5d6c; --green: #3ddc97;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: radial-gradient(1100px 600px at 70% -10%, #0d1b36 0%, var(--bg) 55%) fixed, var(--bg);
  color: var(--ink); font: 14px/1.55 -apple-system, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
a { color: var(--cyan); text-decoration: none; }

/* ---------- layout ---------- */
.shell { display: grid; grid-template-columns: 212px 1fr; min-height: 100vh; }
.rail {
  border-right: 1px solid var(--line); background: var(--panel2);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 2px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.rail .brand { font-family: var(--mono); font-size: 12px; color: var(--cyan); letter-spacing: .08em; padding: 2px 8px 10px; }
.rail .brand b { display: block; font-size: 15px; color: var(--ink); letter-spacing: 0; }
.nav-item {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
  padding: 7px 8px; border-radius: 8px; color: var(--dim); font-size: 13px; white-space: nowrap;
}
.nav-item.current { background: rgba(56, 214, 245, .10); color: var(--ink); box-shadow: inset 2px 0 0 var(--cyan); }
.chip { font-size: 10px; padding: 1px 6px; border-radius: 99px; border: 1px solid var(--line); color: var(--faint); white-space: nowrap; }
.chip.cur { color: #04121a; background: var(--cyan); border-color: var(--cyan); font-weight: 700; }
.chip.sealed { color: var(--green); border-color: rgba(61, 220, 151, .4); }
.chip.design { color: var(--amber); border-color: rgba(255, 180, 84, .4); }
.rail .legend { margin-top: auto; padding: 10px 8px 2px; font-size: 11px; color: var(--faint); border-top: 1px dashed var(--line); }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; }
.dot.sea { background: var(--cyan); } .dot.air { background: var(--amber); } .dot.alert { background: var(--red); }

.main { padding: 16px 20px 40px; min-width: 0; }
.topbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.topbar h1 { font-size: 19px; margin: 0; }
.topbar .sub { color: var(--dim); font-size: 12px; font-family: var(--mono); }
.search { background: var(--panel); border: 1px solid var(--line); color: var(--ink); border-radius: 9px; padding: 8px 12px; min-width: 260px; font-size: 13px; }
.source-badge { font-size: 11px; font-family: var(--mono); padding: 2px 8px; border-radius: 99px; border: 1px solid rgba(61,220,151,.4); color: var(--green); }
.source-badge.fallback { border-color: rgba(255,180,84,.5); color: var(--amber); }

.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 12px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.kpi .k-label { font-size: 12px; color: var(--dim); }
.kpi .k-value { font-size: 26px; font-family: var(--mono); margin: 2px 0; }
.kpi .k-note { font-size: 11px; color: var(--faint); }
#kpi-collector-note { font-size: 10.5px; line-height: 1.5; }
.ts-line { display: block; white-space: nowrap; }

.grid { display: grid; grid-template-columns: 1fr; gap: 12px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.panel h2 { font-size: 14px; margin: 0 0 8px; }
.panel h2 .en { color: var(--faint); font-family: var(--mono); font-size: 11px; font-weight: 400; margin-left: 6px; }
.muted { color: var(--dim); } .small { font-size: 12px; } .tiny { font-size: 11px; color: var(--faint); }
.mono { font-family: var(--mono); }

table { width: 100%; min-width: 920px; border-collapse: collapse; font-size: 12.5px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid rgba(94,156,255,.08); vertical-align: top; }
th { color: var(--dim); font-weight: 600; font-size: 12px; position: sticky; top: 0; background: #0a1120; }
.tablewrap { max-height: 560px; overflow: auto; border: 1px solid rgba(94,156,255,.08); border-radius: 8px; }
td.kind-cell { white-space: nowrap; }
td.num, th.num { text-align: right; font-family: var(--mono); }
.tag { font-size: 10.5px; padding: 1px 7px; border-radius: 99px; border: 1px solid var(--line); white-space: nowrap; }
.tag.none { color: var(--faint); }
.tag.partial { color: var(--amber); border-color: rgba(255,180,84,.4); }
.tag.collecting { color: var(--cyan); border-color: rgba(56,214,245,.35); }
.pos { color: var(--green); } .neg { color: var(--red); }
tr.row-none td { color: var(--faint); }

.alertbox { border: 1px dashed rgba(255,180,84,.35); border-radius: 10px; padding: 10px 12px; color: var(--dim); }
.foot { margin-top: 16px; color: var(--faint); font-size: 11.5px; }

/* ---------- login ---------- */
.center { max-width: 980px; margin: 0 auto; padding: 28px 18px 48px; }
.cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card h2 { margin: 0 0 4px; font-size: 16px; }
label { display: block; font-size: 12.5px; color: var(--dim); margin: 10px 0 4px; }
input[type="text"], input[type="email"], input[type="password"] {
  width: 100%; background: #0a1120; border: 1px solid var(--line); border-radius: 9px;
  color: var(--ink); padding: 9px 11px; font-size: 14px;
}
button {
  background: var(--cyan); color: #04121a; border: 0; border-radius: 9px; font-weight: 700;
  padding: 9px 16px; font-size: 13.5px; cursor: pointer; margin-top: 14px;
}
button.ghost { background: transparent; color: var(--cyan); border: 1px solid rgba(56,214,245,.4); }
.msg { margin-top: 10px; font-size: 12.5px; border-radius: 8px; padding: 8px 10px; display: none; }
.msg.ok { display: block; background: rgba(61,220,151,.10); color: var(--green); }
.msg.bad { display: block; background: rgba(255,93,108,.10); color: var(--red); }
.belong { margin-top: 10px; font-size: 12.5px; color: var(--dim); border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; }
.hidden { display: none !important; }

/* ---------- mobile: rail stays a narrow vertical column on the left ---------- */
@media (max-width: 760px) {
  .shell { grid-template-columns: 76px 1fr; }
  .rail { padding: 10px 5px; }
  .rail .brand { font-size: 0; padding: 2px 2px 8px; text-align: center; }
  .rail .brand b { font-size: 12px; }
  .nav-item { flex-direction: column; gap: 3px; font-size: 11px; padding: 6px 2px; text-align: center; white-space: normal; }
  .nav-item .chip { font-size: 0; padding: 0; width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
  .nav-item .chip.cur { background: var(--cyan); } .nav-item .chip.sealed { background: var(--green); }
  .nav-item .chip.design { background: var(--amber); } .nav-item .chip.build { background: var(--cyan); }
  .rail .legend { display: none; }
  .main { padding: 12px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .cards { grid-template-columns: 1fr; }
  .search { min-width: 0; width: 100%; }
}

/* ---------- v2: directory search ---------- */
.searchwrap { position: relative; flex: 1; max-width: 520px; min-width: 240px; }
.searchwrap .search { width: 100%; min-width: 0; }
.search-scope { font-size: 11px; color: var(--faint); margin-top: 3px; font-family: var(--mono); }
.search-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: #0a1428; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 14px 34px rgba(0,0,0,.55); overflow: hidden; max-height: 380px; overflow-y: auto;
}
.sr-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid rgba(94,156,255,.08);
  padding: 8px 11px; margin: 0; font-weight: 400; cursor: pointer; font-size: 13px;
}
.sr-item:hover { background: rgba(56,214,245,.09); }
.sr-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-en { color: var(--faint); font-size: 11.5px; }
.sr-code { color: var(--cyan); font-size: 11.5px; }
.sr-empty { padding: 10px 12px; color: var(--dim); font-size: 12.5px; }

/* ---------- v2: map + detail ---------- */
.mapgrid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr); gap: 12px; margin-bottom: 12px; }
.mappanel { position: relative; }
.layertoggle { position: absolute; top: 12px; right: 14px; display: flex; gap: 4px; z-index: 5; }
.lt-btn {
  background: rgba(10,17,32,.85); color: var(--dim); border: 1px solid var(--line); border-radius: 8px;
  padding: 4px 12px; font-size: 12px; font-weight: 600; cursor: pointer; margin: 0;
}
.lt-btn.active { background: var(--cyan); color: #04121a; border-color: var(--cyan); }
.mapwrap { background: radial-gradient(700px 320px at 60% 0%, #0b1a33 0%, #060d1c 70%); border: 1px solid rgba(94,156,255,.10); border-radius: 10px; overflow: hidden; }
#worldmap { display: block; width: 100%; height: auto; }
#worldmap .grat line { stroke: rgba(94,156,255,.10); stroke-width: .6; }
#worldmap .land { fill: #16283f; stroke: rgba(120,180,255,.35); stroke-width: .5; }
#worldmap .pt { cursor: pointer; }
#worldmap .mk.has { fill: var(--cyan); stroke: #dff8ff; stroke-width: .7; }
#worldmap .mk.has.choke { fill: var(--amber); }
#worldmap .mk.none { fill: rgba(133,148,179,.15); stroke: #8494b3; stroke-width: .8; }
#worldmap .mk.air-mk { fill: rgba(255,180,84,.12); stroke: var(--amber); stroke-width: .9; }
#worldmap .mk.base-mk { fill: rgba(255,93,108,.10); stroke: var(--red); stroke-width: .9; }
/* Declutter: name labels are hidden by default. A label shows only when it is
   persistent (lbl-vis: sea points with data; lbl-mode: the collision-free
   airport subset in 空层-only mode, chosen by applyAirLabels in console.js)
   or when its point is hovered / selected. */
#worldmap .map-lbl { fill: #a9c3e8; font-size: 9px; pointer-events: none; display: none; }
#worldmap .map-lbl.lbl-vis, #worldmap .map-lbl.lbl-mode { display: block; }
#worldmap g.pt:hover .map-lbl, #worldmap g.pt.sel .map-lbl { display: block; }
#worldmap g.pt.sel .mk { stroke: #ffffff; stroke-width: 1.8; }
#worldmap .map-note { fill: var(--amber); font-size: 13px; }
.mapwrap[data-layer="sea"] #map-air { display: none; }
.mapwrap[data-layer="air"] #map-sea { display: none; }
.maplegend { display: flex; flex-wrap: wrap; gap: 6px 16px; align-items: center; margin: 8px 0 0; }
.lg-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
.lg-dot.hasdata { background: var(--cyan); }
.lg-dot.nodata { background: transparent; border: 1.4px solid #8494b3; }
.lg-sq { display: inline-block; width: 8px; height: 8px; border: 1.4px solid var(--amber); margin-right: 4px; }
.lg-dia { display: inline-block; width: 8px; height: 8px; background: var(--amber); transform: rotate(45deg); margin-right: 4px; }

.detailpanel { max-height: 100%; overflow-y: auto; }
.d-title { font-size: 15px; margin: 2px 0 10px; color: var(--ink); }
.d-row { display: flex; justify-content: space-between; gap: 12px; padding: 4.5px 0; border-bottom: 1px dashed rgba(94,156,255,.10); font-size: 12.5px; }
.d-k { color: var(--dim); white-space: nowrap; }
.d-v { text-align: right; }
.d-sec { margin: 12px 0 4px; font-size: 12px; color: var(--cyan); font-family: var(--mono); letter-spacing: .04em; }
.d-basis { margin-top: 10px; line-height: 1.6; }
.areas-filter { min-width: 0; width: 260px; margin-bottom: 8px; }
tbody tr[data-pid] { cursor: pointer; }
tbody tr[data-pid]:hover td { background: rgba(56,214,245,.05); }

@media (max-width: 1100px) {
  .mapgrid { grid-template-columns: 1fr; }
  .detailpanel { max-height: none; }
}
@media (max-width: 760px) {
  .searchwrap { max-width: none; min-width: 0; width: 100%; order: 3; }
  .areas-filter { width: 100%; }
  .layertoggle { top: 8px; right: 8px; }
  .lt-btn { padding: 3px 9px; font-size: 11px; }
}
