:root {
  color-scheme: light;
  --bg: #f4f6f3;
  --panel: #ffffff;
  --line: #d8ded6;
  --text: #1d2520;
  --muted: #607066;
  --accent: #137347;
  --accent-strong: #0b5735;
  --brand-gold: #e7ad22;
  --warn: #9b4b1b;
  --danger: #a43131;
  --focus: #0f6ea8;
  --sidebar: #123326;
  --sidebar-text: #edf5ef;
}

* {
  box-sizing: border-box;
}

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

html {
  min-width: 320px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.4;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 220px;
  background: var(--sidebar);
  color: var(--sidebar-text);
  padding: 16px 12px;
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  min-height: 46px;
  margin-bottom: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  font-weight: 800;
  color: var(--brand-gold);
}

.brand strong,
.brand span {
  display: block;
  line-height: 1.2;
}

.brand span {
  color: #b8c9be;
  font-size: 13px;
}

nav {
  display: grid;
  gap: 2px;
}

.nav-link {
  min-height: 34px;
  display: flex;
  align-items: center;
  padding: 0 10px;
  border-radius: 6px;
  color: #c9d8cf;
  text-decoration: none;
  font-size: 14px;
  font-weight: 650;
}

.nav-link.active,
.nav-link:hover {
  background: #254836;
  color: #ffffff;
}

.main {
  margin-left: 220px;
  width: calc(100% - 220px);
  min-width: 0;
  padding: 16px 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  margin-bottom: 12px;
}

.user-box {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  flex-wrap: wrap;
}

.user-email {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.logout-form {
  margin: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 0;
}

h2 {
  font-size: 17px;
  line-height: 1.3;
}

h3 {
  font-size: 14px;
  line-height: 1.3;
}

.env,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.env--sandbox {
  border-color: #f0b66c;
  color: #8a3f00;
  background: #fff4e5;
  letter-spacing: .02em;
}

.env--production {
  border-color: #cf756f;
  color: #8f1d17;
  background: #fff0ef;
  letter-spacing: .02em;
}

.production-confirmation {
  margin: 12px 0;
  color: #8f1d17;
  font-weight: 800;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.pill.aprovado,
.pill.ativa,
.pill.ativo,
.pill.confirmado,
.pill.aceito,
.pill.criada,
.pill.pending,
.pill.pronta,
.pill.concluida,
.pill.manual-conferida {
  color: #176044;
  background: #e8f4ee;
  border-color: #c7e3d4;
}

.pill.salvo-com-alteracoes {
  color: #0b5f62;
  background: #e5f5f4;
  border-color: #b9dedc;
}

.pill.rascunho,
.pill.em-revisao,
.pill.boleto-nao-emitido,
.pill.aguardando-revisao,
.pill.em-preparacao,
.pill.planejado,
.pill.manual-pendente-calibracao,
.pill.pendente-credencial,
.pill.pendente-cliente-asaas {
  color: var(--warn);
  background: #fff3e8;
  border-color: #f0d5bd;
}

.pill.reimportacao-pendente {
  color: var(--warn);
  background: #fff3e8;
  border-color: #f0d5bd;
}

.pill.aguardando-cliente,
.pill.aguardando-uc,
.pill.uc-nao-identificada,
.pill.uc-nao-cadastrada,
.pill.importada-pendente-conferencia {
  color: var(--warn);
  background: #fff3e8;
  border-color: #f0d5bd;
}

.pill.cancelado,
.pill.rejeitado,
.pill.erro-asaas,
.pill.conflito-uc-cliente,
.pill.inativa,
.pill.inativo {
  color: var(--danger);
  background: #fbeaea;
  border-color: #ecc9c9;
}

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

.rateio-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  background: #f8faf7;
}

.rateio-summary > div {
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.rateio-summary span,
.rateio-summary strong,
.rateio-summary small {
  display: block;
}

.rateio-summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.rateio-summary strong {
  margin-top: 3px;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.rateio-summary small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.rateio-summary__status {
  grid-column: 1 / -1;
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 800;
}

.rateio-summary__status.is-ok {
  color: #176044;
  background: #e8f4ee;
}

.rateio-summary__status.is-warning {
  color: var(--warn);
  background: #fff3e8;
}

.rateio-summary__status.is-danger {
  color: var(--danger);
  background: #fbeaea;
}

.cofre-row {
  background: #f1f8f4;
}

.cofre-row td:first-child {
  box-shadow: inset 4px 0 0 var(--accent);
}

@media (max-width: 760px) {
  .rateio-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

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

.metric {
  min-height: 74px;
  padding: 12px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 4px;
}

.metric strong {
  font-size: 24px;
}

.panel {
  padding: 14px;
  margin-bottom: 10px;
}

.list-panel {
  overflow: hidden;
  padding: 0;
}

.list-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
}

.list-toolbar h2,
.list-toolbar p {
  margin-bottom: 0;
}

.list-toolbar .muted {
  margin-top: 2px;
  font-size: 12px;
}

.client-list .list-toolbar {
  align-items: flex-start;
}

.client-list-controls {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.table-search {
  width: min(310px, 40vw);
}

.table-search input,
.reference-filter select {
  min-height: 36px;
}

.reference-filter {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 0;
}

.reference-filter label {
  gap: 3px;
  font-size: 11px;
}

.reference-filter select {
  width: 112px;
  padding-block: 5px;
}

.column-picker {
  position: relative;
}

.column-picker-button {
  min-width: 92px;
}

.column-picker-menu {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 40;
  width: min(420px, calc(100vw - 32px));
  max-height: min(620px, calc(100vh - 140px));
  padding: 14px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #ffffff;
  box-shadow: 0 14px 40px rgb(17 45 31 / 20%);
}

.column-picker-menu[hidden],
th[hidden],
td[hidden] {
  display: none !important;
}

.column-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.column-picker-head span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.column-picker-menu > .muted {
  margin: 5px 0 11px;
  font-size: 11px;
}

.column-picker-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 8px;
  margin-bottom: 12px;
}

.column-picker-option {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 5px 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
}

.column-picker-option:hover {
  border-color: var(--line);
  background: #f7faf7;
}

.column-picker-option input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent-strong);
}

.column-picker-option small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 800;
  text-transform: uppercase;
}

