:root {
  --ink: #102536;
  --muted: #6c7d89;
  --line: rgba(16, 37, 54, 0.12);
  --blue: #0c709f;
  --blue-deep: #0c3146;
  --green: #1d9c4a;
  --green-deep: #10733a;
  --gold: #ffc857;
  --canvas-width: 807;
  --canvas-height: 551;
  color-scheme: light;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 8% 0%, rgba(28, 156, 74, 0.14), transparent 30rem),
    linear-gradient(135deg, #f2f6f5 0%, #e8eef0 48%, #dae5e8 100%);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1440px, calc(100% - 48px));
  margin: 0 auto;
  padding: 28px 0 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: inherit;
  text-decoration: none;
}

.brand__mark {
  position: relative;
  display: inline-block;
  width: 46px;
  height: 46px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--blue-deep);
  box-shadow: 0 8px 18px rgba(12, 49, 70, 0.2);
}

.brand__mark::before,
.brand__mark::after,
.brand__mark i {
  position: absolute;
  display: block;
  content: "";
  height: 6px;
  border-radius: 999px;
  background: var(--gold);
  transform: skewX(-27deg);
}

.brand__mark::before {
  top: 14px;
  left: 10px;
  width: 19px;
}

.brand__mark::after {
  top: 25px;
  left: 18px;
  width: 21px;
}

.brand__mark i:first-child {
  top: 25px;
  left: 7px;
  width: 8px;
}

.brand__mark i:last-child {
  top: 14px;
  left: 33px;
  width: 6px;
}

.brand__eyebrow,
.scene-card__kicker,
.section-kicker,
.control-panel__title {
  display: block;
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.brand h1 {
  margin: 2px 0 0;
  font-size: clamp(1.25rem, 2vw, 1.75rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.topbar__status {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 13px;
  border: 1px solid rgba(29, 156, 74, 0.2);
  border-radius: 999px;
  color: var(--green-deep);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.88rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-dot,
.scene-readout__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 4px rgba(29, 156, 74, 0.13);
}

.cycle-count {
  padding-left: 8px;
  color: var(--muted);
  border-left: 1px solid var(--line);
  font-size: 0.78rem;
  font-weight: 600;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(245px, 295px) minmax(0, 1fr);
  gap: 18px;
  align-items: stretch;
}

.info-panel,
.scene-card {
  border: 1px solid rgba(16, 37, 54, 0.09);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 22px 55px rgba(20, 54, 70, 0.11);
  backdrop-filter: blur(12px);
}

.info-panel {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 26px 24px 22px;
}

.info-panel__heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-index {
  color: var(--muted);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.info-panel h2,
.scene-card h2 {
  margin: 10px 0 0;
  color: var(--blue-deep);
  font-size: clamp(1.5rem, 2.5vw, 2.1rem);
  line-height: 1;
  letter-spacing: -0.05em;
}

.info-panel > p {
  margin: 20px 0 24px;
  color: #4c6471;
  font-size: 0.94rem;
  line-height: 1.58;
}

.flow-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow-item {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 11px;
  align-items: center;
  min-height: 55px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 14px;
  color: var(--muted);
  transition: 240ms ease;
}

.flow-item.is-current {
  color: var(--ink);
  border-color: rgba(29, 156, 74, 0.2);
  background: rgba(29, 156, 74, 0.08);
  transform: translateX(3px);
}

.flow-item__number {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid currentColor;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 800;
}

.flow-item strong,
.flow-item small {
  display: block;
}

.flow-item strong {
  font-size: 0.88rem;
}

.flow-item small {
  margin-top: 3px;
  color: currentColor;
  font-size: 0.72rem;
  opacity: 0.72;
}

.control-panel {
  margin-top: auto;
  padding-top: 20px;
}

.control-panel__buttons {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 8px;
  margin-top: 11px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  font-size: 0.83rem;
  font-weight: 800;
  transition: 180ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(12, 112, 159, 0.32);
  outline-offset: 3px;
}

.button--primary {
  color: white;
  background: var(--blue-deep);
  box-shadow: 0 8px 16px rgba(12, 49, 70, 0.2);
}

.button--ghost {
  color: var(--blue-deep);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.6);
}

.button__icon {
  position: relative;
  width: 12px;
  height: 12px;
}

.button__icon--pause::before,
.button__icon--pause::after {
  position: absolute;
  top: 1px;
  width: 3px;
  height: 10px;
  border-radius: 3px;
  background: currentColor;
  content: "";
}

.button__icon--pause::before {
  left: 1px;
}

.button__icon--pause::after {
  right: 1px;
}

.button__icon--play::before {
  position: absolute;
  top: 0;
  left: 3px;
  content: "";
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid currentColor;
}

.speed-control {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px 12px;
  align-items: center;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 700;
}

.speed-control output {
  color: var(--blue-deep);
}

.speed-control input {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--green);
}

.scene-card {
  min-width: 0;
  padding: 20px;
  overflow: hidden;
}

.scene-card__header,
.scene-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.scene-card__header {
  padding: 4px 4px 18px;
}

.scene-card__header h2 {
  margin-top: 7px;
  font-size: clamp(1.35rem, 2.3vw, 1.85rem);
}

.scene-readout {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--green-deep);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: right;
}

.scene-frame {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 1px solid rgba(12, 49, 70, 0.12);
  border-radius: 17px;
  background: #d9ddde;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.45), 0 14px 30px rgba(12, 49, 70, 0.12);
  aspect-ratio: 807 / 551;
}

.scene-frame::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  background: linear-gradient(110deg, rgba(255, 255, 255, 0.13), transparent 25%, transparent 76%, rgba(12, 49, 70, 0.08));
  mix-blend-mode: screen;
}

