: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; }
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 { 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 {
  width: 100%;
  color: var(--text);
  background: #0c1513;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  outline: none;
}
input:focus { border-color: var(--green-2); box-shadow: 0 0 0 2px rgba(104, 227, 161, .1); }

.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);
}
.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); }

@media (max-width: 1050px) {
  .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; }
  .connection { width: 100%; }
  .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); }
}
