:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #eef6f8;
  --ink: #182230;
  --muted: #607085;
  --line: #d8e1eb;
  --brand: #106b7f;
  --brand-strong: #084e5f;
  --accent: #d96c45;
  --shadow: 0 18px 55px rgba(24, 34, 48, 0.12);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding-bottom: 58px;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(16, 107, 127, 0.10), rgba(16, 107, 127, 0) 360px),
    var(--bg);
}

button,
select,
input {
  font: inherit;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 24px;
  align-items: end;
  margin-bottom: 24px;
}

h1 {
  max-width: 780px;
  margin: 0;
  font-size: clamp(1rem, 2vw, 3rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 0 14px;
  color: #ffffff;
  background: var(--brand);
  cursor: pointer;
  font-weight: 750;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.btn:hover {
  background: var(--brand-strong);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(16, 107, 127, 0.18);
}

.btn.secondary {
  color: var(--brand-strong);
  background: #ffffff;
  border-color: var(--line);
}

.btn.secondary:hover {
  background: var(--surface-2);
  box-shadow: none;
}

.btn.icon {
  width: 40px;
  min-width: 40px;
  padding: 0;
}

.btn svg,
.value-link svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.3;
}

.notice {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  margin: 0 0 18px;
  padding: 14px 16px;
  border: 1px solid rgba(217, 108, 69, 0.34);
  border-radius: var(--radius);
  background: #fff7f2;
  color: #6d3b25;
  line-height: 1.45;
}

.notice strong {
  color: #4f2819;
}

.notice svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.3;
}

.generator {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: #334155;
  background: #edf5f7;
  font-size: 0.76rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

tbody tr {
  background: #ffffff;
}

tbody tr:nth-child(even) {
  background: #f8fbfc;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.doc-name {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.doc-name strong {
  font-size: 1rem;
}

.doc-name span {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.controls {
  display: grid;
  gap: 10px;
}

.select-wrap {
  position: relative;
  display: block;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 36px 0 12px;
  color: var(--ink);
  background: #ffffff;
  appearance: none;
  cursor: pointer;
}

.select-wrap::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  width: max-content;
  min-height: 38px;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.track {
  width: 50px;
  height: 28px;
  border: 1px solid #b8c6d4;
  border-radius: 999px;
  background: #e7edf3;
  transition: background 160ms ease, border-color 160ms ease;
}

.track::after {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  margin: 2px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(24, 34, 48, 0.22);
  transition: transform 160ms ease;
}

.switch input:checked + .track {
  border-color: var(--brand);
  background: var(--brand);
}

.switch input:checked + .track::after {
  transform: translateX(22px);
}

.plain-option {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  color: var(--muted);
  font-weight: 700;
}

.value-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.value-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  flex: 1;
  max-width: 100%;
  min-height: 40px;
  border: 1px solid rgba(16, 107, 127, 0.20);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--brand-strong);
  background: rgba(16, 107, 127, 0.07);
  font-size: 0.95rem;
  font-weight: 750;
  text-decoration: none;
  overflow: hidden;
  cursor: pointer;
}

tr:not([data-doc="nome"]) .value-link {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.value-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

tr[data-doc="certidao"] .value-link {
  font-size: 0.82rem;
}

tr[data-doc="certidao"] .value-text {
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  background: #fbfdfe;
  color: var(--muted);
  font-size: 0.88rem;
}

.bulk-generator {
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.bulk-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 18px 16px;
  background: #fbfdfe;
  cursor: pointer;
  list-style: none;
}

.bulk-generator[open] .bulk-header {
  border-bottom: 1px solid var(--line);
}

.bulk-header::-webkit-details-marker {
  display: none;
}

.bulk-header h2 {
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: 0;
}

.bulk-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.accordion-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--brand-strong);
  background: #ffffff;
  transition: transform 160ms ease, background 160ms ease;
}

.accordion-indicator svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.4;
}

.bulk-generator[open] .accordion-indicator {
  transform: rotate(180deg);
  background: var(--surface-2);
}

.bulk-content {
  display: grid;
}

.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
  padding: 18px 18px 0;
}

.bulk-controls {
  display: grid;
  grid-template-columns: minmax(120px, 160px) minmax(220px, auto) 1fr;
  gap: 16px;
  align-items: start;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.field,
.checkbox-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0;
}

.field input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  color: var(--ink);
  background: #ffffff;
}

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
  min-height: 40px;
  padding-top: 24px;
  color: var(--ink);
  font-size: 0.94rem;
  font-weight: 700;
}

.checkbox-field input,
.column-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--brand);
}

.column-picker legend {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
  letter-spacing: 0;
}

.column-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.column-option {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 10px;
  background: #ffffff;
  color: var(--ink);
  font-weight: 700;
  cursor: pointer;
}

.batch-result {
  position: relative;
  overflow: auto;
  max-height: 460px;
}

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

.batch-table th,
.batch-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

.batch-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf5f7;
  color: #334155;
  font-size: 0.76rem;
  text-transform: uppercase;
}

.batch-table td {
  color: var(--ink);
  font-size: 0.92rem;
}

.empty-result {
  margin: 0;
  padding: 22px 18px;
  color: var(--muted);
}

.empty-result.hidden {
  display: none;
}

.contact-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 8;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 -10px 28px rgba(24, 34, 48, 0.10);
  font-size: 0.92rem;
  font-weight: 700;
}

.contact-footer a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid rgba(16, 107, 127, 0.20);
  border-radius: var(--radius);
  padding: 0 10px;
  color: var(--brand-strong);
  background: rgba(16, 107, 127, 0.07);
  text-decoration: none;
}

.contact-footer svg {
  width: 17px;
  height: 17px;
  stroke-width: 2.3;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 70px;
  z-index: 10;
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  border-radius: var(--radius);
  padding: 12px 14px;
  color: #ffffff;
  background: #172033;
  box-shadow: 0 16px 34px rgba(24, 34, 48, 0.25);
  font-weight: 750;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.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;
}

@media (max-width: 840px) {
  .page {
    width: min(100% - 22px, 720px);
    padding-top: 22px;
  }

  .hero {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .generator {
    border-radius: var(--radius);
  }

  .table,
  thead,
  tbody,
  tr,
  th,
  td {
    display: block;
  }

  thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }

  tr {
    padding: 14px;
    border-bottom: 1px solid var(--line);
  }

  tbody tr:nth-child(even) {
    background: #ffffff;
  }

  td {
    display: grid;
    grid-template-columns: 112px minmax(0, 1fr);
    gap: 12px;
    align-items: center;
    border-bottom: 0;
    padding: 8px 0;
  }

  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 0.74rem;
    font-weight: 850;
    letter-spacing: 0;
    text-transform: uppercase;
  }

  .value-cell {
    align-items: stretch;
  }

  .value-link {
    min-width: 0;
    flex: 1;
  }

  .footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .bulk-header {
    flex-direction: column;
  }

  .bulk-actions,
  .bulk-actions .btn {
    width: 100%;
  }

  .bulk-controls {
    grid-template-columns: 1fr;
  }

  .checkbox-field {
    padding-top: 0;
  }
}

@media (max-width: 520px) {
  body {
    padding-bottom: 78px;
  }

  .hero-actions,
  .btn {
    width: 100%;
  }

  td {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .value-cell {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 40px;
  }

  .contact-footer {
    flex-direction: column;
    gap: 6px;
    min-height: 70px;
  }
}
