* {
  box-sizing: border-box;
}

:root {
  color-scheme: dark;
  --bg: #080c12;
  --panel: #101722;
  --panel-2: #0d131c;
  --border: #273244;
  --border-soft: #202a38;
  --text: #f3f5f8;
  --muted: #96a2b2;
  --gold: #e2c16d;
  --gold-light: #f0d98d;
  --danger: #ff7777;
  --success: #64d69a;
}

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

body {
  margin: 0;
  background:
    radial-gradient(circle at 80% 0%, rgba(226, 193, 109, 0.09), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

.topbar {
  min-height: 78px;
  display: flex;
  align-items: center;
  padding: 16px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--border);
  background: rgba(8, 12, 18, 0.88);
  backdrop-filter: blur(16px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(226, 193, 109, 0.45);
  border-radius: 13px;
  background: linear-gradient(145deg, #f2d989, #a98534);
  color: #12100a;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(226, 193, 109, 0.13);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 13px;
  letter-spacing: 0.12em;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.page {
  width: min(1180px, calc(100% - 28px));
  margin: 28px auto 64px;
}

.hidden {
  display: none !important;
}

.state-card,
.summary-card,
.pdf-card,
.signing-card,
.signed-card {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(16, 23, 34, 0.98), rgba(12, 18, 27, 0.98));
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.28);
}

.state-card {
  width: min(560px, 100%);
  margin: 12vh auto 0;
  padding: 42px 32px;
  text-align: center;
}

.state-card h1 {
  margin: 20px 0 10px;
  font-size: 26px;
}

.state-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.spinner {
  width: 36px;
  height: 36px;
  margin: auto;
  border: 3px solid rgba(226, 193, 109, 0.18);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.state-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 50%;
  font-size: 22px;
  font-weight: 800;
}

.state-icon-error {
  border: 1px solid rgba(255, 119, 119, 0.35);
  color: var(--danger);
}

.state-icon-success {
  border: 1px solid rgba(100, 214, 154, 0.4);
  background: rgba(100, 214, 154, 0.08);
  color: var(--success);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.summary-card,
.signing-card {
  padding: clamp(22px, 4vw, 34px);
  margin-bottom: 20px;
}

.summary-heading,
.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

h1,
h2 {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 36px);
}

h2 {
  font-size: 24px;
}

.status-badge,
.step-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 11px;
  border: 1px solid rgba(226, 193, 109, 0.3);
  border-radius: 999px;
  background: rgba(226, 193, 109, 0.1);
  color: var(--gold);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.details-grid > div {
  min-height: 86px;
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel-2);
}

.details-grid span,
.details-grid strong {
  display: block;
}

.details-grid span {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.details-grid strong {
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.45;
}

.actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
}

.button {
  min-height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  font: inherit;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.button-primary {
  border-color: var(--gold);
  background: linear-gradient(180deg, var(--gold-light), #d8b75f);
  color: #12100a;
}

.button-primary:hover:not(:disabled) {
  filter: brightness(1.05);
}

.button-secondary {
  border-color: #344154;
  background: #171f2a;
  color: var(--text);
}

.notice,
.legal-note {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.notice {
  margin: 14px 0 0;
}

.pdf-card {
  overflow: hidden;
  margin-bottom: 20px;
  background: #fff;
}

iframe {
  width: 100%;
  min-height: 760px;
  display: block;
  border: 0;
  background: white;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 28px;
}

.field span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.field input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1px solid #334052;
  border-radius: 11px;
  outline: none;
  background: #0b1119;
  color: var(--text);
}

.field input:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(226, 193, 109, 0.1);
}

.field input[readonly] {
  color: #a8b1bf;
  background: #0d131c;
}

.signature-block {
  margin-top: 22px;
}

.signature-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.signature-header strong,
.signature-header span {
  display: block;
}

.signature-header span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.text-button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--gold);
  cursor: pointer;
  font-weight: 700;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 1px solid #394658;
  border-radius: 14px;
  background: #fff;
}

#signature-canvas {
  width: 100%;
  height: 240px;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.signature-line-label {
  position: absolute;
  right: 18px;
  bottom: 10px;
  color: #7b8491;
  font-size: 11px;
  pointer-events: none;
}

.consent {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  align-items: flex-start;
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 13px;
  background: #0d131c;
  color: #c7ced8;
  font-size: 13px;
  line-height: 1.55;
}

.consent input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--gold);
}

.sign-button {
  width: 100%;
  margin-top: 18px;
}

.form-error {
  margin-top: 14px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 119, 119, 0.35);
  border-radius: 10px;
  background: rgba(255, 119, 119, 0.08);
  color: #ffaaaa;
  font-size: 13px;
}

.legal-note {
  margin: 12px 0 0;
  text-align: center;
}

.signed-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 24px;
}

.signed-card h2 {
  margin-bottom: 5px;
}

.signed-card p {
  margin: 0;
  color: var(--muted);
}

.success-button {
  margin-top: 22px;
}

@media (max-width: 860px) {
  .details-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 650px) {
  .page {
    width: min(100% - 18px, 1180px);
    margin-top: 14px;
  }

  .summary-heading,
  .section-heading,
  .actions,
  .signature-header {
    flex-direction: column;
    align-items: stretch;
  }

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

  .button {
    width: 100%;
  }

  iframe {
    min-height: 620px;
  }

  #signature-canvas {
    height: 210px;
  }
}
