:root {
  --bg: #050505;
  --panel: #0b0b0b;
  --panel-2: #111111;
  --panel-3: #161616;
  --line: #272727;
  --text: #f2f2f2;
  --muted: #8c8c8c;
  --green: #00d084;
  --blue: #3291ff;
  --yellow: #f5d547;
  --red: #ff4d4f;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button, input, textarea, select {
  font: inherit;
  letter-spacing: 0;
  border-radius: 0;
}

button {
  border: 0;
  background: none;
  color: inherit;
}

strong, small, span, p, h1, h2, h3, b, em { max-width: 100%; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1px 42px 42px 42px 1fr auto;
  gap: 10px;
  border-right: 1px solid var(--line);
  background: #000;
}

.brand-lockup {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid #fff;
  background: #fff;
  color: #000;
  font-weight: 900;
  font-size: 14px;
}

.brand-lockup strong,
.brand-lockup span,
.rail-footer strong {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.brand-lockup strong,
.rail-footer strong {
  font-size: 13px;
  font-weight: 900;
}

.brand-lockup span,
.rail-footer small {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  font-weight: 800;
}

.rail-rule {
  background: var(--line);
}

.rail-btn {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  color: var(--muted);
  text-align: left;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  background: #000;
}

.rail-btn:hover,
.rail-btn.active {
  background: var(--panel-2);
  color: #fff;
}

.rail-legend {
  align-self: start;
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: grid;
  gap: 8px;
}

.rail-legend div,
.rail-footer {
  min-width: 0;
  border: 1px solid var(--line);
  background: #000;
  padding: 10px 11px;
}

.rail-legend strong,
.rail-legend small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.rail-legend strong {
  margin-top: 5px;
  font-size: 11px;
}

.rail-legend small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.rail-footer {
  display: grid;
  gap: 4px;
}

.workspace {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(5, 5, 5, 0.96);
  backdrop-filter: blur(10px);
}

.topbar-copy {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2, h3, p { margin-top: 0; }

h1 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.05;
  font-weight: 900;
  text-transform: lowercase;
}

h2 {
  margin-bottom: 12px;
  font-size: 34px;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: 0;
}

h3 {
  font-size: 14px;
  line-height: 1.15;
  font-weight: 900;
}

.hero-copy {
  max-width: 900px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.worklights {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  background: var(--panel);
}

.light {
  min-width: 0;
  padding: 10px 11px;
  border-right: 1px solid var(--line);
}

.light:last-child { border-right: 0; }

.light strong,
.light small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.light strong {
  margin-top: 5px;
  font-size: 11px;
}

.light small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  vertical-align: middle;
  box-shadow: 0 0 0 3px rgba(255,255,255,.06);
}

.green { background: var(--green); }
.blue { background: var(--blue); }
.yellow { background: var(--yellow); }
.red { background: var(--red); }

.txt-green { color: var(--green); }
.txt-blue { color: var(--blue); }
.txt-yellow { color: var(--yellow); }
.txt-red { color: var(--red); }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  background: #000;
  color: var(--text);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0;
}

.pill.green { border-color: rgba(0, 208, 132, 0.4); }
.pill.blue { border-color: rgba(50, 145, 255, 0.4); }
.pill.yellow { border-color: rgba(245, 213, 71, 0.45); }
.pill.red { border-color: rgba(255, 77, 79, 0.45); }

.view {
  display: none;
  padding: 20px;
  gap: 18px;
}

.view.active {
  display: grid;
}

.hero-panel,
.panel,
.metric-card,
.summary-card,
.node-card,
.node-lane,
.flow-node,
.client-card,
.selected-block,
.pipeline-stage,
.route-card,
.target-card {
  border: 1px solid var(--line);
  background: var(--panel);
}

.hero-panel {
  padding: 24px;
  display: grid;
  gap: 18px;
}

.hero-head {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: start;
}

.hero-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.summary-card {
  min-width: 0;
  padding: 12px;
}

.summary-card b {
  display: block;
  font-size: 22px;
  line-height: 1;
  font-weight: 900;
}

