html {
  overflow-x: hidden;
}

/* Scrollbars de todo o sistema: fina, SEM fundo (trilho transparente) */
* {
  scrollbar-width: thin;
  scrollbar-color: rgb(148 163 184 / 0.55) transparent;
}
::-webkit-scrollbar {
  width: 9px;
  height: 9px;
  background: transparent;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: rgb(148 163 184 / 0.5);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgb(148 163 184 / 0.75);
}
::-webkit-scrollbar-corner {
  background: transparent;
}

html.theme-light * {
  scrollbar-color: rgb(100 116 139 / 0.55) transparent;
}
html.theme-light ::-webkit-scrollbar-thumb {
  background-color: rgb(100 116 139 / 0.45);
}
html.theme-light ::-webkit-scrollbar-thumb:hover {
  background-color: rgb(100 116 139 / 0.7);
}

/* ===== Transicao suave entre telas (View Transitions API) =====
   Numa navegacao same-origin, o navegador faz um crossfade nativo entre as
   paginas. A sidebar recebe um view-transition-name proprio e estavel: como sua
   geometria nao muda entre as telas, ela fica PARADA (nao pisca) enquanto so o
   conteudo faz o fade. Navegadores sem suporte ignoram e fazem a navegacao
   normal (sem animacao, mas sem o flicker da Fase 0). */
@view-transition { navigation: auto; }
.app-sidebar { view-transition-name: app-sidebar; }
::view-transition-old(root),
::view-transition-new(root) { animation-duration: 180ms; }
@media (prefers-reduced-motion: reduce) {
  ::view-transition-group(*),
  ::view-transition-old(*),
  ::view-transition-new(*) { animation: none !important; }
}

/* Scroll interno das tabelas/listas: altura DINAMICA = acompanha a tela do usuario.
   Cresce conforme a viewport; rola por dentro quando o conteudo passa do limite. */
.table-scroll {
  max-height: calc(100vh - 22rem);
  max-height: calc(100dvh - 22rem);
  overflow-y: auto;
  overflow-x: auto;
}

/* Conteudo com fundo transparente (content_transparent=True no base.html): os
   cards de dentro SAO o proprio conteudo. O respiro do topo vem do mt-6 do
   wrapper; aqui zeramos a margem do PRIMEIRO card pra ele "colar" no topo (sem
   margem dupla). O espacamento ENTRE os cards fica por conta do gap/space-y da
   propria tela (ex.: Acessos e Dashboard usam grid gap-4). */
.content-transparent > :first-child { margin-top: 0; }

/* Modais (overlays fixed inset-0, filhos diretos do body) precisam ficar ACIMA do
   cabecalho sticky (z-index 20), senao o titulo "vaza" por cima do escurecido.
   Abaixo do toast (z-80), que deve aparecer sobre o modal. */
body > .fixed.inset-0 { z-index: 50; }

/* Botoes "Novo/criar": texto na cor do FUNDO DO CARD (efeito de texto "transparente"
   que se mistura ao card). button.btn-blend vence o utilitario .text-slate-950 do Tailwind. */
button.btn-blend { color: #0e1122; transition: filter 160ms ease; } /* tema escuro: cor do card */
button.btn-blend:hover { filter: brightness(1.1); }
html.theme-light button.btn-blend { color: #eceff4; }              /* tema claro: cor do card */

/* Botao de reload (so icone) do dashboard: gira no hover e roda enquanto carrega */
.refresh-icon-btn svg { transition: transform 500ms ease; }
.refresh-icon-btn:hover svg { transform: rotate(-180deg); }
.refresh-icon-btn.is-loading svg { animation: refresh-spin 0.8s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }

body,
button,
input,
select,
textarea {
  min-width: 0;
}

button,
input,
select,
textarea {
  max-width: 100%;
}

select option,
select optgroup {
  background-color: rgb(255 255 255);
  color: rgb(30 58 138);
}

select option:checked {
  background-color: rgb(219 234 254);
  color: rgb(30 58 138);
}

#modalBackdrop,
#infoBackdrop,
#filterBackdrop,
#inventoryBackdrop {
  z-index: 40;
}

#modal,
#infoModal,
#filterModal,
#inventoryModal {
  z-index: 50;
}

#modal > div,
#infoModal > div,
#filterModal > div,
#inventoryModal > div {
  display: flex;
  max-height: calc(100dvh - 2rem);
  flex-direction: column;
  overflow: hidden;
}

