:root {
  --ink: #14181F;
  --ink-soft: #5B5F68;
  --paper: #F6F4EF; /* Fundo geral um pouco mais quente para dar contraste com o cartão */
  --paper-raised: #FFFFFF;
  --seal: #A23B2E;
  --seal-dark: #7E2E23;
  --slate: #3D5A73;
  --sand: #DAD4C4;
  --sand-hairline: rgba(20, 24, 31, 0.08);

  --font-display: 'Fraunces', 'Iowan Old Style', serif;
  --font-body: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

/* ---- Topbar ---- */

.topbar {
  padding: 24px 40px 0;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
}

.brand-mark {
  width: 24px;
  height: 24px;
  color: var(--seal);
}

/* ---- Estágio Principal & Cartão ---- */

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 800px; /* Expandido de 560px para 800px */
  width: 100%;
  margin: 0 auto;
  padding: 40px 24px;
}

.state {
  display: flex;
  flex-direction: column;
  background: var(--paper-raised);
  border: 1px solid var(--sand);
  border-radius: 16px;
  padding: 48px 44px; /* Espaçamento interno confortável */
  box-shadow: 0 10px 30px -10px rgba(20, 24, 31, 0.05);
}

.state[hidden] {
  display: none !important;
}

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--slate);
  margin: 0 0 12px;
}

h1 {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 32px;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 12px;
}

.lede {
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink-soft);
  margin: 0 0 32px;
  max-width: 60ch; /* Expandido o tamanho limite das linhas de texto */
}

/* ---- Campos ---- */

.field {
  margin-bottom: 24px;
}

.field[hidden] {
  display: none !important;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--ink-soft);
  margin-bottom: 8px;
  font-weight: 500;
}

.field select,
.field input {
  width: 100%;
  border: 1px solid var(--sand);
  border-radius: 8px;
  background: #FAF9F6;
  padding: 12px 16px;
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.field select {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235B5F68' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 40px;
  cursor: pointer;
}

.field select:hover,
.field input:hover {
  background: var(--paper-raised);
}

.field input:focus-visible,
.field select:focus-visible,
button:focus-visible,
.dropzone:focus-visible {
  outline: 2px solid var(--slate);
  outline-offset: 2px;
}

.field-pin {
  margin-bottom: 0;
  flex: 1;
}

.field-pin input {
  font-family: var(--font-mono);
  letter-spacing: 0.15em;
  max-width: 220px;
}

/* ---- Dropzone ---- */

.dropzone {
  border: 2px dashed var(--sand);
  border-radius: 12px;
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  color: var(--ink-soft);
  background: #FAF9F6;
  transition: border-color 160ms ease, background 160ms ease;
  margin-bottom: 24px;
}

.dropzone:hover,
.dropzone.is-dragover {
  border-color: var(--seal);
  background: rgba(162, 59, 46, 0.03);
}

.dropzone-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 14px;
  color: var(--slate);
}

.dropzone p {
  margin: 0;
  font-size: 15px;
}

.dropzone strong {
  color: var(--ink);
  font-weight: 600;
}

/* ---- Lista de Arquivos ---- */

.file-list {
  list-style: none;
  margin: 0 0 28px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.file-list[hidden] {
  display: none !important;
}

.file-row,
.file-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  border: 1px solid var(--sand-hairline);
  border-radius: 10px;
  background: #FAF9F6;
  font-size: 14.5px;
}

.file-row .file-name,
.file-list li span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.file-status {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ink-soft);
}

.file-status.is-done { color: #2E6B3B; font-weight: 500; }
.file-status.is-error { color: var(--seal); font-weight: 500; }
.file-status.is-signing { color: var(--slate); font-weight: 500; }

.file-remove {
  background: none;
  border: none;
  color: var(--ink-soft);
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color 120ms ease;
}
.file-remove:hover { color: var(--seal); }

.file-download {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--slate);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  white-space: nowrap;
}

/* ---- Controles & Botões ---- */

.sign-controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-top: 8px;
  margin-bottom: 8px;
  padding-top: 16px;
  border-top: 1px solid var(--sand-hairline);
}

.sign-controls[hidden] {
  display: none !important;
}

.action-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-body);
  font-size: 15px;
  font-weight: 500;
  border-radius: 8px;
  padding: 13px 24px;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, transform 100ms ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--ink);
  color: var(--paper-raised);
}
.btn-primary:hover { background: #262c38; }

.btn-ghost {
  background: transparent;
  border-color: var(--sand);
  color: var(--ink);
}
.btn-ghost:hover { 
  border-color: var(--ink-soft);
  background: #FAF9F6;
}

.btn-seal {
  background: var(--seal);
  color: #fff;
  white-space: nowrap;
}
.btn-seal:hover { background: var(--seal-dark); }
.btn-seal:disabled {
  background: var(--sand);
  color: var(--ink-soft);
  cursor: not-allowed;
}

.seal-icon {
  width: 16px;
  height: 16px;
}

.form-error {
  color: var(--seal);
  font-size: 14px;
  margin-top: 16px;
  padding: 10px 14px;
  background: rgba(162, 59, 46, 0.06);
  border-radius: 6px;
  border: 1px solid rgba(162, 59, 46, 0.15);
}

.form-error[hidden] {
  display: none !important;
}

/* ---- Selo de Conclusão ---- */

.seal-stamp {
  width: 80px;
  height: 80px;
  margin-bottom: 20px;
  color: var(--seal);
}

.seal-stamp svg { width: 100%; height: 100%; }

.seal-ring {
  stroke: currentColor;
  stroke-dasharray: 327;
  stroke-dashoffset: 327;
  animation: seal-ring-draw 480ms cubic-bezier(0.65, 0, 0.35, 1) 80ms forwards;
}

.seal-check {
  stroke: currentColor;
  stroke-dasharray: 64;
  stroke-dashoffset: 64;
  animation: seal-check-draw 320ms cubic-bezier(0.65, 0, 0.35, 1) 460ms forwards;
}

@keyframes seal-ring-draw {
  to { stroke-dashoffset: 0; }
}
@keyframes seal-check-draw {
  to { stroke-dashoffset: 0; }
}

/* ---- Rodapé ---- */

.footer {
  padding: 24px 32px 36px;
  text-align: center;
  margin-top: auto;
}

.footer p {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.5;
  max-width: 560px;
  margin: 0 auto;
}

/* ---- Responsividade ---- */

@media (max-width: 640px) {
  .topbar { padding: 20px 20px 0; }
  .stage { padding: 24px 16px 40px; }
  .state { padding: 28px 20px; }
  h1 { font-size: 26px; }
  .sign-controls { flex-direction: column; align-items: stretch; gap: 16px; }
  .field-pin input { max-width: none; }
  .btn-seal { width: 100%; }
}