:root {
  --bg: #09100f;
  --panel: #111a18;
  --panel-2: #16221f;
  --line: #273632;
  --text: #eef5f1;
  --muted: #90a39d;
  --green: #68e3a1;
  --green-2: #1f9d69;
  --amber: #f2b84b;
  --red: #ff6b6b;
  --shadow: 0 18px 50px rgba(0, 0, 0, .32);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: var(--text);
  background: var(--bg);
  font: 14px/1.45 Inter, "Noto Sans SC", "Microsoft YaHei", sans-serif;
}
button, input, select { font: inherit; }
button {
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 12px;
  cursor: pointer;
  transition: border-color .15s, background .15s, transform .15s;
}
button:hover { border-color: #4b665e; background: #1b2a26; }
button:active { transform: translateY(1px); }
button:disabled {
  cursor: not-allowed;
  opacity: .42;
  transform: none;
}
button.primary, button.accent {
  color: #06130d;
  background: var(--green);
  border-color: var(--green);
  font-weight: 700;
}
button.danger-outline { border-color: rgba(255, 107, 107, .55); color: #ffaaaa; }
input, select {
  width: 100%;
  color: var(--text);
  background: #0c1513;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  outline: none;
}
input:focus, select:focus {
  border-color: var(--green-2);
  box-shadow: 0 0 0 2px rgba(104, 227, 161, .1);
}
input:read-only { color: var(--muted); cursor: not-allowed; }

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(9, 16, 15, .94);
  backdrop-filter: blur(12px);
}
.brand { display: flex; align-items: center; gap: 12px; letter-spacing: .04em; }
.brand > div { display: flex; flex-direction: column; }
.brand strong { font-size: 17px; letter-spacing: .18em; }
.brand span { color: var(--muted); font-size: 11px; }
.brand-mark {
  width: 32px; height: 32px; border: 2px solid var(--green); border-radius: 50%;
  position: relative; box-shadow: inset 0 0 0 6px rgba(104, 227, 161, .08);
}
.brand-mark::after {
  content: ""; position: absolute; inset: 8px; border-radius: 50%; background: var(--green);
}
.workspace-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0 auto 0 28px;
}
.topbar-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 36px;
  padding: 7px 11px;
  background: #0c1513;
}
.action-badge {
  padding: 2px 6px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--panel-2);
  font-size: 9px;
}
.action-badge.active { color: #06130d; background: var(--green); }
.action-badge.warning { color: #1c1201; background: var(--amber); }
.connection { display: flex; align-items: end; gap: 9px; color: var(--muted); }
.connection label { display: grid; gap: 3px; font-size: 10px; text-transform: uppercase; letter-spacing: .1em; }
.connection input { width: 180px; padding: 7px 9px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #51605c; margin: 0 0 7px 4px; }
.status-dot.online { background: var(--green); box-shadow: 0 0 12px var(--green); }
#connection-label { margin-bottom: 1px; min-width: 56px; }
.auth-state {
  align-self: center;
  margin-right: 4px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #0c1513;
  font-size: 10px;
  white-space: nowrap;
}
.auth-state[data-state="active"] { color: var(--green); border-color: rgba(104, 227, 161, .45); }
.auth-state[data-state="refreshing"] { color: var(--amber); border-color: rgba(242, 184, 75, .45); }
.auth-state[data-state="error"] { color: #ffaaaa; border-color: rgba(255, 107, 107, .48); }
.auth-state[data-state="missing"] { color: var(--muted); }

.workspace {
  height: calc(100vh - 64px);
  display: grid;
  grid-template-columns: 270px minmax(400px, 1fr) 300px;
}
.sidebar {
  overflow-y: auto;
  background: var(--panel);
  scrollbar-width: thin;
  scrollbar-color: #31443e transparent;
}
.left-panel { border-right: 1px solid var(--line); }
.right-panel { border-left: 1px solid var(--line); }
.sidebar section { padding: 18px; border-bottom: 1px solid var(--line); }
.sidebar h1 { margin: 3px 0 15px; font-size: 20px; }
.sidebar h2 { margin: 0 0 13px; font-size: 14px; }
.sidebar label { display: grid; gap: 5px; color: var(--muted); font-size: 11px; margin: 9px 0; }
.eyebrow { margin: 0; color: var(--green); font-size: 10px; letter-spacing: .16em; font-weight: 700; }
.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-grid div { background: #0c1513; border: 1px solid #1c2a27; border-radius: 8px; padding: 9px; }
.status-grid span { display: block; color: var(--muted); font-size: 10px; }
.status-grid strong { display: block; margin-top: 3px; font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 9px; }
.row { display: grid; grid-template-columns: 1fr 88px; gap: 7px; }
.hint { color: var(--muted); font-size: 11px; margin: 9px 0; }
.navigation-detail {
  min-height: 34px;
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.navigation-controls { grid-template-columns: repeat(3, 1fr); }

.map-stage { position: relative; min-width: 0; overflow: hidden; background: #070c0b; }
#map-canvas { width: 100%; height: 100%; display: block; cursor: grab; }
#map-canvas.crosshair { cursor: crosshair; }
.map-tools {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 5px; padding: 5px;
  background: rgba(17, 26, 24, .93); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow);
}
.map-tools .tool { padding: 7px 10px; border-color: transparent; background: transparent; }
.map-tools .tool.active { color: #06130d; background: var(--green); }
.tool-divider { width: 1px; height: 22px; background: var(--line); }
.coordinate-readout {
  position: absolute; left: 14px; bottom: 14px; padding: 7px 10px;
  color: var(--muted); background: rgba(10, 17, 16, .88); border: 1px solid var(--line);
  border-radius: 7px; font: 11px/1.2 ui-monospace, SFMono-Regular, monospace;
}
.empty-state {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 7px; pointer-events: none; color: var(--muted);
}
.empty-state.hidden { display: none; }
.empty-state strong { color: var(--text); font-size: 16px; }
.radar {
  width: 86px; height: 86px; margin-bottom: 10px; border: 1px solid #284139;
  border-radius: 50%; background: repeating-radial-gradient(circle, transparent 0 13px, #1d302a 14px 15px);
  position: relative; overflow: hidden;
}
.radar::after {
  content: ""; position: absolute; inset: 50% 0 0 50%; transform-origin: 0 0;
  background: linear-gradient(25deg, rgba(104, 227, 161, .45), transparent 55%);
  animation: sweep 2.5s linear infinite;
}
@keyframes sweep { to { transform: rotate(360deg); } }
.toast-stack { position: absolute; right: 14px; bottom: 14px; display: grid; gap: 7px; max-width: 340px; }
.toast {
  padding: 10px 12px; border: 1px solid var(--line); border-left: 3px solid var(--green);
  background: rgba(17, 26, 24, .96); border-radius: 7px; box-shadow: var(--shadow);
  animation: enter .18s ease-out;
}
.toast.error { border-left-color: var(--red); }
@keyframes enter { from { transform: translateY(8px); opacity: 0; } }

.asset-list { display: grid; gap: 6px; margin-top: 12px; }
.asset-item {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px;
  padding: 8px 9px; background: #0c1513; border: 1px solid #1c2a27; border-radius: 7px;
}
.asset-item strong { display: block; font-size: 12px; }
.asset-item span { color: var(--muted); font-size: 10px; }
.asset-item .draft { color: var(--amber); }
.asset-actions { display: flex; gap: 5px; }
.asset-item button { padding: 5px 8px; color: #ffaaaa; }
.asset-item button.navigate { color: var(--green); }
.asset-item button.edit { color: #9bcfff; }

.workspace-dialog {
  width: min(680px, calc(100vw - 28px));
  max-height: min(820px, calc(100vh - 28px));
  padding: 0;
  color: var(--text);
  background: transparent;
  border: 0;
  overflow: visible;
}
.workspace-dialog::backdrop {
  background: rgba(2, 7, 6, .76);
  backdrop-filter: blur(3px);
}
.dialog-shell {
  max-height: min(820px, calc(100vh - 28px));
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #334841;
  border-radius: 14px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, .58);
}
.dialog-shell-compact { width: min(500px, 100%); margin: auto; }
.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 17px 20px;
  border-bottom: 1px solid var(--line);
  background: #0d1614;
}
.dialog-header h2 { margin: 3px 0 0; font-size: 18px; }
.dialog-close { color: var(--muted); background: transparent; }
.dialog-body {
  max-height: calc(min(820px, 100vh - 28px) - 72px);
  overflow-y: auto;
  padding: 18px 20px 20px;
  scrollbar-width: thin;
  scrollbar-color: #31443e transparent;
}
.dialog-body label {
  display: grid;
  gap: 5px;
  margin: 9px 0;
  color: var(--muted);
  font-size: 11px;
}
.dialog-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 11px;
}
.telemetry-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}
.telemetry-card {
  min-width: 0;
  padding: 11px;
  background: #0c1513;
  border: 1px solid #1c2a27;
  border-radius: 9px;
}
.telemetry-card span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}
.telemetry-card strong {
  display: block;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
}
.telemetry-card strong.good { color: var(--green); }
.telemetry-card strong.bad { color: #ffaaaa; }
.raw-telemetry {
  margin-top: 14px;
  padding: 10px 12px;
  background: #0c1513;
  border: 1px solid #1c2a27;
  border-radius: 9px;
  color: var(--muted);
}
.raw-telemetry summary { cursor: pointer; font-size: 11px; }
.raw-telemetry pre {
  max-height: 260px;
  overflow: auto;
  margin: 10px 0 0;
  color: #c8d7d2;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: 10px/1.45 ui-monospace, SFMono-Regular, Consolas, monospace;
}
.task-fields { margin-top: 12px; }
.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.navigation-summary {
  padding: 12px;
  background: #0c1513;
  border: 1px solid #1c2a27;
  border-radius: 10px;
}
.navigation-modes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
  margin: 16px 0;
}
.standby-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.dialog-body .mode-card {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0;
  padding: 11px;
  background: #0c1513;
  border: 1px solid var(--line);
  border-radius: 9px;
  cursor: pointer;
}
.mode-card:has(input:checked) {
  border-color: var(--green-2);
  box-shadow: inset 0 0 0 1px rgba(104, 227, 161, .18);
}
.mode-card input { width: auto; margin: 3px 0 0; accent-color: var(--green); }
.mode-card span { min-width: 0; }
.mode-card strong { display: block; color: var(--text); font-size: 12px; }
.mode-card small { display: block; margin-top: 3px; color: var(--muted); font-size: 10px; }
.task-panel {
  padding: 14px;
  background: #0d1614;
  border: 1px solid var(--line);
  border-radius: 10px;
}
.route-picker {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 8px;
}
.route-picker label { margin-bottom: 0; }
.route-point-list { display: grid; gap: 6px; margin-top: 12px; }
.route-point-item {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: #0a1210;
  border: 1px solid #1c2a27;
  border-radius: 8px;
}
.route-point-index {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: #06130d;
  background: var(--green);
  border-radius: 50%;
  font-size: 10px;
  font-weight: 800;
}
.route-point-copy { min-width: 0; }
.route-point-copy strong, .route-point-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.route-point-copy strong { font-size: 12px; }
.route-point-copy span { color: var(--muted); font-size: 10px; }
.route-point-actions { display: flex; gap: 4px; }
.route-point-actions button { padding: 4px 7px; color: var(--muted); }
.route-point-empty {
  padding: 14px;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  font-size: 11px;
}

@media (max-width: 1050px) {
  .workspace-actions { margin-left: 14px; }
  .topbar-action { padding-inline: 9px; }
  .action-badge { display: none; }
  .auth-state { display: none; }
  .workspace { grid-template-columns: 230px 1fr; }
  .right-panel {
    position: absolute; right: 0; top: 64px; bottom: 0; width: 290px;
    z-index: 5; box-shadow: var(--shadow);
  }
  .map-stage { margin-right: 290px; }
}
@media (max-width: 760px) {
  body { overflow: auto; }
  .topbar { height: auto; min-height: 64px; flex-wrap: wrap; gap: 10px; padding: 10px 14px; }
  .workspace-actions { order: 3; width: 100%; margin: 0; }
  .workspace-actions .topbar-action { flex: 1; justify-content: center; }
  .connection { width: 100%; order: 2; }
  .connection label { flex: 1; }
  .connection input { width: 100%; }
  .workspace { height: auto; min-height: calc(100vh - 106px); display: flex; flex-direction: column; }
  .sidebar, .right-panel { position: static; width: auto; max-height: none; border: 0; }
  .map-stage { order: -1; height: 60vh; min-height: 420px; margin: 0; border-bottom: 1px solid var(--line); }
  .workspace-dialog { width: calc(100vw - 16px); max-height: calc(100vh - 16px); }
  .dialog-shell { max-height: calc(100vh - 16px); }
  .dialog-body { max-height: calc(100vh - 88px); padding: 15px; }
  .telemetry-grid { grid-template-columns: 1fr 1fr; }
  .navigation-modes { grid-template-columns: 1fr; }
  .standby-picker { grid-template-columns: 1fr; }
}
