:root {
  --bg: #010206;
  --panel: rgba(8, 14, 24, 0.92);
  --panel-card: rgba(15, 23, 42, 0.7);
  --line: rgba(70, 100, 130, 0.25);
  --line-bright: rgba(6, 182, 212, 0.4);
  --text: #e2e8f0;
  --muted: #64748b;
  --cyan: #06b6d4;
  --amber: #f59e0b;
  --green: #10b981;
  --mono: 'DM Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  --display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--display);
  font-size: 11px;
  overflow-x: hidden;
}

.mono {
  font-family: var(--mono);
}

.app-shell {
  width: 100%;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at 50% 50%, #060e1a 0%, #010206 100%);
  overflow-x: hidden;
}

/* TOPBAR */
.topbar {
  height: 52px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: rgba(3, 7, 18, 0.95);
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 28px;
  height: 28px;
  background: linear-gradient(135deg, var(--cyan), #0284c7);
  color: #000;
  font-weight: 900;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  box-shadow: 0 0 12px rgba(6, 182, 212, 0.4);
}

.brand strong {
  display: block;
  font-size: 13px;
  letter-spacing: 0.12em;
  color: #fff;
}

.brand small {
  display: block;
  font-size: 8px;
  font-family: var(--mono);
  color: var(--cyan);
  letter-spacing: 0.14em;
}

.mission {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.status-dot, .health-dot {
  width: 6px;
  height: 6px;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 8px var(--green);
  display: inline-block;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.utc {
  font-size: 10px;
  color: var(--muted);
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* WORKSPACE */
.workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 260px 1fr 280px;
}

.sidebar {
  background: var(--panel);
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: var(--mono);
}

.left-panel {
  border-right: 1px solid var(--line);
}

.right-panel {
  border-left: 1px solid var(--line);
}

.eyebrow {
  font-size: 9px;
  letter-spacing: 0.12em;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.eyebrow span {
  color: var(--green);
}

.eyebrow .amber-text {
  color: var(--amber);
}

.telemetry-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.metric {
  background: var(--panel-card);
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 4px;
}

.metric-label {
  font-size: 8px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

.metric-value {
  font-size: 16px;
  font-weight: 600;
  color: #fff;
  margin: 4px 0;
}

.metric-value small {
  font-size: 9px;
  color: var(--muted);
  font-weight: 400;
}

.amber-text {
  color: var(--amber) !important;
}

.meter {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.meter b {
  display: block;
  height: 100%;
  background: var(--green);
}

.meter.cyan b {
  background: var(--cyan);
}

.metric-note {
  font-size: 8px;
  color: var(--muted);
  margin-top: 4px;
}

.metric-note.positive {
  color: var(--green);
}

.mini-card {
  background: var(--panel-card);
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 4px;
}

.card-title {
  font-size: 8px;
  color: var(--cyan);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  display: flex;
  justify-content: space-between;
}

.vector-row, .health-row {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  padding: 3px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.vector-row:last-child, .health-row:last-child {
  border-bottom: none;
}

.panel-footer {
  margin-top: auto;
  font-size: 8px;
  color: var(--muted);
  line-height: 1.5;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

/* VIEWPORT */
.viewport-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #010206;
}

#viewport {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.viewport-top {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
  z-index: 5;
}

.scene-label {
  font-family: var(--mono);
  font-size: 10px;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
}

.green-line {
  width: 16px;
  height: 2px;
  background: var(--green);
}

.view-actions {
  pointer-events: auto;
  display: flex;
  gap: 6px;
}

.view-btn {
  background: rgba(8, 14, 24, 0.8);
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 9px;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
}

.view-btn.active, .view-btn:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

/* HUD */
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 100px;
  height: 100px;
  border: 1px dashed rgba(6, 182, 212, 0.3);
  border-radius: 50%;
}

.reticle-corner {
  position: absolute;
  width: 8px;
  height: 8px;
  border-color: var(--cyan);
}

.reticle-corner.tl { top: -2px; left: -2px; border-top: 2px solid; border-left: 2px solid; }
.reticle-corner.tr { top: -2px; right: -2px; border-top: 2px solid; border-right: 2px solid; }
.reticle-corner.bl { bottom: -2px; left: -2px; border-bottom: 2px solid; border-left: 2px solid; }
.reticle-corner.br { bottom: -2px; right: -2px; border-bottom: 2px solid; border-right: 2px solid; }

.reticle-cross {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
}

.reticle-cross:before, .reticle-cross:after {
  content: "";
  position: absolute;
  background: var(--cyan);
}

.reticle-cross:before {
  top: 7px;
  left: 0;
  right: 0;
  height: 2px;
}

.reticle-cross:after {
  left: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
}

.port-tag {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 8px;
  color: var(--cyan);
  white-space: nowrap;
}

.hud-readout {
  position: absolute;
  background: rgba(3, 7, 18, 0.75);
  border: 1px solid var(--line);
  padding: 8px 12px;
  border-radius: 4px;
  font-family: var(--mono);
}

.range-readout {
  top: 56px;
  left: 14px;
}

.attitude-readout {
  top: 56px;
  right: 14px;
}

.hud-readout small {
  display: block;
  font-size: 7px;
  color: var(--muted);
}

.hud-readout strong {
  display: block;
  font-size: 14px;
  color: #fff;
  margin: 2px 0;
}

.hud-readout span {
  font-size: 8px;
  color: var(--muted);
}

.corridor {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--amber);
}

.corridor-line {
  width: 60px;
  height: 1px;
  background: var(--amber);
}

.crosshair-axis {
  position: absolute;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--cyan);
}

.crosshair-axis.x { top: 52%; right: calc(50% - 70px); }
.crosshair-axis.y { left: 52%; top: calc(50% - 70px); }

.viewport-bottom {
  position: absolute;
  bottom: 12px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--mono);
  font-size: 8px;
  color: var(--muted);
  pointer-events: none;
}

.legend {
  display: flex;
  gap: 12px;
}

.dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.dot.green { background: var(--green); }
.dot.cyan { background: var(--cyan); }
.dot.amber { background: var(--amber); }

.toast {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(6, 182, 212, 0.9);
  color: #000;
  padding: 6px 14px;
  border-radius: 20px;
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.1em;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

/* RIGHT PANEL CONTROLS */
.autopilot-card {
  background: var(--panel-card);
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 4px;
}

.auto-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.toggle {
  width: 32px;
  height: 16px;
  background: #334155;
  border: none;
  border-radius: 8px;
  position: relative;
  cursor: pointer;
}

.toggle span {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 12px;
  height: 12px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}

.toggle.on {
  background: var(--green);
}

.toggle.on span {
  left: 18px;
}

.auto-progress {
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin: 8px 0;
  overflow: hidden;
}

.auto-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--cyan);
}

.auto-readout {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  color: var(--muted);
}

.controls-card {
  background: var(--panel-card);
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 4px;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
  margin: 6px 0 10px;
}

.control-grid button {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 2px;
  font-family: var(--mono);
  font-size: 9px;
  border-radius: 3px;
  cursor: pointer;
  text-align: center;
}

.control-grid button small {
  display: block;
  font-size: 6px;
  color: var(--muted);
  margin-top: 2px;
}

.control-grid button:hover, .control-grid button:active {
  border-color: var(--cyan);
  color: var(--cyan);
}

.rotation-title {
  margin-top: 10px;
}

.key-hint {
  font-size: 7px;
  color: var(--muted);
  text-align: center;
}

.key {
  display: inline-block;
  padding: 1px 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin: 0 1px;
}

.event-card {
  background: var(--panel-card);
  border: 1px solid var(--line);
  padding: 10px;
  border-radius: 4px;
  flex: 1;
  min-height: 100px;
}

.event-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
  font-size: 8px;
}

