/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg:               #f5f4f0;
  --surface:          #ffffff;
  --border:           #e5e4e0;
  --border-focus:     #a0a09e;
  --text-primary:     #1a1917;
  --text-secondary:   #6b6a67;
  --text-placeholder: #b5b3af;
  --accent:           #2f80ed;
  --accent-light:     #eaf2fd;
  --accent-hover:     #1a6fd4;
  --danger:           #e03e3e;
  --danger-light:     #fdf2f2;
  --success:          #0c8346;
  --success-light:    #edf7f1;
  --warning:          #c17d10;
  --warning-light:    #fdf6ec;
  --shadow-sm:        0 1px 2px rgba(0,0,0,.06), 0 1px 3px rgba(0,0,0,.04);
  --shadow-md:        0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:        0 8px 32px rgba(0,0,0,.10);
  --radius:           10px;
  --radius-sm:        6px;
  --font:             'Inter', system-ui, -apple-system, sans-serif;
  --transition:       .15s ease;
}

body {
  font-family: var(--font);
  background-color: var(--bg);
  background-image: radial-gradient(rgba(0,0,0,.07) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--text-primary);
  min-height: 100vh;
  padding: 56px 16px 96px;
  -webkit-font-smoothing: antialiased;
}

/* ─── Top Progress Bar ──────────────────────────────────────── */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: transparent;
  z-index: 1000;
}
.top-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #7db8f7 100%);
  width: 0%;
  transition: width .5s cubic-bezier(.4, 0, .2, 1);
  border-radius: 0 2px 2px 0;
}

/* ─── Entrance animations ───────────────────────────────────── */
@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

.container > *:nth-child(1) { animation: cardIn .45s ease .00s both; }
.container > *:nth-child(2) { animation: cardIn .45s ease .08s both; }
.container > *:nth-child(3) { animation: cardIn .45s ease .16s both; }
.container > *:nth-child(4) { animation: cardIn .45s ease .24s both; }
.container > *:nth-child(5) { animation: cardIn .45s ease .32s both; }
.container > *:nth-child(6) { animation: cardIn .45s ease .40s both; }
.container > *:nth-child(7) { animation: cardIn .45s ease .48s both; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}
.shake { animation: shake .35s ease; }

/* ─── Layout ────────────────────────────────────────────────── */
.container { max-width: 740px; margin: 0 auto; }

/* ─── Header ────────────────────────────────────────────────── */
.header { margin-bottom: 40px; }

.header__badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .1em;
  background: var(--accent-light);
  border: 1px solid #c2daf9;
  border-radius: 20px;
  padding: 4px 10px;
  margin-bottom: 14px;
}

.header h1 {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -.04em;
  line-height: 1.2;
  background: linear-gradient(135deg, #1a1917 55%, #3a5a8a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header p {
  margin-top: 10px;
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.65;
  max-width: 520px;
}

/* ─── Steps ─────────────────────────────────────────────────── */
.steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 20px;
  box-shadow: var(--shadow-sm);
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}
.step:not(:last-child)::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
  margin: 0 6px;
  transition: background .3s;
}
.step.done:not(:last-child)::after { background: var(--success); opacity: .4; }
.step__num {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-placeholder);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .25s, border-color .25s, color .25s, transform .25s;
}
.step__label {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-placeholder);
  white-space: nowrap;
  transition: color .25s;
}
.step.active .step__num  { background: var(--accent); border-color: var(--accent); color: #fff; transform: scale(1.08); }
.step.active .step__label { color: var(--accent); font-weight: 600; }
.step.done .step__num    { background: var(--success); border-color: var(--success); color: #fff; }
.step.done .step__label  { color: var(--success); }

/* ─── Card ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  /* overflow: visible para não cortar popovers absolutamente posicionados */
  overflow: visible;
  transition: box-shadow .2s, border-color .2s, transform .2s;
}
.card:hover          { box-shadow: var(--shadow-md); border-color: #d8d7d3; }
.card:focus-within   { box-shadow: var(--shadow-md); border-color: #c2daf9; }

.card__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafaf8, #f7f6f2);
  /* garante que o fundo do header respeite o border-radius do card */
  border-radius: var(--radius) var(--radius) 0 0;
}
.card__icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent-light);
  border: 1px solid #c2daf9;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
}
.card__header-text { flex: 1; }
.card__title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
.card__subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 1px;
}
.card__step-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-placeholder);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 2px 8px;
}

