:root {
  --bg: #f6f7f3;
  --ink: #1b1f23;
  --panel: #ffffff;
  --line: #d3d8df;
  --accent: #0f6d59;
  --accent-contrast: #ffffff;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, #e4efe9 0%, transparent 40%),
    radial-gradient(circle at 100% 100%, #dce8ee 0%, transparent 36%),
    var(--bg);
}

.layout {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(900px, 100%);
  padding: 28px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(18, 23, 29, 0.07);
}

.header-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-logo {
  display: block;
  margin: 0;
  width: 150px;
  height: auto;
}

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

.header-spacer {
  width: 150px;
}

h1 {
  margin: 0 0 4px;
  font-size: 1.8rem;
  text-align: center;
}

.subtitle {
  margin: 0;
  color: #4c5968;
  text-align: center;
}

form {
  display: grid;
  gap: 34px;
}

#dynamic-fields {
  display: grid;
  gap: 28px;
}

.group {
  border: 1px solid #d5dde6;
  border-radius: 18px;
  padding: 16px;
  display: grid;
  gap: 18px;
  background:
    linear-gradient(180deg, #ffffff 0%, #f8fbff 100%),
    radial-gradient(circle at top right, rgba(15, 109, 89, 0.08), transparent 45%);
  box-shadow:
    0 14px 28px rgba(15, 27, 39, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.7);
  position: relative;
  overflow: hidden;
}

.group h3 {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #0f6d59;
  padding-bottom: 8px;
  border-bottom: 1px dashed #c9d6e4;
}

.signature-place-line {
  margin: 0;
  font-size: 0.9rem;
  font-style: italic;
}

.date-place-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  font-size: 0.9rem;
}

.date-city-input {
  width: 180px !important;
  flex: 0 0 180px;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #ccd5df;
  border-radius: 10px;
  background: #ffffff;
}

.legal-info {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  background: #f7f9fb;
  display: grid;
  gap: 8px;
}

.legal-info p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.35;
  text-align: justify;
}

.field {
  display: grid;
  gap: 10px;
  position: relative;
}

.field-help {
  margin: 0;
  font-size: 0.87rem;
  color: #4c5968;
}

.input-error {
  border-color: #d63939 !important;
  background: #fff6f6;
  box-shadow: 0 0 0 4px rgba(214, 57, 57, 0.12) !important;
}

.date-place-row {
  position: relative;
}

.field-error-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  margin: 0;
  font-size: 0.8rem;
  color: #7a1111;
  background: linear-gradient(180deg, #fff5f5 0%, #ffecec 100%);
  border: 1px solid #f3b9b9;
  border-radius: 10px;
  padding: 8px 10px;
  box-shadow: 0 10px 20px rgba(122, 17, 17, 0.12);
  z-index: 12;
  animation: popIn 0.16s ease-out;
}

.field-error-popover::before {
  content: "";
  position: absolute;
  top: -6px;
  left: 12px;
  width: 10px;
  height: 10px;
  background: #fff2f2;
  border-left: 1px solid #f3b9b9;
  border-top: 1px solid #f3b9b9;
  transform: rotate(45deg);
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-footer-info {
  margin: 4px 0 0;
  font-size: 0.86rem;
  color: #4c5968;
  line-height: 1.35;
  text-align: center;
}

.form-footer-info a {
  color: #0f6d59;
  text-decoration: underline;
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

.radio-group {
  border: 1px solid #d7dee6;
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 8px;
  background: #ffffff;
}

.radio-group legend {
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0 6px;
}

.radio-group.is-disabled {
  opacity: 0.55;
  filter: grayscale(0.2);
}

.radio-title {
  margin: 6px 0 2px;
  font-size: 0.9rem;
  font-weight: 700;
}

label {
  font-size: 0.95rem;
  font-weight: 600;
}

input[type="text"],
input[type="email"],
textarea {
  width: 100%;
  border: 1px solid #ccd5df;
  border-radius: 12px;
  padding: 10px;
  font-size: 0.95rem;
  background: #ffffff;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.15s ease;
}

input[type="text"],
input[type="email"] {
  height: 42px;
  padding: 0 10px;
}

textarea {
  min-height: 90px;
  resize: vertical;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
.date-city-input:focus {
  outline: none;
  border-color: #0f6d59;
  box-shadow: 0 0 0 4px rgba(15, 109, 89, 0.14);
}

button {
  margin-top: 8px;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
}

.secondary-btn {
  width: fit-content;
  background: #dfe5ea;
  color: #1b1f23;
  padding: 0 12px;
  margin-top: 4px;
}

.signature-canvas {
  width: 100%;
  max-width: 520px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  touch-action: none;
}

#status {
  min-height: 22px;
  font-size: 0.95rem;
}

.success-message {
  min-height: 55vh;
  display: grid;
  align-content: center;
  justify-items: center;
  text-align: center;
  gap: 22px;
  padding: 24px;
}

.success-logo {
  width: min(155px, 38vw);
  height: auto;
  display: block;
  margin-bottom: 8px;
}

.success-message h2 {
  margin: 0;
  font-size: clamp(1.5rem, 2.9vw, 2.3rem);
  line-height: 1.05;
  color: #0f6d59;
}

.success-message p {
  margin: 0;
  max-width: 720px;
  font-size: clamp(0.96rem, 1.5vw, 1.12rem);
  line-height: 1.45;
}

.success-link {
  margin-top: 18px;
  color: #0f6d59;
  font-weight: 600;
  text-decoration: underline;
}

@media (max-width: 720px) {
  .panel {
    padding: 18px;
  }

  .header-row {
    grid-template-columns: 1fr;
  }

  .brand-logo {
    margin: 0 auto;
  }

  .header-spacer {
    display: none;
  }
}
