:root {
  color-scheme: light;
  --bg: #f3f4f6;
  --panel: #ffffff;
  --ink: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #0f766e;
  --accent-ink: #ffffff;
  --danger: #b91c1c;
  --ok: #047857;
  font-family: "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
}

.app-shell {
  max-width: 1860px;
  margin: 0 auto;
  padding: 16px 24px 32px;
}

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

.topbar h1 { margin: 0; font-size: 1.6rem; }

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

nav { display: flex; gap: 8px; align-items: center; }

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

nav a,
.nav-dropdown-toggle,
.userbar a {
  text-decoration: none;
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  font: inherit;
  cursor: pointer;
}

nav a.active,
.nav-dropdown-toggle.active,
.userbar a.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.nav-dropdown {
  position: relative;
}

.nav-dropdown-toggle::after {
  content: "";
  display: inline-block;
  margin-left: 6px;
  border: 4px solid transparent;
  border-top-color: currentColor;
  transform: translateY(2px);
}

.nav-dropdown-menu {
  display: flex;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: calc(100% - 2px);
  left: 0;
  min-width: 200px;
  padding: 10px 6px 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  z-index: 40;
  flex-direction: column;
  gap: 2px;
  transition: opacity 0.12s ease, visibility 0.12s ease;
  transition-delay: 0.18s;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu,
.nav-dropdown.open .nav-dropdown-menu {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}

.nav-dropdown-menu a {
  white-space: nowrap;
}

.nav-dropdown-menu a.active {
  background: var(--accent);
  color: var(--accent-ink);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 16px;
}

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

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

.filters,
.settings-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.9rem;
}

input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font: inherit;
  background: #fff;
}