.summary-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head span {
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 420px);
  gap: 18px;
}

.span-two {
  min-width: 0;
}

.node-grid {
  display: grid;
  gap: 12px;
}

.node-lane {
  padding: 14px;
}

.lane-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.lane-head strong,
.lane-head span {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.lane-head span {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.lane-nodes {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.node-card {
  min-width: 0;
  padding: 12px;
  display: grid;
  gap: 10px;
}

.node-card p,
.flow-node small,
.route-card small,
.target-card p,
.client-card small,
.client-card span,
.client-card .client-folder,
.selected-block p,
.task span {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.node-top {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  align-items: start;
}

.node-top strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 13px;
}

.node-chip {
  padding: 2px 7px;
  border: 1px solid var(--line);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
  white-space: nowrap;
}

.node-chip.green { border-color: rgba(0, 208, 132, 0.4); }
.node-chip.blue { border-color: rgba(50, 145, 255, 0.4); }
.node-chip.yellow { border-color: rgba(245, 213, 71, 0.45); }
.node-chip.red { border-color: rgba(255, 77, 79, 0.45); }

.flow-map {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
}

.flow-node {
  position: relative;
  min-width: 0;
  min-height: 112px;
  padding: 14px 12px 18px;
  display: grid;
  align-content: space-between;
}

.flow-node strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.flow-node small {
  display: block;
}

.flow-node .flow-arrow {
  position: absolute;
  right: -16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 18px;
}

.flow-node:last-child .flow-arrow { display: none; }

.client-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.client-card {
  padding: 12px;
  display: grid;
  gap: 8px;
  cursor: pointer;
}

.client-card.active {
  background: var(--panel-2);
}

.client-card-head,
.target-head,
.stage-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
}

.client-card strong,
.target-card strong,
.route-card strong,
.pipeline-stage strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-folder {
  padding-top: 4px;
  border-top: 1px solid var(--line);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.selected {
  display: grid;
  gap: 10px;
}

.selected-block {
  padding: 12px;
}

.selected-block h3 {
  margin-bottom: 6px;
}

.task-list {
  display: grid;
  gap: 8px;
}

.task {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.task:first-child {
  border-top: 0;
  padding-top: 0;
}

.task div {
  min-width: 0;
}

.task strong,
.task span,
.task em {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.task em {
  color: var(--text);
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.metric-card {
  min-width: 0;
  padding: 12px;
}

.metric-card b {
  display: block;
  font-size: 20px;
  line-height: 1;
  font-weight: 900;
}

.metric-card span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.pipeline-rows,
.route-list,
.target-grid {
  display: grid;
  gap: 10px;
}

.pipeline-stage,
.route-card,
.target-card {
  padding: 12px;
}

.pipeline-stage p,
.route-card span,
.route-card small,
.target-card p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.route-card strong,
.route-card span,
.route-card small {
  display: block;
}

.target-card.yellow { box-shadow: inset 3px 0 0 var(--yellow); }
.target-card.blue { box-shadow: inset 3px 0 0 var(--blue); }
.target-card.green { box-shadow: inset 3px 0 0 var(--green); }
.target-card.red { box-shadow: inset 3px 0 0 var(--red); }

.toast {
  position: fixed;
  left: 20px;
  bottom: 20px;
  min-width: 220px;
  max-width: calc(100vw - 40px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #000;
  color: var(--text);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease, transform .18s ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1180px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .rail {
    position: relative;
    height: auto;
    grid-template-rows: auto 1px 42px 42px 42px auto auto;
  }

  .topbar,
  .dashboard-shell {
    grid-template-columns: 1fr;
  }

  .flow-map,
  .client-grid,
  .metric-grid,
  .summary-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .lane-nodes {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .view { padding: 14px; }
  .topbar { padding: 14px; }
  h2 { font-size: 26px; }
  .worklights,
  .flow-map,
  .client-grid,
  .metric-grid,
  .summary-strip {
    grid-template-columns: 1fr;
  }

  .flow-node .flow-arrow {
    display: none;
  }
}
