:root {
  --azul: #003a5d;
  --verde: #3dae2b;
  /* Verde institucional falha em contraste AA (2.88:1) como cor de texto —
     usado só para botões/bordas/ícones. Texto usa este tom mais escuro,
     que mantém o mesmo matiz e passa em 5.4:1. */
  --verde-texto: #2c7a1e;
  --cinza-escuro: #4b4f54;
  --cinza-claro: #9aa2a5;
  --vermelho: #ce0e2d;
  --fundo: #f4f7f8;
  --linha: #d9e1e4;
  --texto: #1f2a30;
  --bs-primary: #003a5d;
  --bs-primary-rgb: 0, 58, 93;
  --bs-success: #3dae2b;
  --bs-success-rgb: 61, 174, 43;
  font-family: "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
}

body {
  color: var(--texto);
  background:
    radial-gradient(circle at top right, rgba(61, 174, 43, .08), transparent 28rem),
    linear-gradient(180deg, #f8fbfc 0%, var(--fundo) 100%);
  font-family: "Roboto Condensed", "Arial Narrow", Arial, sans-serif;
}

.hidden { display: none !important; }

.btn-primary {
  --bs-btn-bg: var(--azul);
  --bs-btn-border-color: var(--azul);
  --bs-btn-hover-bg: #064c78;
  --bs-btn-hover-border-color: #064c78;
}

.btn-success {
  --bs-btn-bg: var(--verde);
  --bs-btn-border-color: var(--verde);
  --bs-btn-hover-bg: #318f23;
  --bs-btn-hover-border-color: #318f23;
}

.btn-outline-primary {
  --bs-btn-color: var(--azul);
  --bs-btn-border-color: var(--azul);
  --bs-btn-hover-bg: var(--azul);
  --bs-btn-hover-border-color: var(--azul);
}

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

.login-panel {
  width: min(430px, calc(100vw - 32px));
  padding: 32px;
  border-radius: 14px;
  box-shadow: 0 24px 70px rgba(0, 58, 93, .16);
}

.brand-lockup,
.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 150px;
  min-width: 100px;
  height: auto;
  display: block;
}

.login-panel h1,
.topbar h1,
.admin-grid h2,
.empty-state h2 {
  color: var(--azul);
}

.hint { color: var(--cinza-escuro); }

.app-shell {
  display: grid;
  grid-template-columns: 288px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, #003a5d 0%, #052f49 100%);
  color: #fff;
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  box-shadow: 8px 0 28px rgba(0, 58, 93, .18);
  position: sticky;
  top: 0;
  align-self: start;
  height: 100vh;
  overflow-y: auto;
}

.brand-block {
  min-height: 64px;
}

.brand-logo-sidebar { width: 130px; }

.sidebar-nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 4px solid transparent;
  border-radius: 8px;
  color: #eaf2f4;
  padding: 11px 12px;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.nav-item i {
  width: 20px;
  text-align: center;
  color: rgba(255,255,255,.78);
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255,255,255,.13);
  border-left-color: var(--verde);
  color: #fff;
}

.nav-item:hover { transform: translateX(2px); }

.nav-group-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  background: transparent;
  border: 0;
  border-left: 4px solid transparent;
  border-radius: 8px;
  color: rgba(255, 255, 255, .78);
  padding: 11px 12px;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-weight: 700;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.nav-group-toggle i:first-child { width: 20px; text-align: center; color: rgba(255, 255, 255, .6); }

.nav-group-toggle:hover { background: rgba(255, 255, 255, .08); transform: translateX(2px); }

.nav-group-chevron { margin-left: auto; font-size: 1em; transition: transform .15s ease; }

.nav-group-toggle[aria-expanded="true"] .nav-group-chevron { transform: rotate(180deg); }

.nav-group.has-active > .nav-group-toggle { border-left-color: var(--verde); color: #fff; }

.nav-group-items { display: grid; gap: 6px; padding-top: 4px; }

.content {
  min-width: 0;
  padding: 24px;
}

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

.topbar h1 {
  margin: 0;
  font-size: clamp(24px, 2vw, 32px);
  font-weight: 700;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--verde-texto);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: .04em;
}

.apuracao-selector {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 auto;
  max-width: 360px;
  margin: 0 16px;
}

.apuracao-selector .dropdown {
  flex: 1 1 auto;
  min-width: 0;
}

.apuracao-selector .dropdown-toggle {
  min-width: 220px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.apuracao-panel {
  min-width: 280px;
  max-width: min(420px, 90vw);
}

.apuracao-option.selected {
  background: rgba(0, 58, 93, .1);
  color: var(--azul);
  font-weight: 700;
}

.topbar-user-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--linha);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
  background: #fff;
}

