:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --surface: #ffffff;
  --line: #d8dee8;
  --line-strong: #b8c2cf;
  --text: #1f2933;
  --muted: #65758b;
  --accent: #1c7c75;
  --accent-dark: #145f5a;
  --accent-soft: #e4f4f2;
  --stage-col: minmax(0, 1fr);
  --order-col: clamp(188px, 22vw, 230px);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button {
  font: inherit;
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 28px 18px;
}

.app-header {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 18px;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.35rem, 2vw, 1.8rem);
  font-weight: 720;
  letter-spacing: 0;
}

.add-order-form {
  display: flex;
  gap: 8px;
}

.add-order-input {
  width: min(260px, 36vw);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

.add-order-input:focus {
  border-color: var(--accent);
  outline: 0;
}

.add-order-button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  padding: 8px 12px;
  font-weight: 700;
}

.add-order-button:hover,
.add-order-button:focus-visible {
  background: var(--accent-dark);
  outline: 0;
}

.pipeline-shell {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 12px 30px rgb(31 41 51 / 8%);
}

.pipeline {
  --stage-count: 7;
  display: grid;
  grid-template-columns: var(--order-col) repeat(var(--stage-count), var(--stage-col));
  width: 100%;
  min-width: 0;
}

.cell {
  min-height: 68px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.cell:nth-child(8n) {
  border-right: 0;
}

.header-cell {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  min-height: 56px;
  padding: 10px 12px;
  background: #eef3f8;
  font-size: 0.76rem;
  font-weight: 760;
  color: #2a3848;
  text-transform: uppercase;
  letter-spacing: 0;
}

.order-header,
.order-cell {
  position: sticky;
  left: 0;
  z-index: 3;
  border-right: 1px solid var(--line-strong);
}

.order-cell {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
}

.order-number {
  margin: 0 0 3px;
  font-size: 0.78rem;
  font-weight: 760;
  color: var(--muted);
}

.order-name {
  margin: 0;
  font-size: 0.94rem;
  font-weight: 680;
  line-height: 1.25;
}

.row-controls {
  display: flex;
  gap: 6px;
}

.move-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #f9fbfd;
  color: var(--text);
  cursor: pointer;
}

.move-button:hover:not(:disabled),
.move-button:focus-visible:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent-dark);
  outline: 0;
}

.move-button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.stage-cell {
  position: relative;
  display: grid;
  place-items: center;
}

.stage-cell::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  border-top: 2px solid #dfe5ed;
  transform: translateY(-50%);
}

.stage-cell.is-active {
  background: var(--accent-soft);
  cursor: grab;
  touch-action: none;
}

.stage-cell.is-drop-target {
  background: #d9eeeb;
}

.stage-cell.is-active.is-dragging {
  cursor: grabbing;
}

.marker {
  position: relative;
  z-index: 1;
  width: 24px;
  height: 24px;
  border: 3px solid var(--surface);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 3px 10px rgb(31 41 51 / 24%);
  cursor: grab;
  touch-action: none;
}

.marker:focus-visible {
  outline: 3px solid rgb(28 124 117 / 35%);
  outline-offset: 3px;
}

.marker.is-dragging {
  cursor: grabbing;
  transform: scale(1.1);
}

.stage-cell.is-active.is-dragging .marker {
  transform: scale(1.1);
}

.row-end {
  border-bottom: 0;
}

@media (max-width: 700px) {
  :root {
    --order-col: 178px;
    --stage-col: 118px;
  }

  .pipeline {
    width: max-content;
    min-width: calc(var(--order-col) + (var(--stage-count) * var(--stage-col)));
  }

  .app {
    padding: 18px 10px;
  }

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .add-order-form {
    width: 100%;
  }

  .add-order-input {
    flex: 1;
    min-width: 0;
    width: auto;
  }

  .pipeline-shell {
    border-radius: 6px;
  }

  .cell {
    min-height: 76px;
  }

  .order-cell {
    grid-template-columns: 1fr;
    align-content: center;
    gap: 8px;
  }

  .row-controls {
    justify-content: flex-start;
  }
}