.button-icon {
  width: 17px;
  height: 17px;
  margin-right: 7px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.client-signal-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 6px 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--line);
  background: #f8faf7;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.client-signal-legend > strong {
  color: var(--text);
  font-size: 12px;
}

.legend-item,
.legend-colors,
.legend-colors span {
  display: inline-flex;
  align-items: center;
}

.legend-item {
  gap: 5px;
  color: inherit;
  text-decoration: none;
}

.legend-item:hover {
  color: var(--accent-strong);
}

.legend-colors {
  gap: 9px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}

.legend-colors span {
  gap: 4px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #9aa59e;
}

.dot-ok {
  background: #21835a;
}

.dot-warn {
  background: #c77a20;
}

.dot-bad {
  background: #b33d3d;
}

.dot-neutral {
  background: #909b94;
}

.client-signals {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex: 0 0 auto;
}

.client-signal {
  display: inline-grid;
  place-items: center;
  width: 23px;
  height: 23px;
  flex: 0 0 23px;
  border: 1px solid #d4dbd6;
  border-radius: 50%;
  color: #7c8980;
  background: #f2f4f2;
}

.client-signal svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

a.client-signal {
  text-decoration: none;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

a.client-signal:hover,
a.client-signal:focus-visible {
  z-index: 1;
  transform: translateY(-1px) scale(1.08);
  box-shadow: 0 2px 7px rgb(20 55 37 / 18%);
  outline: none;
}

.signal--ok {
  color: #176044;
  border-color: #b9dcc9;
  background: #e8f4ee;
}

.signal--warn {
  color: #9b571e;
  border-color: #ebcba9;
  background: #fff3e8;
}

.signal--bad {
  color: #a43131;
  border-color: #e7bebe;
  background: #fbeaea;
}

.signal--info {
  color: #0f628f;
  border-color: #bed9e8;
  background: #eaf5fb;
}

.signal--neutral {
  color: #718078;
  border-color: #d7ddda;
  background: #f1f3f2;
}

.legend-item .client-signal {
  width: 22px;
  height: 22px;
  flex-basis: 22px;
}

.legend-item .client-signal svg {
  width: 13px;
  height: 13px;
}

.client-primary {
  min-width: 390px;
}

.uc-primary {
  min-width: 360px;
}

.client-primary-line {
  display: flex;
  align-items: center;
  gap: 9px;
}

.client-primary-line .entity-link {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cell-note {
  display: block;
  margin-top: 1px;
  color: var(--muted);
  font-size: 10px;
}

.client-table th:first-child,
.client-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #ffffff;
}

.client-table th:first-child {
  z-index: 2;
  background: #eef2ed;
}

.client-table tbody tr:hover td:first-child {
  background: #f7faf7;
}

.uc-table th:first-child,
.uc-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  background: #ffffff;
}

.uc-table th:first-child {
  z-index: 2;
  background: #eef2ed;
}

.uc-table tbody tr:hover td:first-child {
  background: #f7faf7;
}

.privacy-pair {
  display: inline;
}

.privacy-pair > .private-placeholder {
  display: none;
  color: #536159;
  font-weight: 750;
}

.privacy-active .private-value {
  display: none;
}

.privacy-active .private-placeholder {
  display: inline;
}

.privacy-active .privacy-toggle {
  color: #ffffff;
  border-color: var(--sidebar);
  background: var(--sidebar);
}

.record-code {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.client-record-header {
  padding-bottom: 8px;
}

.record-nav {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
}

.record-nav a {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 5px;
  color: var(--accent-strong);
  background: #eef5f0;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
}

.record-nav a:hover {
  background: #dfede4;
}

.record-nav a.active,
.record-nav a[aria-selected="true"] {
  color: #ffffff;
  background: var(--accent-strong);
}

[data-client-panel][hidden] {
  display: none !important;
}

.subtable-block + .subtable-block {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.subtable-block h3 {
  margin: 0 0 9px;
  font-size: 14px;
}

.communication-form,
.plant-link-form {
  margin: 0 10px 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
}

.uc-rateio-form {
  grid-template-columns: minmax(240px, 1fr) minmax(300px, 1fr) minmax(210px, 0.8fr);
  align-items: start;
}

.uc-rateio-form > label {
  display: grid;
  grid-template-rows: auto 38px minmax(30px, auto);
  gap: 4px;
  min-width: 0;
}

.uc-rateio-form > label > input,
.uc-rateio-form > label > select {
  width: 100%;
  min-width: 0;
}

.uc-rateio-form > button {
  align-self: start;
  min-height: 38px;
  margin-top: 22px;
}

.monthly-forecast-section,
.uc-cofre-selector {
  grid-column: 1 / -1;
  min-width: 0;
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf7;
}

.monthly-forecast-section legend,
.uc-cofre-selector legend {
  padding: 0 6px;
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 850;
}

.monthly-forecast-section > .muted,
.uc-cofre-selector > .muted {
  margin: 0 0 10px;
}

.monthly-forecast-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(105px, 1fr));
  gap: 7px;
}