button {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
  align-self: end;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

button.btn-mini.danger {
  color: var(--danger);
  border-color: #fecaca;
  padding: 6px 10px;
  font-size: 0.8rem;
}

button:disabled { opacity: 0.65; cursor: not-allowed; }

.pager {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

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

.previa-resumo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin: 0 0 16px;
}

.previa-resumo-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.previa-resumo-item p {
  margin: 0;
  font-size: 0.92rem;
}

.previa-resumo-item button {
  align-self: flex-start;
}

.previa-box-miss {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.previa-box-inativo {
  background: #fffbeb;
  border-color: #fde68a;
  color: #92400e;
}

.previa-box-atu {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #065f46;
}

.previa-box-exc {
  background: #fff7ed;
  border-color: #fed7aa;
  color: #9a3412;
}

.previa-box-inc {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e40af;
}

.previa-box-zero {
  background: #f9fafb;
  border-color: #e5e7eb;
  color: #6b7280;
}

table.envios-lista {
  border-collapse: separate;
  border-spacing: 0;
}

.envios-lista .envio-contrato td {
  background: #fff;
  border-top: 1px solid #d5e0dd;
  border-bottom: none;
  padding-top: 12px;
  padding-bottom: 8px;
}

.envios-lista .envio-contrato td:first-child {
  border-left: 4px solid var(--accent);
  border-top-left-radius: 10px;
}

.envios-lista .envio-contrato td:last-child {
  border-right: 1px solid #d5e0dd;
  border-top-right-radius: 10px;
}

.envios-lista .envio-texto-nf-row td {
  border-top: 1px solid #e7eeec;
  border-bottom: 1px solid #d5e0dd;
  border-left: 4px solid var(--accent);
  border-right: 1px solid #d5e0dd;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  background: #f4f8f7;
  padding: 8px 12px 14px;
}

.envios-lista .envio-separador td {
  height: 18px;
  padding: 0;
  border: none;
  background: transparent;
  line-height: 0;
  font-size: 0;
}

.envio-texto-nf-row label {
  margin: 0;
}

.texto-nf {
  width: 100%;
  min-height: 4.5rem;
  resize: vertical;
  font: inherit;
  font-size: 0.85rem;
  line-height: 1.4;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}

.table-wrap {
  overflow: auto;
  max-height: calc(100vh - 280px);
}

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

th,
td {
  text-align: left;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  vertical-align: top;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 1;
}

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

th.centro,
td.centro {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.alert {
  color: var(--danger);
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 10px 12px;
  border-radius: 8px;
}

.ok {
  color: var(--ok);
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  padding: 10px 12px;
  border-radius: 8px;
}

.toast-root {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  width: min(520px, calc(100vw - 32px));
}

.toast {
  width: 100%;
  text-align: center;
  background: var(--ok);
  color: #fff;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 12px 32px rgba(15, 118, 110, 0.28);
  font-size: 0.95rem;
  animation: toast-in 0.22s ease;
}

.toast-out {
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
  padding: 16px;
}

.modal[hidden] {
  display: none !important;
}

.modal-card {
  background: #fff;
  border-radius: 16px;
  padding: 20px;
  width: min(480px, 100%);
  display: grid;
  gap: 12px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.18);
}

.modal-card h3,
.modal-card p {
  margin: 0;
}

.compare-card {
  --pares-acao: 9.5rem;
  --pares-qtd: 4.5rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
  background: #fff;
  overflow: visible;
  position: relative;
}

.compare-card.picker-aberto {
  z-index: 30;
}

.compare-frozen {
  border-color: #99f6e4;
  background: #f0fdfa;
}

.compare-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.compare-head h3 {
  margin: 0;
  font-size: 1.05rem;
  flex: 1;
}

.envio-check {
  display: flex;
  align-items: center;
  margin: 0;
}

.envio-check input {
  width: 18px;
  height: 18px;
}

.badge-congelado,
.badge-ok,
.badge-pend {
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.badge-congelado {
  background: #ccfbf1;
  color: #0f766e;
}

.badge-ok {
  background: #d1fae5;
  color: #047857;
}

.badge-faturado {
  background: #dbeafe;
  color: #1d4ed8;
  font-size: 0.78rem;
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}

.os-nfse {
  margin: 4px 0 0;
  font-size: 0.86rem;
}

.os-nfse a {
  color: var(--accent);
}

.os-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0 0;
}

.acoes-envio {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.badge-pend {
  background: #fee2e2;
  color: #b91c1c;
}

.envio-barra {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin: 0 0 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fafc;
}

.envio-marcar-todos {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.envio-marcar-todos input {
  width: 18px;
  height: 18px;
}

.modal-colaboradores {
  width: min(960px, 100%);
  max-height: min(86vh, 860px);
  overflow: auto;
}

.campo-mensagem {
  grid-column: 1 / -1;
}

.campo-mensagem textarea {
  min-height: 140px;
  resize: vertical;
}

.tags-ajuda code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.detalhamento-mensagem {
  white-space: pre-wrap;
  margin: 0 0 18px;
  padding: 12px 14px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
}

.detalhamento-componente {
  margin: 0 0 16px;
}

.detalhamento-componente header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  margin: 0 0 6px;
}

.detalhamento-componente h4,
.detalhamento-componente header p {
  margin: 0;
}

.detalhamento-componente header p {
  white-space: nowrap;
}

.detalhamento-total {
  margin: 4px 0 0;
}

.modal-colaboradores-topo {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.modal-colaboradores-topo h3 {
  margin: 0 0 4px;
}

.compare-miss {
  border-color: #fecaca;
  background: #fff7f7;
}

.compare-warn {
  border-color: #fde68a;
  background: #fffbeb;
}

.compare-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--pares-qtd) var(--pares-acao) minmax(0, 1fr) var(--pares-qtd);
  column-gap: 0;
  row-gap: 0;
  align-items: stretch;
}

.compare-meta-rel {
  grid-column: 1 / 3;
  padding: 0 6px 12px 0;
}

.compare-meta-omie {
  grid-column: 4 / 6;
  padding: 0 0 12px 6px;
}

.compare-layout h4 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--muted);
}