.scene-world {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 807px;
  height: 551px;
  transform: translate(-50%, -50%) scale(var(--scene-scale, 1));
  transform-origin: center;
  isolation: isolate;
}

.scene-navigation {
  position: absolute;
  z-index: 10;
  top: 47px;
  left: 273px;
  width: 481px;
  height: 48px;
  pointer-events: none;
}

.scene-navigation__bar,
.scene-navigation__bar > img:first-child {
  position: absolute;
  inset: 0;
  width: 481px;
  height: 48px;
}

.scene-navigation__bar > img:first-child {
  display: block;
}

.scene-navigation__home {
  position: absolute;
  top: 11px;
  left: 45px;
  width: 28px;
  height: 25px;
}

.scene-navigation__link {
  position: absolute;
  top: 11px;
  color: white;
  font-family: "Segoe UI", sans-serif;
  font-size: 17px;
  line-height: 25px;
  white-space: nowrap;
}

.scene-navigation__link b {
  display: inline-grid;
  place-items: center;
  width: 21px;
  height: 21px;
  margin-left: 2px;
  border-radius: 50%;
  color: var(--blue-deep);
  background: white;
  font-size: 14px;
}

.scene-navigation__link--a {
  left: 94px;
}

.scene-navigation__link--b {
  left: 244px;
}

.scene-navigation__link--c {
  left: 395px;
  color: #075a2b;
}

.scene-navigation__cloud {
  position: absolute;
  top: -37px;
  left: 337px;
  width: 199px;
  height: 185px;
  filter: drop-shadow(5px 8px 2px rgba(0, 0, 0, 0.2));
}

.scene-navigation__cloud > img:first-child {
  position: absolute;
  inset: 0;
  width: 199px;
  height: 185px;
}

.scene-navigation__title {
  position: absolute;
  top: 36px;
  left: 27px;
  width: 148px;
  height: 85px;
}

.scene-layer {
  position: absolute;
  inset: 0;
  display: block;
  width: 807px;
  height: 551px;
  max-width: none;
  pointer-events: none;
  user-select: none;
}

.scene-layer--background {
  z-index: 0;
}

.scene-layer--belt {
  z-index: 2;
}

.scene-layer--stacks {
  z-index: 4;
}

.person {
  position: absolute;
  z-index: 1;
  display: block;
  width: 31px;
  height: 76px;
  background-repeat: no-repeat;
  background-size: 807px 551px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  will-change: transform;
}

.person--operator-left {
  top: 306px;
  left: 288px;
  background-image: url("public/assets/operarios.png");
  background-position: -288px -306px;
}

.person--operator-right {
  top: 306px;
  left: 321px;
  background-image: url("public/assets/operarios.png");
  background-position: -321px -306px;
}

.person--supervisor {
  top: 307px;
  left: 521px;
  width: 31px;
  height: 75px;
  background-image: url("public/assets/persona.png");
  background-position: -521px -307px;
}

.person:hover {
  filter: drop-shadow(0 4px 4px rgba(12, 49, 70, 0.28));
}

.person.is-dragging {
  z-index: 7;
  cursor: grabbing;
  filter: drop-shadow(0 9px 7px rgba(12, 49, 70, 0.34));
}

.person.is-settled {
  z-index: 1;
}