.card__body { padding: 24px; }

/* ─── Form Fields ───────────────────────────────────────────── */
.form-row {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.form-row:last-child { margin-bottom: 0; }
.form-row.cols-2 { grid-template-columns: 1fr 1fr; }
.form-row.cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.field { display: flex; flex-direction: column; gap: 5px; }

label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: .01em;
}
label .required { color: var(--danger); margin-left: 2px; }

input[type="text"],
input[type="date"],
textarea {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  width: 100%;
}
input[type="text"]:hover,
input[type="date"]:hover  { border-color: var(--border-focus); background: #fefefe; }
input[type="text"]:focus,
input[type="date"]:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47,128,237,.10);
  background: #fff;
}
input[type="text"]::placeholder,
textarea::placeholder { color: var(--text-placeholder); }

input.error {
  border-color: var(--danger) !important;
  background: var(--danger-light);
  box-shadow: 0 0 0 3px rgba(224,62,62,.08) !important;
}
input.success {
  border-color: var(--success) !important;
  background: var(--success-light);
}

.field-hint {
  font-size: 11.5px;
  color: var(--text-placeholder);
  display: flex;
  align-items: center;
  gap: 4px;
}
.field-hint.error-msg   { color: var(--danger); }
.field-hint.success-msg { color: var(--success); }

/* ─── CNPJ Spinner ──────────────────────────────────────────── */
.cnpj-wrapper { position: relative; }
.cnpj-wrapper input { padding-right: 38px; }
.cnpj-spinner {
  position: absolute;
  right: 11px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: none;
}
.cnpj-spinner.active { display: block; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

/* ─── Company Auto-filled ───────────────────────────────────── */
.company-info {
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-top: 10px;
  border: 1.5px solid #c2daf9;
  display: none;
  animation: fadeSlide .25s ease;
}
.company-info.visible { display: block; }

.company-info-header {
  background: var(--accent);
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
}

.company-info-body { background: var(--accent-light); padding: 12px 14px; }

.company-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 6px;
  padding: 5px 0;
  border-bottom: 1px solid #d8ecfd;
  font-size: 13px;
  align-items: baseline;
}
.company-row:last-child { border-bottom: none; padding-bottom: 0; }
.company-row-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #3a6da8;
}
.company-row-value { color: var(--text-primary); font-weight: 500; }
.company-row-value strong { font-weight: 700; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Signature Canvas ──────────────────────────────────────── */
.signature-area {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 31px,
    #f0eeea 31px,
    #f0eeea 32px
  );
  position: relative;
  cursor: crosshair;
  transition: border-color .2s, background .2s;
}
.signature-area:hover { border-color: var(--accent); }
.signature-area.signed {
  border-style: solid;
  border-color: #c5e5d5;
  background: #f9fef9;
}
#signatureCanvas {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: none;
  position: relative;
  z-index: 1;
}
.signature-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  color: var(--text-placeholder);
  font-size: 13px;
  gap: 8px;
  transition: opacity .2s;
  z-index: 2;
}
.signature-placeholder svg { opacity: .35; }
.signature-placeholder span { font-size: 12.5px; }
.signature-placeholder.hidden { opacity: 0; }

.signature-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}
.signature-status {
  margin-left: auto;
  font-size: 12px;
  color: var(--success);
  display: none;
  align-items: center;
  gap: 4px;
  font-weight: 500;
}
.signature-status.visible { display: flex; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background .15s, transform .1s, box-shadow .15s, color .15s, border-color .15s;
  white-space: nowrap;
  text-decoration: none;
  letter-spacing: -.01em;
}
.btn:active { transform: scale(.96); }

