:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #64716b;
  --line: rgba(23, 33, 28, 0.12);
  --panel: rgba(255, 255, 255, 0.78);
  --panel-solid: #fbfcf8;
  --green: #0f8d68;
  --green-dark: #26634c;
  --coral: #e76652;
  --blue: #244c74;
  --field-blue: #2f80ed;
  --field-blue-deep: #1957b8;
  --shadow: 0 18px 50px rgba(20, 32, 28, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 10%, rgba(76, 147, 255, 0.24), transparent 30%),
    radial-gradient(circle at 84% 12%, rgba(28, 91, 184, 0.28), transparent 32%),
    linear-gradient(135deg, #eaf5ff 0%, #c9e0ff 48%, #eef7ff 100%);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  min-height: 100vh;
  padding: 20px;
}

.stage,
.control-panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.stage {
  display: flex;
  flex-direction: column;
  min-width: 0;
  border-radius: 18px;
  overflow: hidden;
}

.control-panel {
  border-radius: 18px;
  padding: 18px;
  overflow: auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 22px 24px 14px;
}

.brand {
  margin-bottom: 12px;
  color: var(--green-dark);
  font-size: 0.88rem;
  font-weight: 800;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 5vw, 4.4rem);
  line-height: 0.92;
  letter-spacing: 0;
}

#destination {
  margin-top: 10px;
  color: var(--muted);
  font-weight: 650;
}

.progress-card {
  min-width: 128px;
  align-self: flex-start;
  padding: 14px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid var(--line);
}

.progress-card strong {
  display: block;
  font-size: 1.8rem;
  line-height: 1;
}

.progress-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.progress-track {
  height: 8px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(15, 141, 104, 0.14);
  overflow: hidden;
}

#progress-fill {
  width: 0%;
  height: 100%;
  background: var(--green);
  transition: width 220ms ease;
}

.mode-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin: 0 24px;
  padding: 5px;
  border-radius: 8px;
  background: rgba(23, 33, 28, 0.08);
}

.mode-button {
  height: 38px;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  font-weight: 800;
}

.mode-button.is-active {
  color: var(--ink);
  background: white;
  box-shadow: 0 8px 18px rgba(23, 33, 28, 0.08);
}

.workspace {
  position: relative;
  flex: 1;
  min-height: 560px;
}

.bag-view,
.list-view {
  position: absolute;
  inset: 0;
}

.bag-view {
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(47, 128, 237, 0.22), transparent 42%),
    linear-gradient(180deg, rgba(240, 248, 255, 0.72), rgba(204, 226, 255, 0.55));
}

.bag-svg,
.bag-items {
  position: absolute;
  inset: 5% 8% 4%;
  width: 84%;
  height: 88%;
}

.bag-svg {
  filter:
    drop-shadow(0 24px 30px rgba(25, 87, 184, 0.2))
    drop-shadow(0 0 24px rgba(80, 158, 255, 0.34));
}

.bag-path {
  fill: rgba(47, 128, 237, 0.22);
  stroke: rgba(18, 94, 204, 0.72);
  stroke-width: 5;
  stroke-linejoin: miter;
  vector-effect: non-scaling-stroke;
}

.bag-rim {
  display: none;
}

.bag-items {
  container-type: size;
}

.bag-object {
  position: absolute;
  width: clamp(32px, calc(var(--size-ratio) * 100cqw), 102px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%) rotate(var(--rotate));
  transition: left 240ms ease, top 240ms ease, transform 240ms ease, opacity 160ms ease;
}

.object-button {
  position: relative;
  width: 100%;
  height: 100%;
  background: transparent;
}

.object-media {
  position: absolute;
  inset: 4px;
  display: grid;
  place-items: center;
}

.object-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 11px 10px rgba(20, 29, 24, 0.25));
}

