:root {
  --bg: #0b1118;
  --panel: #111923;
  --border: #243041;
  --text: #d7e2ef;
  --muted: #8ea0b5;
  --accent: #00a651;
  --accent-soft: rgba(0, 166, 81, 0.15);
  --warn: #f59e0b;
  --danger: #ff6b6b;
  --sans: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  background: radial-gradient(circle at top, #152131 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--sans);
}

body {
  display: flex;
  flex-direction: column;
}

.app {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  gap: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 14px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 25, 35, 0.92);
}

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

.brand strong {
  display: block;
  font-size: 16px;
}

.guide-subtitle {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 12px var(--accent);
  flex-shrink: 0;
}

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

.model-picker-label {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.model-select {
  min-width: 180px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #0d1520;
  color: var(--text);
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
}

.model-select:focus {
  outline: 1px solid var(--accent);
  border-color: var(--accent);
}

.model-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 25, 35, 0.75);
}

.model-chip {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 140px;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0, 103, 179, 0.12);
  border: 1px solid rgba(0, 103, 179, 0.25);
}

.model-chip span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.model-chip strong {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.progress-wrap {
  min-width: 160px;
}

.progress-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
}

.progress-bar {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.25s ease;
}

.btn-link {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid rgba(0, 166, 81, 0.45);
  background: rgba(0, 166, 81, 0.18);
  color: #b8f0d0;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
}

.btn-link:hover {
  background: rgba(0, 166, 81, 0.32);
}

.btn-muted-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.btn-muted-link:hover {
  color: var(--text);
}

button {
  border: 1px solid var(--border);
  background: #182433;
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: #3a5068;
  background: #1f3044;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-muted {
  color: var(--muted);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 12px;
  min-height: 0;
}

.phase-nav {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(17, 25, 35, 0.92);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.phase-list {
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 8px;
}

.phase-block {
  border: 1px solid rgba(0, 166, 81, 0.2);
  border-radius: 10px;
  overflow: hidden;
}

.phase-header {
  width: 100%;
  text-align: left;
  padding: 10px 12px;
  border: none;
  border-radius: 0;
  background: rgba(8, 14, 22, 0.8);
  color: var(--text);
}

.phase-header.active {
  background: var(--accent-soft);
  border-bottom: 1px solid rgba(0, 166, 81, 0.25);
}

.phase-header strong {
  display: block;
  font-size: 13px;
  color: #b8f0d0;
}

.phase-header span {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  line-height: 1.35;
}

.step-list {
  display: grid;
  gap: 2px;
  padding: 6px;
}

.step-link {
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-color: transparent;
  background: transparent;
  font-size: 12px;
}

.step-link.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #b8f0d0;
}

.step-link.done {
  color: #86efac;
}

.step-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(8, 12, 18, 0.96);
  overflow: hidden;
}

.step-content {
  flex-shrink: 0;
  padding: 20px 24px 8px;
}

.step-summary {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
}

.lab-heading {
  margin: 12px 0 0;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.lab-panel {
  flex: 1;
  overflow: auto;
  padding: 0 24px 16px;
  min-height: 0;
}

.lab-wrap {
  border: 1px solid rgba(0, 166, 81, 0.3);
  border-radius: 10px;
  background: rgba(17, 25, 35, 0.7);
  padding: 16px;
}

.lab-wrap.lab-done {
  border-color: rgba(0, 166, 81, 0.55);
}

.lab-prompt {
  margin: 0 0 14px;
  font-size: 14px;
  line-height: 1.45;
}

.lab-body {
  display: grid;
  gap: 12px;
}

.lab-feedback {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.lab-feedback.ok {
  color: #86efac;
}

.lab-feedback.err {
  color: #fca5a5;
}

.lab-status {
  flex: 1;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  align-self: center;
}

.lab-status.complete {
  color: #86efac;
}

.tap-grid, .seq-grid, .port-grid {
  display: grid;
  gap: 8px;
}

.tap-card, .seq-btn, .port-btn, .match-btn, .device-btn {
  text-align: left;
  padding: 10px 12px;
}

.tap-card.tapped, .seq-btn.done, .port-btn.connected, .match-btn.matched, .device-btn.placed {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #b8f0d0;
}

.match-btn.selected, .device-btn.selected {
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.2);
}

.match-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.match-col {
  display: grid;
  gap: 8px;
}

.lab-form {
  display: grid;
  gap: 10px;
  max-width: 360px;
}

.lab-field {
  display: grid;
  gap: 4px;
  font-size: 13px;
}

.lab-field input {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0b1118;
  color: var(--text);
  font: inherit;
}

.device-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.rack-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 4px;
  max-height: 280px;
  overflow: auto;
}