.event-list div {
  display: flex;
  gap: 6px;
}

.event-list time {
  color: var(--muted);
}

.abort-btn {
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #f87171;
  padding: 8px;
  border-radius: 4px;
  font-family: var(--mono);
  font-size: 9px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.abort-btn:hover {
  background: rgba(239, 68, 68, 0.3);
}

/* FOOTER */
.bottombar {
  height: 28px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  font-size: 8px;
  color: var(--muted);
  background: rgba(3, 7, 18, 0.95);
  font-family: var(--mono);
  z-index: 10;
}

/* RESPONSIVE: 390px Mobile screen */
@media (max-width: 900px) {
  html, body {
    overflow-y: auto;
  }
  .app-shell {
    height: auto;
    min-height: 100vh;
    min-width: 0;
  }
  .workspace {
    display: flex;
    flex-direction: column;
  }
  .viewport-wrap {
    height: 52vh;
    min-height: 340px;
    order: -1;
  }
  .left-panel, .right-panel {
    border: none;
    border-bottom: 1px solid var(--line);
  }
  .left-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .left-panel .eyebrow, .left-panel .panel-footer {
    grid-column: 1 / -1;
  }
  .telemetry-stack {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .right-panel {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .mission, .utc {
    display: none;
  }
  .bottombar span:nth-child(2) {
    display: none;
  }
}
