:root {
  --bg: #f4f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #111827;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #0f766e;
  --brand-dark: #115e59;
  --brand-soft: #ccfbf1;
  --danger: #b91c1c;
  --shadow: 0 24px 70px rgba(15, 23, 42, .10);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(circle at 10% -10%, rgba(15, 118, 110, .14), transparent 30rem),
    radial-gradient(circle at 95% 10%, rgba(37, 99, 235, .08), transparent 24rem),
    var(--bg);
}

button, input { font: inherit; }
button { border: 0; cursor: pointer; }

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 36px 0 72px;
}

.search-panel {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: 28px;
  align-items: end;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid rgba(226, 232, 240, .9);
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.badge, .report-kicker {
  display: inline-flex;
  width: fit-content;
  padding: 7px 11px;
  border-radius: 999px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  max-width: 620px;
  margin-bottom: 12px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: .98;
  letter-spacing: -.055em;
}
.brand-block p {
  max-width: 650px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.65;
}

.search-form {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}
.search-form label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.input-action {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}
input {
  width: 100%;
  min-height: 52px;
  padding: 14px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}
input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, .12);
}
.search-form small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
}

button {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 16px;
  color: white;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
  font-weight: 800;
  transition: transform .2s, filter .2s, opacity .2s;
}
button:hover { transform: translateY(-1px); filter: brightness(1.03); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-secondary {
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line-strong);
  box-shadow: none;
}

.hidden { display: none !important; }
.status-area {
  margin-top: 18px;
  padding: 15px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: #fff;
  color: var(--muted);
}
.status-area.error { color: var(--danger); border-color: rgba(185, 28, 28, .25); }
.status-area.success { color: var(--brand-dark); border-color: rgba(15, 118, 110, .25); }

.report-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 22px 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.8);
}
.report-actions strong { display: block; margin-bottom: 3px; }
.report-actions span { color: var(--muted); font-size: 14px; }
.action-buttons { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.report-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.report-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 30px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(135deg, #ffffff, #f8fafc);
}
.report-header h2 {
  margin: 12px 0 0;
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.08;
  letter-spacing: -.03em;
}
.report-cnpj {
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--brand-dark);
  background: #fff;
  font-weight: 900;
  white-space: nowrap;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 0;
  padding: 14px;
}
.field-card {
  grid-column: span 12;
  width: 100%;
  min-height: unset;
  text-align: left;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid transparent;
  color: var(--ink);
  background: transparent;
  transition: background .2s, border-color .2s, transform .2s;
}
.field-card:hover {
  background: var(--surface-soft);
  border-color: var(--line);
  transform: translateY(-1px);
}
.field-card.span-3 { grid-column: span 3; }
.field-card.span-4 { grid-column: span 4; }
.field-card.span-6 { grid-column: span 6; }
.field-card.span-8 { grid-column: span 8; }
.field-card.span-12 { grid-column: span 12; }
.field-label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.field-value {
  display: block;
  color: var(--ink);
  font-size: 15px;
  font-weight: 650;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.list-value {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.list-value li {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
}
.partner-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 18px;
  align-items: start;
}
.partner-id {
  color: var(--muted);
  font-weight: 800;
  white-space: nowrap;
}
.partner-meta {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
}

.report-footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 18px 30px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 13px;
}
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 20;
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  padding: 12px 16px;
  border-radius: 999px;
  color: #fff;
  background: #111827;
  box-shadow: 0 18px 40px rgba(15,23,42,.2);
  transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 900px) {
  .search-panel { grid-template-columns: 1fr; }
  .report-actions { align-items: stretch; flex-direction: column; }
  .action-buttons { justify-content: stretch; }
  .action-buttons button { flex: 1; }
  .field-card.span-3, .field-card.span-4, .field-card.span-6, .field-card.span-8 { grid-column: span 12; }
  .report-header { flex-direction: column; }
  .report-cnpj { white-space: normal; }
}

@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .no-print, .toast { display: none !important; }
  .app-shell { width: 100%; padding: 0; }
  .report-card {
    display: block !important;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  .report-header { padding: 0 0 12px; }
  .report-grid { padding: 8px 0; }
  .field-card {
    break-inside: avoid;
    page-break-inside: avoid;
    padding: 10px 8px;
    border-bottom: 1px solid #e5e7eb;
    border-radius: 0;
  }
  .field-card:hover { background: transparent; border-color: transparent; transform: none; }
  .list-value li { background: #fff; }
  .report-footer { padding: 12px 0 0; }
}