.modal-body {
  min-height: 0;
  overflow-y: auto;
}

#statusesWrap,
#fieldsWrap,
#fieldsContainer,
#inventoryFieldsByCategory {
  max-height: min(22rem, 42dvh);
  overflow-y: auto;
  scrollbar-width: thin;
}

#statusesWrap,
#fieldsWrap,
#fieldsContainer,
#inventoryFieldsByCategory,
.modal-body {
  scrollbar-color: rgb(148 163 184 / 0.45) transparent;
}

.mobile-topbar,
.mobile-sidebar-backdrop,
.mobile-sidebar-close {
  display: none;
}

.sidebar-collapse-toggle {
  display: grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  margin-left: auto;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 0.65rem;
  background: rgb(255 255 255 / 0.05);
  color: rgb(226 232 240);
  font-size: 1.25rem;
  line-height: 1;
  transition: background 160ms ease, transform 160ms ease;
}

.sidebar-collapse-toggle:hover {
  background: rgb(255 255 255 / 0.1);
}

.sidebar-icon-wrap {
  color: rgb(125 211 252);
}

.sidebar-icon-svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Link ATIVO da sidebar: destaque chamativo com a cor da marca (#c99339/#bb7c38)
   + barra lateral esquerda, pra deixar claro qual tela esta selecionada. */
.sidebar-link-active {
  background: rgb(187 124 56 / 0.16);
  border-color: rgb(201 147 57 / 0.55) !important;
  color: #e7b873;
  font-weight: 600;
  box-shadow: inset 3px 0 0 0 #c99339;
}
.sidebar-link-active .sidebar-icon-wrap {
  color: #e7b873;
  background: rgb(201 147 57 / 0.18);
  border-color: rgb(201 147 57 / 0.5);
}
/* Tema claro: mesma ideia, tons mais escuros pra legibilidade sobre fundo claro */
html.theme-light .sidebar-link-active {
  background: rgb(201 147 57 / 0.2);
  border-color: rgb(187 124 56 / 0.55) !important;
  color: #875518;
  box-shadow: inset 3px 0 0 0 #bb7c38;
}
html.theme-light .sidebar-link-active .sidebar-icon-wrap {
  color: #875518;
  background: rgb(201 147 57 / 0.22);
  border-color: rgb(187 124 56 / 0.5);
}

/* ===== Grupos da sidebar (submenus expansiveis) ===== */
.nav-group-header { color: inherit; cursor: pointer; }
.nav-chevron { transition: transform 220ms ease; }
/* filho direto: subgrupo abre/fecha independente do grupo pai */
.nav-group.open > .nav-group-header .nav-chevron { transform: rotate(180deg); }

/* Colapso animado do submenu: grid-template-rows 0fr -> 1fr (inner com overflow hidden) */
.nav-group-items {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 220ms ease;
}
.nav-group.open > .nav-group-items { grid-template-rows: 1fr; }
.nav-group-items-inner {
  overflow: hidden;
  margin: 0.15rem 0 0.35rem 1.4rem;
  padding-left: 0.6rem;
  border-left: 1px solid rgb(255 255 255 / 0.08);
}

/* Itens do submenu */
.nav-subitem {
  color: rgb(203 213 225);
  transition: background-color 160ms ease, color 160ms ease, box-shadow 160ms ease, border-color 160ms ease;
}
.nav-subitem-dot {
  flex: 0 0 auto;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 999px;
  background: currentColor;
  opacity: 0.45;
}
.nav-subitem.sidebar-link-active .nav-subitem-dot { opacity: 1; }

html.theme-light .nav-group-items-inner { border-left-color: #cdd5e1; }
html.theme-light .nav-subitem { color: #475569; }

/* Rotulo dos subgrupos (ex.: Integracoes) na MESMA cor de um submenu normal */
.nav-subgroup > .nav-group-header { color: rgb(203 213 225); }
html.theme-light .nav-subgroup > .nav-group-header { color: #475569; }

.app-toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 80;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: min(24rem, calc(100vw - 2rem));
  min-height: 3.25rem;
  overflow: hidden;
  border: 1px solid rgb(34 211 238 / 0.28);
  border-radius: 0.9rem;
  background: rgb(15 23 42 / 0.96);
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.34);
  color: rgb(226 232 240);
  opacity: 0;
  padding: 0.85rem 1rem;
  pointer-events: none;
  transform: translateY(0.7rem) scale(0.98);
  transition: opacity 220ms ease, transform 220ms ease;
  backdrop-filter: blur(14px);
}

.app-toast::before {
  content: "";
  flex: 0 0 auto;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 999px;
  background: rgb(34 211 238);
  box-shadow: 0 0 0 0.35rem rgb(34 211 238 / 0.13);
}

.app-toast::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, rgb(34 211 238), rgb(129 140 248));
  transform: scaleX(0);
  transform-origin: left;
}