.btn-primary {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 2px rgba(47,128,237,.3), 0 2px 8px rgba(47,128,237,.2);
}
.btn-primary:hover {
  background: var(--accent-hover);
  box-shadow: 0 2px 4px rgba(47,128,237,.4), 0 4px 16px rgba(47,128,237,.3);
  transform: translateY(-1px);
}
.btn-primary:active { transform: scale(.96) translateY(0); }

.btn-ghost {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { background: var(--bg); color: var(--text-primary); border-color: var(--border-focus); }

.btn-sm  { padding: 6px 12px; font-size: 12.5px; }
.btn-lg  { padding: 13px 28px; font-size: 15px; font-weight: 600; letter-spacing: -.02em; }

/* ─── Actions bar ───────────────────────────────────────────── */
.actions-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  flex-wrap: wrap;
  transition: border-color .3s, background .3s, box-shadow .3s;
}
.actions-card .btn-primary { flex: 1; justify-content: center; }

.actions-card.ready {
  border-color: #b3e0c7;
  background: linear-gradient(to right, #f6fef9, #eff8ff);
  box-shadow: 0 2px 12px rgba(12,131,70,.08);
}
.actions-card.ready .btn-primary {
  background: linear-gradient(135deg, #0c8346 0%, #1a7fd4 100%);
  box-shadow: 0 1px 2px rgba(12,131,70,.3), 0 2px 12px rgba(12,131,70,.2);
}
.actions-card.ready .btn-primary:hover {
  background: linear-gradient(135deg, #0a7040 0%, #1668b5 100%);
}

.ready-label {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  font-size: 12px;
  font-weight: 600;
  color: var(--success);
  background: var(--success-light);
  border: 1px solid #b3e0c7;
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  animation: fadeSlide .2s ease;
}

/* ─── Preview / Document ────────────────────────────────────── */
#previewSection { display: none; margin-top: 8px; }
#previewSection.visible { display: block; animation: fadeSlide .3s ease; }

.preview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-md);
}
.preview-card-header {
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(to bottom, #fafaf8, #f7f6f2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.preview-card-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.preview-card-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.preview-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.preview-card-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
}
.preview-badge {
  font-size: 11px;
  font-weight: 600;
  color: var(--success);
  background: var(--success-light);
  border: 1px solid #b3e0c7;
  border-radius: 20px;
  padding: 2px 8px;
}

.preview-paper-bg {
  background: #dedad3;
  padding: 36px 28px;
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 29px, rgba(0,0,0,.03) 29px, rgba(0,0,0,.03) 30px);
}

.doc-preview {
  background: #fff;
  max-width: 640px;
  margin: 0 auto;
  padding: 56px 64px;
  box-shadow:
    0 2px 4px rgba(0,0,0,.06),
    0 8px 24px rgba(0,0,0,.10),
    0 24px 64px rgba(0,0,0,.10);
  font-size: 13.5px;
  line-height: 1.8;
  color: #111;
  position: relative;
  border-radius: 2px;
  font-family: 'Georgia', 'Times New Roman', serif;
}
.doc-preview::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, #1a3a6b 0%, #2f80ed 50%, #1a3a6b 100%);
}

