:root {
  --green: #49b946;
  --green-dark: #2e8f38;
  --blue: #1f4f8b;
  --blue-dark: #16375f;
  --ink: #1d2b3f;
  --muted: #66788f;
  --line: #d8e1ec;
  --bg: #f4f7fc;
  --paper: #ffffff;
  --danger: #bf1e2e;
  --ok: #1f8f4a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #f9fbff 0%, var(--bg) 100%);
}

.page {
  width: min(760px, calc(100% - 24px));
  margin: 24px auto 36px;
}

.form-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}

.form-head {
  text-align: center;
  padding: 24px 18px 18px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.logo {
  width: 180px;
  max-width: 100%;
  display: block;
  margin: 0 auto 10px;
}

h1 {
  margin: 0;
  color: var(--blue-dark);
  font-size: 25px;
  line-height: 1.2;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.section {
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.section:last-child {
  border-bottom: none;
}

h2 {
  margin: 0 0 12px;
  color: var(--blue-dark);
  font-size: 17px;
  font-weight: 700;
  padding-bottom: 8px;
  border-bottom: 1px solid #e8eef7;
}

h3 {
  margin: 0;
  font-size: 15px;
  color: var(--blue-dark);
}

.grid {
  display: grid;
  gap: 10px;
}

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

.grid.one {
  grid-template-columns: 1fr;
  margin-top: 10px;
}

label {
  display: block;
  font-size: 12px;
  color: var(--blue-dark);
  font-weight: 700;
}

label > input,
label > select,
label > textarea {
  display: block;
  margin-top: 4px;
}

strong {
  color: var(--danger);
}

.required {
  color: var(--danger);
  margin-left: 2px;
  display: inline;
  white-space: nowrap;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid #cbd4df;
  border-radius: 6px;
  min-height: 36px;
  padding: 8px 10px;
  font: inherit;
  font-size: 14px;
  color: #1e2b3f;
  background: #fff;
  outline: none;
}

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

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 2px rgba(31, 79, 139, .12);
}

label.field-error input,
label.field-error textarea,
label.field-error select,
.upload-box.field-error,
.signature-block.field-error,
input.field-error,
textarea.field-error,
select.field-error {
  border-color: #cc1e2f !important;
  box-shadow: 0 0 0 2px rgba(204, 30, 47, .12);
  background: #fff8f8;
}

.field-message {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #cc1e2f;
  font-weight: 700;
}

.field-message.ok {
  color: var(--ok);
}

label.field-success input,
input.field-success {
  border-color: var(--ok) !important;
  box-shadow: 0 0 0 2px rgba(31, 143, 74, .12);
  background: #f8fff9;
}

.siret-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.siret-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #c7d4e4;
  border-top-color: var(--blue);
  border-radius: 999px;
  animation: siret-spin .8s linear infinite;
}

@keyframes siret-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 12px;
}

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

.upload-box {
  border: 1px solid #cfdae7;
  border-radius: 7px;
  padding: 10px;
  background: #fbfdff;
}

.upload-box input {
  min-height: auto;
  border: none;
  padding: 8px 0 0;
  background: transparent;
}

.upload-box em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
  display: block;
}

.document-panel {
  margin-top: 12px;
  border: 1px solid #d9e3ef;
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}

.document-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  margin-bottom: 10px;
}

.document-heading a {
  color: var(--green-dark);
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
}

.document-panel > img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid #e2e9f3;
  border-radius: 6px;
  margin-bottom: 12px;
}

.signature-block {
  position: relative;
  border: 1px solid #8aa9cb;
  border-radius: 9px;
  padding: 16px 10px 10px;
  background: #fcfdff;
}

.signature-block.final {
  margin-top: 10px;
}

.drawn-label {
  position: absolute;
  top: -11px;
  left: 10px;
  background: #fffef7;
  border: 1px solid #7fa962;
  color: #275082;
  border-radius: 10px 11px 10px 12px;
  padding: 3px 10px;
  font-size: 11px;
  font-weight: 700;
  transform: rotate(-1deg);
}

.signature-pad {
  width: 100%;
  height: 130px;
  display: block;
  border: 1px dashed #9bb3cf;
  border-radius: 6px;
  background: #fff;
  touch-action: none;
}

.sig-actions {
  display: flex;
  gap: 8px;
  align-items: end;
  justify-content: space-between;
  margin-top: 8px;
}

.inline-date {
  display: grid;
  gap: 4px;
  width: 170px;
  font-size: 11px;
}

.inline-date input {
  min-height: 32px;
  padding: 6px 8px;
}

button,
.link-button {
  border: 0;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 36px;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 13px;
}

.primary {
  background: var(--green);
  color: #fff;
}

.primary:hover {
  background: var(--green-dark);
}

.secondary {
  background: #eef4fb;
  color: var(--blue-dark);
}

.actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.checkline {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  line-height: 1.35;
  font-weight: 600;
  color: #24354b;
}

.checkline input {
  width: 18px;
  min-height: 18px;
  margin-top: 1px;
}

.thanks-page {
  min-height: 80vh;
  display: grid;
  place-items: center;
}

.thanks {
  padding: 32px;
  text-align: center;
  max-width: 620px;
}

.thanks-logo {
  width: 170px;
  margin-bottom: 14px;
}

.reference {
  background: #f0f8f0;
  border: 1px solid rgba(73, 185, 70, .35);
  padding: 12px;
  border-radius: 8px;
  color: var(--blue-dark);
}

.error-list {
  border: 1px solid #f0b8b1;
  background: #fff4f2;
  color: var(--danger);
  padding: 12px;
  border-radius: 8px;
  margin-bottom: 14px;
}

.delivery-list {
  display: grid;
  gap: 10px;
}

.delivery-row {
  display: grid;
  grid-template-columns: 34px 130px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  border: 1px solid #d9e3ef;
  border-radius: 8px;
  background: #fbfdff;
  padding: 10px;
}

.delivery-row.is-off {
  opacity: .72;
}

.delivery-check-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 3px;
}

.delivery-check-wrap input {
  width: 18px;
  min-height: 18px;
}

.delivery-day {
  border: 1px solid #cfd9e6;
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--blue-dark);
  text-align: center;
}

.delivery-times {
  display: grid;
  gap: 8px;
}

.delivery-time {
  display: grid;
  grid-template-columns: 90px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
}

.delivery-time > span {
  font-size: 12px;
  font-weight: 700;
  color: var(--blue-dark);
}

.delivery-value {
  display: none;
}

@media (max-width: 760px) {
  .page {
    width: calc(100% - 14px);
    margin: 10px auto 20px;
  }

  .section,
  .form-head {
    padding: 14px;
  }

  .grid.two,
  .upload-grid {
    grid-template-columns: 1fr;
  }

  .document-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .sig-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .inline-date {
    width: 100%;
  }

  .actions {
    justify-content: stretch;
  }

  .primary {
    width: 100%;
  }

  .delivery-row {
    grid-template-columns: 28px 1fr;
  }

  .delivery-times {
    grid-column: 1 / -1;
  }

  .delivery-time {
    grid-template-columns: 78px minmax(0, 1fr);
  }
}

.hidden {
  display: none;
}

.conditional {
  margin-top: 12px;
}