/* Variante de erro: pontinho, borda e barra vermelhos (distincao real do sucesso) */
.app-toast.toast-error {
  border-color: rgb(244 63 94 / 0.45);
  background: rgb(31 12 16 / 0.96);
}

.app-toast.toast-error::before {
  background: rgb(244 63 94);
  box-shadow: 0 0 0 0.35rem rgb(244 63 94 / 0.15);
}

.app-toast.toast-error::after {
  background: linear-gradient(90deg, rgb(244 63 94), rgb(251 113 133));
}

.app-toast.toast-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.app-toast.toast-visible::after {
  animation: toast-timeline 2200ms linear forwards;
}

.app-toast.hidden.toast-leaving {
  display: flex !important;
  opacity: 0;
  transform: translateY(0.7rem) scale(0.98);
}

@keyframes toast-timeline {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@media (min-width: 768px) {
  /* Trava a altura na tela: o body nao rola, quem rola e o conteudo interno */
  body > .min-h-screen.flex {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  /* Sidebar fixa. Sem overflow aqui: o aside e o container do botao de recolher
     (por causa do backdrop-blur), e um overflow cortaria o botao que fica meio
     pra fora da borda quando a sidebar esta recolhida. */
  body > .min-h-screen.flex > aside {
    height: 100vh;
    height: 100dvh;
  }

  /* O main passa a ser a area que rola */
  body > .min-h-screen.flex > main {
    height: 100vh;
    height: 100dvh;
    overflow-y: auto;
    padding-top: 0;
  }

  /* O titulo (primeiro bloco do main) fica fixo no topo enquanto o resto rola */
  body > .min-h-screen.flex > main > :first-child {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgb(2 6 23);
    padding-top: 2.5rem;
    padding-bottom: 1rem;
  }

  /* content_fit: cards + tabela cabem na viewport; a tabela absorve o resto e rola
     por dentro (em vez do cap fixo de 22rem do .table-scroll). Reutilizavel: o filho
     direto com .fit-grow cresce; os demais ficam na altura natural. */
  main.main-fit { display: flex; flex-direction: column; }
  main.main-fit > .content-fit { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .content-fit > * { flex: 0 0 auto; }
  .content-fit > .fit-grow { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .content-fit .fit-grow > .table-scroll { flex: 1 1 auto; min-height: 0; max-height: none; }

  body > .min-h-screen.flex > aside {
    transition: width 180ms ease;
  }

  body.sidebar-collapsed > .min-h-screen.flex > aside {
    width: 5.25rem !important;
  }

  body.sidebar-collapsed > .min-h-screen.flex > aside .leading-tight,
  body.sidebar-collapsed > .min-h-screen.flex > aside nav .uppercase,
  body.sidebar-collapsed > .min-h-screen.flex > aside nav a span:last-child,
  body.sidebar-collapsed > .min-h-screen.flex > aside > .px-5.pb-6 {
    display: none;
  }

  body.sidebar-collapsed > .min-h-screen.flex > aside > .h-16 {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  body.sidebar-collapsed > .min-h-screen.flex > aside nav {
    padding-left: 0.55rem;
    padding-right: 0.55rem;
  }

  body.sidebar-collapsed > .min-h-screen.flex > aside nav a {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }

  body.sidebar-collapsed .sidebar-collapse-toggle {
    position: absolute;
    right: -1rem;
    top: 1rem;
    z-index: 5;
    background: rgb(15 23 42);
  }

  /* Grupos no modo recolhido: mostra so o icone; o submenu vira flyout no hover */
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group-header .flex-1,
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-chevron {
    display: none;
  }
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group-header {
    justify-content: center;
    padding-left: 0.5rem;
    padding-right: 0.5rem;
  }
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group { position: relative; }
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group-items {
    position: absolute;
    left: calc(100% + 0.4rem);
    top: 0;
    z-index: 90;
    min-width: 12rem;
    grid-template-rows: 1fr;
    display: none;
  }
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group:hover .nav-group-items {
    display: block;
  }
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group-items-inner {
    margin: 0;
    padding: 0.4rem;
    border: 1px solid rgb(255 255 255 / 0.1);
    border-radius: 0.85rem;
    background: rgb(15 23 42 / 0.98);
    box-shadow: 0 20px 50px rgb(0 0 0 / 0.35);
    backdrop-filter: blur(12px);
  }
  /* No flyout os subitens voltam ao layout normal (label visivel, alinhado a esquerda) */
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group-items a {
    justify-content: flex-start !important;
    padding-left: 0.6rem !important;
    padding-right: 0.6rem !important;
  }
  body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group-items a span:last-child {
    display: inline !important;
  }
  html.theme-light body.sidebar-collapsed > .min-h-screen.flex > aside .nav-group-items-inner {
    background: #eceff4;
    border-color: #cdd5e1;
  }
}

@media (max-width: 767px) {
  body > .min-h-screen.flex {
    display: block !important;
  }

  body.mobile-menu-open {
    overflow: hidden;
  }

  .mobile-topbar {
    position: sticky;
    top: 0;
    z-index: 35;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 4rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid rgb(255 255 255 / 0.1);
    background: rgb(2 6 23 / 0.96);
    backdrop-filter: blur(12px);
  }

  .mobile-topbar-text {
    min-width: 0;
    line-height: 1.2;
    text-align: right;
  }

  .mobile-topbar-kicker {
    color: rgb(148 163 184);
    font-size: 0.75rem;
  }

  .mobile-topbar-title {
    max-width: 12rem;
    overflow: hidden;
    color: rgb(241 245 249);
    font-size: 0.875rem;
    font-weight: 500;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-menu-button,
  .mobile-sidebar-close {
    display: grid;
    place-items: center;
    width: 2.75rem;
    height: 2.75rem;
    border: 1px solid rgb(255 255 255 / 0.1);
    border-radius: 0.75rem;
    background: rgb(255 255 255 / 0.05);
    color: rgb(226 232 240);
  }

  .sidebar-collapse-toggle {
    display: none;
  }

  .mobile-menu-button:active,
  .mobile-sidebar-close:active {
    background: rgb(255 255 255 / 0.1);
  }

  .hamburger-icon {
    display: grid;
    gap: 0.25rem;
    width: 1.25rem;
  }

  .hamburger-icon span {
    display: block;
    height: 2px;
    border-radius: 999px;
    background: currentColor;
  }

  .mobile-sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: block;
    border: 0;
    background: rgb(0 0 0 / 0.6);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
  }

  body.mobile-menu-open .mobile-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  body > .min-h-screen.flex > aside {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 60;
    width: min(18rem, 84vw) !important;
    height: 100dvh;
    overflow-y: auto;
    border-right: 1px solid rgb(255 255 255 / 0.1) !important;
    border-bottom: 0 !important;
    background: rgb(2 6 23 / 0.96);
    box-shadow: 24px 0 80px rgb(0 0 0 / 0.35);
    transform: translateX(-100%);
    transition: transform 220ms ease;
  }

  body.mobile-menu-open > .min-h-screen.flex > aside {
    transform: translateX(0);
  }

  body > .min-h-screen.flex > aside > .h-16 {
    height: auto;
    min-height: 4rem;
    padding-block: 0.75rem;
  }

  .mobile-sidebar-close {
    margin-left: auto;
  }

  body > .min-h-screen.flex > aside nav {
    overflow: visible;
    padding-bottom: 1rem;
  }

  body > .min-h-screen.flex > aside nav > .uppercase {
    display: block;
  }

  body > .min-h-screen.flex > aside nav > .space-y-1 {
    display: block;
    overflow: visible;
    padding-bottom: 0;
  }

  body > .min-h-screen.flex > aside > .px-5.pb-6 {
    padding: 0 1.25rem 1.25rem;
  }

  body > .min-h-screen.flex > main {
    min-width: 0;
    padding: 1.5rem 1rem !important;
  }

  body > .min-h-screen.flex > main > .flex.items-start.justify-between,
  body > .min-h-screen.flex > main > .flex.items-center.justify-between {
    align-items: stretch !important;
    flex-direction: column;
    gap: 1rem;
  }

  body > .min-h-screen.flex > main > .flex.items-start.justify-between button {
    width: 100%;
  }

  #modal,
  #infoModal,
  #filterModal,
  #inventoryModal {
    align-items: flex-end !important;
    padding: 0 !important;
  }

  #modal > div,
  #infoModal > div,
  #filterModal > div,
  #inventoryModal > div {
    width: 100%;
    max-height: 100dvh;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

  #statusesWrap,
  #fieldsWrap,
  #fieldsContainer,
  #inventoryFieldsByCategory {
    max-height: 16rem;
  }

  #modal > div > .px-6,
  #infoModal > div > .px-6,
  #filterModal > div > .px-6,
  #inventoryModal > div > .px-6 {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }

  #modal > div > .flex.items-center.justify-between.gap-3 {
    align-items: stretch !important;
    flex-direction: column-reverse;
  }

  #modal > div > .flex.items-center.justify-between.gap-3 button {
    width: 100%;
  }

  #categoriesList > div {
    align-items: stretch !important;
    flex-direction: column;
  }

  #categoriesList > div > div:last-child {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
  }

  .responsive-table {
    overflow: visible !important;
  }

  .responsive-table table,
  .responsive-table thead,
  .responsive-table tbody,
  .responsive-table tr,
  .responsive-table td {
    display: block;
    width: 100%;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody {
    border-top: 0;
  }

  .responsive-table tr {
    padding: 0.75rem 1rem;
  }

  .responsive-table tr + tr {
    border-top: 1px solid rgb(255 255 255 / 0.1);
  }

  .responsive-table td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0 !important;
    text-align: right;
    word-break: break-word;
  }

  .responsive-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    color: rgb(148 163 184);
    font-size: 0.75rem;
    font-weight: 500;
    letter-spacing: 0;
    text-align: left;
    text-transform: uppercase;
  }

  .responsive-table td[colspan] {
    display: block;
    text-align: left;
  }

  .responsive-table td[colspan]::before {
    display: none;
  }

  .responsive-table td > .flex {
    flex-wrap: wrap;
    justify-content: flex-end;
  }
}