.monthly-forecast-grid > label {
  min-width: 0;
}

.monthly-forecast-grid input {
  width: 100%;
  min-width: 0;
  font-variant-numeric: tabular-nums;
}

.monthly-forecast-summary {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.monthly-forecast-summary h3 {
  margin: 0 0 9px;
  font-size: 14px;
}

.monthly-forecast-grid--summary > div {
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.monthly-forecast-grid--summary span,
.monthly-forecast-grid--summary strong {
  display: block;
}

.monthly-forecast-grid--summary span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.monthly-forecast-grid--summary strong {
  margin-top: 2px;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.uc-cofre-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(260px, 1fr));
  gap: 7px;
  max-height: 260px;
  overflow: auto;
}

.uc-cofre-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  cursor: pointer;
}

.uc-cofre-option:hover {
  border-color: #9ac7ad;
  background: #f2f8f4;
}

.uc-cofre-option input {
  flex: 0 0 auto;
  width: 17px;
  height: 17px;
}

.uc-cofre-option span {
  min-width: 0;
  overflow-wrap: anywhere;
}

.client-summary-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.client-summary-strip > div {
  min-width: 0;
  min-height: 56px;
  padding: 7px 10px;
  background: #ffffff;
}

.client-summary-strip span,
.client-summary-strip strong,
.client-summary-strip small {
  display: block;
}

.client-summary-strip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
}

.client-summary-strip strong {
  margin-top: 3px;
  color: var(--text);
  font-size: 18px;
  line-height: 1.1;
}

.client-summary-strip strong.summary-text {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.3;
  text-overflow: ellipsis;
}

.client-summary-strip small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
}

.client-detail section[id] {
  scroll-margin-top: 12px;
}

.list-panel > .table-wrap {
  border: 0;
  border-radius: 0;
}

.form-page {
  width: 100%;
  max-width: none;
}

.list-panel,
.client-detail,
.document-header,
.metrics {
  width: 100%;
  max-width: none;
}

.import-panel {
  border-top: 4px solid var(--accent);
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
  grid-auto-rows: minmax(58px, auto);
}

.info-grid > div {
  height: 100%;
  min-height: 58px;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf7;
}

.info-grid span,
.info-grid strong {
  display: block;
}