.hand,
.bag {
  position: absolute;
  display: block;
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

.hand {
  top: 333px;
  background-image: url("public/assets/mano-operarios.png");
  opacity: 0.9;
  animation: hand-motion 1.6s ease-in-out infinite;
}

.hand--left {
  left: 310px;
  width: 5px;
  height: 24px;
}

.hand--left-copy {
  left: 341px;
  animation-delay: -0.7s;
}

.hand--right {
  left: 539px;
  width: 9px;
  height: 26px;
  background-image: url("public/assets/mano.png");
  animation-delay: -0.3s;
}

.bag {
  z-index: 3;
  left: 0;
  top: 0;
  width: 31px;
  height: 32px;
  background-image: url("public/assets/bulto-azucar.png");
  animation: bag-line 13s linear infinite;
  animation-duration: calc(13s / var(--speed, 1));
  cursor: grab;
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  will-change: transform;
}

.bag:hover {
  filter: drop-shadow(0 4px 4px rgba(12, 49, 70, 0.28));
}

.bag.is-dragging {
  z-index: 7;
  cursor: grabbing;
  filter: drop-shadow(0 9px 7px rgba(12, 49, 70, 0.34));
}

.bag.is-settled,
.bag.is-returning {
  animation: none !important;
}

.bag.is-returning {
  transition: transform 520ms cubic-bezier(0.2, 0.85, 0.3, 1);
}

.bag--one {
  animation-delay: -0.4s;
}

.bag--two {
  animation-delay: -4.7s;
}

.bag--three {
  animation-delay: -9s;
}

.machine {
  position: absolute;
  z-index: 6;
  top: 86px;
  left: -518px;
  width: 807px;
  height: 551px;
  pointer-events: none;
}

.machine__carrito,
.machine__grua,
.machine__pickup-bag {
  transform-origin: 50% 50%;
  animation-duration: calc(13s / var(--speed, 1));
}

.machine__carrito {
  animation: vehicle-route calc(13s / var(--speed, 1)) ease-in-out infinite;
}

.machine__grua {
  animation: mechanical-arm calc(13s / var(--speed, 1)) ease-in-out infinite;
}

.machine__pickup-bag {
  animation: pickup-bag calc(13s / var(--speed, 1)) ease-in-out infinite;
}

.is-paused .bag,
.is-paused .machine__carrito,
.is-paused .machine__grua,
.is-paused .machine__pickup-bag,
.is-paused .hand {
  animation-play-state: paused;
}

.scene-card__footer {
  flex-wrap: wrap;
  padding: 15px 4px 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.drag-hint {
  color: var(--green-deep);
  font-size: 0.72rem;
  letter-spacing: 0.02em;
}

.drag-hint > span {
  display: inline-block;
  margin-right: 4px;
  color: var(--gold);
  font-size: 1rem;
  line-height: 0;
}

.footer-marker {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 4px;
  border-radius: 2px;
  background: var(--gold);
  transform: rotate(45deg);
}

.footer-code {
  color: var(--blue);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}

.page-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 4px 0;
  color: rgba(16, 37, 54, 0.58);
  font-size: 0.75rem;
}

@keyframes bag-line {
  0% {
    opacity: 1;
    transform: translate(718px, 322px) rotate(-3deg);
  }
  4% {
    opacity: 1;
    transform: translate(704px, 329px) rotate(-1deg);
  }
  7% {
    opacity: 1;
    transform: translate(690px, 336px) rotate(0deg);
  }
  23% {
    transform: translate(610px, 336px) rotate(0deg);
  }
  43% {
    transform: translate(535px, 336px) rotate(0deg);
  }
  63% {
    transform: translate(400px, 336px) rotate(1deg);
  }
  74% {
    transform: translate(320px, 336px) rotate(0deg);
  }
  81% {
    transform: translate(270px, 331px) rotate(7deg);
  }
  87% {
    transform: translate(230px, 324px) rotate(12deg);
  }
  93% {
    opacity: 1;
    transform: translate(190px, 313px) rotate(15deg);
  }
  100% {
    opacity: 1;
    transform: translate(160px, 301px) rotate(15deg);
  }
}

@keyframes vehicle-route {
  0%,
  6% {
    transform: translateX(0);
  }
  43%,
  63% {
    transform: translateX(763px);
  }
  100% {
    transform: translateX(0);
  }
}

@keyframes mechanical-arm {
  0%,
  6% {
    transform: translate(0, 0);
  }
  43%,
  45%,
  46% {
    transform: translate(763px, 0);
  }
  48% {
    transform: translate(763px, 9px);
  }
  53%,
  63% {
    transform: translate(763px, -20px);
  }
  100% {
    transform: translate(0, -20px);
  }
}

@keyframes pickup-bag {
  0% {
    opacity: 1;
    transform: translate(764px, 0);
  }
  6%,
  43% {
    opacity: 1;
    transform: translate(764px, 0);
  }
  48% {
    opacity: 1;
    transform: translate(764px, 9px);
  }
  53%,
  63% {
    opacity: 1;
    transform: translate(764px, -20px);
  }
  98% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(0, -20px);
  }
}

@keyframes hand-motion {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(2px) rotate(-7deg);
  }
}

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

  .info-panel {
    min-height: 0;
  }

  .info-panel > p {
    max-width: 720px;
  }

  .flow-list {
    grid-template-columns: repeat(4, 1fr);
  }

  .flow-item {
    grid-template-columns: 1fr;
    gap: 6px;
    min-height: 0;
  }

  .flow-item.is-current {
    transform: none;
  }

  .control-panel {
    max-width: 440px;
    margin-top: 22px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 24px, 1440px);
    padding-top: 16px;
  }

  .topbar,
  .scene-card__header,
  .scene-card__footer,
  .page-footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar {
    gap: 15px;
  }

  .topbar__status {
    align-self: stretch;
    justify-content: center;
  }

  .info-panel,
  .scene-card {
    border-radius: 19px;
  }

  .info-panel,
  .scene-card {
    padding: 18px;
  }

  .flow-list {
    grid-template-columns: repeat(2, 1fr);
  }

  .scene-card__header {
    gap: 12px;
  }

  .scene-readout {
    text-align: left;
  }

  .scene-card__footer,
  .page-footer {
    gap: 8px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .flow-item,
  .button {
    transition: none;
  }
}
