:root {
  --comex-blue: #0d47a1;
  --comex-blue-soft: #1e88e5;
  --comex-green-soft: #c8f3dd;
  --comex-bg: #f5f9ff;
  --comex-white: #ffffff;
  --comex-text: #13334c;
  --sirius-teal: #26a69a;
  --sirius-teal-hover: #2eb8aa;
  --sirius-teal-muted: rgba(38, 166, 154, 0.22);
  --sirius-sidebar-bg: #eceff1;
  --sirius-page-bg: #f8f9fa;
  --sirius-rail-collapsed: 3.5rem;
  --sirius-rail-expanded: 15rem;
}

body {
  min-height: 100vh;
  background: var(--sirius-page-bg);
  color: var(--comex-text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}

/* Shell: mini sidebar (referência visual) + top bar + conteúdo */
.app-layout {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  min-height: 100vh;
  width: 100%;
}

.app-main {
  min-width: 0;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  background: var(--sirius-page-bg);
}

body.page-listing-flat {
  background: var(--sirius-page-bg);
}

body.page-listing-flat .app-main {
  background: var(--sirius-page-bg);
}

/* Top bar (logo, relógio, empresa, usuário) */
.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: 3.25rem;
  padding: 0.5rem 1rem;
  background: #fff;
  border-bottom: 1px solid #dee2e6;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 1030;
}

@media (min-width: 992px) {
  .app-topbar {
    padding: 0.5rem 1.25rem 0.5rem 1rem;
  }
}

.app-topbar__brand {
  font-size: 1.35rem;
  font-weight: 700;
  font-style: italic;
  color: #00897b;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.app-topbar__clock {
  flex: 1;
  text-align: center;
  color: #6c757d;
  font-size: 0.9rem;
  min-width: 0;
}

.app-topbar__tenant {
  display: inline-block;
  background: var(--sirius-teal);
  color: #fff;
  padding: 0.35rem 0.95rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}

.app-topbar__user .dropdown-toggle {
  border: 0;
  padding: 0.25rem 0.5rem;
}

.app-topbar__user .dropdown-toggle::after {
  margin-left: 0.35rem;
}

.sidebar-rail__open-mobile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.5rem;
  min-height: 2.5rem;
  border-radius: 0.5rem;
}

/* Barra lateral estreita clara + offcanvas no mobile */
.sidebar-rail {
  --bs-offcanvas-width: min(18rem, 92vw);
  background: var(--sirius-sidebar-bg);
  color: #495057;
  border: 0;
  border-right: 1px solid #dee2e6;
  box-shadow: none;
}

.sidebar-rail .offcanvas-header {
  padding: 0.85rem 1rem;
}

.sidebar-rail__drawer-head {
  background: var(--sirius-sidebar-bg);
}

.sidebar-rail .offcanvas-body {
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-rail__body {
  padding: 0.75rem 0.4rem 1rem;
  min-height: 0;
}

.sidebar-rail__hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin: 0 auto 0.85rem;
  padding: 0;
  border: 0;
  border-radius: 0.5rem;
  background: transparent;
  color: #495057;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.sidebar-rail__hamburger:hover {
  background: rgba(0, 0, 0, 0.06);
}

.sidebar-rail__nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  align-items: stretch;
  width: 100%;
}

.sidebar-rail__link {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.75rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 0.5rem;
  color: #6c757d;
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.sidebar-rail__link i {
  font-size: 1.2rem;
  flex-shrink: 0;
  width: 1.5rem;
  text-align: center;
}

.sidebar-rail__link:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #343a40;
}

.sidebar-rail__link.active {
  background: var(--sirius-teal-muted);
  color: #00695c;
}

.sidebar-rail__link.active i {
  color: #00897b;
}