.compare-layout p {
  margin: 0 0 6px;
  font-size: 0.9rem;
}

.pares-h,
.pares-cell {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  font-size: 0.78rem;
  overflow-wrap: anywhere;
  word-break: break-word;
  min-width: 0;
}

.pares-h {
  font-weight: 600;
  color: var(--muted);
  min-height: 2.25rem;
  display: flex;
  align-items: flex-end;
}

.pares-cell {
  min-height: 3rem;
  display: flex;
  align-items: center;
}

.pares-cell.num,
.pares-h.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.acao-cell {
  text-align: center;
  vertical-align: middle;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-preview {
  max-height: 72px;
  max-width: 220px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px;
  background: #fff;
}

a.btn-mini {
  display: inline-block;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 0.8rem;
}

.conta-cc-box {
  display: grid;
  gap: 8px;
  margin: 8px 0 4px;
}

.conta-cc-box select {
  width: 100%;
}

.servico-picker {
  position: relative;
  width: 100%;
  min-width: 0;
  z-index: 4;
}

.pares-cell:has(.servico-picker) {
  overflow: visible;
  z-index: 4;
}

.servico-busca {
  width: 100%;
  min-height: 2.8rem;
  box-sizing: border-box;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
}

.servico-lista {
  position: absolute;
  z-index: 40;
  top: calc(100% + 4px);
  right: 0;
  left: auto;
  width: min(36rem, 72vw);
  max-height: 28rem;
  overflow: auto;
  margin: 0;
  padding: 6px 0;
  list-style: none;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.18);
}

.servico-opcao {
  padding: 12px 16px;
  cursor: pointer;
  font-size: 0.95rem;
}

.servico-opcao:hover {
  background: #f1f5f9;
}

.servico-vazio {
  padding: 12px 16px;
  color: var(--muted);
  font-size: 0.95rem;
}

.item-ausente,
.item-ausente-cell {
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 900px) {
  .compare-layout {
    grid-template-columns: minmax(0, 1fr) 3.5rem 7.5rem minmax(0, 1fr) 3.5rem;
    min-width: 640px;
  }
  .compare-card {
    overflow-x: auto;
  }
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 10px;
}

legend { padding: 0 6px; color: var(--muted); }

.actions {
  display: flex;
  gap: 8px;
  grid-column: 1 / -1;
}

.cadastro-form {
  display: grid;
  gap: 16px;
}

.cadastro-secao {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: grid;
  gap: 12px;
}

.cadastro-secao h3 {
  margin: 0;
  font-size: 1rem;
}

.cadastro-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.cadastro-span {
  grid-column: 1 / -1;
}

.cliente-selecionado {
  margin: 0;
  background: #ecfdf5;
  border-radius: 8px;
  padding: 8px 10px;
}

.cliente-lista {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 200px;
  overflow: auto;
  background: #fff;
}

.cliente-lista button {
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: #fff;
}

.cliente-lista button:hover {
  background: #f3f4f6;
}

body.sem-sessao .app-shell { display: none; }

.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-screen[hidden] { display: none !important; }

.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
}

.login-card h1 {
  margin: 0;
  font-size: 1.6rem;
}

.login-card .muted { margin: 0; }

.login-card button.primary { justify-self: stretch; }

.userbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}

.userbar span {
  color: var(--muted);
  font-size: 0.9rem;
}

.usuarios-layout { display: grid; gap: 16px; }

.form-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  align-items: end;
}

.form-inline[hidden] { display: none !important; }

.form-inline h3 {
  margin: 0;
  font-size: 1rem;
}

.check-inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.tabela-simples { table-layout: auto; }

.tabela-simples th,
.tabela-simples td { font-size: 0.9rem; }

.row-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

button.btn-mini {
  padding: 6px 10px;
  font-size: 0.8rem;
  align-self: center;
}