.fallback-icon {
  display: grid;
  place-items: center;
  width: 82%;
  height: 82%;
  border-radius: 8px;
  color: white;
  font-size: 2.5rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--blue), var(--coral));
  box-shadow: 0 12px 24px rgba(20, 29, 24, 0.18);
}

.object-label {
  position: absolute;
  left: 50%;
  bottom: 2px;
  max-width: 96%;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(20, 29, 24, 0.14);
  font-size: 0.74rem;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bag-object.is-packed {
  opacity: 0.65;
}

.packed-badge {
  position: absolute;
  top: 0;
  right: 2px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  color: white;
  background: var(--green);
  box-shadow: 0 8px 18px rgba(15, 141, 104, 0.28);
  font-weight: 900;
}

.list-view {
  overflow: auto;
  padding: 24px;
}

.checklist {
  display: grid;
  gap: 10px;
  max-width: 780px;
  margin: 0 auto;
}

.check-row,
.queue-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
}

.check-row {
  padding: 12px;
}

.check-toggle {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  color: white;
  background: var(--green);
  font-weight: 900;
}

.check-toggle:not(.is-packed) {
  color: var(--muted);
  background: rgba(23, 33, 28, 0.08);
}

.check-title,
.queue-title {
  min-width: 0;
  font-weight: 850;
}

.check-title span,
.queue-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-title small,
.queue-title small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions button,
.agent-card button {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 7px;
  color: var(--ink);
  background: rgba(23, 33, 28, 0.08);
  font-weight: 850;
}

.add-form {
  margin-bottom: 18px;
}

.add-form label,
.section-title {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr 52px;
  gap: 8px;
}

.input-row input {
  min-width: 0;
  height: 52px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: white;
  outline: none;
}

.input-row input:focus {
  border-color: rgba(15, 141, 104, 0.5);
  box-shadow: 0 0 0 4px rgba(15, 141, 104, 0.12);
}

.input-row button {
  border-radius: 8px;
  color: white;
  background: var(--green);
  font-size: 1.6rem;
  font-weight: 800;
}

.panel-section {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.panel-section + .panel-section {
  margin-top: 16px;
}

.queue-list {
  display: grid;
  gap: 8px;
}

.queue-row {
  grid-template-columns: 36px 1fr auto;
  padding: 9px;
}

.queue-thumb {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: contain;
  background: rgba(23, 33, 28, 0.08);
}

.agent-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.agent-card > div {
  min-width: 0;
}

.api-status {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.agent-card code {
  display: block;
  overflow: hidden;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 850;
  text-overflow: ellipsis;
}

.event-log {
  display: grid;
  gap: 6px;
}

.event {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.image-dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 12px;
  padding: 0;
  color: var(--ink);
  background: var(--panel-solid);
  box-shadow: 0 24px 90px rgba(20, 29, 24, 0.3);
}

.image-dialog::backdrop {
  background: rgba(10, 18, 15, 0.46);
  backdrop-filter: blur(4px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.dialog-head strong,
.dialog-head span {
  display: block;
}

.dialog-head span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

#dialog-close {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  color: var(--ink);
  background: rgba(23, 33, 28, 0.08);
  font-size: 1.4rem;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  padding: 18px;
}

.candidate {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  text-align: left;
  background: white;
}

.candidate img {
  width: 100%;
  height: 122px;
  object-fit: contain;
  border-radius: 7px;
  background: rgba(23, 33, 28, 0.06);
}

.candidate strong {
  display: block;
  margin-top: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.candidate span {
  display: block;
  min-height: 1.1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.upload-row {
  padding: 0 18px 18px;
}

.empty {
  display: grid;
  place-items: center;
  min-height: 280px;
  color: var(--muted);
  font-weight: 800;
  text-align: center;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .workspace {
    min-height: 520px;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 18px 18px 12px;
  }

  .progress-card {
    min-width: 100px;
  }

  .workspace {
    min-height: 430px;
  }

  .bag-svg,
  .bag-items {
    inset: 10% 0 6%;
    width: 100%;
  }
}
