:root {
  color-scheme: light;
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #151515;
  --muted: #6f6a62;
  --line: #ddd6ca;
  --accent: #b9f227;
  --accent-ink: #172100;
  --rose: #e6b7a4;
  --blue: #9ec7d6;
  --danger: #c04444;
  --ok: #39824b;
  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(--ink);
}

button,
input {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
}

.workspace {
  width: min(1180px, 100%);
  margin: 0 auto;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 7vw, 4.5rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.campaign-pill {
  display: grid;
  width: min(100%, 320px);
  padding: 12px 16px;
  border: 1px solid #111;
  background: linear-gradient(135deg, #111 0%, #2c2c2c 100%);
  color: #f7f2e8;
  box-shadow: 0 18px 40px rgba(21, 21, 21, 0.16);
}

.campaign-pill span {
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.campaign-pill small {
  margin-top: 4px;
  color: rgba(247, 242, 232, 0.7);
}

.main-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  gap: 18px;
}

.capture-panel,
.result-panel {
  border: 1px solid var(--line);
  background: var(--surface);
}

.customer-form {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}

.customer-form label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.customer-form span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.customer-form input {
  min-width: 0;
  min-height: 42px;
  border: 1px solid #111;
  padding: 8px 10px;
  background: #fff;
  color: var(--ink);
}

.customer-form input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.preview-frame {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 4 / 3;
  min-height: 360px;
  overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(185, 242, 39, 0.08), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(158, 199, 214, 0.12), transparent 50%),
    linear-gradient(180deg, #f0ece4 0%, #e8e2d8 100%);
  border-bottom: 1px solid var(--line);
}

.preview-media {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #111;
}

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  color: var(--muted);
  padding: 32px;
}

.empty-icon {
  position: relative;
  width: 100px;
  height: 100px;
  color: var(--ink);
}

.empty-svg {
  width: 100%;
  height: 100%;
  animation: emptyPulse 3s ease-in-out infinite;
}

@keyframes emptyPulse {
  0%, 100% { opacity: 0.6; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

.empty-text {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}

.empty-label {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}

.empty-hint {
  font-size: 0.8rem;
  color: var(--muted);
  opacity: 0.7;
}

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, 44px) minmax(128px, 1fr);
  gap: 10px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

.icon-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border: 1px solid #111;
  background: #fff;
  color: #111;
  cursor: pointer;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 44px;
  font-size: 1.35rem;
  line-height: 1;
}

.icon-button svg {
  flex-shrink: 0;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 800;
}

.secondary-button {
  background: #111;
  color: #fff;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.result-panel {
  display: flex;
  min-height: 480px;
  flex-direction: column;
  padding: 18px;
  gap: 14px;
}

.status-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 32px;
  color: var(--muted);
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9b948a;
}

.status-dot.ok {
  background: var(--ok);
}

.status-dot.warn {
  background: #bd7a18;
}

.status-dot.error {
  background: var(--danger);
}

.coupon-view {
  display: grid;
  gap: 14px;
  padding: 8px 0 22px;
}

.coupon-amount {
  font-size: clamp(2.25rem, 8vw, 5rem);
  line-height: 0.95;
  font-weight: 900;
}

.result-label {
  margin: 0;
  color: var(--muted);
}

.product-name {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 750;
}

.product-link {
  margin: 0;
}

.product-link a {
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
}

.product-link a:hover {
  text-decoration: underline;
}

.reference-image {
  width: 100%;
  max-height: 180px;
  object-fit: contain;
  border: 1px solid var(--line);
  background: #f8f8f8;
}

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

.metric {
  border: 1px solid var(--line);
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.8rem;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 1.05rem;
}

.json-panel {
  margin-top: auto;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.json-panel summary {
  cursor: pointer;
  color: var(--muted);
}

pre {
  max-height: 260px;
  overflow: auto;
  padding: 12px;
  background: #111;
  color: #f8f8f8;
  font-size: 0.78rem;
}

.muted {
  color: var(--muted);
}

.is-hidden {
  display: none !important;
}

.turnstile-container {
  display: none;
}

.turnstile-container.is-active {
  display: flex;
  justify-content: center;
  padding: 12px;
  border-top: 1px solid var(--line);
}

@media (max-width: 860px) {
  .app-shell {
    padding: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .main-grid {
    grid-template-columns: 1fr;
  }

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

  .preview-frame {
    min-height: 280px;
    aspect-ratio: 16 / 10;
  }

  .result-panel {
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  .topbar {
    display: grid;
  }

  .campaign-pill {
    width: 100%;
  }

  .toolbar {
    grid-template-columns: repeat(4, 44px);
  }

  .customer-form {
    grid-template-columns: 1fr;
  }

  .primary-button {
    grid-column: 1 / -1;
  }

  .metrics {
    grid-template-columns: 1fr;
  }
}
