:root {
  color-scheme: light;
  --bg: #f3f0e9;
  --bg-soft: #fbfaf6;
  --panel: #fffefa;
  --ink: #17211e;
  --muted: #61706b;
  --line: #ded8cc;
  --line-strong: #c9bfae;
  --accent: #126b5a;
  --accent-dark: #0a4c40;
  --accent-soft: #e4f1ec;
  --warn: #8a3124;
  --shadow: 0 18px 60px rgba(33, 42, 37, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Manrope", "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    linear-gradient(135deg, rgba(18, 107, 90, 0.08), transparent 38%),
    linear-gradient(225deg, rgba(138, 49, 36, 0.05), transparent 30%),
    var(--bg);
  color: var(--ink);
}

.shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 64px;
}

.intro {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.hero-panel {
  padding: 28px;
  border: 1px solid rgba(222, 216, 204, 0.82);
  border-radius: 8px;
  background: rgba(255, 254, 250, 0.78);
  box-shadow: 0 10px 40px rgba(33, 42, 37, 0.07);
  backdrop-filter: blur(10px);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.92rem;
  font-weight: 900;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 720px;
  font-size: clamp(2.05rem, 5vw, 4.1rem);
  line-height: 0.98;
  margin-bottom: 14px;
  letter-spacing: 0;
}

h2 {
  font-size: 1.16rem;
  margin: 0;
  letter-spacing: 0;
}

.intro p,
.hint,
.signature-block p {
  color: var(--muted);
  line-height: 1.65;
}

.intro p {
  max-width: 690px;
  margin-bottom: 0;
  font-size: 1.06rem;
}

.status-pill,
.text-link {
  border: 1px solid var(--line);
  padding: 9px 13px;
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.form-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}

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

.step-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.step-head span {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.82rem;
  font-weight: 900;
}

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

.wide {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  color: #52625e;
  font-size: 0.96rem;
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 13px 14px;
  font: inherit;
  color: var(--ink);
  background: #fff;
  transition: border-color 150ms ease, box-shadow 150ms ease, background 150ms ease;
}

input:focus,
select:focus,
textarea:focus {
  outline: 0;
  border-color: rgba(18, 107, 90, 0.62);
  box-shadow: 0 0 0 4px rgba(18, 107, 90, 0.12);
}

input[readonly],
.mirrored-input {
  color: #4f5d59;
  background: #f1f4f1;
  border-color: var(--line);
}

textarea {
  resize: vertical;
}

.radio-list {
  display: grid;
  gap: 10px;
  margin: 14px 0;
}

.radio-list label,
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
}

.radio-list input,
.check input {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  accent-color: var(--accent);
}

.compact {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
  padding: 14px 0;
}

.danger {
  color: var(--warn);
}

.candidate-list {
  display: grid;
  gap: 14px;
}

.candidate-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  padding: 18px;
}

.candidate-title {
  display: flex;
  justify-content: space-between;
  margin-bottom: 16px;
}

.matrix-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  margin: 14px 0 18px;
}

.matrix {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
}

.matrix th,
.matrix td {
  border-bottom: 1px solid var(--line);
  border-inline-start: 1px solid var(--line);
  padding: 9px;
  vertical-align: middle;
}

.matrix th {
  background: var(--bg-soft);
  color: var(--ink);
  font-size: 0.84rem;
}

.matrix td:first-child,
.matrix th:first-child {
  width: 280px;
  border-inline-start: 0;
  color: #52625e;
  font-size: 0.86rem;
  font-weight: 800;
}

.matrix select {
  min-width: 70px;
  padding: 9px 10px;
}

.signature-block {
  display: grid;
  gap: 12px;
  margin-top: 18px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
}

.signature-block strong {
  font-size: 1.02rem;
}

.signature-block p {
  margin: 4px 0 0;
}

#signaturePad {
  width: 100%;
  height: 180px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(#fff, #fff) padding-box,
    repeating-linear-gradient(0deg, transparent 0 32px, rgba(18, 107, 90, 0.06) 33px) border-box;
  touch-action: none;
  cursor: crosshair;
}

.actions {
  padding: 24px 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: #fbfaf6;
}

button {
  appearance: none;
  border: 0;
  border-radius: 7px;
  padding: 13px 18px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

button:hover {
  background: var(--accent-dark);
  box-shadow: 0 10px 24px rgba(18, 107, 90, 0.18);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--accent-dark);
}

button.secondary:hover {
  background: var(--accent-soft);
}

#result,
#status {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  padding: 0 28px 28px;
}

.row {
  width: 100%;
  text-align: right;
  background: #f7f6f1;
  color: var(--ink);
  border: 1px solid var(--line);
}

.admin-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.pdf-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 14px;
  background: #fff;
  color: var(--accent-dark);
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 3;
  border-top: 1px solid var(--line);
  box-shadow: 0 -10px 30px rgba(33, 42, 37, 0.08);
}

.details {
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
  background: #17211e;
  color: #f4fff8;
  border-radius: 8px;
  padding: 16px;
  margin: 0 28px 28px;
  overflow: auto;
}

.token-row {
  padding: 28px 28px 0;
}

.signature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding: 0 28px 28px;
}

.signature-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  background: #fff;
}

.signature-card h2 {
  font-size: 1.1rem;
  margin-bottom: 6px;
}

.signature-card p {
  margin: 0 0 4px;
  color: var(--muted);
}

.signature-preview {
  display: grid;
  place-items: center;
  min-height: 116px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg-soft);
  overflow: hidden;
}

.signature-preview img {
  width: 100%;
  max-height: 150px;
  object-fit: contain;
}

.missing-signature {
  color: var(--muted);
  font-weight: 800;
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1040px);
    padding-top: 18px;
  }

  .intro {
    display: block;
  }

  .hero-panel {
    padding: 20px;
  }

  .status-pill,
  .text-link {
    display: inline-block;
    margin-top: 12px;
  }

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

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

  .step,
  .actions,
  .token-row {
    padding: 20px;
  }

  .list,
  .signature-grid {
    padding: 0 20px 20px;
  }

  .details {
    margin: 0 20px 20px;
  }

  #signaturePad {
    height: 150px;
  }
}