@media (max-width: 480px) {
  body.min-h-screen.flex.items-center.justify-center {
    align-items: flex-start;
    padding: 1rem;
  }

  body.min-h-screen.flex.items-center.justify-center .relative.p-7 {
    padding: 1.25rem;
  }
}

/* Interruptor de tema (sol/lua) no rodape da sidebar */
.theme-switch-wrap {
  display: flex;
  justify-content: center;
  margin-top: 0.85rem;
}

.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.3rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 0.7rem;
  line-height: 1;
}

.theme-switch .ts-track {
  position: relative;
  width: 2.3rem;
  height: 1.2rem;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.12);
  border: 1px solid rgb(255 255 255 / 0.16);
  transition: background 160ms ease, border-color 160ms ease;
}

.theme-switch .ts-knob {
  position: absolute;
  top: 50%;
  left: calc(100% - 1.07rem);   /* tema escuro: knob a direita (lado da lua) */
  transform: translateY(-50%);
  width: 0.9rem;
  height: 0.9rem;
  border-radius: 999px;
  background: #e2e8f0;
  box-shadow: 0 1px 2px rgb(0 0 0 / 0.3);
  transition: left 180ms ease, background 160ms ease;
}

.theme-switch .ts-icon { transition: opacity 160ms ease; }
.theme-switch .ts-sun { opacity: 0.4; }
.theme-switch .ts-moon { opacity: 1; }

