:root {
  --orange: #f39c12;
  --green: #27ae60;
  --green-light: #c8e6c9;
  --blue: #2980b9;
  --blue-light: #bbdefb;
  --yellow: #f1c40f;
  --purple: #8e44ad;
  --red: #c0392b;
  --red-border: #e74c3c;
  --bg: #ffffff;
  --text: #2c3e50;
  --shadow: rgba(44, 62, 80, 0.08);
  --gap-dev: 0.5rem;
  --gap-team: clamp(0.95rem, 2.4vh, 1.65rem);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Ubuntu, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.4;
  overflow-x: hidden;
  overflow-y: auto;
}

.page {
  height: 100vh;
  height: 100dvh;
  max-width: none;
  margin: 0;
  padding: 0.4rem 0.65rem 0.5rem;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: visible;
}

.page-title {
  font-size: clamp(0.75rem, 1.6vw, 1rem);
  font-weight: 600;
  text-align: center;
  margin: 0 0 0.25rem;
  color: var(--text);
  flex-shrink: 0;
}

.diagram {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  padding: 1.15rem 0.75rem 1.15rem;
  display: flex;
  flex-direction: column;
  overflow: visible;
}

.feedback-loops {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.loop {
  opacity: 0.95;
}

.diagram__inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  justify-content: center;
  gap: clamp(0.55rem, 1.4vw, 1rem);
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

.diagram__cluster {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: clamp(0.45rem, 1.1vw, 0.75rem);
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
}

.col--dev {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
  align-self: stretch;
}

.dev-stack {
  display: flex;
  flex-direction: column;
  gap: var(--gap-dev);
  flex: 1 1 auto;
  min-height: 0;
  justify-content: stretch;
}

.dev-stack .box--dev {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.box {
  border-radius: 12px;
  padding: 0.35rem 0.5rem;
  font-size: clamp(0.58rem, min(1.1vw, 1.8vh), 0.75rem);
  font-weight: 600;
  text-align: center;
  box-shadow: 0 2px 8px var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.box--dev {
  background: var(--orange);
  color: #fff;
  min-width: clamp(5.5rem, 12vw, 7.5rem);
}

.box--pm {
  background: var(--green);
  color: #fff;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.box--pm.box--highlight {
  background: var(--green-light);
  color: #1b5e20;
  border: 2px solid var(--red-border);
}

.box--us {
  background: var(--blue);
  color: #fff;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}

.box--us.box--highlight {
  background: var(--blue-light);
  color: #0d47a1;
  border: 2px solid var(--red-border);
}

.box--upwork {
  background: var(--yellow);
  color: var(--red);
  font-size: clamp(1rem, min(3.5vw, 5vh), 1.85rem);
  font-weight: 800;
  letter-spacing: 0.06em;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  min-width: clamp(4.5rem, 10vw, 6.5rem);
  padding: 0.5rem;
}

.bridge {
  display: flex;
  flex-direction: column;
  align-self: stretch;
  min-height: 0;
  flex: 0 0 auto;
  min-width: clamp(1.35rem, 3vw, 1.85rem);
}

.bridge--to-teams {
  justify-content: stretch;
}

.bridge__slot {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.col--teams {
  display: flex;
  flex-direction: column;
  gap: var(--gap-team);
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  max-width: none;
}

.team-row {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.35rem;
  flex: 1 1 0;
  min-height: 0;
}

.pair {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.pair__cell {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  gap: 0.15rem;
}

.pair .plus {
  align-self: center;
  margin-bottom: 0.25rem;
}

.plus {
  color: var(--purple);
  font-size: clamp(1rem, 2.2vw, 1.35rem);
  font-weight: 800;
  line-height: 1;
  flex-shrink: 0;
}

.block-arrow {
  color: var(--purple);
  font-size: clamp(1.15rem, 2.5vw, 1.5rem);
  font-weight: 900;
  line-height: 1;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.block-arrow--out {
  font-size: clamp(1.2rem, 2.6vw, 1.65rem);
}

.col--platform {
  flex: 0 0 auto;
  align-self: stretch;
  display: flex;
  min-height: 0;
}

.col--platform .box--upwork {
  flex: 1;
}

.callout {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  order: -1;
  flex-shrink: 0;
}

.callout__label {
  color: var(--red);
  font-weight: 800;
  font-size: clamp(0.6rem, 1.2vw, 0.72rem);
  text-align: center;
  white-space: nowrap;
}

.callout__arrow {
  width: 0;
  height: 0;
  margin-bottom: 2px;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 10px solid var(--blue);
}

.box.is-active,
.box:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(44, 62, 80, 0.15);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .page {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .diagram {
    flex: none;
    min-height: min(70vh, 520px);
  }

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

  .col--dev {
    align-self: center;
    flex: none;
    max-height: 45vh;
    width: 100%;
    max-width: 22rem;
  }

  .dev-stack {
    flex: none;
    overflow-y: auto;
    max-height: 45vh;
  }

  .dev-stack .box--dev {
    flex: 0 0 auto;
    min-height: 1.65rem;
  }

  .diagram__cluster {
    flex-wrap: wrap;
    width: 100%;
    flex: none;
    min-height: min(50vh, 480px);
  }

  .bridge--to-teams {
    flex-direction: row;
    width: 100%;
    min-height: 2rem;
    flex: none;
  }

  .bridge__slot {
    flex: 1;
  }

  .col--teams {
    flex: 1 1 auto;
    min-height: 280px;
  }

  .team-row {
    flex: 1 1 0;
  }

  .diagram__cluster .col--platform {
    width: 100%;
    flex: none;
  }

  .diagram__cluster .col--platform .box--upwork {
    min-height: 3.5rem;
  }
}

@media (max-width: 600px) {
  .pair {
    flex-wrap: wrap;
    justify-content: center;
  }

  .pair .plus {
    width: 100%;
    text-align: center;
    margin-bottom: 0;
  }
}
