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

html {
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #f6f4ef;
}

body, h1, h2, h3, p { margin: 0; }

body {
  min-height: 100vh;
  letter-spacing: 0.005em;
}

a { color: inherit; text-decoration: inherit; }

button, input, select, textarea { font: inherit; }

button { border: 0; cursor: pointer; }

img { display: block; max-width: 100%; height: auto; }

.block { display: block; }
.flex { display: flex; }
.grid { display: grid; }
.inline-block { display: inline-block; }

.w-full { width: 100%; }
.max-w-5xl { max-width: 64rem; }
.min-h-screen { min-height: 100vh; }
.aspect-square { aspect-ratio: 1 / 1; }

.items-center { align-items: center; }
.justify-center { justify-content: center; }

.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }

.space-y-4 > * + * { margin-top: 1rem; }

.mx-auto { margin-left: auto; margin-right: auto; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-4 { margin-bottom: 1rem; }

.p-5 { padding: 1.25rem; }
.p-6 { padding: 1.5rem; }
.p-4 { padding: 1rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-2 { padding-top: 0.5rem; padding-bottom: 0.5rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-4 { padding-top: 1rem; padding-bottom: 1rem; }

.rounded { border-radius: 0.25rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }

.border { border: 1px solid #e6e0d6; }
.border-b { border-bottom: 1px solid #e6e0d6; }
.border-dashed { border-style: dashed; }
.border-slate-200 { border-color: #e6e0d6; }
.border-slate-300 { border-color: #cfc7b8; }

.bg-white { background-color: #fff; }
.bg-slate-50 { background-color: #f6f4ef; }
.bg-slate-100 { background-color: #eee9df; }
.bg-slate-900 { background-color: #1f4e8c; }
.bg-red-100 { background-color: #fee2e2; }
.bg-emerald-100 { background-color: #d1fae5; }

.text-white { color: #fff; }
.text-slate-500 { color: #6f685d; }
.text-slate-900 { color: #171512; }
.text-red-800 { color: #991b1b; }
.text-emerald-800 { color: #065f46; }

.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }

.text-center { text-align: center; }

.shadow-sm { box-shadow: 0 1px 8px 0 rgb(23 21 18 / 0.06); }

.hover\:bg-slate-50:hover { background-color: #f6f4ef; }
.hover\:bg-slate-800:hover { background-color: #173963; }

.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
}

.template-card {
  display: grid;
  grid-template-columns: 4.5rem 1fr;
  gap: 0.75rem;
  align-items: center;
  border: 1px solid #cfc7b8;
  border-radius: 0.5rem;
  cursor: pointer;
  padding: 0.5rem;
}

.template-card:has(input:checked) {
  border-color: #1f4e8c;
  box-shadow: 0 0 0 3px rgb(31 78 140 / 0.12);
}

.template-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.template-thumb {
  aspect-ratio: 16 / 9;
  border-radius: 0.35rem;
  height: 3rem;
  object-fit: cover;
  width: 4.5rem;
}

.batch-list {
  display: grid;
  gap: 0.75rem;
}

.batch-list-item {
  align-items: center;
  border: 1px solid #e6e0d6;
  border-radius: 0.5rem;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 4.5rem 1fr auto;
  padding: 0.75rem;
}

.batch-status-dot {
  background: #1f4e8c;
  border-radius: 999px;
  height: 0.75rem;
  justify-self: center;
  width: 0.75rem;
}

.batch-thumb {
  aspect-ratio: 1 / 1;
  border-radius: 0.35rem;
  height: 4.5rem;
  object-fit: cover;
  width: 4.5rem;
}

.drop-area {
  border: 2px dashed #cfc7b8;
  border-radius: 0.75rem;
  padding: 1.25rem;
}

.drop-area-active {
  border-color: #1f4e8c;
  box-shadow: 0 0 0 3px rgb(31 78 140 / 0.12);
}

.upload-list {
  border: 1px solid #e6e0d6;
  border-radius: 0.5rem;
  overflow: hidden;
}

.upload-list-item {
  align-items: center;
  display: flex;
  gap: 1rem;
  justify-content: space-between;
  padding: 0.75rem;
}

.upload-list-item + .upload-list-item {
  border-top: 1px solid #e6e0d6;
}

.calibration-header,
.calibration-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: space-between;
}

.calibration-stage {
  border: 1px solid #cfc7b8;
  border-radius: 0.5rem;
  cursor: crosshair;
  overflow: hidden;
  position: relative;
}

.calibration-stage img,
.calibration-stage svg {
  height: auto;
  width: 100%;
}

.calibration-stage svg {
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.calibration-axis {
  background: rgb(31 78 140 / 0.08);
  border: 0;
  bottom: 0;
  cursor: ew-resize;
  padding: 0;
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  width: 2rem;
}

.calibration-axis::before {
  background: #ef4444;
  box-shadow: 0 0 14px rgb(239 68 68 / 0.75);
  content: "";
  inset: 0 auto 0 50%;
  position: absolute;
  transform: translateX(-50%);
  width: 3px;
}

.calibration-axis span {
  background: #ef4444;
  border-radius: 999px;
  color: #fff;
  font-size: 0.75rem;
  font-weight: 700;
  left: 50%;
  padding: 0.25rem 0.5rem;
  pointer-events: none;
  position: absolute;
  top: 0.75rem;
  transform: translateX(-50%);
  white-space: nowrap;
}

.calibration-polygon {
  fill: rgb(31 78 140 / 0.14);
  stroke: #1f4e8c;
  stroke-width: 3;
}

.calibration-line {
  fill: none;
  stroke: #1f4e8c;
  stroke-dasharray: 8 6;
  stroke-width: 3;
}

.calibration-point {
  fill: #fff;
  stroke: #1f4e8c;
  stroke-width: 4;
}

.calibration-label {
  fill: #1f4e8c;
  font-size: 22px;
  font-weight: 700;
  paint-order: stroke;
  stroke: #fff;
  stroke-width: 4;
}

input {
  background: #fff;
  color: #171512;
  border-radius: 0.35rem;
}

input[type="color"] {
  height: 2.6rem;
  padding: 0.25rem;
}

.shadow-toggle {
  width: 1rem;
  height: 1rem;
  accent-color: #1f4e8c;
}

input:focus {
  border-color: #1f4e8c;
  box-shadow: 0 0 0 3px rgb(31 78 140 / 0.12);
  outline: none;
}

@media (min-width: 768px) {
  .md\:grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sm\:py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
}

@media (min-width: 640px) {
  .sm\:py-6 { padding-top: 1.5rem; padding-bottom: 1.5rem; }
}