.doc-preview .doc-date {
  text-align: right;
  font-size: 12px;
  color: #666;
  margin-bottom: 28px;
  font-family: var(--font);
}
.doc-preview .doc-title {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .09em;
  margin-bottom: 6px;
  color: #111;
}
.doc-preview .doc-subtitle {
  text-align: center;
  font-size: 11px;
  color: #888;
  font-family: var(--font);
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 2px solid #222;
}
.doc-preview .doc-section { margin-bottom: 18px; }
.doc-preview .doc-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: #999;
  font-family: var(--font);
  margin-bottom: 3px;
}
.doc-preview .doc-value {
  font-size: 13.5px;
  border-bottom: 1px solid #e0e0e0;
  padding-bottom: 4px;
  min-height: 24px;
  color: #111;
}
.doc-preview .doc-divider {
  border: none;
  border-top: 1px solid #e0e0e0;
  margin: 22px 0;
}
.doc-preview .doc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 28px;
  margin-bottom: 18px;
}
.doc-preview .doc-body {
  margin: 24px 0;
  text-align: justify;
  line-height: 2.1;
  color: #1a1a1a;
}
.doc-preview .doc-body p + p { margin-top: 16px; }
.doc-preview .doc-sig-block {
  margin-top: 56px;
  display: flex;
  justify-content: center;
}
.doc-preview .doc-sig-inner { text-align: center; min-width: 280px; }
.doc-preview .doc-sig-line {
  border-top: 1.5px solid #333;
  padding-top: 10px;
  font-size: 13px;
  color: #111;
  font-family: var(--font);
}
.doc-preview .doc-sig-line small { color: #888; font-size: 11px; }
.doc-preview .sig-img { max-height: 72px; margin-bottom: 6px; display: block; margin-inline: auto; }

/* ─── Toast ─────────────────────────────────────────────────── */
#toast {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1a1917;
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 4px 24px rgba(0,0,0,.24);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), background .2s;
  z-index: 1000;
  pointer-events: none;
  white-space: nowrap;
  display: flex;
  align-items: center;
  gap: 8px;
}
#toast.show { transform: translateX(-50%) translateY(0); }
#toast[data-type="success"] { background: #0a6e3a; }
#toast[data-type="error"]   { background: #b52e2e; }
#toast[data-type="info"]    { background: #1a1917; }
#toast[data-type="warning"] { background: #9a6208; }

/* ─── Help Button & Popover ─────────────────────────────────── */
.label-row { display: flex; align-items: center; gap: 6px; }

.help-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 1.5px solid var(--border-focus);
  background: transparent;
  color: var(--text-secondary);
  font-size: 9.5px;
  font-weight: 700;
  cursor: pointer;
  padding: 0;
  transition: border-color var(--transition), background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.help-btn:hover,
.help-btn.active {
  border-color: var(--accent);
  background: var(--accent-light);
  color: var(--accent);
}

.help-anchor { position: relative; display: inline-flex; }

.help-popover {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  width: 284px;
  background: #18171a;
  color: #e8e8e8;
  border-radius: 10px;
  padding: 14px 16px;
  font-size: 12.5px;
  line-height: 1.65;
  box-shadow: 0 8px 32px rgba(0,0,0,.30);
  z-index: 200;
  pointer-events: none;
  font-family: var(--font);
}
.help-popover::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #18171a;
}
.help-popover.visible     { display: block; pointer-events: auto; animation: fadeSlide .15s ease; }
.help-popover.below       { bottom: auto; top: calc(100% + 8px); }
.help-popover.below::after {
  top: auto; bottom: 100%;
  border-top-color: transparent;
  border-bottom-color: #18171a;
}
.help-popover.align-left         { left: 0; transform: none; }
.help-popover.align-left::after  { left: 12px; transform: none; }
.help-popover.align-right        { left: auto; right: 0; transform: none; }
.help-popover.align-right::after { left: auto; right: 12px; transform: none; }