.rack-slot {
  font-size: 11px;
  padding: 6px 8px;
}

.rack-slot.filled {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.reorder-list {
  display: grid;
  gap: 6px;
  max-width: 320px;
}

.reorder-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.reorder-row button {
  padding: 4px 8px;
  min-width: 32px;
}

.lab-check-btn {
  justify-self: start;
  border-color: var(--accent);
  background: rgba(0, 166, 81, 0.18);
  color: #b8f0d0;
}

.mini-terminal {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #080c12;
  overflow: hidden;
}

.mini-output {
  max-height: 200px;
  overflow: auto;
  padding: 12px;
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 12px;
  white-space: pre-wrap;
}

.mini-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--border);
}

.mini-prompt {
  color: var(--accent);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 12px;
}

.mini-input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text);
  font-family: "Consolas", "Cascadia Mono", monospace;
  font-size: 12px;
  outline: none;
}

.step-content h1 {
  margin: 0 0 8px;
  font-size: 22px;
  color: #b8f0d0;
}

.step-meta {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 20px;
  line-height: 1.5;
}

.step-content h2 {
  margin: 20px 0 10px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.step-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: rgba(12, 18, 26, 0.98);
}

.step-nav button {
  flex-shrink: 0;
}

@media (max-width: 900px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .phase-nav {
    max-height: 240px;
  }
}

@media (max-width: 640px) {
  .app {
    padding: 8px;
  }

  .topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .step-content {
    padding: 16px;
  }
}

/* ── Visual install simulator ── */

.stage-bar {
  display: flex;
  gap: 8px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: rgba(17, 25, 35, 0.92);
}

.stage-tab {
  flex: 1;
  padding: 10px 16px;
  border: 1px solid transparent;
  background: transparent;
  font-weight: 600;
  font-size: 13px;
}

.stage-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #b8f0d0;
}

.stage-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(8, 12, 18, 0.96);
  padding: 20px;
}

.stage-panel.hidden {
  display: none;
}

.stage-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 24px;
  height: 100%;
}

.stage-layout h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: #b8f0d0;
}

.hint {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
}

.palette {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: rgba(17, 25, 35, 0.7);
  align-self: start;
}

.equipment-palette {
  display: grid;
  gap: 12px;
}

.equip-card {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  background: #0d1520;
  cursor: grab;
  position: relative;
}

.equip-card.dragging {
  opacity: 0.5;
}

.equip-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px rgba(0, 166, 81, 0.35);
}

.equip-card .unit-svg {
  width: 100%;
  height: auto;
  display: block;
}

.equip-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-top: 6px;
}

.equip-u {
  font-size: 11px;
  color: var(--muted);
}

