/* ── Workflow Map Page ─────────────────────────────────── */
:root {
  --wfm-bg: #0d1117;
  --wfm-panel: #161b22;
  --wfm-border: #30363d;
  --wfm-text: #e6edf3;
  --wfm-text-muted: #8b949e;
  --wfm-accent: #2a6a1a;
  --wfm-accent-light: #3a8a2a;
}

.wfm-page {
  display: flex;
  height: calc(100vh - 108px);
  overflow: hidden;
  background: var(--wfm-bg);
  color: var(--wfm-text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Sidebar ── */
.wfm-sidebar {
  width: 280px;
  min-width: 280px;
  border-right: 1px solid var(--wfm-border);
  display: flex;
  flex-direction: column;
  background: var(--wfm-panel);
}

.wfm-sidebar-head {
  padding: .75rem .75rem .5rem;
  border-bottom: 1px solid var(--wfm-border);
}

.wfm-sidebar-head h2 {
  font-size: .82rem;
  font-weight: 700;
  margin: 0 0 .5rem;
  color: var(--wfm-text);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.wfm-search {
  width: 100%;
  padding: .35rem .5rem;
  border: 1px solid var(--wfm-border);
  border-radius: 4px;
  font-size: .78rem;
  outline: none;
  background: var(--wfm-bg);
  color: var(--wfm-text);
}

.wfm-search:focus {
  border-color: var(--wfm-accent);
}

.wfm-calc-list {
  flex: 1;
  overflow-y: auto;
  padding: .35rem 0;
  min-height: 0;
}

.wfm-loading {
  padding: 1rem;
  text-align: center;
  color: var(--wfm-text-muted);
  font-size: .78rem;
}

.wfm-calc-item {
  padding: .45rem .75rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}

.wfm-calc-item:hover {
  background: rgba(42, 106, 26, .12);
}

.wfm-calc-item--active {
  background: rgba(42, 106, 26, .2);
  border-left-color: var(--wfm-accent);
}

.wfm-calc-code {
  font-size: .72rem;
  font-weight: 600;
  color: var(--wfm-text);
  font-family: 'SF Mono', 'Fira Code', monospace;
  word-break: break-all;
}

.wfm-calc-meta {
  font-size: .65rem;
  color: var(--wfm-text-muted);
  margin-top: .1rem;
}

/* ── Detail panel ── */
.wfm-detail-panel {
  border-top: 1px solid var(--wfm-border);
  padding: .65rem .75rem;
  max-height: 280px;
  overflow-y: auto;
}

.wfm-detail-head {
  font-size: .72rem;
  font-weight: 700;
  color: var(--wfm-accent-light);
  margin-bottom: .4rem;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.wfm-detail-step {
  display: flex;
  align-items: center;
  gap: .4rem;
  padding: .2rem 0;
  font-size: .7rem;
  border-bottom: 1px solid rgba(48,54,61,.5);
}

.wfm-detail-step-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.wfm-detail-step-name {
  flex: 1;
}

.wfm-detail-step--inactive {
  opacity: .4;
}

.wfm-detail-step-time {
  font-weight: 600;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .65rem;
}

.wfm-detail-step-cost {
  color: var(--wfm-accent-light);
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: .65rem;
}

.wfm-detail-totals {
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  margin-top: .4rem;
}

.wfm-detail-chip {
  font-size: .62rem;
  padding: .15rem .4rem;
  background: rgba(42, 106, 26, .15);
  border: 1px solid rgba(42, 106, 26, .3);
  border-radius: 3px;
  color: var(--wfm-text);
}

.wfm-detail-chip strong {
  color: var(--wfm-accent-light);
}

/* ── Detail actions ── */
.wfm-detail-actions {
  display: flex;
  gap: .4rem;
  margin-top: .6rem;
  padding-top: .5rem;
  border-top: 1px solid var(--wfm-border);
}

.wfm-action-btn {
  font-size: .68rem;
  padding: .25rem .5rem;
  border: 1px solid var(--wfm-accent);
  border-radius: 4px;
  background: none;
  color: var(--wfm-accent-light);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s;
}

.wfm-action-btn:hover {
  background: rgba(42, 106, 26, .2);
}

.wfm-action-btn--subtle {
  border-color: var(--wfm-border);
  color: var(--wfm-text-muted);
}

/* ── Legend ── */
.wfm-legend {
  border-top: 1px solid var(--wfm-border);
  padding: .5rem .75rem;
  overflow-y: auto;
  flex-shrink: 0;
  max-height: 200px;
}

.wfm-legend-title {
  font-size: .68rem;
  font-weight: 700;
  color: var(--wfm-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: .35rem;
}

.wfm-legend-group {
  margin-bottom: .3rem;
}

.wfm-legend-type {
  display: flex;
  align-items: center;
  gap: .3rem;
  font-size: .68rem;
  font-weight: 700;
  color: var(--wfm-text);
}

.wfm-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.wfm-legend-machine {
  font-size: .62rem;
  color: var(--wfm-text-muted);
  padding-left: 1.1rem;
  line-height: 1.5;
}

.wfm-legend-model {
  opacity: .6;
}

/* ── Main canvas area ── */
.wfm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Toolbar */
.wfm-toolbar {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .4rem .65rem;
  background: var(--wfm-panel);
  border-bottom: 1px solid var(--wfm-border);
  flex-shrink: 0;
  z-index: 10;
}

.wfm-tool-btn {
  padding: .25rem .55rem;
  font-size: .72rem;
  border: 1px solid var(--wfm-border);
  border-radius: 4px;
  background: var(--wfm-bg);
  color: var(--wfm-text);
  cursor: pointer;
  transition: background .15s, border-color .15s;
}

.wfm-tool-btn:hover {
  background: rgba(42,106,26,.15);
  border-color: var(--wfm-accent);
}

.wfm-tool-btn--active {
  background: var(--wfm-accent);
  border-color: var(--wfm-accent);
  color: #fff;
}

.wfm-toolbar-sep {
  width: 1px;
  height: 20px;
  background: var(--wfm-border);
  margin: 0 .2rem;
}

.wfm-zoom-label {
  font-size: .7rem;
  color: var(--wfm-text-muted);
  min-width: 36px;
  text-align: center;
}

.wfm-toolbar-info {
  margin-left: auto;
  font-size: .7rem;
  color: var(--wfm-text-muted);
}

/* SVG canvas */
.wfm-canvas-wrap {
  flex: 1;
  overflow: hidden;
  position: relative;
  cursor: default;
}

.wfm-canvas-wrap--pan {
  cursor: grab;
}

.wfm-canvas-wrap--panning {
  cursor: grabbing;
}

#wfmSvg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Responsive ── */
@media (max-width: 860px) {
  .wfm-page {
    flex-direction: column;
    height: auto;
  }
  .wfm-sidebar {
    width: 100%;
    min-width: unset;
    max-height: 180px;
    border-right: none;
    border-bottom: 1px solid var(--wfm-border);
  }
}