.info-grid span {
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.info-grid strong {
  overflow-wrap: anywhere;
  font-size: 14px;
}

.detail-grid .info-wide {
  grid-column: span 2;
}

.panel-head,
.actions,
.action-panel,
.totals {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.actions {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel-head h2,
.panel-head p {
  margin-bottom: 0;
}

.muted {
  color: var(--muted);
}

.asaas-preflight {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 9px 10px;
  border: 1px solid #efc484;
  border-radius: 8px;
  background: #fff8eb;
}

.asaas-preflight strong,
.asaas-preflight small {
  flex-basis: 100%;
}

.asaas-preflight span {
  font-variant-numeric: tabular-nums;
}

.approval-check {
  padding: 9px;
  border: 1px solid #efc484;
  border-radius: 8px;
  background: #fff8eb;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 8px;
  align-items: end;
}

/* O demonstrativo tem campos de alturas diferentes. A grade dedicada evita
   que ajudas e textareas empurrem controles vizinhos para baixo e mantém os
   grupos financeiros na mesma linha visual. */
.demonstrativo-form-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-areas:
    "due due discount status"
    "fine interest lost other"
    "pass-through pass-through total total"
    "economy-month economy-month economy-total economy-total"
    "description description notes notes"
    "message message options options";
  align-items: start;
}

.demo-field-due { grid-area: due; }
.demo-field-discount { grid-area: discount; }
.demo-field-status { grid-area: status; }
.demo-field-fine { grid-area: fine; }
.demo-field-interest { grid-area: interest; }
.demo-field-lost { grid-area: lost; }
.demo-field-other { grid-area: other; }
.demo-field-pass-through { grid-area: pass-through; }
.demo-field-total { grid-area: total; }
.demo-field-economy-month { grid-area: economy-month; }
.demo-field-economy-total { grid-area: economy-total; }
.demo-field-description { grid-area: description; }
.demo-field-notes { grid-area: notes; }
.demo-field-message { grid-area: message; }

.demonstrativo-form-grid textarea {
  min-height: 88px;
}

.demonstrativo-form-options {
  grid-area: options;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
}

.demonstrativo-form-options .approval-check {
  flex: 1 1 520px;
}

.form-section {
  padding: 12px;
  margin-bottom: 8px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fbfcfa;
}

.form-section h3 {
  margin-bottom: 10px;
  color: var(--accent-strong);
}

.credit-source-card {
  padding: 10px;
  margin-bottom: 8px;
  border: 1px solid #c7e3d4;
  border-radius: 8px;
  background: #f2f8f4;
}

.credit-source-card h4 {
  margin: 0 0 8px;
  color: var(--accent-strong);
}

.tariff-period-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.tariff-period-card,
.fine-row,
.extracted-items-group {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
}

.tariff-period-card h4,
.extracted-items-group h4 {
  margin: 0 0 10px;
  color: var(--accent-strong);
}

.tariff-period-card .form-grid {
  grid-template-columns: 1fr;
}

.fine-list {
  display: grid;
  gap: 8px;
}

.fine-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(140px, 1fr);
  gap: 10px;
}

.extracted-items-group + .extracted-items-group {
  margin-top: 10px;
}

.mono-field {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  overflow-wrap: anywhere;
}

.copy-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.extracted-details summary {
  color: var(--accent-strong);
  font-weight: 800;
  cursor: pointer;
}

.extracted-details-body {
  margin-top: 12px;
}

/* Conferencia na ordem da fatura: um unico fluxo de linhas. Em cada linha a
   descricao fica a esquerda e o campo/valor a direita, como na fatura da
   concessionaria. O seletor fica restrito ao editor para nao alterar os
   demais cadastros do sistema. */
.import-conference-flow {
  width: min(100%, 980px);
  margin-inline: auto;
}

.import-conference-flow .info-grid,
.invoice-editor .form-grid,
.invoice-editor .tariff-period-grid,
.invoice-editor .fine-row {
  grid-template-columns: minmax(0, 1fr);
}

.import-conference-flow .info-grid > div {
  min-height: 0;
}

.invoice-editor label.wide {
  grid-column: auto;
}

.invoice-editor .form-grid > label:not(.check),
.invoice-editor .fine-row > label:not(.check) {
  display: grid;
  grid-template-columns: minmax(180px, 40%) minmax(190px, 1fr);
  column-gap: 14px;
  row-gap: 6px;
  align-items: start;
  min-width: 0;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
}

.invoice-editor .form-grid > label:not(.check):last-child,
.invoice-editor .fine-row > label:not(.check):last-child {
  border-bottom: 0;
}

.invoice-editor .form-grid > label:not(.check) > input,
.invoice-editor .form-grid > label:not(.check) > select,
.invoice-editor .form-grid > label:not(.check) > textarea,
.invoice-editor .form-grid > label:not(.check) > .copy-actions,
.invoice-editor .fine-row > label:not(.check) > input,
.invoice-editor .fine-row > label:not(.check) > select,
.invoice-editor .fine-row > label:not(.check) > textarea {
  grid-column: 2;
  min-width: 0;
  width: 100%;
}

.invoice-editor .form-grid > label:not(.check) > .copy-actions {
  margin-top: 0;
}

.invoice-editor .form-grid > label.check {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

/* O cabeçalho importado é evidência da fatura, não uma área de edição. Ele
   ocupa sempre duas colunas no desktop. O fluxo tem largura máxima de 980px;
   uma terceira coluna deixaria os valores estreitos mesmo em monitores 4K. */
.invoice-editor .invoice-fixed .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
}

.invoice-editor .invoice-fixed label.wide {
  grid-column: 1 / -1;
}

.invoice-editor .invoice-fixed input[readonly],
.invoice-editor .invoice-fixed textarea[readonly] {
  background: var(--bg);
  color: var(--text);
  cursor: default;
}

/* Classificações podem conter a descrição completa do subgrupo tarifário. */
.invoice-editor .invoice-fixed label:has(> input[name="classificacao"]) {
  grid-column: 1 / -1;
}

/* A origem de créditos usa a mesma densidade do cabeçalho: duas colunas no
   desktop e uma quando a área útil já não comporta rótulo e valor inteiros. */
.invoice-editor .invoice-credit-summary .form-grid,
.invoice-editor .invoice-credit-source .form-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  column-gap: 24px;
}

@media (max-width: 1100px) {
  .invoice-editor .invoice-fixed .form-grid,
  .invoice-editor .invoice-credit-summary .form-grid,
  .invoice-editor .invoice-credit-source .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .invoice-editor .invoice-fixed label.wide {
    grid-column: auto;
  }
}

.import-decision-heading,
.import-decision-actions {
  grid-column: 1 / -1;
}

.import-decision-heading {
  padding-top: 4px;
}

.import-decision-heading:not(:first-of-type) {
  margin-top: 8px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.import-decision-actions {
  margin-top: 6px;
}

.import-conference-flow .tariff-period-card,
.import-conference-flow .credit-source-card,
.import-conference-flow .extracted-items-group {
  width: 100%;
}

.document-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px;
  margin-bottom: 14px;
  border-top: 5px solid var(--accent);
  border-bottom: 2px solid var(--brand-gold);
  background: #fff;
}

.document-header div {
  display: grid;
  gap: 4px;
}

.document-header div:last-child {
  text-align: right;
}

.document-header strong {
  color: var(--accent-strong);
  font-size: 17px;
}

.document-header span,
.site-footer {
  color: var(--muted);
  font-size: 12px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 6px;
}

.inline-form select {
  min-width: 150px;
}

.document-review-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(170px, 1fr));
  gap: 7px;
  min-width: 430px;
  align-items: end;
}

.document-review-form .wide {
  grid-column: 1 / -1;
}

.document-review-form .check {
  display: flex;
  align-items: center;
  gap: 7px;
}

.document-review-form .check input {
  width: auto;
}

.document-review-form .button {
  justify-self: start;
}

.signature-review {
  display: grid;
  gap: 6px;
  min-width: 240px;
}

.signature-review small {
  max-width: 360px;
  color: var(--muted);
  line-height: 1.35;
}

.signature-review form {
  margin: 0;
}

.metric strong.metric-small {
  font-size: 17px;
}

.site-footer {
  padding: 8px 4px 4px;
  text-align: center;
}

label {
  display: grid;
  gap: 4px;
  color: #39463e;
  font-size: 12px;
  font-weight: 750;
}