/* Tema claro: knob a esquerda (lado do sol), realca o sol */
html.theme-light .theme-switch .ts-knob { left: 0.17rem; background: #f59e0b; }
html.theme-light .theme-switch .ts-track { background: #cbd5e1; border-color: #94a3b8; }
html.theme-light .theme-switch .ts-sun { opacity: 1; }
html.theme-light .theme-switch .ts-moon { opacity: 0.4; }

/* =====================================================================
   TEMA CLARO  (ativado por html.theme-light; toggle no mobile-menu.js)
   Override dos utilitarios dark escritos inline nos templates.
   A especificidade ".theme-light .classe" vence o utilitario do Tailwind.
   ===================================================================== */

html.theme-light body { background-color: #d2d9e4; color: #0f172a; }

/* Fundos — base cinza (pagina/modal) com superficies off-white (cards/inputs)
   um pouco mais escuras que branco puro, mantendo contraste sobre a pagina. */
html.theme-light .bg-slate-950 { background-color: #d2d9e4; }   /* pagina/modal */

/* Sombra suave para destacar os cards/paineis sobre o fundo cinza */
html.theme-light .rounded-2xl.border,
html.theme-light .rounded-xl.border {
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.08), 0 1px 2px rgb(15 23 42 / 0.05);
}
html.theme-light .bg-slate-950\/60 { background-color: #eceff4; } /* sidebar */
html.theme-light .bg-slate-950\/30 { background-color: #e2e6ec; } /* linhas/pilulas dentro de cards */
html.theme-light .bg-white\/5 { background-color: #eceff4; }     /* cards/inputs/secoes */
html.theme-light .bg-white\/10 { background-color: #dde2ea; }
html.theme-light .bg-white\/20 { background-color: #cbd5e1; }

/* Hover de fundo */
html.theme-light .hover\:bg-white\/5:hover { background-color: #e4e8ee; }
html.theme-light .hover\:bg-white\/10:hover { background-color: #d3dae4; }

/* Bordas */
html.theme-light .border-white\/10 { border-color: #cdd5e1; }
html.theme-light .border-white\/20 { border-color: #b8c2d0; }
html.theme-light .hover\:border-white\/10:hover { border-color: #b8c2d0; }
/* separadores das listas/tabelas (divide-y) visiveis no tema claro */
html.theme-light .divide-white\/10 > :not([hidden]) ~ :not([hidden]) { border-color: #cdd5e1; }

/* Textos */
html.theme-light .text-slate-100 { color: #0f172a; }
html.theme-light .text-slate-200 { color: #1e293b; }
html.theme-light .text-slate-300 { color: #334155; }
html.theme-light .text-slate-400 { color: #475569; }
html.theme-light .text-slate-500 { color: #64748b; }
/* Texto dos botoes (gradiente azul): igual a cor do fundo da pagina no tema claro
   (efeito "2D"). No tema escuro permanece slate-950, que ja e a cor do fundo escuro. */
html.theme-light .text-slate-950 { color: #d2d9e4; }

/* Acentos: melhorar legibilidade sobre fundo claro */
html.theme-light .text-rose-200 { color: #be123c; }
html.theme-light .text-rose-300 { color: #e11d48; }
html.theme-light .text-emerald-100 { color: #047857; }
html.theme-light .text-emerald-200 { color: #059669; }
html.theme-light .text-amber-200,
html.theme-light .text-amber-300 { color: #b45309; }
html.theme-light .text-cyan-100,
html.theme-light .text-cyan-200 { color: #0e7490; }

/* Scrollbars finas */
html.theme-light #statusesWrap,
html.theme-light #fieldsWrap,
html.theme-light #fieldsContainer,
html.theme-light #inventoryFieldsByCategory,
html.theme-light .modal-body {
  scrollbar-color: rgb(100 116 139 / 0.5) transparent;
}

/* Titulo/subtitulo: mesma cor da pagina = "sem fundo" (e cobre o conteudo que rola) */
html.theme-light body > .min-h-screen.flex > main > :first-child {
  background: #d2d9e4;
}

/* Botao de recolher a sidebar */
html.theme-light .sidebar-collapse-toggle {
  border-color: #cdd5e1;
  background: #eceff4;
  color: #334155;
}
html.theme-light .sidebar-collapse-toggle:hover { background: #e4e8ee; }
html.theme-light body.sidebar-collapsed .sidebar-collapse-toggle { background: #eceff4; }

/* Icones da sidebar (SVG injetado) */
html.theme-light .sidebar-icon-wrap { color: #0891b2; }

/* Toast */
html.theme-light .app-toast {
  background: rgb(255 255 255 / 0.98);
  color: #1e293b;
  border-color: rgb(8 145 178 / 0.4);
  box-shadow: 0 20px 50px rgb(15 23 42 / 0.15);
}
html.theme-light .app-toast.toast-error {
  background: rgb(255 241 242 / 0.98);
  border-color: rgb(244 63 94 / 0.45);
  color: #9f1239;
}

/* Topbar e sidebar mobile */
html.theme-light .mobile-topbar { background: rgb(236 239 244 / 0.96); border-bottom-color: #cdd5e1; }
html.theme-light .mobile-topbar-kicker { color: #64748b; }
html.theme-light .mobile-topbar-title { color: #0f172a; }
html.theme-light .mobile-menu-button,
html.theme-light .mobile-sidebar-close {
  border-color: #cdd5e1;
  background: #e4e8ee;
  color: #334155;
}
html.theme-light body > .min-h-screen.flex > aside {
  background: #eceff4;
}

/* Tabela responsiva (modo mobile) */
html.theme-light .responsive-table tr + tr { border-top-color: #cdd5e1; }
html.theme-light .responsive-table td::before { color: #64748b; }

/* =====================================================================
   CORES DA MARCA (Triade)  --  #c99339 (claro) / #bb7c38 (escuro)
   Remapeia os acentos cian/indigo do sistema para o dourado da marca.
   ===================================================================== */

/* Botoes gradiente (create/primary): degrade da marca */
html .from-cyan-400 {
  --tw-gradient-from: #c99339 var(--tw-gradient-from-position);
  --tw-gradient-to: rgb(201 147 57 / 0) var(--tw-gradient-to-position);
  --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to);
}
html .to-indigo-500 {
  --tw-gradient-to: #bb7c38 var(--tw-gradient-to-position);
}

/* Foco dos inputs (ring/borda) na cor da marca */
html .focus\:ring-cyan-400\/60:focus { --tw-ring-color: rgb(201 147 57 / 0.6); }
html .focus\:ring-cyan-400\/40:focus { --tw-ring-color: rgb(201 147 57 / 0.45); }
html .focus\:border-cyan-400\/60:focus { border-color: rgb(201 147 57 / 0.65); }

/* Textos/icones de acento */
html .text-cyan-200,
html .text-cyan-300 { color: #c99339; }
html .hover\:text-cyan-300:hover { color: #c99339; }
html.theme-light .text-cyan-100,
html.theme-light .text-cyan-200,
html.theme-light .text-cyan-300 { color: #a6692c; }

.sidebar-icon-wrap { color: #c99339; }
html.theme-light .sidebar-icon-wrap { color: #a6692c; }

/* Toast (acento de sucesso) na cor da marca */
.app-toast { border-color: rgb(201 147 57 / 0.35); }
.app-toast::before { background: #c99339; box-shadow: 0 0 0 0.35rem rgb(201 147 57 / 0.14); }
.app-toast::after { background: linear-gradient(90deg, #c99339, #bb7c38); }
html.theme-light .app-toast { border-color: rgb(187 124 56 / 0.4); }

/* Card selecionado (mini-dash de Clientes): anel dourado da marca, visivel nos 2 temas */
.cust-card-active { border-color: #c99339 !important; box-shadow: 0 0 0 2px #c99339; }
html.theme-light .cust-card-active { border-color: #a6692c !important; box-shadow: 0 0 0 2px #a6692c; }

/* Checkbox estilizado (appearance:none) — visual proprio, imune a extensoes/navegador
   que repintam o input nativo (ex.: autofill de CPF/CNPJ virando "radio"). */
input.pick[type="checkbox"] {
  -webkit-appearance: none; appearance: none;
  flex: 0 0 auto; width: 1rem; height: 1rem; margin: 0;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 0.3rem;
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer; position: relative;
}
input.pick[type="checkbox"]:checked { background: #22d3ee; border-color: #22d3ee; }
input.pick[type="checkbox"]:checked::after {
  content: ""; position: absolute; left: 4.5px; top: 1px;
  width: 4px; height: 8px; border: solid #0f172a; border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}
html.theme-light input.pick[type="checkbox"] { border-color: #94a3b8; background: #ffffff; }
html.theme-light input.pick[type="checkbox"]:checked { background: #0891b2; border-color: #0891b2; }
html.theme-light input.pick[type="checkbox"]:checked::after { border-color: #ffffff; }

/* Card de destaque (Total faturado): destaque por CONTRASTE de tema (borda dourada) */
.cust-card-hero { background: rgba(255, 255, 255, 0.12); border-color: #c99339; }   /* escuro: um pouco mais claro que os cards normais */
html.theme-light .cust-card-hero { background: #1e293b; border-color: #c99339; }     /* claro: card escuro (tipo tema-escuro) */
/* no tema claro o fundo fica escuro -> textos internos voltam as cores do tema escuro p/ contraste */
html.theme-light .cust-card-hero .text-slate-400 { color: #94a3b8; }
html.theme-light .cust-card-hero #cardFaturado { color: #a7f3d0; }

/* Logo da marca no quadradinho da sidebar (substitui o icone via JS) */
.sidebar-logo { width: 100%; height: 100%; object-fit: contain; border-radius: 0.45rem; }
