:root {
  color-scheme: light;
  --bg: #f3f5f7;
  --surface: #ffffff;
  --surface-muted: #f8fafb;
  --text: #17212b;
  --muted: #61707f;
  --line: #dce2e7;
  --line-strong: #c7d0d8;
  --blue: #1769aa;
  --blue-dark: #0e568f;
  --blue-soft: #eaf3fa;
  --green: #218451;
  --green-soft: #eaf7f0;
  --amber: #a86400;
  --amber-soft: #fff4dd;
  --teal: #0f766e;
  --teal-soft: #e8f6f4;
  --red: #b42318;
  --red-soft: #fff0ee;
  --shadow: 0 10px 28px rgba(28, 44, 58, 0.08);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: 0.65; }

.topbar {
  min-height: 72px;
  padding: 12px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand-block, .top-actions, .query-form, .dialog-actions, .status-line,
.route-heading, .vehicle-title, .metric, .tab, .primary-button, .secondary-button,
.connection-status, .switch-label {
  display: flex;
  align-items: center;
}

.brand-block { gap: 12px; min-width: 230px; }
.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 6px;
}
.brand-mark svg { width: 23px; height: 23px; }
h1 { margin: 0; font-size: 19px; line-height: 1.3; letter-spacing: 0; }
.brand-block p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.connection-status {
  gap: 7px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 13px;
  background: var(--surface-muted);
  border: 1px solid var(--line);
  border-radius: 4px;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #98a4ae; }
.connection-status.connected { color: var(--green); background: var(--green-soft); border-color: #b8dec9; }
.connection-status.connected .status-dot { background: var(--green); }

.switch-label { gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
.switch-label input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch { width: 34px; height: 20px; border-radius: 10px; background: #aeb8c0; padding: 2px; transition: 160ms ease; }
.switch::after { content: ""; display: block; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: 160ms ease; }
.switch-label input:checked + .switch { background: var(--green); }
.switch-label input:checked + .switch::after { transform: translateX(14px); }

.icon-button, .primary-button, .secondary-button, .tab {
  border: 1px solid transparent;
  border-radius: 5px;
  min-height: 38px;
}
.icon-button {
  width: 38px;
  padding: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: var(--surface);
  border-color: var(--line-strong);
}
.icon-button:hover { color: var(--blue); border-color: var(--blue); }
.icon-button svg { width: 18px; height: 18px; }
.primary-button, .secondary-button { justify-content: center; gap: 8px; padding: 8px 14px; white-space: nowrap; }
.primary-button { color: #fff; background: var(--blue); border-color: var(--blue); }
.primary-button:hover { background: var(--blue-dark); }
.secondary-button { color: var(--text); background: var(--surface); border-color: var(--line-strong); }
.secondary-button:hover { border-color: var(--blue); color: var(--blue); }
.primary-button svg, .secondary-button svg { width: 17px; height: 17px; }

.workspace { width: min(1180px, calc(100% - 40px)); margin: 24px auto 44px; }
body.hd-map-active .workspace { width: min(1600px, calc(100% - 32px)); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line-strong); }
.tab {
  position: relative;
  gap: 8px;
  padding: 9px 15px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 0;
}
.tab::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: transparent; }
.tab.active { color: var(--blue); font-weight: 600; }
.tab.active::after { background: var(--blue); }
.tab svg { width: 18px; height: 18px; }
.view { display: none; }
.view.active { display: block; }

.query-band {
  min-height: 112px;
  padding: 22px 0;
  display: grid;
  grid-template-columns: minmax(210px, 0.65fr) minmax(430px, 1.35fr);
  gap: 32px;
  align-items: end;
}
.query-copy h2 { margin: 0 0 6px; font-size: 20px; letter-spacing: 0; }
.query-copy p { margin: 0; color: var(--muted); font-size: 13px; }
.title-line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.title-line h2 { margin-bottom: 0; }
.shadow-badge { padding: 3px 7px; color: var(--red); background: var(--red-soft); border: 1px solid #efc2bc; border-radius: 12px; font-size: 11px; font-weight: 600; }
.berthing-query-band { align-items: center; }
.monitor-tools { display: flex; align-items: flex-end; justify-content: flex-end; gap: 18px; min-width: 0; }
.category-filter { flex: 0 0 132px; }
.audit-query-band { align-items: center; }
.motherport-query-band { align-items: center; }
.hd-map-query-band { align-items: center; }
.hd-map-key { justify-self: end; display: flex; align-items: center; flex-wrap: wrap; gap: 18px; color: var(--muted); font-size: 12px; }
.hd-map-key span { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.road-key { width: 24px; height: 3px; display: inline-block; border-radius: 2px; background: #146b85; }
.road-key.disabled { background: #8b979f; }
.road-key.slow { height: 5px; background: #e5a000; }
.road-key.congested { height: 5px; background: #df5b31; }
.road-key.severe { height: 5px; background: #b52232; }
.road-key.motherport { height: 10px; background: rgba(33, 132, 81, 0.12); border: 1px dashed #218451; }
.vehicle-dot { width: 9px; height: 9px; display: inline-block; border: 1px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px rgba(23, 33, 43, 0.2); }
.vehicle-dot.driving, .vehicle-key.driving::before { background: #218451; }
.vehicle-dot.slow, .vehicle-key.slow::before { background: #e5a000; }
.vehicle-dot.stopped, .vehicle-key.stopped::before { background: #d94841; }
.vehicle-dot.suspended, .vehicle-key.suspended::before { background: #7b4bb7; }
.vehicle-dot.pending, .vehicle-key.pending::before { background: #2474c6; }
.vehicle-dot.idle, .vehicle-key.idle::before { background: #7c8992; }
.motherport-select { flex-basis: 180px; }
.motherport-destination-select { flex-basis: 240px; }
.motherport-vehicle-select { flex-basis: 150px; }
.motherport-query-band .monitor-tools { flex-wrap: wrap; }
.scenario-picker { position: relative; min-width: 280px; }
.scenario-picker-button { width: 100%; min-height: 40px; padding: 8px 10px; display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--text); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; }
.scenario-picker-button:focus-visible { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12); outline: none; }
.scenario-picker-button svg { width: 16px; height: 16px; flex: 0 0 auto; }
.scenario-picker-menu { position: absolute; z-index: 30; top: calc(100% + 5px); right: 0; width: min(380px, calc(100vw - 32px)); max-height: 360px; padding: 6px; overflow-y: auto; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 5px; box-shadow: 0 12px 30px rgba(23, 33, 43, 0.16); }
.scenario-picker-option { min-height: 38px; margin: 0; padding: 7px 8px; display: flex; align-items: center; gap: 9px; border-radius: 4px; color: var(--text); font-size: 12px; font-weight: 500; cursor: pointer; }
.scenario-picker-option:hover { background: #f1f5f7; }
.scenario-picker-option input { width: 16px; min-height: 16px; margin: 0; padding: 0; accent-color: var(--blue); }
.scenario-picker-option span { overflow-wrap: anywhere; }
.neolix-query-band { align-items: center; }
.neolix-controls { display: flex; align-items: flex-end; justify-content: flex-end; gap: 14px; flex-wrap: wrap; }
.neolix-controls .field { width: 260px; }
.neolix-source-status { min-height: 40px; padding: 8px 11px; display: inline-flex; align-items: center; gap: 8px; color: var(--muted); background: var(--surface-muted); border: 1px solid var(--line); border-radius: 5px; font-size: 12px; }
.neolix-source-status svg { width: 16px; height: 16px; }
.neolix-source-status.ready { color: var(--green); background: var(--green-soft); border-color: #b9dfca; }
.neolix-source-status.pending { color: #7a5600; background: #fff5cc; border-color: #ead37a; }
.neolix-source-status.unavailable { color: var(--red); background: var(--red-soft); border-color: #efc2bc; }
.neolix-subtabs { padding: 0 18px; display: flex; gap: 4px; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 5px 5px 0 0; }
.neolix-panel[hidden] { display: none; }
.neolix-controls[hidden] { display: none; }
.neolix-subtab { min-height: 44px; padding: 0 14px; color: var(--muted); white-space: nowrap; background: transparent; border: 0; border-bottom: 2px solid transparent; }
.neolix-subtab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }
.neolix-result { border-radius: 0 0 5px 5px; }
.neolix-result-toolbar { min-height: 72px; padding: 14px 18px; display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; border-bottom: 1px solid var(--line); }
.neolix-result-toolbar h3 { margin: 0 0 6px; font-size: 16px; }
.neolix-result-toolbar .field { width: min(360px, 100%); }
.neolix-data-time { color: var(--muted); font-size: 12px; }
.neolix-stale { color: var(--amber); font-weight: 600; }
.neolix-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.neolix-table { min-width: 820px; }
.neolix-table th:nth-child(1) { width: 26%; }
.neolix-table th:nth-child(2) { width: 22%; }
.neolix-table th:nth-child(3) { width: 22%; }
.version-toolbar { align-items: flex-end; flex-wrap: wrap; }
.version-search-form { width: min(620px, 100%); display: flex; align-items: flex-end; gap: 10px; }
.version-search-form .field { flex: 1 1 auto; width: auto; }
.version-search-form .primary-button { flex: 0 0 auto; }
.version-filter-field { width: 190px !important; }
.fleet-version-view-field { width: 230px !important; }
.version-view-heading { padding: 12px 18px; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; color: #173a55; background: #f7fafc; border-bottom: 1px solid var(--line); }
.version-view-heading span { font-weight: 700; }
.version-view-heading strong { font-size: 18px; }
.version-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.version-match-note { padding: 11px 18px; display: flex; justify-content: space-between; gap: 12px; color: #37556e; background: #edf5fa; border-bottom: 1px solid #c8dae7; font-size: 13px; }
.version-partial-warning { color: var(--red); font-weight: 600; }
.version-code { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.version-data-time { display: flex; align-items: flex-end; flex-direction: column; gap: 4px; }
.version-refresh-state { display: inline-flex; align-items: center; gap: 6px; color: #7a5600; }
.version-refresh-state svg { width: 14px; height: 14px; }
.version-table td { vertical-align: top; }
.version-table th:last-child { width: 92px; }
.status-pill.fleet-enabled { color: #176b46; background: #e8f6ee; border-color: #b8dfca; }
.status-pill.fleet-disabled { color: #a42f2a; background: #fff0ee; border-color: #eac0bb; }
.status-pill.fleet-unknown { color: #66737d; background: #eef1f3; border-color: #cdd4d9; }
.fleet-status-note { padding: 9px 18px; display: flex; align-items: center; gap: 8px; color: #315f4b; background: #f0f8f4; border-bottom: 1px solid #cce2d6; font-size: 12px; }
.fleet-status-note.unavailable { color: #6f5b27; background: #fff8e7; border-bottom-color: #eadcae; }
.fleet-status-note svg { width: 16px; height: 16px; flex: 0 0 auto; }
.auto-upgrade-note { padding: 12px 18px; display: flex; align-items: flex-start; gap: 10px; color: #194e72; background: #eef7fc; border-bottom: 1px solid #c8e0ef; }
.auto-upgrade-note > svg { width: 18px; height: 18px; margin-top: 2px; flex: 0 0 auto; }
.auto-upgrade-note > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.auto-upgrade-note span, .auto-upgrade-note small { color: #496878; overflow-wrap: anywhere; }
.auto-upgrade-note.stopped { color: #8a322c; background: var(--red-soft); border-bottom-color: #efc2bc; }
.credential-dialog-panel { width: min(620px, calc(100vw - 32px)); }
.credential-dialog-panel textarea { resize: vertical; min-height: 96px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; overflow-wrap: anywhere; }
.credential-source-list { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.credential-source { padding: 11px 12px; display: flex; flex-direction: column; gap: 7px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 5px; }
.credential-source > div { display: flex; justify-content: space-between; gap: 10px; }
.credential-source span, .credential-source small { color: var(--muted); }
.credential-source.ready { border-color: #b9dfca; background: var(--green-soft); }
.credential-source.expired { border-color: #efc2bc; background: var(--red-soft); }
.loading-inline { min-height: 60px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); }
.version-upgrade-button, .danger-button { min-height: 36px; padding: 7px 10px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; color: #fff; background: var(--red); border: 1px solid #a72e27; border-radius: 4px; font-weight: 600; }
.version-upgrade-button svg, .danger-button svg { width: 16px; height: 16px; }
.version-upgrade-button:disabled { color: #7b8790; background: #edf0f2; border-color: #c9d0d5; cursor: not-allowed; }
.version-current { color: var(--muted); font-size: 12px; white-space: nowrap; }
.upgrade-enabled-note, .upgrade-disabled-note { padding: 9px 18px; display: flex; align-items: center; gap: 8px; color: #28694a; background: #edf8f2; border-bottom: 1px solid #c4e3d1; font-size: 12px; }
.upgrade-disabled-note { color: #6f5b27; background: #fff8e7; border-bottom-color: #eadcae; }
.upgrade-enabled-note svg, .upgrade-disabled-note svg { width: 16px; height: 16px; flex: 0 0 auto; }
.upgrade-target { margin-bottom: 14px; padding: 12px; display: grid; grid-template-columns: 1fr 1fr; gap: 5px 14px; background: var(--surface-muted); border: 1px solid var(--line); border-radius: 5px; }
.upgrade-target strong { font-size: 17px; }
.upgrade-target span { justify-self: end; color: var(--muted); }
.upgrade-target small { color: #42515f; overflow-wrap: anywhere; }
.upgrade-warning { margin-bottom: 15px; }
.audit-filters { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 10px; }
.berthing-definition { justify-self: end; display: flex; align-items: center; gap: 11px; min-width: 280px; padding: 10px 0 10px 16px; border-left: 3px solid var(--amber); }
.berthing-definition svg { width: 20px; height: 20px; color: var(--amber); }
.departure-definition { border-left-color: var(--teal); }
.departure-definition svg { color: var(--teal); }
.suspended-definition { border-left-color: var(--amber); }
.berthing-definition span { display: block; margin-bottom: 3px; color: var(--muted); font-size: 11px; }
.berthing-definition strong { display: block; font-size: 13px; }
.query-form { align-items: end; gap: 10px; }
.query-form .combobox, .query-form .field { flex: 1; min-width: 0; }
.query-form .filter-field { flex: 0 0 112px; }
label { display: block; margin: 0 0 7px; color: #42515f; font-size: 13px; font-weight: 600; }
.input-wrap { position: relative; }
.input-wrap svg { position: absolute; left: 11px; top: 50%; width: 17px; height: 17px; color: #7a8996; transform: translateY(-50%); pointer-events: none; }
input, select {
  width: 100%;
  min-height: 40px;
  padding: 8px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  outline: none;
}
.filter-field select { padding-right: 28px; }
.input-wrap input { padding-left: 36px; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(23, 105, 170, 0.12); }

.combobox { position: relative; }
.suggestions {
  position: absolute;
  z-index: 20;
  top: calc(100% + 5px);
  left: 0;
  right: 0;
  max-height: 286px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  box-shadow: var(--shadow);
}
.suggestions-summary {
  position: sticky;
  z-index: 1;
  top: 0;
  padding: 8px 11px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
}
.suggestion { width: 100%; padding: 10px 12px; display: flex; justify-content: space-between; gap: 12px; text-align: left; background: #fff; border: 0; border-bottom: 1px solid #edf0f2; }
.suggestion:last-child { border-bottom: 0; }
.suggestion:hover, .suggestion:focus { background: var(--blue-soft); outline: none; }
.suggestion-main { min-width: 0; }
.suggestion-name { display: block; overflow-wrap: anywhere; }
.suggestion-sub { display: block; min-height: 15px; margin-top: 2px; color: var(--muted); font-size: 11px; }
.suggestion-meta { color: var(--muted); font-size: 12px; white-space: nowrap; }
.suggestion-message { padding: 18px 12px; display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--muted); text-align: center; font-size: 13px; }
.suggestion-message svg { width: 17px; height: 17px; }
.load-more { width: 100%; min-height: 38px; display: flex; align-items: center; justify-content: center; gap: 7px; color: var(--blue); background: var(--surface-muted); border: 0; border-top: 1px solid var(--line); }
.load-more:hover { background: var(--blue-soft); }
.load-more svg { width: 16px; height: 16px; }

.result-shell {
  min-height: 390px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 2px 10px rgba(28, 44, 58, 0.04);
}
.empty-state { min-height: 388px; padding: 38px; display: grid; place-items: center; align-content: center; text-align: center; color: var(--muted); }
.empty-state svg { width: 40px; height: 40px; margin-bottom: 14px; color: #8fa1af; }
.empty-state h3 { margin: 0 0 7px; color: #394957; font-size: 16px; letter-spacing: 0; }
.empty-state p { margin: 0; font-size: 13px; }
.empty-state.error svg { color: var(--red); }

.result-header { min-height: 90px; padding: 18px 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; border-bottom: 1px solid var(--line); }
.route-heading { gap: 12px; min-width: 0; }
.route-icon { flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 5px; }
.route-icon svg { width: 20px; height: 20px; }
.route-icon.parking, .vehicle-badge.parking { color: var(--amber); background: var(--amber-soft); }
.route-icon.suspended, .vehicle-badge.suspended { color: var(--amber); background: var(--amber-soft); }
.route-icon.departure, .vehicle-badge.departure { color: var(--teal); background: var(--teal-soft); }
.route-icon.audit, .vehicle-badge.audit { color: var(--red); background: var(--red-soft); }
.route-icon.motherport { color: var(--teal); background: var(--teal-soft); }
.route-heading h3, .vehicle-summary h3 { margin: 0 0 5px; font-size: 17px; overflow-wrap: anywhere; letter-spacing: 0; }
.route-heading p, .vehicle-summary p { margin: 0; color: var(--muted); font-size: 12px; }
.count-block { text-align: right; flex: 0 0 auto; }
.count-number { display: block; color: var(--green); font-size: 29px; line-height: 1; font-weight: 700; }
.count-number.parking-count { color: var(--amber); }
.count-number.suspended-count { color: var(--amber); }
.count-number.departure-count { color: var(--teal); }
.count-number.audit-count { color: var(--red); }
.count-label { color: var(--muted); font-size: 12px; }

.route-facts { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.route-version-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.route-version-table { min-width: 760px; }
.route-update-toolbar { padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: #f7fafc; }
.route-update-toolbar > div { display: grid; gap: 3px; }
.route-update-toolbar span { color: var(--muted); font-size: 12px; }
.route-update-button { min-height: 38px; padding: 8px 12px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; flex: 0 0 auto; color: #fff; background: #325e87; border: 1px solid #244b70; border-radius: 4px; font-weight: 600; }
.route-update-button svg { width: 16px; height: 16px; }
.route-update-button:disabled { color: #7b8790; background: #edf0f2; border-color: #c9d0d5; cursor: not-allowed; }
.berthing-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.suspended-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.departure-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.audit-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.motherport-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.motherport-flow-strip { padding: 10px 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 10px 24px; color: var(--muted); background: #f7f9fa; border-bottom: 1px solid var(--line); font-size: 11px; }
.motherport-flow-strip span { white-space: nowrap; }
.motherport-flow-strip strong { margin-right: 4px; color: var(--teal); font-size: 16px; }
.motherport-flow-strip small { flex: 1 1 400px; text-align: right; line-height: 1.5; }
.hd-map-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.hd-traffic-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.berthing-facts .fact:last-child { border-right: 0; }
.suspended-facts .fact:last-child { border-right: 0; }
.departure-facts .fact:last-child { border-right: 0; }
.audit-facts .fact:last-child { border-right: 0; }
.motherport-facts .fact:last-child { border-right: 0; }
.hd-map-facts .fact:last-child { border-right: 0; }
.fact { min-height: 76px; padding: 14px 16px; border-right: 1px solid var(--line); }
.fact:last-child { border-right: 0; }
.fact span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.fact strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.section-heading { min-height: 64px; padding: 13px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.section-heading h3 { margin: 0 0 4px; font-size: 14px; letter-spacing: 0; }
.section-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.map-controls { display: flex; align-items: center; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.map-controls .icon-button { width: 34px; min-height: 34px; height: 34px; background: var(--surface); }
.map-layer-toggle { min-height: 34px; display: inline-flex; align-items: center; cursor: pointer; }
.map-layer-toggle input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.map-layer-toggle span { height: 34px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.map-layer-toggle svg { width: 16px; height: 16px; }
.map-layer-toggle input:checked + span { color: #126d79; background: #e4f4f5; border-color: #79afb6; }
.map-layer-toggle input:focus-visible + span { outline: 2px solid var(--blue); outline-offset: 2px; }
.route-map-band { border-bottom: 1px solid var(--line); }
.route-map-shell { position: relative; width: 100%; height: 360px; overflow: hidden; background: #eef2f5; border-top: 1px solid var(--line); touch-action: none; }
.motherport-map-shell { height: 460px; }
.hd-map-shell { height: clamp(720px, 72vh, 900px); }
.official-hd-map { width: 100%; height: 100%; background: #eef2f5; }
.official-hd-map .maplibregl-canvas { cursor: grab; }
.official-hd-map .maplibregl-canvas:active { cursor: grabbing; }
.hd-view-switch { display: inline-flex; height: 34px; border: 1px solid var(--line-strong); border-radius: 4px; overflow: hidden; background: var(--surface); }
.hd-view-switch button { min-width: 92px; padding: 0 10px; border: 0; border-right: 1px solid var(--line-strong); color: var(--muted); background: transparent; cursor: pointer; font: inherit; font-size: 12px; }
.hd-view-switch button:last-child { border-right: 0; }
.hd-view-switch button.active { color: #fff; background: #1769aa; }
.official-layer-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 16px; padding: 10px 18px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f7f9fa; font-size: 12px; }
.official-layer-tools > span { color: var(--text); font-weight: 700; }
.official-layer-tools label { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.official-layer-tools small { margin-left: auto; color: var(--muted); }
.maplibregl-popup-content { border-radius: 4px; color: #17212b; font: 12px/1.55 "Microsoft YaHei", sans-serif; }
.hd-map-shell:fullscreen { width: 100vw; height: 100vh; border: 0; background: #eef2f5; }
.hd-map-fullscreen-exit { display: none; position: absolute; z-index: 3; top: 16px; right: 16px; color: #fff; background: rgba(23, 33, 43, 0.82); border-color: rgba(255, 255, 255, 0.55); }
.hd-map-fullscreen-exit:hover { color: #fff; background: #17212b; border-color: #fff; }
.hd-map-shell:fullscreen .hd-map-fullscreen-exit { display: grid; }
.hd-map-icon { color: #126d79; background: #e4f4f5; }
.hd-map-count { color: #126d79; }
.hd-disabled-toggle input:checked + span { color: #53626e; background: #eef1f3; border-color: #9eabb4; }
.hd-region-control { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 11px; }
.hd-region-control select { width: 170px; height: 34px; padding-block: 5px; }
.hd-lane-zoom { min-height: 34px; height: 34px; padding: 5px 10px; color: #126d79; border-color: #79afb6; }
.hd-lane-zoom.active { color: #fff; background: #1769aa; border-color: #1769aa; }
.road-correction-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: #f7f9fa; }
.road-correction-tools[hidden] { display: none; }
.road-correction-tools label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; }
.road-correction-tools input { width: 160px; height: 34px; }
.road-correction-tools select { width: 120px; height: 34px; padding-block: 5px; }
.road-correction-tools .road-correction-saved { width: 220px; }
.road-correction-tools button { min-height: 34px; height: 34px; padding-block: 5px; }
.road-correction-tools .danger { color: #a51e2e; border-color: #d9a7ae; }
.road-correction-tools .active { color: #fff; background: #1769aa; border-color: #1769aa; }
.road-correction-status { display: inline-flex; align-items: center; gap: 7px; min-width: 190px; color: #1769aa; font-size: 11px; font-weight: 700; }
.road-correction-status svg { width: 16px; height: 16px; }
.hd-traffic-toggle input:checked + span { color: #17663f; background: #e9f6ef; border-color: #78b895; }
.hd-traffic-band { border-top: 1px solid var(--line); }
.lane-experiment-band { border-top: 1px solid var(--line-strong); }
.lane-experiment-heading { background: #f8fafb; }
.lane-experiment-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-block: 1px solid var(--line); }
.lane-experiment-facts small { display: block; margin-top: 5px; color: var(--muted); font-size: 10px; }
.lane-rule-note { padding: 10px 18px; color: var(--muted); background: #f7f9fa; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.6; }
.lane-position-legend { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 9px 18px; border-bottom: 1px solid var(--line); }
.lane-position { display: inline-flex; align-items: center; gap: 6px; color: #1769aa; font-size: 11px; font-weight: 700; }
.lane-position::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.lane-position.middle { color: #a56a00; }
.lane-position.right { color: #218451; }
.lane-position.unconfirmed { color: #758491; }
.lane-empty-note { padding: 18px; color: var(--muted); border-bottom: 1px solid var(--line); text-align: center; font-size: 12px; }
.lane-map-shell { height: 620px; }
.lane-confidence { display: inline-flex; min-width: 38px; justify-content: center; padding: 3px 6px; border: 1px solid #79afb6; border-radius: 3px; color: #126d79; background: #e4f4f5; font-size: 11px; font-weight: 700; }
.lane-confidence.medium { color: #7b6000; background: #fff6d9; border-color: #dec46d; }
.lane-confidence.low { color: #64727c; background: #eef1f3; border-color: #a9b3ba; }
.lane-table { min-width: 720px; }
.lane-table th:nth-child(1) { width: 18%; }
.lane-table th:nth-child(2) { width: 14%; }
.lane-table th:nth-child(3) { width: 18%; }
.lane-table th:nth-child(4) { width: 32%; }
.lane-table th:nth-child(5) { width: 18%; }
.hd-traffic-heading { border-bottom: 0; }
.traffic-match-note { color: var(--muted); font-size: 12px; white-space: nowrap; }
.traffic-thresholds { padding: 11px 18px; color: var(--muted); background: #f7f9fa; border-bottom: 1px solid var(--line); font-size: 11px; line-height: 1.6; }
.vehicle-state-summary { padding: 10px 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px 16px; border-bottom: 1px solid var(--line); }
.vehicle-key { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 11px; font-weight: 600; }
.vehicle-key::before { content: ""; width: 9px; height: 9px; border-radius: 50%; }
.traffic-normal { color: #218451; }
.traffic-slow { color: #b17a00; }
.traffic-congested { color: #c64722; }
.traffic-severe { color: #a51e2e; }
.traffic-status { display: inline-flex; min-width: 68px; justify-content: center; padding: 4px 7px; color: #17663f; background: #e9f6ef; border: 1px solid #a7d2ba; border-radius: 3px; font-size: 11px; font-weight: 700; }
.traffic-status.slow { color: #815900; background: #fff5d8; border-color: #e5c96e; }
.traffic-status.congested { color: #9b361a; background: #fff0eb; border-color: #e7a48e; }
.traffic-status.severe { color: #8a1725; background: #fdecef; border-color: #dfa0aa; }
.hd-traffic-table th:nth-child(1) { width: 150px; }
.hd-traffic-table th:nth-child(2) { width: 120px; }
.hd-traffic-table th:nth-child(3) { width: 130px; }
.hd-traffic-table .traffic-row { cursor: pointer; }
.hd-traffic-table .traffic-row:hover, .hd-traffic-table .traffic-row:focus-visible { background: #edf5f7; outline: none; }
.vehicle-id-list { overflow-wrap: anywhere; line-height: 1.6; }
.route-map-shell canvas { display: block; width: 100%; height: 100%; cursor: grab; }
.route-map-shell canvas.dragging { cursor: grabbing; }
.route-map-shell canvas.correction-mode { cursor: crosshair; }
.route-map-shell canvas.correction-mode.dragging { cursor: grabbing; }
.map-empty { min-height: 170px; display: flex; align-items: center; justify-content: center; gap: 9px; color: var(--muted); background: var(--surface-muted); border-top: 1px solid var(--line); font-size: 13px; }
.map-empty svg { width: 21px; height: 21px; }
.vehicle-section-heading { border-bottom: 1px solid var(--line); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th, td { padding: 13px 16px; text-align: left; border-bottom: 1px solid #e8ecef; vertical-align: middle; }
th { color: var(--muted); background: var(--surface-muted); font-size: 12px; font-weight: 600; }
td { font-size: 13px; overflow-wrap: anywhere; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfcfd; }
.vehicle-title { gap: 9px; font-weight: 700; }
.vehicle-badge { width: 30px; height: 30px; display: grid; place-items: center; color: var(--blue); background: var(--blue-soft); border-radius: 4px; }
.vehicle-badge svg { width: 17px; height: 17px; }
.subtext { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px; color: var(--green); background: var(--green-soft); border: 1px solid #c9e7d6; border-radius: 12px; font-size: 12px; white-space: nowrap; }
.status-pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.status-pill.idle { color: var(--amber); background: var(--amber-soft); border-color: #efd8a8; }
.status-pill.idle::before { background: var(--amber); }
.status-pill.telemetry-stale { color: var(--muted); background: var(--surface-muted); border-color: var(--line-strong); }
.status-pill.telemetry-stale::before { background: var(--muted); }
.status-pill.berthing { color: var(--blue); background: var(--blue-soft); border-color: #c8dfee; }
.status-pill.berthing::before { background: var(--blue); }
.status-pill.departure { color: var(--teal); background: var(--teal-soft); border-color: #b8ddd9; }
.status-pill.departure::before { background: var(--teal); }
.status-pill.audit-high { color: var(--red); background: var(--red-soft); border-color: #efc2bc; }
.status-pill.audit-high::before { background: var(--red); }
.status-pill.audit-medium { color: var(--amber); background: var(--amber-soft); border-color: #efd8a8; }
.status-pill.audit-medium::before { background: var(--amber); }
.status-pill.audit-observe { color: var(--muted); background: var(--surface-muted); border-color: var(--line-strong); }
.status-pill.audit-observe::before { background: var(--muted); }
.remote-evidence { color: var(--red); font-weight: 600; }
.route-vehicle-table th:nth-child(1) { width: 18%; }
.route-vehicle-table th:nth-child(2) { width: 12%; }
.route-vehicle-table th:nth-child(3) { width: 28%; }
.route-vehicle-table th:nth-child(4) { width: 15%; }
.route-vehicle-table th:nth-child(5) { width: 15%; }
.route-vehicle-table th:nth-child(6) { width: 12%; }
.berthing-table { min-width: 980px; }
.suspended-table { min-width: 1060px; }
.suspended-table th:nth-child(1) { width: 16%; }
.suspended-table th:nth-child(2) { width: 27%; }
.suspended-table th:nth-child(3) { width: 17%; }
.suspended-table th:nth-child(4) { width: 13%; }
.suspended-table th:nth-child(5) { width: 18%; }
.suspended-table th:nth-child(6) { width: 9%; }
.berthing-table th:nth-child(1) { width: 17%; }
.berthing-table th:nth-child(2) { width: 24%; }
.berthing-table th:nth-child(3) { width: 14%; }
.berthing-table th:nth-child(4) { width: 14%; }
.berthing-table th:nth-child(5) { width: 12%; }
.berthing-table th:nth-child(6) { width: 10%; }
.berthing-table th:nth-child(7) { width: 9%; }
.departure-table { min-width: 1040px; }
.departure-table th:nth-child(1) { width: 16%; }
.departure-table th:nth-child(2) { width: 25%; }
.departure-table th:nth-child(3) { width: 20%; }
.departure-table th:nth-child(4) { width: 13%; }
.departure-table th:nth-child(5) { width: 11%; }
.departure-table th:nth-child(6) { width: 8%; }
.departure-table th:nth-child(7) { width: 7%; }
.audit-table { min-width: 1180px; }
.motherport-table { min-width: 900px; }
.motherport-table th:nth-child(1) { width: 18%; }
.motherport-table th:nth-child(2) { width: 18%; }
.motherport-table th:nth-child(3) { width: 18%; }
.motherport-table th:nth-child(4) { width: 12%; }
.motherport-table th:nth-child(5) { width: 34%; }
.audit-table th:nth-child(1) { width: 14%; }
.audit-table th:nth-child(2) { width: 17%; }
.audit-table th:nth-child(3) { width: 18%; }
.audit-table th:nth-child(4) { width: 18%; }
.audit-table th:nth-child(5) { width: 10%; }
.audit-table th:nth-child(6) { width: 10%; }
.audit-table th:nth-child(7) { width: 13%; }

.no-vehicles { min-height: 298px; display: grid; align-content: center; justify-items: center; padding: 30px; text-align: center; }
.no-vehicles .check-icon { width: 42px; height: 42px; display: grid; place-items: center; color: var(--green); background: var(--green-soft); border-radius: 50%; }
.no-vehicles h3 { margin: 13px 0 6px; font-size: 16px; letter-spacing: 0; }
.no-vehicles p { margin: 0; color: var(--muted); font-size: 13px; }

.vehicle-result { padding: 22px; }
.vehicle-summary { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; padding-bottom: 20px; border-bottom: 1px solid var(--line); }
.vehicle-summary .vehicle-title { font-size: 18px; }
.mission-banner { margin: 20px 0; padding: 18px; display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; background: var(--blue-soft); border: 1px solid #c8dfee; border-radius: 5px; }
.station { min-width: 0; }
.station:last-child { text-align: right; }
.station-label { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.station strong { display: block; overflow-wrap: anywhere; }
.mission-arrow { color: var(--blue); }
.mission-arrow svg { width: 24px; height: 24px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
.metric { min-height: 74px; padding: 13px 15px; gap: 10px; border-right: 1px solid var(--line); }
.metric:last-child { border-right: 0; }
.metric svg { flex: 0 0 auto; width: 19px; height: 19px; color: var(--blue); }
.metric-label { display: block; color: var(--muted); font-size: 11px; }
.metric-value { display: block; margin-top: 3px; font-size: 14px; font-weight: 700; overflow-wrap: anywhere; }

dialog { width: min(460px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 7px; box-shadow: 0 24px 70px rgba(22, 34, 45, 0.28); }
dialog::backdrop { background: rgba(23, 33, 43, 0.44); }
.dialog-panel { padding: 22px; }
.dialog-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.dialog-header h2 { margin: 0 0 5px; font-size: 19px; letter-spacing: 0; }
.dialog-header p { margin: 0; color: var(--muted); font-size: 12px; }
.dialog-panel > label { margin-top: 14px; }
.security-note { padding: 10px 11px; display: flex; gap: 9px; color: var(--amber); background: var(--amber-soft); border: 1px solid #efd8a8; border-radius: 5px; font-size: 12px; line-height: 1.5; }
.security-note svg { flex: 0 0 auto; width: 17px; height: 17px; margin-top: 1px; }
.form-error { padding: 9px 10px; color: var(--red); background: var(--red-soft); border-radius: 4px; font-size: 12px; }
.dialog-actions { justify-content: flex-end; gap: 9px; margin-top: 20px; }
.dialog-actions #disconnectButton { margin-right: auto; }

.toast { position: fixed; z-index: 100; right: 22px; bottom: 22px; max-width: min(380px, calc(100% - 44px)); padding: 11px 14px; color: #fff; background: #24323e; border-radius: 5px; box-shadow: var(--shadow); font-size: 13px; }
.spin { animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 820px) {
  .topbar { align-items: flex-start; padding: 12px 16px; }
  .top-actions { max-width: 330px; }
  .workspace { width: min(100% - 24px, 1180px); margin-top: 16px; }
  body.hd-map-active .workspace { width: calc(100% - 24px); }
  .query-band { grid-template-columns: 1fr; gap: 18px; align-items: stretch; }
  .query-form { flex-wrap: wrap; }
  .query-form .combobox { flex-basis: 100%; }
  .query-form .filter-field { flex: 1 1 140px; }
  .berthing-definition { justify-self: start; }
  .monitor-tools { justify-content: flex-start; flex-wrap: wrap; }
  .audit-filters { width: 100%; }
  .hd-map-key { justify-self: start; }
  .route-facts { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .route-facts .fact:nth-child(3) { border-right: 0; }
  .route-facts .fact:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .metrics { grid-template-columns: 1fr 1fr; }
  .metric:nth-child(2) { border-right: 0; }
  .metric:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 580px) {
  .topbar { display: block; }
  .top-actions { margin-top: 12px; max-width: none; justify-content: flex-start; }
  .connection-status { order: 1; }
  .switch-label { order: 2; }
  #refreshButton { margin-left: auto; }
  .secondary-button span { display: none; }
  .tabs { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); overflow: visible; }
  .tab { justify-content: center; min-width: 0; padding-inline: 6px; gap: 5px; font-size: 13px; }
  .tab:last-child:nth-child(odd) { grid-column: 1 / -1; }
  .query-form { align-items: stretch; flex-direction: column; flex-wrap: nowrap; }
  .query-form .combobox, .query-form .field { width: 100%; flex: 0 0 auto; }
  .query-form .filter-field { flex: 1 1 auto; }
  .query-form .primary-button { width: 100%; }
  .result-header { align-items: flex-start; }
  .route-heading { align-items: flex-start; }
  table { min-width: 760px; }
  .vehicle-summary { display: block; }
  .vehicle-summary .status-pill { margin-top: 12px; }
  .mission-banner { grid-template-columns: 1fr; }
  .station:last-child { text-align: left; }
  .mission-arrow { transform: rotate(90deg); }
  .metrics { grid-template-columns: 1fr; }
  .route-facts { grid-template-columns: 1fr 1fr; }
  .berthing-facts { grid-template-columns: 1fr 1fr; }
  .suspended-facts { grid-template-columns: 1fr 1fr; }
  .departure-facts { grid-template-columns: 1fr 1fr; }
  .audit-facts { grid-template-columns: 1fr 1fr; }
  .motherport-facts { grid-template-columns: 1fr 1fr; }
  .hd-map-facts { grid-template-columns: 1fr 1fr; }
  .hd-traffic-facts { grid-template-columns: 1fr 1fr; }
  .lane-experiment-facts { grid-template-columns: 1fr 1fr; }
  .fact, .fact:nth-child(3) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .fact:nth-child(even) { border-right: 0; }
  .fact:nth-last-child(-n+2) { border-bottom: 0; }
  .berthing-definition { min-width: 0; width: 100%; }
  .monitor-tools { display: grid; grid-template-columns: 1fr; width: 100%; }
  .category-filter { width: 100%; }
  .scenario-picker { width: 100%; min-width: 0; }
  .scenario-picker-menu { left: 0; right: auto; width: 100%; }
  .neolix-controls { width: 100%; display: grid; grid-template-columns: 1fr; }
  .neolix-controls .field { width: 100%; }
  .neolix-result-toolbar { align-items: stretch; flex-direction: column; }
  .neolix-facts { grid-template-columns: 1fr 1fr; }
.route-version-facts { grid-template-columns: 1fr 1fr; }
.route-update-toolbar { align-items: stretch; flex-direction: column; }
  .version-search-form { display: grid; grid-template-columns: 1fr; }
  .version-search-form .primary-button { width: 100%; }
  .version-filter-field { width: 100% !important; }
  .fleet-version-view-field { width: 100% !important; }
  .version-facts { grid-template-columns: 1fr 1fr; }
  .credential-source-list { grid-template-columns: 1fr; }
  .version-match-note { flex-direction: column; }
  .version-data-time { align-items: flex-start; }
  .upgrade-target { grid-template-columns: 1fr; }
  .upgrade-target span { justify-self: start; }
  .audit-filters { grid-template-columns: 1fr; }
  .route-map-shell { height: 300px; }
  .motherport-map-shell { height: 340px; }
  .motherport-flow-strip small { flex-basis: 100%; text-align: left; }
  .hd-map-shell { min-height: 460px; height: min(62vh, 560px); }
  .lane-map-shell { height: 460px; }
  .hd-region-control { width: 100%; }
  .hd-region-control select { flex: 1 1 auto; min-width: 0; }
  .road-correction-tools { align-items: stretch; }
  .road-correction-tools label { width: 100%; justify-content: space-between; }
  .road-correction-tools input, .road-correction-tools select { flex: 1 1 auto; width: auto; min-width: 0; }
  .hd-view-switch { width: 100%; }
  .hd-view-switch button { flex: 1; }
  .official-layer-tools { align-items: flex-start; }
  .official-layer-tools small { width: 100%; margin-left: 0; }
  .traffic-match-note { white-space: normal; }
  .metric, .metric:nth-child(2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .metric:last-child { border-bottom: 0; }
}
