:root {
  color-scheme: light;
  --ink: #17201b;
  --muted: #65716a;
  --line: #d9dfdc;
  --soft: #f5f1ea;
  --panel: #ffffff;
  --brand: #096b5d;
  --brand-dark: #08483f;
  --accent: #b54d27;
  --accent-soft: #fff1e9;
  --good: #0c7a43;
  --wait: #8a5a00;
  --bad: #a02929;
  --shadow: 0 18px 42px rgba(30, 42, 35, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    linear-gradient(115deg, rgba(9, 107, 93, 0.07), rgba(181, 77, 39, 0.05)),
    var(--soft);
  color: var(--ink);
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  min-height: 100vh;
  padding: 32px;
}

.workspace {
  max-width: 1320px;
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.portal-title {
  flex: 1;
  min-width: 280px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2rem, 3.2vw, 3.5rem);
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 1.05rem;
  line-height: 1.2;
}

.eyebrow {
  color: var(--brand);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.notice {
  border-left: 4px solid var(--accent);
  background: rgba(255, 255, 255, 0.68);
  padding: 14px 16px;
  margin-bottom: 18px;
  line-height: 1.45;
}

.portal-grid {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.portal-sidebar {
  position: sticky;
  top: 18px;
  display: grid;
  gap: 12px;
}

.tabs {
  display: grid;
  gap: 8px;
}

.tab-button {
  width: 100%;
  min-height: 70px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.74);
  color: var(--brand-dark);
  display: grid;
  gap: 5px;
  justify-items: start;
  align-content: center;
  text-align: left;
  padding: 12px 14px;
  box-shadow: none;
}

.tab-button.active,
.tab-button:hover {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.tab-button span {
  font-size: 0.95rem;
}

.tab-button small {
  color: currentColor;
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.25;
  opacity: 0.78;
}

.sidebar-note {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  padding: 14px;
}

.sidebar-note strong {
  display: block;
  margin-bottom: 6px;
  color: var(--brand-dark);
  font-size: 0.9rem;
}

.sidebar-note p {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.portal-content {
  min-width: 0;
}

.workflow-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.workflow-step {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
  color: var(--brand-dark);
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  text-align: left;
  font-size: 0.82rem;
  line-height: 1.25;
  box-shadow: none;
}

.workflow-step span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e1efe9;
  color: var(--brand-dark);
  flex: 0 0 auto;
}

.workflow-step.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.workflow-step.active span {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: pageIn 160ms ease-out;
}

@keyframes pageIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-heading {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 2px 2px 0;
}

.page-heading h2 {
  font-size: clamp(1.35rem, 2vw, 2rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.layout {
  display: grid;
  grid-template-columns: minmax(390px, 0.95fr) minmax(430px, 1.05fr);
  gap: 18px;
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.form-panel {
  padding: 22px;
  display: grid;
  gap: 0;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 14px;
}

.section-title:not(:first-child) {
  margin-top: 28px;
}

.section-title span {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e1efe9;
  color: var(--brand-dark);
  font-size: 0.82rem;
  font-weight: 800;
}

.section-title.compact {
  padding: 18px 18px 0;
}

label {
  display: grid;
  align-content: start;
  gap: 7px;
  margin-bottom: 14px;
  color: #29352e;
  font-size: 0.92rem;
  font-weight: 700;
}

.field-hint {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

input,
select,
textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid #cbd3cf;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fbfcfb;
  color: var(--ink);
}

input:focus,
select:focus,
textarea:focus {
  outline: 3px solid rgba(9, 107, 93, 0.18);
  border-color: var(--brand);
}

textarea {
  min-height: 112px;
  resize: vertical;
  line-height: 1.45;
}

.enhanced-select-source {
  display: none;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(138px, 100%), 1fr));
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.segment-option {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  color: #29352e;
  padding: 9px 10px;
  font-size: 0.86rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  overflow-wrap: anywhere;
  box-shadow: none;
}

.segment-option:hover {
  background: #eef8f4;
  color: var(--brand-dark);
}

.segment-option.active {
  border-color: var(--brand);
  background: var(--brand);
  color: #fff;
}

.grid {
  display: grid;
  gap: 12px;
  align-items: start;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stacked-fields {
  display: grid;
  gap: 12px;
  align-content: start;
}

#reportForm .grid.two {
  grid-template-columns: 1fr;
}

.inline-fields {
  display: grid;
  grid-template-columns: minmax(78px, 1fr) max-content minmax(70px, 0.85fr) max-content;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
  min-width: 0;
}

.inline-fields span {
  white-space: nowrap;
}

.grid.two .inline-fields,
.detail-field .inline-fields,
.special-only .inline-fields {
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 8px 10px;
}

.inline-fields input {
  min-width: 0;
  text-align: center;
  font-weight: 800;
}

.switch-row {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr;
}

.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  width: 100%;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfb;
  cursor: pointer;
  transition:
    border-color 140ms ease,
    background 140ms ease,
    box-shadow 140ms ease,
    transform 140ms ease;
}

.check input {
  flex: 0 0 auto;
  width: 18px;
  min-height: 18px;
  accent-color: var(--brand);
}

.check span {
  min-width: 0;
  line-height: 1.35;
}

.check:hover {
  border-color: rgba(9, 107, 93, 0.38);
  box-shadow: 0 10px 24px rgba(30, 42, 35, 0.07);
}

.check:has(input:checked) {
  border-color: rgba(9, 107, 93, 0.55);
  background: #eef8f4;
}

.check:has(input:checked) span {
  color: var(--brand-dark);
}

.special-only {
  display: none;
  margin-top: 14px;
}

.detail-field {
  display: none;
  margin-top: 14px;
}

.special-only.visible,
.detail-field.visible {
  display: grid;
  align-content: start;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 24px;
}

button {
  min-height: 46px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--brand-dark);
}

button.secondary {
  background: transparent;
  color: var(--brand);
  border: 1px solid var(--brand);
}

.results {
  display: grid;
  gap: 18px;
  position: sticky;
  top: 18px;
}

.summary-card {
  padding: 24px;
  min-height: 190px;
  display: grid;
  gap: 12px;
  align-content: start;
}

.summary-card h2 {
  font-size: clamp(1.4rem, 2.5vw, 2.15rem);
  line-height: 1.08;
}

.summary-card p {
  color: var(--muted);
  line-height: 1.5;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 6px;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  background: #fbfcfb;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 4px;
  font-size: 1rem;
}

.rules-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.report-output {
  padding: 18px;
  display: grid;
  gap: 14px;
}

.document-panel {
  overflow: hidden;
}

.document-toolbar,
.document-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 18px 0;
}

.document-tab {
  min-height: 38px;
  background: #fbfcfb;
  border: 1px solid var(--line);
  color: var(--brand-dark);
}

.document-tab.active {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.legal-document {
  display: none;
  margin: 18px;
  padding: 28px;
  min-height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #171717;
  line-height: 1.55;
  box-shadow: inset 0 0 0 1px rgba(9, 107, 93, 0.03);
}

.legal-document.active {
  display: block;
}

.legal-document h1 {
  font-size: 1.35rem;
  line-height: 1.25;
  text-align: center;
  margin: 0 0 22px;
  text-transform: uppercase;
}

.legal-document h2 {
  font-size: 1rem;
  margin: 18px 0 8px;
  text-transform: uppercase;
}

.legal-document p {
  margin: 0 0 12px;
  text-align: justify;
}

.signature-lines {
  display: grid;
  gap: 34px;
  margin-top: 42px;
}

.signature-line {
  border-top: 1px solid #222;
  padding-top: 8px;
  text-align: center;
}

.lgpd-consent {
  border-color: rgba(181, 77, 39, 0.4);
  background: var(--accent-soft);
}

.clients-list {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.client-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
  display: grid;
  gap: 10px;
}

.client-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.client-card h3 {
  margin: 0;
  font-size: 1rem;
}

.client-card p {
  color: var(--muted);
  line-height: 1.45;
}

.client-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.status-select {
  max-width: 220px;
}

.report-block {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fbfcfb;
}

.report-block h3 {
  margin: 0 0 8px;
  font-size: 1rem;
}

.report-block p,
.report-block li {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.report-block ul {
  margin: 0;
  padding-left: 18px;
}

.rule-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  display: grid;
  gap: 8px;
  background: #fbfcfb;
}

.rule-card.best {
  border-color: rgba(9, 107, 93, 0.45);
  background: #eef8f4;
}

.rule-card:hover,
.report-block:hover {
  border-color: rgba(9, 107, 93, 0.28);
}

.rule-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.rule-head h3 {
  margin: 0;
  font-size: 1rem;
}

.tag {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 0.76rem;
  font-weight: 900;
  max-width: 100%;
  overflow-wrap: anywhere;
  text-align: center;
}

.tag.ok {
  color: var(--good);
  background: #dff4e9;
}

.tag.wait {
  color: var(--wait);
  background: #fff1d5;
}

.tag.bad {
  color: var(--bad);
  background: #fbe2e2;
}

.rule-card p,
.rule-card li {
  color: var(--muted);
  line-height: 1.45;
  font-size: 0.9rem;
}

.rule-card ul {
  margin: 0;
  padding-left: 18px;
}

footer {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
  padding: 18px 0 0;
  display: grid;
  gap: 4px;
}

@media (max-width: 920px) {
  .app-shell {
    padding: 18px;
  }

  .topbar,
  .layout,
  .portal-grid {
    display: grid;
  }

  .portal-grid,
  .layout,
  .grid.two,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .portal-sidebar,
  .results {
    position: static;
  }

  .tabs {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .workflow-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tab-button {
    min-height: 82px;
  }

  .segmented {
    grid-template-columns: repeat(auto-fit, minmax(min(160px, 100%), 1fr));
  }

  .status-pill {
    width: fit-content;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 12px;
  }

  .form-panel,
  .summary-card {
    padding: 16px;
  }

  label {
    margin-bottom: 16px;
  }

  .inline-fields {
    grid-template-columns: minmax(0, 1fr) max-content;
    gap: 8px 10px;
  }

  .inline-fields input {
    min-height: 46px;
  }

  .segmented {
    grid-template-columns: 1fr;
  }

  .segment-option {
    text-align: left;
    justify-content: start;
    padding-inline: 12px;
  }

  .check {
    align-items: flex-start;
    padding: 12px;
  }

  .check input {
    margin-top: 2px;
  }

  .actions,
  .rule-head {
    display: grid;
  }

  .tabs {
    grid-template-columns: 1fr;
  }

  .workflow-strip {
    grid-template-columns: 1fr;
  }

  .page-heading {
    display: grid;
  }

  button {
    width: 100%;
  }
}

@media print {
  @page {
    margin: 24mm 14mm 20mm;
  }

  body {
    background: #fff;
    color: #111;
  }

  body::after {
    content: "Relatório gerado por: " attr(data-report-owner);
    position: fixed;
    right: 14mm;
    bottom: 7mm;
    left: 14mm;
    border-top: 1px solid #d8d8d8;
    padding-top: 4mm;
    color: #555;
    font-size: 9pt;
    text-align: right;
    z-index: 9999;
  }

  .app-shell {
    padding: 0;
  }

  .workspace {
    max-width: none;
  }

  .topbar,
  .portal-sidebar,
  .notice,
  .actions,
  .sidebar-note {
    display: none !important;
  }

  .portal-grid,
  .layout,
  .grid.two {
    display: block;
  }

  .portal-content,
  .tab-panel.active,
  .panel,
  .results {
    display: block;
    position: static;
    box-shadow: none;
  }

  .tab-panel {
    display: none !important;
  }

  .tab-panel.active {
    display: block !important;
  }

  .panel,
  .rule-card,
  .report-block,
  .metric {
    border-color: #ddd;
    break-inside: avoid;
  }

  .summary-card,
  .form-panel,
  .rules-list,
  .report-output {
    padding: 10mm 0 0;
  }

  input,
  select,
  textarea,
  .segment-option,
  .check {
    border-color: #ddd;
    background: #fff !important;
    color: #111 !important;
  }
}