.topbar-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--azul);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  flex-shrink: 0;
}

.profile-avatar {
  width: 56px;
  height: 56px;
  /* impeccable-disable-next-line design-system-font-size -- one-off initials size scaled to this larger avatar, not a reusable type step */
  font-size: 1.4rem;
}

.topbar-user-info {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.2;
}

.topbar-user-info small {
  color: var(--cinza-escuro);
}

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

.metric {
  background: #fff;
  border: 0;
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 12px 32px rgba(0, 58, 93, .08);
}

.metric span {
  color: var(--cinza-escuro);
  font-size: .92rem;
}

.metric strong {
  display: block;
  margin-top: 6px;
  color: var(--azul);
  font-size: 1.8rem;
  line-height: 1;
}

.metric i {
  width: 36px;
  height: 36px;
  display: inline-grid;
  place-items: center;
  border-radius: 10px;
  background: rgba(61, 174, 43, .12);
  color: var(--verde);
}

.chart-card canvas {
  max-height: 320px;
}

.critical-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--linha);
  padding: 8px 0;
}

.critical-item-badge {
  background: rgba(0, 58, 93, .08);
  color: var(--azul);
  border: 1px solid rgba(0, 58, 93, .18);
}

.critical-item-reason {
  color: var(--vermelho);
  font-weight: 700;
}

.toolbar {
  display: grid;
  gap: 12px;
  margin-bottom: 12px;
  padding: 14px;
  border-radius: 12px;
}

.import-help {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: rgba(61, 174, 43, .08) !important;
  border-color: rgba(61, 174, 43, .25) !important;
  border-radius: 12px;
  margin-bottom: 12px;
  color: var(--cinza-escuro);
}

.import-help strong {
  color: var(--azul);
  white-space: nowrap;
}

.import-help strong i {
  color: var(--verde);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 8px;
}

.filters-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 auto;
}

.filters-fields .ms-filter {
  flex: 1 1 150px;
  min-width: 130px;
  max-width: 220px;
}

.filters-buttons {
  display: flex;
  gap: 8px;
  flex: 0 0 auto;
}

.ms-filter {
  position: relative;
}

.ms-filter:has(.dropdown-menu.show) {
  z-index: 1055;
}

.ms-filter .dropdown-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ms-panel {
  min-width: 240px;
  max-width: min(320px, 90vw);
}

.ms-options {
  max-height: 220px;
  overflow-y: auto;
}

.ms-option {
  padding: 2px 4px;
  border-radius: 6px;
}

.ms-option:hover {
  background: var(--fundo);
}

.ms-option.selected,
.ms-option:has(input:checked) {
  background: rgba(0, 58, 93, .1);
}

.ms-option.selected .form-check-label,
.ms-option:has(input:checked) .form-check-label {
  color: var(--azul);
  font-weight: 700;
}

.ms-option.hidden {
  display: none !important;
}

.ms-option .form-check-label {
  font-size: .88rem;
  word-break: break-word;
}

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