label small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 550;
}

label.wide {
  grid-column: span 2;
}

.repeatable-field.wide {
  min-width: 0;
  grid-column: span 2;
}

.repeatable-field {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.repeatable-field legend {
  padding: 0 5px;
  color: #39463e;
  font-size: 13px;
  font-weight: 750;
}

.client-person-help {
  margin: 0;
}

[data-client-person-list][hidden] {
  display: none;
}

.client-person-rows {
  display: grid;
  gap: 8px;
}

.client-person-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf8;
}

.client-person-name {
  grid-column: span 2;
}

.client-person-responsible {
  align-self: center;
  min-height: 40px;
}

.client-person-remove {
  justify-self: end;
}

.subtable-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.subtable-heading span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.email-row,
.phone-row,
.input-with-action {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.add-field {
  justify-self: start;
}

label.check,
label.inline {
  display: flex;
  align-items: center;
  gap: 8px;
}

label.check input[type="checkbox"],
label.inline input[type="checkbox"] {
  width: auto;
  height: 18px;
  min-height: 18px;
  padding: 0;
  margin: 0;
  flex: 0 0 auto;
  accent-color: var(--accent);
}

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid #cbd4ce;
  border-radius: 6px;
  padding: 6px 8px;
  color: var(--text);
  background: #ffffff;
  font: inherit;
  font-weight: 550;
}

textarea {
  min-height: 72px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus,
button:focus,
a:focus {
  outline: 3px solid rgba(15, 110, 168, 0.24);
  outline-offset: 1px;
}

input:disabled,
select:disabled,
textarea:disabled {
  background: #eef1ee;
  color: #657268;
}

.button,
button {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0 12px;
  background: #ffffff;
  color: var(--text);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.button:not(.primary):not(.danger):hover,
button:not(.primary):not(.danger):hover {
  border-color: #b7c2ba;
  background: #f5f8f5;
}

.button.primary,
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
}

.button.primary:hover,
button.primary:hover {
  background: var(--accent-strong);
}

.button.danger,
button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #ffffff;
}

.button.danger:hover,
button.danger:hover {
  background: #842727;
  border-color: #842727;
}

.button.compact {
  min-height: 32px;
  padding: 0 9px;
  font-size: 11.5px;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 24px;
  background: #e9efe9;
}

.login-card {
  width: min(100%, 430px);
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 18px 45px rgba(23, 37, 29, 0.12);
}

.login-brand {
  color: var(--text);
  margin-bottom: 22px;
}

.login-brand .brand-mark {
  border-color: var(--line);
  background: var(--sidebar);
  color: #fff;
}