.rack-area {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.rack-view {
  flex: 1;
  min-height: 400px;
}

.rack-frame {
  border: 3px solid #3d5166;
  border-radius: 4px;
  background: linear-gradient(90deg, #0a0f16 0%, #121a24 50%, #0a0f16 100%);
  padding: 12px 16px;
  max-width: 420px;
}

.rack-slots {
  display: grid;
  gap: 2px;
}

.rack-slot {
  display: grid;
  grid-template-columns: 36px 1fr;
  align-items: stretch;
  min-height: 28px;
}

.u-label {
  font-size: 10px;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid rgba(255,255,255,0.06);
}

.u-drop {
  border: 1px dashed rgba(255,255,255,0.08);
  border-radius: 2px;
  min-height: 26px;
  position: relative;
  transition: background 0.15s;
}

.u-drop.drag-over {
  background: rgba(0, 166, 81, 0.15);
  border-color: var(--accent);
}

.u-drop.u-target {
  border-color: rgba(0, 166, 81, 0.45);
  background: rgba(0, 166, 81, 0.06);
}

.u-drop.u-target::after {
  content: "target";
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent);
  opacity: 0.85;
}

.placed-unit {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 0;
  z-index: 2;
  pointer-events: auto;
  cursor: pointer;
}

.placed-unit .unit-svg {
  width: 100%;
  height: 100%;
}

.placed-controller {
  height: calc(var(--u-height, 2) * 28px + (var(--u-height, 2) - 1) * 2px);
}

.placed-shelf {
  height: calc(var(--u-height, 4) * 28px + (var(--u-height, 4) - 1) * 2px);
}

.btn-primary {
  align-self: flex-start;
  border-color: var(--accent);
  background: rgba(0, 166, 81, 0.22);
  color: #b8f0d0;
  font-weight: 600;
  padding: 10px 18px;
}

.btn-primary:hover:not(:disabled) {
  background: rgba(0, 166, 81, 0.38);
}

.stage-feedback {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
}

.feedback-success { color: #86efac; }
.feedback-warn { color: var(--warn); }
.feedback-error { color: #fca5a5; }

/* Cable stage */
.cable-layout {
  grid-template-columns: minmax(0, 1fr) 280px;
}

.cable-diagram {
  position: relative;
  min-height: 420px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0a0f16;
  overflow: hidden;
}

.cable-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cable-units {
  position: relative;
  min-height: 420px;
  padding: 16px;
}

.cable-unit {
  position: absolute;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(17, 25, 35, 0.95);
  min-width: 120px;
}

.cable-unit-title {
  font-size: 12px;
  font-weight: 700;
  color: #b8f0d0;
  margin-bottom: 8px;
}

.cable-port {
  display: block;
  width: 100%;
  margin: 4px 0;
  padding: 6px 8px;
  font-size: 11px;
  text-align: left;
}

.cable-port.selected {
  border-color: #60a5fa;
  background: rgba(59, 130, 246, 0.25);
}

.cable-port.connected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #b8f0d0;
}

.cable-infra {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 8px;
}

.cable-infra .cable-port {
  width: auto;
  flex: 1;
  min-width: 80px;
}

.cable-tasks {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: rgba(17, 25, 35, 0.7);
  align-self: start;
}

.cable-task-list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
  display: grid;
  gap: 8px;
}

.cable-task {
  font-size: 12px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  line-height: 1.4;
}

.cable-task.done {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #b8f0d0;
}

.cable-type {
  display: inline-block;
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 6px;
  border-radius: 4px;
  margin-right: 6px;
  font-weight: 700;
}

.cable-type-power { background: rgba(245, 158, 11, 0.25); color: #fcd34d; }
.cable-type-sas { background: rgba(34, 197, 94, 0.25); color: #86efac; }
.cable-type-nvme { background: rgba(167, 139, 250, 0.25); color: #ddd6fe; }
.cable-type-net { background: rgba(56, 189, 248, 0.25); color: #7dd3fc; }

/* Cluster stage */
.cluster-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.power-panel, .cli-panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: rgba(17, 25, 35, 0.7);
}

.power-buttons {
  display: grid;
  gap: 8px;
}

.power-btn.done {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: #b8f0d0;
}

.cli-task {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 600;
  color: #b8f0d0;
}

.cli-panel .mini-terminal {
  margin-bottom: 12px;
}

.cli-panel .mini-output {
  max-height: 280px;
}

@media (max-width: 900px) {
  .stage-layout,
  .cable-layout,
  .cluster-layout {
    grid-template-columns: 1fr;
  }
}