.file-action {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.file-action input { display: none; }

.pagination-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.record-count {
  font-weight: 600;
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pagination-controls button:disabled {
  opacity: .5;
}

.table-shell {
  overflow: auto;
  max-height: calc(100vh - 330px);
  border-radius: 12px;
}

table { min-width: 1200px; }

/* Tables inside a modal (e.g. Contatos do Fornecedor, Histórico de
   Execuções) are short — a handful of narrow columns — so forcing the
   1200px min-width above onto them just creates a needless horizontal
   scrollbar in a much narrower modal. Let them size to their own content
   instead. */
.modal-body table { min-width: 0; }

.table > :not(caption) > * > * {
  padding: .58rem .7rem;
  white-space: nowrap;
  font-size: .88rem;
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #edf4f6;
  color: var(--azul);
  border-bottom: 1px solid var(--linha);
}

/* Keeps a column (e.g. "Ações") pinned to the right edge of a horizontally
   scrolling table, so it stays reachable without scrolling — see the
   `sticky` column option in renderRegistryTable(). */
.table td.col-sticky-end,
.table th.col-sticky-end {
  position: sticky;
  right: 0;
  z-index: 1;
  background: #fff;
  box-shadow: -4px 0 4px -4px rgba(0, 0, 0, .2);
}

.table thead th.col-sticky-end {
  z-index: 2;
  background: #edf4f6;
}

.table tbody tr:hover td.col-sticky-end {
  background: var(--bs-table-hover-bg, #f5f7f9);
}

.column-help {
  display: inline-block;
  font-size: .85rem;
  vertical-align: middle;
  opacity: .55;
  /* Padded hit-area without growing the visible glyph — 13.6px icon +
     16px of invisible padding gets close to the 24px WCAG 2.5.8 minimum. */
  padding: 8px;
  margin: -8px;
}

.column-help:hover,
.column-help:focus {
  opacity: 1;
}

.tracking-stepper {
  display: flex;
  align-items: flex-start;
}

.tracking-step {
  flex: 1;
  text-align: center;
  position: relative;
  padding-top: 8px;
}

.tracking-step:not(:first-child)::before {
  content: "";
  position: absolute;
  top: 28px;
  left: -50%;
  width: 100%;
  height: 3px;
  background: var(--linha);
  z-index: 0;
}

.tracking-step.done:not(:first-child)::before,
.tracking-step.active:not(:first-child)::before {
  background: var(--verde);
}

.tracking-step-dot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--cinza-claro);
  color: #fff;
  display: inline-grid;
  place-items: center;
  font-weight: 700;
  position: relative;
  z-index: 1;
  margin: 0 auto 8px;
}

.tracking-step.done .tracking-step-dot {
  background: var(--verde);
}

.tracking-step.active .tracking-step-dot {
  background: var(--azul);
}

.tracking-step-label {
  font-size: .82rem;
  color: var(--cinza-escuro);
}

.tracking-step.active .tracking-step-label {
  color: var(--azul);
  font-weight: 700;
}

.column-help-popover {
  max-width: 360px;
}

.status-ok {
  color: var(--verde-texto) !important;
  font-weight: 700;
}

.status-warn {
  color: var(--vermelho) !important;
  font-weight: 700;
}

.admin-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.admin-grid article,
.empty-state {
  border-radius: 12px;
  padding: 18px;
}

.admin-grid h2,
.empty-state h2 {
  font-size: 1.25rem;
  margin-bottom: 12px;
}

code { color: var(--azul); }

.batch {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--linha);
  padding: 8px 0;
}

.import-files-split,
.import-paste-split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.import-paste-actions {
  display: flex;
  gap: 8px;
}

.import-dropzone,
.import-paste {
  padding: 22px;
  border-radius: 12px;
}

.import-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  border: 2px dashed var(--linha);
  transition: border-color .15s ease, background .15s ease;
}

.import-dropzone-compact {
  padding: 14px;
}

.import-dropzone-compact i {
  /* impeccable-disable-next-line design-system-font-size -- icon glyph size, not body typography; the type ramp doesn't govern icon dimensions */
  font-size: 1.6rem;
  margin-bottom: 2px;
}

.import-paste-compact {
  padding: 14px;
}

.import-dropzone.dragover {
  border-color: var(--verde);
  background: rgba(61, 174, 43, .08);
}

.import-dropzone.import-busy,
.import-paste.import-busy {
  opacity: .6;
  pointer-events: none;
}

.import-processing {
  display: flex;
  align-items: center;
}

.import-dropzone i {
  /* impeccable-disable-next-line design-system-font-size -- icon glyph size, not body typography; the type ramp doesn't govern icon dimensions */
  font-size: 2.2rem;
  color: var(--azul);
  margin-bottom: 8px;
}

.import-paste textarea {
  font-family: "Roboto Condensed", monospace;
  font-size: .85rem;
}

.import-history h2 {
  /* Same subheading step as .admin-grid h2 / .empty-state h2 (was 1.15rem,
     a near-duplicate one-off) — one size for this tier, not two. */
  font-size: 1.25rem;
  color: var(--azul);
  margin-bottom: 8px;
}

.batch-delete {
  --bs-btn-padding-y: .2rem;
  --bs-btn-padding-x: .5rem;
}

@media (max-width: 900px) {
  .import-files-split,
  .import-paste-split { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  /* Drop the animated interpolation only — the resulting state (color,
     background, position) still changes instantly, so no feedback is lost. */
  .nav-item,
  .import-dropzone,
  .nav-group-toggle,
  .nav-group-chevron,
  .collapsing {
    transition: none;
  }
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 460px;
  background: var(--cinza-escuro);
  color: #fff;
  padding: 14px 16px;
  border-radius: 10px;
  box-shadow: 0 12px 30px rgba(0,0,0,.2);
  z-index: 1080;
}

@media (max-width: 1180px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .sidebar-nav, .nav-group-items { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .nav-group { grid-column: 1 / -1; }
  .admin-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 680px) {
  .content { padding: 16px; }
  .admin-grid, .import-help, .sidebar-nav, .nav-group-items { grid-template-columns: 1fr; }
  .filters-fields .ms-filter { flex: 1 1 100%; max-width: none; }
  .filters-buttons { width: 100%; }
  .filters-buttons .btn { flex: 1 1 auto; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar .btn { width: 100%; }
}