.login-brand span {
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0 12px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.google-login {
  width: 100%;
  min-height: 42px;
  justify-content: center;
  border-color: #c9d1da;
  background: #fff;
  color: #263238;
}

.google-login::before {
  content: "G";
  color: #1a73e8;
  font-weight: 900;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 100%;
}

.data-table--wide {
  min-width: 760px;
}

.data-table--compact th,
.data-table--compact td {
  padding: 6px 8px;
  font-size: 12.5px;
}

.data-table--compact th {
  font-size: 11px;
}

.data-table tbody tr:hover {
  background: #f7faf7;
}

.entity-link {
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.uc-table .entity-link {
  font-weight: 500;
}

.uc-table tr.rateio-blocker {
  background: #fff8e8;
}

.rateio-focus-alert {
  margin: 10px 14px;
  padding: 12px;
  border: 1px solid #e0a72f;
  border-radius: 10px;
  background: #fff7dd;
  color: #6b4700;
}

.rateio-focus-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 6px 12px;
  margin-top: 8px;
}

.rateio-focus-list a {
  color: inherit;
  font-weight: 600;
  display: block;
}

.rateio-focus-list small {
  display: block;
  color: #775f2c;
}

.rateio-focus-ok {
  margin: 10px 14px;
}

.demo-field-lost-tool {
  grid-column: 1 / -1;
  display: grid;
  gap: 7px;
  padding: 10px 12px;
  border: 1px solid #d9c08b;
  border-radius: 10px;
  background: #fffaf0;
}

.demo-field-lost-tool label {
  max-width: 760px;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 7px 8px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
}

th {
  background: #eef2ed;
  color: #405047;
  font-size: 11px;
  text-transform: uppercase;
}

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

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.invoice-html-items th:first-child,
.invoice-html-items td:first-child {
  text-align: left;
}

.invoice-html-items th:not(:first-child),
.invoice-html-items td.num {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.totals {
  justify-content: flex-start;
  flex-wrap: wrap;
  margin-top: 10px;
}

.totals span {
  min-width: 145px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8faf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.totals strong {
  display: block;
  margin-top: 4px;
  color: var(--text);
  font-size: 16px;
}

.totals .total-rule {
  min-width: 190px;
  max-width: 260px;
  border-color: #bcd9c9;
  background: #f0f8f3;
}

.total-rule small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.2;
}

.charge-primary-action {
  justify-content: flex-start;
}

.charge-actions-more {
  width: 100%;
}

.charge-actions-more summary,
.charge-history > summary {
  cursor: pointer;
  font-weight: 800;
}

.charge-actions-more .actions {
  justify-content: flex-start;
  margin-top: 8px;
}

.charge-history {
  padding: 12px 16px;
}

.charge-history > summary {
  color: var(--muted);
}

.charge-history[open] > summary {
  margin-bottom: 10px;
}

.item-table input {
  min-width: 96px;
}

.subform {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 12px;
  margin-top: 14px;
  align-items: end;
}

.subform h3 {
  grid-column: 1 / -1;
  margin-bottom: 0;
}

.snapshot {
  margin-top: 14px;
}

pre {
  overflow: auto;
  padding: 12px;
  background: #17251d;
  color: #e5efe8;
  border-radius: 8px;
}

.error,
.form-status.error {
  color: var(--danger);
  font-weight: 800;
}

.success,
.notice {
  padding: 10px 12px;
  border-radius: 6px;
  font-weight: 700;
}

.success {
  color: #176044;
  background: #e8f4ee;
  border: 1px solid #c7e3d4;
}

.notice {
  color: var(--warn);
  background: #fff3e8;
  border: 1px solid #f0d5bd;
}

.observed-simulation-banner {
  color: #7a3314;
  background: #fff0df;
  border-color: #e8a76e;
  border-left: 5px solid #c65d22;
  letter-spacing: 0.01em;
}

.form-status {
  color: var(--muted);
  font-weight: 750;
}

/* Documentos e preparacao do rateio */
.compliance-list,
.document-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 8px;
  margin: 12px 14px 16px;
  padding: 0;
  list-style: none;
}

.compliance-item,
.document-checklist-item {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  min-height: 54px;
  padding: 9px 10px 9px 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f8faf7;
}

.compliance-item::before,
.document-checklist-item::before {
  position: absolute;
  top: 10px;
  left: 10px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border: 1px solid currentColor;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
}

.compliance-item strong,
.document-checklist-item strong {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
  font-size: 12px;
  line-height: 1.3;
}

.compliance-item span,
.document-checklist-item span {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.compliance-item.is-ok,
.document-checklist-item.is-ok {
  color: #176044;
  border-color: #c7e3d4;
  background: #f0f8f4;
}

.compliance-item.is-ok::before,
.document-checklist-item.is-ok::before {
  content: "\2713";
  background: #e1f2e9;
}

.compliance-item.is-pending,
.document-checklist-item.is-pending {
  color: var(--warn);
  border-color: #efcfad;
  background: #fff8ef;
}

.compliance-item.is-pending::before,
.document-checklist-item.is-pending::before {
  content: "!";
  background: #ffedd8;
}

.operational-alerts,
.rateio-alerts {
  display: grid;
  gap: 7px;
  margin: 10px 0;
}

.operational-alert,
.rateio-alert,
.clickable-alert {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  padding: 9px 11px;
  border: 1px solid #efcfad;
  border-radius: 7px;
  color: #7d4319;
  background: #fff7ed;
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  text-decoration: none;
}

.operational-alert::after,
.rateio-alert::after,
.clickable-alert::after {
  content: "\203A";
  flex: 0 0 auto;
  font-size: 20px;
  line-height: 1;
}

.operational-alert:hover,
.rateio-alert:hover,
.clickable-alert:hover {
  border-color: #db9d61;
  background: #ffefdc;
}

.operational-alert:focus-visible,
.rateio-alert:focus-visible,
.clickable-alert:focus-visible,
a.client-signal:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.rateio-workbench {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.rateio-grid {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.rateio-card,
.rateio-row {
  display: grid;
  grid-template-columns: minmax(210px, 1.7fr) repeat(auto-fit, minmax(112px, 1fr));
  align-items: center;
  gap: 8px 12px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: 7px;
  background: #fff;
}

.rateio-card__header,
.rateio-row__main {
  min-width: 0;
}

.rateio-card__header strong,
.rateio-row__main strong,
.rateio-card__header small,
.rateio-row__main small,
.rateio-field span,
.rateio-field strong {
  display: block;
}

.rateio-card__header strong,
.rateio-row__main strong {
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rateio-card__header small,
.rateio-row__main small,
.rateio-field span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
}

.rateio-field {
  min-width: 0;
}

.rateio-field strong,
.rateio-value {
  margin-top: 2px;
  overflow-wrap: anywhere;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.rateio-row.is-pending,
.rateio-card.is-pending,
[data-rateio-state="pending"] {
  border-left-color: #c77a20;
  background: #fffaf3;
}

.rateio-row.is-zero,
.rateio-card.is-zero,
[data-rateio-state="zero"] {
  border-style: dashed;
  border-left-style: solid;
  border-left-color: #909b94;
  background: #f5f7f5;
  color: #59655e;
}

.rateio-row.is-blocked,
.rateio-card.is-blocked,
[data-rateio-state="blocked"] {
  border-left-color: var(--danger);
  background: #fff5f5;
}

.rateio-row.is-blocked::after,
.rateio-card.is-blocked::after,
[data-rateio-state="blocked"]::after {
  content: "Documentacao pendente";
  justify-self: end;
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--danger);
  background: #fbeaea;
  font-size: 10px;
  font-weight: 850;
  white-space: nowrap;
}

.rateio-total,
[data-rateio-total] {
  position: sticky;
  z-index: 5;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 10px 13px;
  border: 1px solid #b8d3c3;
  border-radius: 8px;
  background: #f5fbf7;
  box-shadow: 0 -5px 14px rgb(20 55 37 / 9%);
  font-variant-numeric: tabular-nums;
}

.rateio-total strong,
[data-rateio-total] strong {
  color: var(--accent-strong);
  font-size: 18px;
}

.rateio-total.is-unbalanced,
[data-rateio-total].is-unbalanced {
  border-color: #e4b98f;
  background: #fff5e9;
}

.rateio-total.is-unbalanced strong,
[data-rateio-total].is-unbalanced strong {
  color: var(--warn);
}

@media (pointer: coarse) {
  a.client-signal {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }
}

@media (max-width: 1280px) and (min-width: 981px) {
  .sidebar {
    width: 190px;
    padding: 14px 10px;
  }

  .main {
    margin-left: 190px;
    width: calc(100% - 190px);
    padding: 12px;
  }

  .brand {
    margin-bottom: 10px;
  }

  .nav-link {
    min-height: 32px;
    font-size: 13px;
  }

  .topbar {
    min-height: 38px;
    margin-bottom: 10px;
  }

  .panel {
    padding: 12px;
  }

  .list-panel {
    padding: 0;
  }
}

@media (max-width: 980px) {
  .rateio-card,
  .rateio-row {
    grid-template-columns: minmax(190px, 1.5fr) repeat(2, minmax(110px, 1fr));
  }

  .tariff-period-grid,
  .fine-row {
    grid-template-columns: 1fr;
  }
  .sidebar {
    position: static;
    width: 100%;
    padding: 10px;
  }

  .brand {
    margin-bottom: 10px;
  }

  nav {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .nav-link {
    flex: 0 0 auto;
    min-height: 36px;
    justify-content: center;
    text-align: center;
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 12px;
  }

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

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

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

  .demonstrativo-form-grid {
    grid-template-areas:
      "due due"
      "discount status"
      "fine interest"
      "lost other"
      "total total"
      "economy-month economy-total"
      "description notes"
      "message options";
  }

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

  .client-list-controls {
    justify-content: flex-start;
  }

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

  .uc-rateio-form > button {
    grid-column: 1 / -1;
    width: 100%;
    margin-top: 0;
  }

  .monthly-forecast-grid {
    grid-template-columns: repeat(3, minmax(105px, 1fr));
  }

  .uc-cofre-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .uc-rateio-form,
  .monthly-forecast-grid {
    grid-template-columns: 1fr;
  }

  .compliance-list,
  .document-checklist {
    grid-template-columns: 1fr;
    margin-inline: 10px;
  }

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

  .rateio-card__header,
  .rateio-row__main {
    grid-column: 1 / -1;
  }

  .rateio-total,
  [data-rateio-total] {
    align-items: flex-start;
    flex-direction: column;
  }

  .invoice-editor .form-grid > label:not(.check),
  .invoice-editor .fine-row > label:not(.check) {
    grid-template-columns: minmax(0, 1fr);
    row-gap: 6px;
  }

  .invoice-editor .form-grid > label:not(.check) > input,
  .invoice-editor .form-grid > label:not(.check) > select,
  .invoice-editor .form-grid > label:not(.check) > textarea,
  .invoice-editor .form-grid > label:not(.check) > .copy-actions,
  .invoice-editor .fine-row > label:not(.check) > input,
  .invoice-editor .fine-row > label:not(.check) > select,
  .invoice-editor .fine-row > label:not(.check) > textarea {
    grid-column: 1;
  }

  .invoice-editor .copy-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .metrics,
  .form-grid,
  .subform {
    grid-template-columns: 1fr;
  }

  .demonstrativo-form-grid {
    grid-template-areas:
      "due"
      "discount"
      "status"
      "fine"
      "interest"
      "lost"
      "other"
      "total"
      "economy-month"
      "economy-total"
      "description"
      "notes"
      "message"
      "options";
  }

  .demonstrativo-form-options {
    align-items: stretch;
    flex-direction: column;
  }

  .demonstrativo-form-options .approval-check {
    flex-basis: auto;
  }

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

  label.wide {
    grid-column: auto;
  }

  .repeatable-field.wide {
    grid-column: auto;
  }

  .client-person-row {
    grid-template-columns: 1fr;
  }

  .client-person-name {
    grid-column: auto;
  }

  .client-person-remove {
    justify-self: stretch;
  }

  .topbar,
  .panel-head,
  .list-toolbar,
  .action-panel,
  .document-header {
    align-items: stretch;
    flex-direction: column;
  }

  .user-box {
    justify-content: flex-start;
  }

  h1 {
    font-size: 22px;
  }

  .document-header div:last-child {
    text-align: left;
  }

  .inline-form {
    align-items: stretch;
    flex-direction: column;
  }

  .document-review-form {
    grid-template-columns: 1fr;
    min-width: 300px;
  }

  .document-review-form .wide {
    grid-column: auto;
  }

  .actions {
    align-items: stretch;
    justify-content: flex-start;
  }

  .column-picker-button {
    width: 100%;
  }

  .column-picker-options {
    grid-template-columns: 1fr;
  }

  .detail-grid .info-wide {
    grid-column: auto;
  }

  .client-list-controls {
    width: 100%;
    align-items: stretch;
    justify-content: stretch;
  }

  .table-search {
    width: 100%;
    flex-basis: 100%;
  }

  .reference-filter {
    flex: 1 1 210px;
  }

  .reference-filter label {
    flex: 1 1 auto;
  }

  .reference-filter select {
    width: 100%;
  }

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

  .client-primary {
    min-width: 350px;
  }
}

.equatorial-collector {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(280px, auto);
  align-items: center;
  gap: 10px 18px;
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid #d8e0e6;
  border-radius: 10px;
  background: #f8fafb;
}

.equatorial-collector p {
  margin: 4px 0 0;
  color: var(--muted, #64717d);
  font-size: 13px;
}

.equatorial-collector form {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.equatorial-collector__status {
  grid-column: 1 / -1;
  margin: 0;
  padding: 9px 11px;
  border-left: 4px solid #8796a3;
  background: #eef2f4;
  color: #394957;
}

.equatorial-collector__status.state-green { border-color: #2d8a55; background: #e9f6ee; color: #205f3d; }
.equatorial-collector__status.state-yellow { border-color: #c48416; background: #fff5d9; color: #75500e; }
.equatorial-collector__status.state-red { border-color: #bd3b3b; background: #faeaea; color: #842929; }

.ufv-card {
  --ufv-state: #8796a3;
  margin-bottom: 18px;
  padding: 18px;
  border: 1px solid #d6dee5;
  border-top: 4px solid var(--ufv-state);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 7px 20px rgba(28, 47, 62, .06);
}

.ufv-card[data-ufv-href] { cursor: pointer; }
.ufv-card.state-green { --ufv-state: #2d9b60; }
.ufv-card.state-yellow { --ufv-state: #d39422; }
.ufv-card.state-red { --ufv-state: #c74343; }
.ufv-card.state-gray { --ufv-state: #8796a3; }

.ufv-card__head,
.ufv-card__head > div,
.ufv-card__head h2 {
  min-width: 0;
}

.ufv-card__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.ufv-card__head h2 { margin: 2px 0 0; font-size: 20px; }
.ufv-source { color: #64717d; font-size: 12px; white-space: nowrap; }

.ufv-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 6px;
  border-radius: 50%;
  background: currentColor;
  color: var(--ufv-state);
  box-shadow: 0 0 0 3px color-mix(in srgb, currentColor 18%, transparent);
}

.ufv-card__metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.ufv-card__metrics > div {
  min-width: 0;
  padding: 11px 12px;
  border: 1px solid #e0e6eb;
  border-radius: 8px;
  background: #f8fafb;
}

.ufv-card__metrics span,
.ufv-card__metrics small {
  display: block;
  color: #64717d;
  font-size: 11px;
}

.ufv-card__metrics strong {
  display: block;
  overflow-wrap: anywhere;
  margin: 5px 0 3px;
  font-size: 18px;
}

.ufv-card__metrics > div:last-child strong { font-size: 14px; line-height: 1.35; }

.ufv-services {
  display: grid;
  grid-template-columns: repeat(7, minmax(90px, 1fr));
  gap: 7px;
}

.ufv-service {
  min-height: 68px;
  padding: 9px;
  border: 1px solid #dce3e8;
  border-radius: 8px;
  background: #fff;
  color: #243643;
  text-align: left;
  cursor: pointer;
}

.ufv-service .ufv-dot { width: 8px; height: 8px; }
.ufv-service.state-green { --ufv-state: #2d9b60; }
.ufv-service.state-yellow { --ufv-state: #d39422; }
.ufv-service.state-red { --ufv-state: #c74343; }
.ufv-service.state-gray { --ufv-state: #8796a3; }
.ufv-service span:not(.ufv-dot), .ufv-service small { display: block; }
.ufv-service span:not(.ufv-dot) { margin-top: 5px; font-weight: 700; font-size: 12px; }
.ufv-service small { margin-top: 3px; color: #64717d; font-size: 10px; }
.ufv-service[aria-expanded="true"] { outline: 2px solid var(--ufv-state); outline-offset: 1px; }

.ufv-card__detail {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #dce3e8;
  border-radius: 8px;
  background: #f8fafb;
}

.ufv-card__detail h3, .ufv-card__detail h4 { margin: 0 0 8px; }
.ufv-card__detail p { margin: 0; }
.ufv-history { display: grid; gap: 7px; margin: 8px 0 0; padding: 0; list-style: none; }
.ufv-history li { display: grid; gap: 3px; padding: 8px 10px; border-left: 3px solid #b9c5ce; background: #fff; }
.ufv-history li strong { font-size: 12px; }
.ufv-history li span { color: #566673; font-size: 12px; }
.ufv-card__error { margin: 12px 0 0; color: #842929; }

@media (max-width: 1050px) {
  .ufv-card__metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ufv-services { grid-template-columns: repeat(4, minmax(100px, 1fr)); }
}

@media (max-width: 700px) {
  .equatorial-collector { grid-template-columns: 1fr; }
  .equatorial-collector form { justify-content: stretch; }
  .equatorial-collector form .button { flex: 1 1 100%; justify-content: center; }
  .ufv-card__head { flex-direction: column; }
  .ufv-card__metrics, .ufv-services { grid-template-columns: 1fr; }
  .ufv-source { white-space: normal; }
}

@media print {
  @page {
    size: A4;
    margin: 12mm;
  }

  body {
    background: #fff;
    color: #000;
    font-size: 11pt;
  }

  .sidebar,
  .topbar .user-box,
  .no-print,
  .privacy-toggle,
  .client-signal-legend,
  script,
  .site-footer {
    display: none !important;
  }

  .main {
    margin: 0;
    padding: 0;
  }

  .topbar {
    display: block;
    min-height: 0;
    margin-bottom: 12px;
  }

  .panel,
  .metric,
  .table-wrap {
    break-inside: avoid;
    border-color: #999;
    box-shadow: none;
  }

  table {
    min-width: 0;
  }

  input,
  select,
  textarea {
    border: 0;
    padding: 0;
    min-height: 0;
    background: transparent !important;
    color: #000 !important;
  }

  details.snapshot {
    display: none;
  }

  .document-header {
    padding: 8px 0;
    border-top-width: 3px;
  }
}