.help-popover strong       { display: block; color: #fff; font-size: 13px; margin-bottom: 8px; }
.help-popover .help-item   { display: flex; gap: 9px; margin-bottom: 8px; }
.help-popover .help-item:last-child { margin-bottom: 0; }
.help-popover .help-icon   { flex-shrink: 0; margin-top: 1px; color: #7dbfff; display: flex; align-items: flex-start; }
.help-popover .help-text b { color: #fff; }
.help-popover hr           { border: none; border-top: 1px solid #2e2e2e; margin: 8px 0; }
.help-popover .help-tag {
  display: inline-block;
  background: #262626;
  border: 1px solid #3a3a3a;
  border-radius: 4px;
  padding: 1px 6px;
  font-family: monospace;
  font-size: 11px;
  color: #93c5fd;
  margin-top: 2px;
}

/* ─── Date Suggestion Box ───────────────────────────────────── */
.date-suggestion {
  margin-top: 8px;
  background: var(--warning-light);
  border: 1.5px solid #f0d090;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: fadeSlide .2s ease;
}
.date-suggestion-text {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  font-size: 12.5px;
  color: var(--warning);
  font-weight: 500;
  line-height: 1.5;
}
.date-suggestion-text svg { flex-shrink: 0; margin-top: 1px; }
.date-suggestion-actions { display: flex; gap: 7px; flex-wrap: wrap; }

.date-confirm-btn {
  background: var(--warning);
  color: #fff;
  border: none;
}
.date-confirm-btn:hover { background: #a06808; }

.date-edit-btn {
  background: transparent;
  color: var(--warning);
  border: 1.5px solid #f0d090;
}
.date-edit-btn:hover { background: #fef3dc; }

/* ─── Date Range ────────────────────────────────────────────── */
.date-range {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 8px;
}
.date-range-col { display: flex; flex-direction: column; gap: 4px; }
.date-range-col-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-placeholder);
}
.date-range-sep {
  color: var(--text-placeholder);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  padding-bottom: 10px;
}

input[type="date"] {
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  width: 100%;
  cursor: pointer;
}
input[type="date"]:hover  { border-color: var(--border-focus); background: #fefefe; }
input[type="date"]:focus  { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47,128,237,.10); background: #fff; }
input[type="date"].error  { border-color: var(--danger) !important; background: var(--danger-light); }
input[type="date"].success { border-color: var(--success) !important; background: var(--success-light); }

/* ─── Acessibilidade: utilitários globais ───────────────────── */

/* Texto apenas para leitores de tela */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* Skip-link */
.skip-link {
  position: absolute;
  top: -100%;
  left: 12px;
  background: var(--accent);
  color: #fff;
  padding: 10px 18px;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  text-decoration: none;
  z-index: 9999;
  transition: top .15s;
}
.skip-link:focus { top: 3px; }

/* Label badge para campos opcionais */
.field-optional {
  font-size: 11px;
  font-weight: 400;
  color: var(--text-placeholder);
  margin-left: 4px;
}

/* Focus ring visível para navegação por teclado */
:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 2px;
}
input:focus-visible,
input[type="date"]:focus-visible,
textarea:focus-visible {
  outline: none; /* handled by box-shadow + border-color */
}
.btn:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
  box-shadow: 0 0 0 5px rgba(47,128,237,.18);
}
.help-btn:focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 3px;
}

/* Alvos de toque mínimos (WCAG 2.5.5) */
input[type="text"],
input[type="date"] { min-height: 44px; }
.btn                { min-height: 44px; }
.btn-sm             { min-height: 36px; }
.help-btn           { width: 20px; height: 20px; font-size: 10px; }

/* ─── Responsive — Tablet (≤ 900px) ────────────────────────── */
@media (max-width: 900px) {
  body { padding: 44px 24px 96px; }
  .container { max-width: 100%; }
}

/* ─── Responsive — Celular grande / Tablet pequeno (≤ 640px) ── */
@media (max-width: 640px) {
  body { padding: 20px 12px 136px; } /* espaço extra para barra sticky */

  .header { margin-bottom: 24px; }
  .header h1 { font-size: 22px; letter-spacing: -.03em; }
  .header p  { font-size: 14px; }

  /* Steps: esconder labels, mostrar apenas bolinhas */
  .steps { padding: 10px 14px; gap: 0; }
  .steps .step__label { display: none; }
  .steps .step:not(:last-child)::after { margin: 0 4px; }

  /* Cards */
  .card__header { padding: 14px 16px; }
  .card__subtitle { display: none; }
  .card__body { padding: 16px; }

  /* Campos: sempre coluna única */
  .form-row.cols-2,
  .form-row.cols-3 { grid-template-columns: 1fr; }

  /* Range de datas: empilhar verticalmente */
  .date-range { grid-template-columns: 1fr; gap: 10px; }
  .date-range-sep { display: none; }

  /* Assinatura: canvas maior para o dedo */
  #signatureCanvas { height: 190px; }

  /* Popovers: largura máxima e ancoragem à direita */
  .help-popover {
    width: min(290px, calc(100vw - 40px));
    left: auto;
    right: 0;
    transform: none;
  }
  .help-popover::after { left: auto; right: 14px; transform: none; }
  .help-popover.align-left { left: 0; right: auto; }
  .help-popover.align-left::after { left: 14px; right: auto; }

  /* Barra de ações: sticky no rodapé */
  .actions-card {
    position: sticky;
    bottom: 0;
    z-index: 100;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    margin-bottom: 0;
    padding: 12px 16px;
    box-shadow: 0 -4px 20px rgba(0,0,0,.12);
    background: var(--surface);
  }
  .actions-card.ready {
    box-shadow: 0 -4px 20px rgba(12,131,70,.15);
  }
  .actions-card .btn-lg { flex: 1; justify-content: center; }
  .ready-label { font-size: 11px; }

  /* Preview */
  .preview-paper-bg { padding: 18px 10px; }
  .doc-preview { padding: 28px 20px; font-size: 12.5px; }
  .doc-preview .doc-grid { grid-template-columns: 1fr; }
  .preview-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 14px 16px;
  }
  .preview-card-header-right {
    width: 100%;
    display: flex;
    gap: 8px;
  }
  .preview-card-header-right .btn {
    flex: 1;
    justify-content: center;
  }
}

/* ─── Responsive — Celular pequeno (≤ 400px) ────────────────── */
@media (max-width: 400px) {
  body { padding: 16px 10px 136px; }
  .header h1 { font-size: 19px; }
  .card__step-badge { display: none; }
  .card__icon { width: 28px; height: 28px; }
  .card__body { padding: 14px; }
  .card__header { padding: 12px 14px; gap: 8px; }
  .doc-preview { padding: 20px 14px; font-size: 12px; }
  .actions-card { padding: 10px 12px; gap: 8px; }
  .btn-lg { font-size: 14px; padding: 11px 16px; }
  .date-suggestion-actions { flex-direction: column; }
  .date-suggestion-actions .btn { width: 100%; justify-content: center; }
}

/* ─── Preferência: reduzir animações ────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .top-bar-fill { transition: none !important; }
}

/* ─── Preferência: alto contraste ──────────────────────────── */
@media (prefers-contrast: high) {
  :root {
    --border:           #555;
    --border-focus:     #111;
    --text-secondary:   #333;
    --text-placeholder: #555;
    --shadow-sm:        none;
    --shadow-md:        none;
    --shadow-lg:        none;
  }
  input[type="text"],
  input[type="date"] { border-width: 2px; }
  .card  { border-width: 2px; }
  .btn   { border-width: 2px; }
  .steps { border-width: 2px; }
  input.success { border-width: 2.5px; }
  input.error   { border-width: 2.5px; }
}

/* ─── Print ─────────────────────────────────────────────────── */
@media print {
  body {
    background: #fff !important;
    background-image: none !important;
    padding: 0 !important;
  }
  .top-bar, .header, .steps, .card, .actions-card,
  .preview-card-header, .preview-paper-bg > *:not(.doc-preview) { display: none !important; }
  #previewSection { display: block !important; }
  .preview-card { border: none !important; box-shadow: none !important; }
  .preview-paper-bg { background: #fff !important; padding: 0 !important; }
  .doc-preview {
    box-shadow: none !important;
    max-width: 100% !important;
    padding: 12mm 20mm !important;
  }
}