/* Desktop lg+: apenas ícones centralizados até expandir */
@media (min-width: 992px) {
  .sidebar-rail {
    --bs-offcanvas-width: var(--sirius-rail-collapsed);
    transition: flex-basis 0.2s ease, width 0.2s ease, min-width 0.2s ease, max-width 0.2s ease;
  }

  .sidebar-rail.sidebar-rail--expanded {
    --bs-offcanvas-width: var(--sirius-rail-expanded);
  }

  .sidebar-rail__hamburger {
    display: flex;
  }

  .sidebar-rail .offcanvas-body {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }

  .sidebar-rail:not(.sidebar-rail--expanded) .sidebar-rail__link {
    position: relative;
    justify-content: center;
    padding: 0.45rem;
  }

  .sidebar-rail:not(.sidebar-rail--expanded) .sidebar-rail__label {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
  }

  .sidebar-rail.sidebar-rail--expanded .sidebar-rail__link {
    justify-content: flex-start;
    padding: 0.45rem 0.75rem;
  }

  .app-layout > aside.sidebar-rail.offcanvas-lg {
    position: relative !important;
    transform: none !important;
    visibility: visible !important;
    display: flex !important;
    flex-direction: column;
    flex: 0 0 var(--bs-offcanvas-width);
    width: var(--bs-offcanvas-width);
    max-width: var(--bs-offcanvas-width);
    min-width: var(--bs-offcanvas-width);
    min-height: 100vh;
    height: auto;
    z-index: 2;
  }

  .app-layout > aside.sidebar-rail.offcanvas-lg .offcanvas-body {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    min-height: 0;
  }

  .sidebar-rail:not(.sidebar-rail--expanded) .sidebar-rail__body {
    padding-left: 0.35rem;
    padding-right: 0.35rem;
  }
}

.main-content {
  flex: 1 1 auto;
  min-height: 0;
  background-color: transparent;
}

.top-card {
  background: var(--comex-white);
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 0.5rem 1.25rem rgba(0, 40, 120, 0.08);
}

.info-card {
  border: 0;
  border-radius: 1rem;
  box-shadow: 0 0.45rem 1rem rgba(0, 40, 120, 0.08);
}

.info-card.green {
  background-color: var(--comex-green-soft);
}

.info-card.blue {
  background-color: #e4f0ff;
}

.nav-tabs .nav-link {
  color: var(--comex-blue);
  border: 0;
  border-radius: 0.75rem 0.75rem 0 0;
  font-weight: 600;
}

.nav-tabs .nav-link.active {
  color: #0b2f4d;
  background-color: var(--comex-green-soft);
  border-bottom: 3px solid var(--comex-blue-soft);
}

.tab-pane-card {
  background-color: var(--comex-white);
  border: 0;
  border-radius: 0 1rem 1rem 1rem;
  box-shadow: 0 0.45rem 1rem rgba(0, 40, 120, 0.08);
}

/* ----- Listagem estilo referência (pesquisa importação) ----- */
.page-title-outside {
  font-size: 1.375rem;
  font-weight: 700;
  color: #374151;
  letter-spacing: -0.02em;
  margin-bottom: 1rem;
  margin-top: 0;
}

.listing-shell-card {
  background: var(--comex-white);
  border-radius: 0.75rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  border: 1px solid rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.listing-card-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 1.125rem 1.5rem;
  border-bottom: 1px solid #e8eaed;
}

.listing-card-title {
  font-weight: 700;
  font-size: 1.0625rem;
  color: #1f2937;
  margin: 0;
}

.listing-card-title .listing-count {
  font-weight: 700;
  color: #6b7280;
}

.btn-filtro-avancado {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid #26a69a;
  color: #00897b;
  background: #fff;
  border-radius: 0.5rem;
  padding: 0.4375rem 1rem;
  font-size: 0.9375rem;
  font-weight: 500;
  line-height: 1.25;
  transition:
    color 0.15s ease,
    background-color 0.15s ease,
    border-color 0.15s ease;
}

.btn-filtro-avancado:hover {
  color: #00695c;
  background: #e0f2f1;
  border-color: #00897b;
}

.listing-filter-panel {
  padding: 1rem 1.5rem 1.25rem;
  background: #f8fafc;
  border-bottom: 1px solid #e8eaed;
}

.table-listing {
  --listing-row-alt: #f9fafb;
  margin-bottom: 0;
  font-size: 0.9375rem;
}

.table-listing thead th {
  background: #f3f4f6;
  color: #374151;
  font-weight: 700;
  font-size: 0.8125rem;
  text-transform: none;
  letter-spacing: 0;
  border-bottom: 1px solid #e5e7eb;
  white-space: nowrap;
  padding: 0.65rem 1rem;
}

.table-listing tbody td {
  padding: 0.65rem 1rem;
  vertical-align: middle;
  border-bottom: 1px solid #eef0f3;
  color: #1f2937;
}

.table-listing tbody tr:nth-child(even) {
  background-color: var(--listing-row-alt);
}

.table-listing tbody tr:nth-child(odd) {
  background-color: #fff;
}

.table-listing tbody tr:hover {
  background-color: #f0fdfa !important;
}

.table-listing .actions-cell {
  white-space: nowrap;
  text-align: center;
}

