:root {
  --bg: #f3f4ef;
  --bg-deep: #e8ece4;
  --ink: #17242b;
  --muted: #4b6168;
  --brand: #0d8f62;
  --brand-strong: #056143;
  --line: #cdd7cf;
  --card: #ffffff;
  --danger: #b1282f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Manrope', sans-serif;
  color: var(--ink);
  background: radial-gradient(1200px 500px at 15% 0%, #d7eadf 0%, transparent 65%),
    radial-gradient(800px 500px at 85% 20%, #dbe7f5 0%, transparent 58%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  min-height: 100vh;
}

.hero {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.orb {
  position: absolute;
  filter: blur(10px);
  border-radius: 50%;
  opacity: 0.5;
}

.orb-1 {
  width: 360px;
  height: 360px;
  background: #9fd6b4;
  top: -120px;
  left: -120px;
}

.orb-2 {
  width: 420px;
  height: 420px;
  background: #bdd6ef;
  bottom: -150px;
  right: -140px;
}

.panel {
  max-width: 720px;
  width: 100%;
  background: color-mix(in srgb, var(--card) 85%, transparent);
  backdrop-filter: blur(7px);
  border: 1px solid #dde7df;
  border-radius: 22px;
  padding: 30px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.08);
  transform: translateY(0);
  animation: rise 450ms ease;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  font-family: 'Space Grotesk', sans-serif;
}

p {
  margin: 0 0 22px;
  color: var(--muted);
}

.btn-primary,
.btn-secondary,
.btn-danger {
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  font-family: 'Space Grotesk', sans-serif;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--brand) 0%, var(--brand-strong) 100%);
  color: #fff;
}

.btn-secondary {
  background: #e6ece8;
  color: var(--ink);
}

.btn-danger {
  background: #f3e0e1;
  color: var(--danger);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(8, 19, 17, 0.56);
  display: none;
  align-items: flex-start;
  justify-content: center;
  z-index: 1000;
  padding: 18px;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.modal-backdrop::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: min(980px, 100%);
  margin: 16px 0 44px;
  overflow: visible;
  background: #f3f5f4;
  border-radius: 18px;
  border: 1px solid #dce7de;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.2);
  animation: modalIn 240ms ease-out;
}

@keyframes modalIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid #e6ede8;
  position: sticky;
  top: 0;
  background: #f7faf7;
  z-index: 3;
}

.modal-content {
  padding: 20px 22px 68px;
  line-height: 1.45;
  background: #f3f5f4;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: grid;
  gap: 8px;
}

.field.spacer {
  visibility: hidden;
}

label {
  font-size: 14px;
  color: #29424a;
  line-height: 1.35;
}

.req {
  color: var(--danger);
  font-weight: 700;
}

.optional-hint {
  color: var(--muted);
  font-weight: 400;
  font-size: 12px;
  margin-left: 4px;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  font: inherit;
  background: #fff;
  transition: border-color 170ms ease, box-shadow 170ms ease, background-color 170ms ease;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, #647b72 50%),
    linear-gradient(135deg, #647b72 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 2px), calc(100% - 12px) calc(50% - 2px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: #88ac97;
  box-shadow: 0 0 0 3px rgba(13, 143, 98, 0.12);
}

.field-invalid {
  border-color: var(--danger) !important;
  box-shadow: 0 0 0 2px rgba(177, 40, 47, 0.15);
}

.field-error {
  color: var(--danger);
  font-size: 12.5px;
  line-height: 1.35;
  margin-top: 2px;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.field-error::before {
  content: '!';
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  margin-top: 2px;
}

.field-error-checkbox {
  margin-left: 26px;
  margin-top: -4px;
  margin-bottom: 6px;
}

#signatureCanvas.field-invalid {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(177, 40, 47, 0.15);
}

.signature-canvas-error {
  margin-top: 6px;
}

.success-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px 40px;
  animation: successIn 320ms ease-out;
}

.success-icon {
  margin-bottom: 18px;
  animation: successPop 420ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.success-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 22px;
  color: #0f5d3e;
  margin: 0 0 12px;
}

.success-text {
  max-width: 520px;
  color: var(--muted);
  margin: 0 0 28px;
  line-height: 1.55;
}

.success-actions {
  display: flex;
  justify-content: center;
}

.success-actions .btn-primary {
  padding: 12px 28px;
}

@keyframes successIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes successPop {
  0% { transform: scale(0.6); opacity: 0; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); }
}

textarea {
  min-height: 94px;
}

textarea[name='productionEans'],
textarea[name='consumptionEans'] {
  min-height: 56px;
  height: 56px;
  resize: vertical;
}

fieldset {
  border: 1px solid #dce6dd;
  border-radius: 12px;
  margin: 18px 0;
  padding: 16px;
  background: #f3f5f4;
}

legend {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: #1b3037;
  padding: 0 8px;
}

.section-title {
  margin-top: 18px;
  margin-bottom: 10px;
  font-family: 'Space Grotesk', sans-serif;
}

.check-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin: 10px 0;
}

.check-row label {
  margin: 0;
  line-height: 1.45;
}

.check-row input[type='checkbox'] {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.signature-mode-group {
  display: grid;
  gap: 8px;
  justify-items: start;
  margin: 8px 0 12px;
}

.signature-mode-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: #29424a;
  cursor: pointer;
}

.signature-mode-option input[type='radio'] {
  width: 16px;
  height: 16px;
  margin: 0;
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 28px;
  padding-bottom: 18px;
}

.captcha-input {
  max-width: 220px;
}

.field-signature-text input {
  max-width: 260px;
}

.hidden {
  display: none !important;
}

html.modal-open,
body.modal-open {
  overflow: hidden;
  height: 100%;
}

body.modal-open {
  position: fixed;
  inset: 0;
  width: 100%;
}

.reveal-in {
  animation: revealIn 240ms ease-out;
}

@keyframes revealIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.notice {
  margin: 10px 0;
  font-size: 13px;
  color: #3d4f57;
}

#productionFields,
#consumptionFields {
  opacity: 1;
  transition: opacity 180ms ease;
}

#productionFields.hidden,
#consumptionFields.hidden {
  opacity: 0;
}

.error-box {
  margin-top: 12px;
  border: 1px solid #f0c6c8;
  background: #fff5f5;
  color: #7d1e26;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}

.error-box ul {
  margin: 4px 0 0;
  padding-left: 20px;
}

.error-box li {
  margin: 3px 0;
}

.success-box {
  margin-top: 12px;
  border: 1px solid #c2e9d8;
  background: #edfaf3;
  color: #0f5d3e;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 14px;
}

#signatureCanvas {
  width: 100%;
  max-width: 380px;
  height: 180px;
  border: 1px dashed #9db0a3;
  border-radius: 10px;
  background: #fff;
  touch-action: none;
}

@media (max-width: 760px) {
  .grid.two {
    grid-template-columns: 1fr;
  }

  .modal-content {
    padding: 14px;
  }

  .modal-header {
    padding: 14px;
  }
}
