* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  height: 100vh;
  overflow: hidden;
}

.sandbox-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  grid-template-rows: 48px 1fr 40px;
  height: 100vh;
  gap: 1px;
  background: #2d2d44;
}

/* --- Header bar --- */
.sandbox-header {
  grid-column: 1 / -1;
  background: #16213e;
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  border-bottom: 1px solid #2d2d44;
}

.sandbox-header h1 {
  font-size: 14px;
  font-weight: 600;
  color: #e94560;
  letter-spacing: 0.5px;
}

.sandbox-header__actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

/* --- PDF Viewer panel --- */
.sandbox-viewer {
  background: #0f0f23;
  overflow: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

.sandbox-viewer__page-wrap {
  position: relative;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.4);
}

.sandbox-viewer__page-wrap canvas {
  display: block;
}

/* --- Overlay zones drawn on canvas --- */
.sandbox-zone {
  position: absolute;
  border: 2px dashed;
  cursor: move;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  font-size: 9px;
  font-weight: 600;
  padding: 2px 4px;
  pointer-events: auto;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.sandbox-zone:hover {
  opacity: 1;
}

.sandbox-zone--composer_lines { border-color: #FF00FF; background: rgba(255,0,255,0.15); color: #FF00FF; }
.sandbox-zone--copyright_footer { border-color: #00FFFF; background: rgba(0,255,255,0.15); color: #00FFFF; }
.sandbox-zone--license_margin { border-color: #FFFF00; background: rgba(255,255,0,0.15); color: #FFFF00; }
.sandbox-zone--qr_code { border-color: #00FF00; background: rgba(0,255,0,0.15); color: #00FF00; }
.sandbox-zone--custom { border-color: #FF8800; background: rgba(255,136,0,0.15); color: #FF8800; }

.sandbox-zone__resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 10px;
  height: 10px;
  background: currentColor;
  cursor: nwse-resize;
}

/* --- Config panel (right) --- */
.sandbox-config {
  background: #16213e;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sandbox-config__section {
  background: #1a1a2e;
  border-radius: 6px;
  padding: 10px;
}

.sandbox-config__section h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #e94560;
  margin-bottom: 8px;
}

/* --- Form controls --- */
.sandbox-field {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.sandbox-field label {
  font-size: 11px;
  color: #888;
  min-width: 60px;
}

.sandbox-field input,
.sandbox-field select,
.sandbox-field textarea {
  flex: 1;
  background: #0f0f23;
  border: 1px solid #2d2d44;
  color: #e0e0e0;
  padding: 4px 6px;
  border-radius: 3px;
  font-size: 12px;
  font-family: inherit;
}

.sandbox-field textarea {
  min-height: 50px;
  resize: vertical;
}

.sandbox-field input:focus,
.sandbox-field textarea:focus {
  border-color: #e94560;
  outline: none;
}

/* --- Zone list --- */
.sandbox-zone-list {
  list-style: none;
}

.sandbox-zone-item {
  padding: 6px;
  margin-bottom: 4px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid transparent;
}

.sandbox-zone-item:hover {
  background: rgba(233,69,96,0.1);
}

.sandbox-zone-item--active {
  border-color: #e94560;
  background: rgba(233,69,96,0.15);
}

.sandbox-zone-item__swatch {
  width: 12px;
  height: 12px;
  border-radius: 2px;
}

/* --- Buttons --- */
.sandbox-btn {
  background: #e94560;
  color: white;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.sandbox-btn:hover { background: #c73652; }
.sandbox-btn--secondary { background: #2d2d44; }
.sandbox-btn--secondary:hover { background: #3d3d54; }
.sandbox-btn--small { padding: 3px 8px; font-size: 11px; }

/* --- Status bar --- */
.sandbox-status {
  grid-column: 1 / -1;
  background: #16213e;
  display: flex;
  align-items: center;
  padding: 0 16px;
  font-size: 11px;
  color: #888;
  gap: 16px;
}

/* --- Page navigation --- */
.sandbox-page-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sandbox-page-nav button {
  background: #2d2d44;
  border: none;
  color: #e0e0e0;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 11px;
}

/* --- Preview toggle --- */
.sandbox-viewer--preview {
  background: #0a0a1a;
}

.sandbox-preview-toggle {
  display: flex;
  gap: 2px;
  background: #0f0f23;
  border-radius: 4px;
  padding: 2px;
}

.sandbox-preview-toggle button {
  background: transparent;
  border: none;
  color: #888;
  padding: 4px 12px;
  border-radius: 3px;
  font-size: 11px;
  cursor: pointer;
}

.sandbox-preview-toggle button.active {
  background: #e94560;
  color: white;
}

/* --- Sign-in overlay --- */
.signin-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 18, 0.92);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Poppins', system-ui, sans-serif;
}
.signin-card {
  background: #14142a;
  border: 1px solid #2a2a44;
  border-radius: 10px;
  padding: 28px 28px 24px;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.6);
}
.signin-card h2 {
  margin: 0;
  font-size: 18px;
  color: #e0e0e0;
  font-weight: 600;
}
.signin-sub {
  margin: -4px 0 8px;
  font-size: 12px;
  color: #888;
}
.signin-card label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: #aaa;
  font-weight: 500;
}
.signin-card input[type="email"],
.signin-card input[type="password"] {
  background: #0a0a1a;
  border: 1px solid #2d2d44;
  border-radius: 5px;
  color: #e0e0e0;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}
.signin-card input:focus {
  border-color: #e94560;
}
.signin-error {
  background: rgba(231, 69, 96, 0.12);
  border: 1px solid rgba(231, 69, 96, 0.4);
  color: #e94560;
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 11px;
}
.signin-card button {
  margin-top: 6px;
}

/* --- Detected text bboxes (debug overlay) --- */
.sandbox-text-bbox {
  position: absolute;
  border: 1px dashed rgba(255, 200, 0, 0.85);
  background: rgba(255, 200, 0, 0.08);
  pointer-events: none;
  box-sizing: border-box;
  z-index: 5;
}
.sandbox-text-bbox--matched {
  border-color: rgba(0, 255, 120, 0.95);
  background: rgba(0, 255, 120, 0.12);
}

/* --- Derivative / part assignment --- */
.sandbox-deriv-list li, .sandbox-parts-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
}
.sandbox-deriv-list li:hover, .sandbox-parts-list li:hover {
  background: #1a1a2f;
}
.sandbox-deriv-list li.active {
  background: #2a2a4a;
}
.part-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #555;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}
.part-check.assigned {
  background: #2ECDA7;
  border-color: #2ECDA7;
  color: #0a0a1a;
}
.part-check.unassigned {
  background: #2a2a3a;
  border-color: #444;
  color: #777;
}
.part-check.no-pdf {
  background: #4a2a2a;
  border-color: #c73652;
  color: #ffb0b8;
}
.part-check.assigned-other {
  background: #6c6c84;
  border-color: #6c6c84;
  color: #0a0a1a;
}

/* --- Print Part Picker modal --- */
.part-picker-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.part-picker__dialog {
  background: #14141f;
  border: 1px solid #2a2a3a;
  border-radius: 8px;
  width: min(560px, 100%);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.part-picker__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #2a2a3a;
}
.part-picker__header h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ddd;
}
.part-picker__close {
  background: transparent;
  border: 0;
  color: #888;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 4px;
}
.part-picker__close:hover { color: #fff; }
.part-picker__body {
  padding: 14px 16px;
  overflow-y: auto;
  flex: 1;
}
.part-picker__body .sandbox-deriv-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  max-height: 160px;
  overflow-y: auto;
}
.part-picker__body .sandbox-parts-list {
  list-style: none;
  padding: 0;
  margin: 6px 0 0;
  max-height: 320px;
  overflow-y: auto;
}
.part-picker__parts-header {
  font-size: 12px;
  color: #aaa;
}
.part-picker__hint {
  font-size: 11px;
  color: #888;
  margin-top: 6px;
}
.part-picker__footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #2a2a3a;
}
.part-picker__status {
  flex: 1;
  font-size: 11px;
  color: #aaa;
}
.sandbox-parts-list li.is-disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.sandbox-parts-list li input[type="checkbox"],
.sandbox-parts-list li input[type="radio"] {
  margin: 0 4px 0 0;
  flex-shrink: 0;
}
.part-pdf-flag {
  font-size: 10px;
  color: #ffb0b8;
  margin-left: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