.table-listing .action-btns {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.table-listing .action-btns .btn-icon {
  color: #9ca3af;
  padding: 0.25rem;
  border: 0;
  background: transparent;
  border-radius: 0.35rem;
  line-height: 1;
}

.table-listing .action-btns .btn-icon:hover {
  color: #00897b;
  background: rgba(0, 137, 123, 0.08);
}

.badge-pill-warn {
  display: inline-block;
  background: #f5d565;
  color: #292524;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
}

.badge-pill-success {
  display: inline-block;
  background: #22c55e;
  color: #fff;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
}

.badge-pill-muted {
  display: inline-block;
  background: #e5e7eb;
  color: #4b5563;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-weight: 600;
  font-size: 0.75rem;
  white-space: nowrap;
}

.alert-cell-critico {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #dc2626;
  font-weight: 600;
  font-size: 0.875rem;
}

.alert-cell-critico i {
  font-size: 1rem;
}

.listing-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  border-top: 1px solid #e8eaed;
  font-size: 0.875rem;
  color: #6b7280;
}

.pagination-listing {
  margin-bottom: 0;
  gap: 0.125rem;
}

.pagination-listing .page-link {
  color: #00897b;
  border: none;
  background: transparent;
  padding: 0.35rem 0.5rem;
  line-height: 1;
  min-width: 2rem;
  text-align: center;
}

.pagination-listing .page-link:hover {
  color: #00695c;
  background: rgba(0, 137, 123, 0.08);
  border-radius: 0.35rem;
}

.pagination-listing .page-item.disabled .page-link {
  color: #6b7280;
  opacity: 1;
}

.pagination-listing .page-range-label {
  border: none;
  background: transparent;
  color: #6b7280;
  padding: 0.35rem 0.65rem;
  pointer-events: none;
}

/* Listagem + layout em telas pequenas */
@media (max-width: 991.98px) {
  .page-title-outside {
    font-size: 1.25rem;
    margin-bottom: 0.75rem;
  }

  .listing-card-header {
    padding: 1rem;
  }

  .listing-card-title {
    font-size: 1rem;
    width: 100%;
  }

  .listing-filter-panel {
    padding: 0.875rem 1rem 1rem;
  }

  .listing-footer {
    padding: 0.65rem 1rem;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }

  .listing-footer nav {
    display: flex;
    justify-content: center;
  }

  .pagination-listing .page-range-label {
    font-size: 0.8rem;
    padding: 0.35rem 0.35rem;
    max-width: 9rem;
    white-space: normal;
    line-height: 1.2;
  }

  .table-responsive {
    -webkit-overflow-scrolling: touch;
  }

  .table-listing {
    font-size: 0.8125rem;
  }

  .table-listing thead th,
  .table-listing tbody td {
    padding: 0.5rem 0.65rem;
  }

  .table-listing .action-btns {
    flex-wrap: wrap;
    justify-content: center;
    max-width: 6.5rem;
  }

  .badge-pill-warn,
  .badge-pill-success,
  .badge-pill-muted {
    font-size: 0.6875rem;
    padding: 0.28rem 0.55rem;
    white-space: normal;
    max-width: 11rem;
    text-align: center;
    line-height: 1.25;
  }
}

/* ----- Aba Gestão (importação): grupos suaves ----- */
.gestao-tab-stack {
  gap: 1.25rem;
}

.gestao-group {
  background: #fff;
  border-radius: 0.75rem;
  border: 1px solid rgba(15, 23, 42, 0.07);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.gestao-group__head {
  padding: 0.65rem 1.25rem;
  background: linear-gradient(90deg, rgba(38, 166, 154, 0.14) 0%, rgba(38, 166, 154, 0.05) 100%);
  border-bottom: 1px solid rgba(38, 166, 154, 0.18);
}

.gestao-group__title {
  display: block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #00897b;
  margin: 0;
}

.gestao-group__body {
  padding: 1.25rem;
}

.gestao-group .form-label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: #495057;
  margin-bottom: 0.35rem;
}

.gestao-group .form-control,
.gestao-group .form-select {
  border-color: #dee2e6;
  border-radius: 0.5rem;
  font-size: 0.9375rem;
}

.gestao-group .input-group-text {
  border-color: #dee2e6;
  color: #6c757d;
  border-radius: 0.5rem 0 0 0.5rem;
}

.gestao-table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  border-bottom-width: 1px;
}

#importacaoTabs.importacao-tabs-teal .nav-link {
  color: #495057;
  border-radius: 0.5rem 0.5rem 0 0;
}

#importacaoTabs.importacao-tabs-teal .nav-link:hover {
  color: #00897b;
}

#importacaoTabs.importacao-tabs-teal .nav-link.active {
  color: #00695c;
  background: #fff;
  border-bottom: 3px solid #26a69a;
}
