:root {
  --ink: #10211f;
  --muted: #65716e;
  --line: #dce7e4;
  --surface: #ffffff;
  --background: #f3f6f4;
  --green: #0d6b5c;
  --green-dark: #0d3b36;
  --accent: #f18f4a;
  --shadow: 0 18px 48px rgba(16, 33, 31, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(13, 107, 92, 0.1), rgba(243, 246, 244, 0) 300px),
    var(--background);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
a:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

.shell {
  width: min(100%, 560px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
  display: grid;
  align-items: center;
}

.panel {
  background: var(--surface);
  border: 1px solid rgba(13, 107, 92, 0.12);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
  margin-bottom: 16px;
}

.brand img {
  width: 70px;
  height: 70px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(1.45rem, 7.5vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2,
h3 {
  margin: 0;
  color: var(--green-dark);
}

h2 {
  font-size: 1.15rem;
  line-height: 1.25;
}

h3 {
  font-size: 0.95rem;
}

.step-heading {
  display: grid;
  gap: 5px;
}

.step-heading .eyebrow {
  margin: 0;
}

.steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}

.steps li {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
  font-size: 0.78rem;
  font-weight: 900;
}

.steps li::before {
  content: attr(data-step-dot);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: #9aa8a4;
  border-radius: 999px;
  font-size: 0.72rem;
}

.steps li.active {
  color: var(--green-dark);
  border-color: rgba(13, 107, 92, 0.32);
  background: rgba(13, 107, 92, 0.08);
}

.steps li.active::before {
  background: var(--green);
}

.steps li.current {
  box-shadow: inset 0 0 0 1px var(--green);
}

.form,
.step-pane {
  display: grid;
  gap: 14px;
}

.step-pane {
  display: none;
}

.step-pane.active {
  display: grid;
}

label {
  display: grid;
  gap: 7px;
  color: var(--green-dark);
  font-size: 0.88rem;
  font-weight: 900;
}

input[type="text"],
input[type="tel"],
input[type="email"] {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fbfdfc;
  outline: none;
}

input[readonly] {
  color: #344743;
  border-color: #cfdcd8;
  background: #eef3f1;
  cursor: default;
}

[aria-invalid="true"] {
  border-color: #b42318 !important;
  box-shadow: 0 0 0 3px rgba(180, 35, 24, 0.12) !important;
}

input[type="file"] {
  width: 100%;
  min-height: 48px;
  border: 1px dashed rgba(13, 107, 92, 0.38);
  border-radius: 8px;
  padding: 12px;
  background: rgba(13, 107, 92, 0.06);
}

input:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(13, 107, 92, 0.16);
}

.inline-alert {
  border: 1px solid;
  border-radius: 8px;
  padding: 12px 13px;
  line-height: 1.4;
  font-size: 0.88rem;
  font-weight: 800;
}

.inline-alert.error {
  color: #7a271a;
  border-color: #f0b6ae;
  background: #fff1ef;
}

.startup-alert {
  margin-bottom: 16px;
}

.status-message,
.field-help,
.field-message,
.result-status {
  margin: 0;
  line-height: 1.4;
}

.field-help {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 650;
}

.field-message {
  border-radius: 6px;
  padding: 9px 10px;
  font-size: 0.8rem;
  font-weight: 800;
}

.field-message.error {
  color: #7a271a;
  background: #fff1ef;
}

.field-message.success {
  color: #075e54;
  background: #eaf7f3;
}

.contract-summary {
  display: grid;
  gap: 11px;
  padding: 13px;
  border: 1px solid rgba(13, 107, 92, 0.25);
  border-radius: 8px;
  background: rgba(13, 107, 92, 0.05);
}

.contract-details {
  display: grid;
  gap: 9px;
  margin: 0;
}

.contract-details div {
  display: grid;
  gap: 3px;
}

.contract-details dt {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.contract-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.contract-details code {
  color: var(--ink);
  font-size: 0.75rem;
}

.contract-link {
  min-height: 44px;
  border: 1px solid rgba(13, 107, 92, 0.3);
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--green-dark);
  background: #fff;
  text-decoration: none;
  font-weight: 900;
}

.otp-box,
.challenge,
.hash-box,
.empty-state {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 13px;
  background: #f9fbfa;
}

.otp-box p,
.empty-state p {
  margin: 0 0 10px;
}

.otp-box[data-state="sending"] {
  border-color: rgba(13, 107, 92, 0.34);
  background: #f2f8f6;
}

.otp-box[data-state="ready"] {
  border-color: rgba(13, 107, 92, 0.48);
  background: #f3faf7;
}

.otp-box[data-state="error"] {
  border-color: #f0b6ae;
  background: #fff5f3;
}

.status-message.error {
  color: #7a271a;
  font-weight: 800;
}

.otp-box input:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

.debug-code {
  color: var(--green-dark);
  font-weight: 900;
}

.challenge {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.challenge span {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.challenge strong {
  color: var(--green-dark);
  font-size: 1.2rem;
}

.upload-field {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfa;
}

.upload-field.invalid {
  border-color: #d92d20;
}

.upload-field.valid {
  border-color: rgba(13, 107, 92, 0.55);
}

.upload-field legend {
  padding: 0 6px;
  color: var(--green-dark);
  font-size: 0.88rem;
  font-weight: 900;
}

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

.upload-options label {
  min-width: 0;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.preview-grid figure {
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.preview-grid img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.preview-grid figcaption {
  padding: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
}

.signature-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.signature-head {
  min-height: 48px;
  padding: 8px 10px 8px 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--green-dark);
  font-weight: 900;
  border-bottom: 1px solid var(--line);
  background: #f9fbfa;
}

.signature-help {
  padding: 10px 13px 0;
}

.signature-message {
  margin: 0 12px 12px;
}

canvas {
  display: block;
  width: 100%;
  height: min(42dvh, 310px);
  min-height: 250px;
  background: #fff;
  touch-action: none;
}

.check {
  grid-template-columns: 24px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.35;
}

.check input {
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  margin-top: 2px;
}

.actions:has(.secondary:not([hidden])) {
  grid-template-columns: 0.7fr 1fr;
}

.primary,
.secondary,
.ghost,
.download {
  min-height: 46px;
  border-radius: 8px;
  border: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  font-weight: 900;
  cursor: pointer;
}

.primary {
  color: #fff;
  background: var(--green);
  box-shadow: 0 10px 22px rgba(13, 107, 92, 0.22);
}

.secondary,
.ghost {
  color: var(--green-dark);
  background: rgba(13, 107, 92, 0.08);
}

.ghost {
  min-height: 36px;
  padding: 0 12px;
}

.primary:disabled,
.secondary:disabled,
.ghost:disabled {
  cursor: wait;
  opacity: 0.72;
}

.download {
  width: 100%;
  color: var(--green-dark);
  border: 1px solid rgba(241, 143, 74, 0.5);
  background: rgba(241, 143, 74, 0.12);
}

.result {
  margin-top: 16px;
  display: grid;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.result.pending {
  border-top-color: #f0b849;
}

.result.completed {
  border-top-color: var(--green);
}

.result-status {
  margin-top: 7px;
  color: var(--green-dark);
  font-weight: 900;
}

.result.pending .result-status {
  color: #7a4e00;
}

.result strong,
.hash-box code,
.verify-list code {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
}

.hash-box span {
  display: block;
  margin-bottom: 6px;
  color: var(--green-dark);
  font-weight: 900;
}

.verify-list {
  display: grid;
  gap: 9px;
  margin: 0 0 14px;
}

.verify-list div {
  border-bottom: 1px solid var(--line);
  padding-bottom: 9px;
}

.verify-list dt {
  color: var(--green-dark);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.verify-list dd {
  margin: 3px 0 0;
  overflow-wrap: anywhere;
}

.event-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.event-list h2 {
  margin: 0;
  color: var(--green-dark);
  font-size: 1.1rem;
}

.event-list article {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f9fbfa;
}

.event-list article strong,
.event-list article span {
  display: block;
}

.event-list article span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.78rem;
}

.event-list article p {
  margin: 8px 0 0;
}

@media (max-width: 390px) {
  .panel {
    padding: 14px;
  }

  .brand img {
    width: 60px;
    height: 60px;
  }

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

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

  .steps li {
    font-size: 0.72rem;
  }
}

@media (min-width: 700px) and (max-width: 1180px) {
  .shell {
    width: min(100%, 720px);
    padding: max(24px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom));
  }

  .panel { padding: 26px; }

  .otp-box { padding: 16px; }

  .primary,
  .secondary,
  .contract-link { min-height: 50px; }
}
