* {
  box-sizing: border-box;
}
body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #f4f6f8;
  color: #172033;
}
header {
  background: #111827;
  color: #fff;
  padding: 18px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
h1 {
  font-size: 21px;
  margin: 0;
}
header small {
  opacity: 0.7;
}
main {
  max-width: 1350px;
  margin: 22px auto;
  padding: 0 16px;
}
nav {
  background: #fff;
  border-bottom: 1px solid #e5e7eb;
  padding: 0 24px;
  display: flex;
  gap: 4px;
}
nav button {
  background: none;
  border: 0;
  padding: 14px 18px;
  color: #6b7280;
  cursor: pointer;
}
nav button.active {
  color: #111827;
  font-weight: bold;
  border-bottom: 2px solid #111827;
}
.panel {
  background: white;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
  box-shadow: 0 2px 12px #0001;
}
.search {
  display: flex;
  gap: 10px;
}
.search input {
  flex: 1;
}
input,
select,
button {
  font: inherit;
}
input,
select {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px;
}
button {
  border: 0;
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
}
.primary {
  background: #111827;
  color: white;
}
.light {
  background: #eef2f7;
  color: #172033;
}
.filters {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 10px;
}
/* Produtos e Estoque: 5 itens por linha (menos em telas menores) */
.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 15px;
}
@media (max-width: 1250px) {
  .cards {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
@media (max-width: 1000px) {
  .cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
@media (max-width: 820px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 10px #0001;
}
.photo {
  height: 185px;
  background: #eef2f7;
  display: flex;
  align-items: center;
  justify-content: center;
}
.photo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.photo span {
  color: #6b7280;
}
.content {
  padding: 15px;
}
.sku {
  font-size: 12px;
  color: #6b7280;
}
/* Cards da aba Produtos: código e fornecedor como etiquetas iguais, centralizadas */
.sku-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center; /* a etiqueta fica do tamanho do texto (sem esticar na altura) */
  gap: 6px;
}
.name {
  font-weight: bold;
  margin: 6px 0;
}
.desc {
  font-size: 12px;
  color: #6b7280;
  min-height: 32px;
}
/* Aba Produtos (XBZ e demais fornecedores): todos os cards de uma linha com as mesmas alturas,
   para preço, estoque, tabela de quantidades e botões ficarem alinhados de um card para o outro. */
#cards .card {
  display: flex;
  flex-direction: column;
}
#cards .content {
  flex: 1;
  display: flex;
  flex-direction: column;
}
#cards .sku {
  min-height: 0; /* só uma linha: etiqueta do código + etiqueta do fornecedor */
}
#cards .name,
#cards .desc {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
#cards .name {
  -webkit-line-clamp: 2;
  line-height: 1.25;
  min-height: 2.5em;
  text-align: center; /* nome centralizado, alinhado com as etiquetas de cima */
}
#cards .desc {
  -webkit-line-clamp: 4;
  line-height: 1.35;
  min-height: 5.4em;
  height: 5.4em;
}
#cards .quote-add-row {
  margin-top: auto !important; /* empurra Qtd. e botões para o fim do card */
  padding-top: 10px;
}
#cards .quote-add-row > div,
#cards .quote-add-row > button,
#cards .quote-add-row + button {
  width: 100%;
}
#cards .quote-add-row .quote-qty {
  width: 100% !important;
  box-sizing: border-box;
}
.tag {
  display: inline-block;
  background: #eef2ff;
  border-radius: 99px;
  padding: 3px 7px;
  font-size: 11px;
}
.price {
  font-size: 26px;
  font-weight: 800;
  margin: 11px 0 2px;
}
.cost {
  font-size: 12px;
  color: #6b7280;
}
.stock {
  font-size: 13px;
  margin: 8px 0;
}
.admin {
  border-top: 1px solid #e5e7eb;
  margin-top: 10px;
  padding-top: 10px;
  font-size: 12px;
}
.hidden {
  display: none !important;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th,
td {
  text-align: left;
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
}
th {
  font-size: 12px;
  color: #6b7280;
  text-transform: uppercase;
}
.right {
  text-align: right;
}
.msg {
  padding: 10px;
  border-radius: 8px;
  background: #ecfdf5;
  margin-top: 10px;
  font-size: 13px;
}
@media (max-width: 900px) {
  .search,
  .filters {
    display: flex;
    flex-direction: column;
  }
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.login-box {
  width: min(390px, calc(100% - 30px));
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 20px 60px #0004;
}
.login-box h2 {
  margin: 0 0 8px;
}
.login-box p {
  font-size: 13px;
  color: #667085;
  margin: 0 0 18px;
}
.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.login-field input {
  width: 100%;
}
.login-actions {
  display: flex;
  gap: 8px;
  margin-top: 15px;
}
.login-error {
  color: #b42318;
  background: #fef3f2;
  padding: 9px;
  border-radius: 8px;
  font-size: 12px;
  margin-top: 10px;
}

:root {
  --bordeaux: #7b1e2b;
  --bordeaux-dark: #5d1520;
  --bordeaux-light: #f7ecee;
}
header {
  background: linear-gradient(135deg, var(--bordeaux-dark), var(--bordeaux));
  min-height: 76px;
}
header h1 {
  display: none;
}
.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand img {
  height: 54px;
  width: auto;
  display: block;
  background: #fff;
  border-radius: 8px;
  padding: 3px;
}
.brand small {
  color: #fff;
  opacity: 0.9;
}
nav button.active {
  color: var(--bordeaux);
  border-bottom-color: var(--bordeaux);
}
.primary {
  background: var(--bordeaux) !important;
  border-color: var(--bordeaux) !important;
}
.primary:hover {
  background: var(--bordeaux-dark) !important;
}
button.light:hover {
  border-color: var(--bordeaux);
  color: var(--bordeaux);
}
input:focus,
select:focus {
  border-color: var(--bordeaux) !important;
  box-shadow: 0 0 0 2px rgba(123, 30, 43, 0.1);
}
.tag {
  background: var(--bordeaux-light) !important;
  color: var(--bordeaux) !important;
}
.price {
  color: var(--bordeaux) !important;
}
.login-box h2 {
  color: var(--bordeaux);
}


/* Melhorias de experiência para vendedores no celular */
@media (max-width: 700px) {
  body {
    background: #f4f6f8;
    overflow-x: hidden;
  }
  header .brand {
    flex: 1;
    min-width: 0;
  }
  header .brand small {
    display: block;
    max-width: 45vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  header .light,
  header button {
    flex: 0 0 auto;
  }

  header {
    padding: 10px 12px;
    min-height: 64px;
  }
  .brand {
    gap: 8px;
    min-width: 0;
  }
  .brand img {
    height: 42px;
    max-width: 180px;
    object-fit: contain;
  }
  .brand small {
    font-size: 10px;
    line-height: 1.2;
  }
  header .light,
  header button {
    padding: 8px 9px;
    font-size: 12px;
    white-space: nowrap;
  }

  nav {
    padding: 0 8px;
    gap: 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  nav button {
    padding: 13px 14px;
    min-height: 46px;
    white-space: nowrap;
    flex: 0 0 auto;
  }

  main {
    width: 100%;
    max-width: none;
    margin: 10px auto;
    padding: 0 10px;
  }
  .panel {
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
  }

  .search,
  .filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  .search input,
  .filters input,
  .filters select,
  .search select {
    width: 100%;
    min-height: 48px;
    font-size: 16px;
  }
  input,
  select,
  button {
    min-height: 44px;
  }


  .cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .card {
    border-radius: 10px;
  }
  .photo {
    height: 180px;
  }
  .content {
    padding: 12px;
  }
  .name {
    font-size: 16px;
    line-height: 1.2;
  }
  .desc {
    font-size: 12px;
    min-height: 0;
    margin-top: 6px;
  }
  .price {
    font-size: 28px;
    margin-top: 10px;
  }
  .stock {
    font-size: 13px;
  }
  .admin {
    font-size: 12px;
  }

  table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  th,
  td {
    padding: 9px 8px;
  }

  .login-box {
    width: calc(100% - 24px);
    padding: 20px;
  }
  .login-actions {
    flex-direction: column;
  }
  .login-actions button {
    width: 100%;
  }
}

@media (max-width: 380px) {
  .brand img {
    height: 38px;
    max-width: 150px;
  }
  .photo {
    height: 160px;
  }
  .price {
    font-size: 26px;
  }
}

.quote-qty:invalid {
  border-color: #b42318 !important;
  box-shadow: 0 0 0 2px rgba(180, 35, 24, 0.08);
}
.quantity-prices {
  margin-top: 12px;
  border-top: 1px solid #e5e7eb;
  padding-top: 10px;
}
.quantity-prices-title {
  font-size: 12px;
  font-weight: 700;
  color: #475467;
  margin-bottom: 6px;
}
.quantity-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 0;
  font-size: 12px;
}
.quantity-row span:first-child {
  color: #667085;
}
.quantity-row strong {
  color: var(--bordeaux);
}
.quantity-note {
  font-size: 10px;
  color: #98a2b3;
  margin-top: 4px;
}
.tier-editor {
  display: grid;
  grid-template-columns: repeat(6, minmax(180px, 1fr));
  gap: 8px;
  align-items: stretch;
  margin-top: 8px;
}
.tier-editor input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
}
.tier-card {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  padding: 8px;
  background: #fafafa;
}
.tier-label {
  font-size: 11px;
  color: #475467;
  font-weight: 700;
  margin-bottom: 6px;
}
.tier-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
}
.tier-grid input:last-child {
  grid-column: 1/-1;
}
.sale-unit-box {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.sale-unit-box label {
  font-size: 11px;
  color: #667085;
  font-weight: 700;
}
.sale-unit-box input {
  width: 90px;
}
.tier-save-note {
  font-size: 10px;
  color: #98a2b3;
  margin-top: 6px;
}
@media (max-width: 700px) {
  .tier-editor {
    grid-template-columns: 1fr 1fr;
    gap: 7px;
  }
}

.category-help {
  font-size: 12px;
  color: #667085;
  line-height: 1.45;
}
.category-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.category-summary span {
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 6px 9px;
  font-size: 11px;
}

/* Abas: Início / Produtos / Cliente / Vendedores */
nav {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
nav::-webkit-scrollbar {
  display: none;
}
nav button {
  white-space: nowrap;
  flex: 0 0 auto;
}
nav button.active {
  color: var(--bordeaux) !important;
  border-bottom-color: var(--bordeaux) !important;
}
/* Logo do cabeçalho: botão que leva ao Início */
header button.brand {
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}
/* Logo centralizada; nome da conta e Sair ficam no canto direito */
header {
  position: relative;
  justify-content: center;
}
header .header-user {
  position: absolute;
  right: 28px;
  top: 50%;
  transform: translateY(-50%);
}
/* Abas do menu centralizadas ("safe": no celular, com rolagem, a primeira aba não fica cortada) */
nav {
  justify-content: center;
  justify-content: safe center;
}
/* Backup e Sair com o mesmo visual da caixinha do nome da conta (.user-box) */
header #backupBtn,
header #logoutBtn {
  padding: 8px 12px !important;
  border: 1px solid #ffffff55 !important;
  border-radius: 8px !important;
  background: #ffffff1a !important;
  color: #fff !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: normal;
  box-shadow: none !important;
  cursor: pointer;
}
header #backupBtn:hover,
header #logoutBtn:hover {
  background: #ffffff33 !important;
}
/* Edição de cliente: botões centralizados, todos bordô e do mesmo tamanho */
#editClientForm .crud-actions {
  justify-content: center;
}
#editClientForm .crud-actions button,
#accountList .crud-btns button {
  background: var(--bordeaux) !important;
  border: 1px solid var(--bordeaux) !important;
  color: #fff !important;
  font-weight: 700;
  min-width: 150px;
}
#editClientForm .crud-actions button:hover,
#accountList .crud-btns button:hover {
  background: var(--bordeaux-dark) !important;
}
/* Aba Contas: Editar, Bloquear e Excluir iguais (mesma cor e largura) */
#accountList .crud-btns {
  align-items: center;
}
#accountList .crud-btns button {
  min-width: 96px;
}
.notes-info {
  text-align: center;
  font-weight: 700;
  color: #172033;
}
.billing-value {
  font-weight: 700;
  color: var(--bordeaux);
}
header button.brand:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
  border-radius: 10px;
}

/* Tela de entrar / gerar conta */
.auth-hint {
  color: #667085;
  font-size: 12px;
  line-height: 1.4;
}
.seller-me {
  font-size: 11px;
  font-weight: 600;
  color: var(--bordeaux);
  background: var(--bordeaux-light);
  border-radius: 999px;
  padding: 2px 8px;
  vertical-align: middle;
}
.acct-group {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 18px 0 10px;
  font-size: 15px;
}
.acct-group:first-child {
  margin-top: 4px;
}
.acct-group span {
  font-size: 12px;
  border-radius: 999px;
  padding: 1px 9px;
  background: #f2f4f7;
  color: #344054;
}
.acct-group.acct-pendente span {
  background: #fffaeb;
  color: #b54708;
}
.acct-group.acct-aprovado span {
  background: #ecfdf3;
  color: #067647;
}
.acct-group.acct-bloqueado span {
  background: #fef3f2;
  color: #b42318;
}
.acct-me {
  color: #667085;
}
.auth-overlay {
  background: linear-gradient(135deg, var(--bordeaux-dark), var(--bordeaux));
  overflow-y: auto;
  padding: 24px 0;
}
body.auth-locked {
  overflow: hidden;
}
body.auth-locked #quoteFab {
  display: none;
}
.auth-logo {
  display: block;
  height: 56px;
  margin: 0 auto 14px;
}
.auth-overlay .login-field input {
  min-height: 44px;
  font-size: 16px;
}
.auth-overlay .login-actions button {
  width: 100%;
}
.auth-switch {
  text-align: center;
  margin: 14px 0 0 !important;
}
.link-btn {
  background: none;
  padding: 0;
  color: var(--bordeaux);
  font-weight: 700;
  text-decoration: underline;
}
.login-error.auth-ok {
  color: #067647;
  background: #ecfdf3;
}

/* Início */
/* Avisos do sistema (só admin): caixa discreta acima dos números */
.admin-avisos {
  max-width: 760px;
  margin: 0 auto 14px;
  padding: 10px 14px;
  border: 1px solid #f1c27d;
  border-left: 4px solid #dc8a00;
  border-radius: 10px;
  background: #fffaf0;
  color: #5f4100;
  font-size: 13px;
}
.admin-avisos ul {
  margin: 6px 0 0;
  padding-left: 18px;
}
.admin-avisos li {
  margin: 3px 0;
  overflow-wrap: anywhere;
}
.admin-avisos li.aviso-info {
  color: #6b7280;
}
.home-grid {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 16px;
}
.home-count {
  width: 220px;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  text-align: center;
}
.home-count b {
  font-size: 40px;
  line-height: 1.1;
  color: #172033;
}
.home-count small {
  color: #667085;
  font-size: 14px;
}
.home-install {
  text-align: center;
  margin-bottom: 16px;
}
.home-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
}
.gallery-item {
  margin: 0;
}
.gallery-item img,
.gallery-item video {
  width: 100%;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 10px;
  display: block;
  background: #1f2937;
}
.home-gallery > .crud-empty {
  grid-column: 1/-1;
}
/* Foto do Início em tela cheia (dois cliques, js/galeria.js) */
.gallery-item img {
  cursor: zoom-in;
}
#galleryFull {
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: #000;
  cursor: zoom-out;
}
#galleryFull::backdrop {
  background: #000;
}
#galleryFull img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
/* Pesquisa das fotos do Início pelo nome (js/galeria.js) */
.gallery-search {
  margin-bottom: 12px;
}
.gallery-search .crud-search {
  margin-bottom: 0;
}
.gallery-item figcaption {
  margin-top: 5px;
  font-size: 13px;
  color: #475467;
  text-align: center;
}
.gallery-missing {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background: #fde8ea;
  color: var(--bordeaux);
  font-size: 11px;
  text-align: center;
}

/* Botão de configuração do painel de fotos (só administrador e Marketing) */
.home-cfg {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 120px;
  background: #fff;
  border: 1px dashed #d0d5dd;
  border-radius: 12px;
  color: #475467;
  box-shadow: 0 2px 10px #0001;
}
.home-cfg svg {
  width: 34px;
  height: 34px;
  color: var(--bordeaux);
}
.home-cfg small {
  font-size: 13px;
  font-weight: 600;
}
.home-cfg:hover,
.home-cfg:focus-visible {
  border-color: var(--bordeaux);
  border-style: solid;
}
body.role-admin .home-cfg,
body.role-marketing .home-cfg {
  display: flex;
}

/* Conta conectada (ao lado do Sair) */
.header-user {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.user-box {
  display: block;
  padding: 8px 12px;
  border: 1px solid #ffffff55;
  border-radius: 8px;
  background: #ffffff1a;
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Marketing e Estoque: Início sem os números de pedidos. Marketing, Estoque e Artes: sem orçamento. */
body.role-marketing #quoteFab,
body.role-estoque #quoteFab,
body.role-artes #quoteFab,
body.role-faturamento #quoteFab,
body.role-producao #quoteFab {
  display: none !important;
}

/* Número do pedido/orçamento antes do nome do cliente (Orçamentos, Pedidos e Faturamento) */
/* Número do pedido: largura fixa e à esquerda, para os números ficarem alinhados um abaixo do outro */
.order-code {
  display: inline-block;
  min-width: 3.4em;
  box-sizing: border-box;
  text-align: center;
  margin-right: 8px;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--bordeaux-light);
  color: var(--bordeaux);
  font-size: 11px;
  font-weight: 700;
  vertical-align: 1px;
}
/* Orçamento: dois modos de pagamento */
.quote-check {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}
.quote-check input {
  width: auto !important;
  min-height: 0 !important;
}
#qPayment2Rest {
  color: var(--bordeaux);
  font-weight: 700;
}

/* Pedidos: coluna Layout */
.order-layout {
  white-space: nowrap;
}
.layout-btn {
  padding: 7px 10px;
  font-size: 13px;
  margin-right: 4px;
}
.layout-none {
  font-size: 12px;
  color: #98a2b3;
}
.order-status:disabled {
  opacity: 1;
  cursor: default;
}

/* Situação só para ver (conta Vendedor) */
.order-status-ro {
  display: inline-block;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
}
/* Edição de cliente: 3 campos em cima e 3 embaixo */
.crud-form.client-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
/* Edição de cliente: grade de 6 colunas; cada linha ocupa a largura toda (bordas alinhadas)
   Nome + CPF | Telefone + E-mail | CEP + Cidade + Bairro | Rua + Número | Complemento + Inscrição estadual */
/* (a janela "Aprovar orçamento", #approveClientForm, usa a mesma grade) */
#editClientForm.client-grid,
#approveClientForm.client-grid {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}
#editClientForm.client-grid > .ec-2,
#approveClientForm.client-grid > .ec-2 {
  grid-column: span 2;
}
#editClientForm.client-grid > .ec-3,
#approveClientForm.client-grid > .ec-3 {
  grid-column: span 3;
}
#editClientForm.client-grid > .ec-4,
#approveClientForm.client-grid > .ec-4 {
  grid-column: span 4;
}
#editClientForm.client-grid > .crud-actions,
#approveClientForm.client-grid > .ec-6 {
  grid-column: 1 / -1;
}
#approveClientForm .crud-actions,
#stockDialog .crud-actions {
  justify-content: center;
}
#apName[readonly] {
  background: #f3f4f6;
}
@media (max-width: 700px) {
  .crud-form.client-grid,
  #editClientForm.client-grid,
  #approveClientForm.client-grid {
    grid-template-columns: 1fr;
  }
  #editClientForm.client-grid > label,
  #approveClientForm.client-grid > label {
    grid-column: auto;
  }
}
/* Vendedores: pesquisa por data centralizada */
.hist-filter-center {
  justify-content: center;
}

/* Edição de cliente (aba própria) */
.back-btn {
  padding: 8px 12px;
  font-size: 13px;
  margin-bottom: 6px;
}

/* Aba Estoque */
.stock-card {
  cursor: pointer;
}
.stock-reserved {
  margin-top: -4px;
  color: var(--bordeaux);
}
.stock-actions {
  display: flex;
  flex-wrap: wrap; /* Editar, Extrato e Excluir: quebram linha em cards estreitos */
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
/* Histórico do pedido (admin), no fim da janela de itens */
.order-history {
  margin-top: 16px;
  padding-top: 10px;
  border-top: 1px solid #e5e7eb;
  font-size: 13px;
}
.order-history h3 {
  margin: 0 0 6px;
  font-size: 14px;
  color: var(--bordeaux);
}
.order-history ul {
  margin: 0;
  padding-left: 18px;
  max-height: 220px;
  overflow-y: auto;
}
.order-history li {
  margin: 3px 0;
  overflow-wrap: anywhere;
}
.order-history .hist-when,
.order-history .hist-detail {
  color: #6b7280;
}
/* Extrato do estoque: entradas em verde, saídas em bordô */
.move-in {
  color: #027a48;
  font-weight: 700;
}
.move-out {
  color: var(--bordeaux);
  font-weight: 700;
}
.stock-nocost {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #b54708;
  background: #fffaeb;
  border-radius: 6px;
  padding: 4px 8px;
  text-align: center;
}
/* Pedidos: colunas com largura fixa para os espaços ficarem iguais */
@media (min-width: 701px) {
  .order-list {
    table-layout: fixed;
  }
  /* Títulos e conteúdo centralizados; colunas iguais conforme quantas o tipo de conta vê */
  .order-table.order-list th,
  .order-table.order-list td {
    text-align: center;
  }
  /* Coluna do cliente à esquerda: os números dos pedidos ficam alinhados um abaixo do outro */
  .order-table.order-list th:first-child,
  .order-table.order-list td:first-child {
    text-align: left;
    padding-left: 14px;
  }
  .order-list .order-btns {
    text-align: center;
  }
  /* Todas as colunas com a mesma largura */
  .order-cols-4 th {
    width: 25%;
  }
  .order-cols-5 th {
    width: 20%;
  }
  .order-cols-6 th {
    width: 16.66%;
  }
  .order-cols-7 th {
    width: 14.28%;
  }
  /* Caixa de situação menor */
  .order-list .order-status {
    min-width: 0;
    width: 100%;
    max-width: 175px;
    font-size: 12px;
    padding: 4px 4px;
  }
  .order-list td:first-child b {
    overflow-wrap: anywhere;
  }
  .order-layout {
    white-space: normal;
  }
}
.stock-form {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 16px;
  align-items: start;
}
.stock-photo {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stock-photo .photo {
  height: 200px;
  border-radius: 10px;
  background: #f2f4f7;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.stock-photo .photo img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}
.file-btn.file-btn-light {
  color: #172033;
  background: #eef2f6;
  justify-content: center;
}
.stock-check {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-size: 13px !important;
  color: #344054 !important;
}
.stock-check input {
  width: 18px;
  height: 18px;
}
body.role-marketing .home-cfg {
  width: auto;
  flex-direction: row;
  padding: 14px 22px;
}

/* Janelas (dialog) do painel */
.app-dialog {
  width: min(760px, calc(100% - 24px));
  max-height: calc(100% - 40px);
  border: 0;
  border-radius: 14px;
  padding: 18px 20px;
  box-shadow: 0 20px 60px #0005;
}
.app-dialog::backdrop {
  background: rgba(15, 23, 42, 0.55);
}
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.dialog-head h2 {
  margin: 0;
  font-size: 20px;
  color: var(--bordeaux);
}
.gallery-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.gallery-upload small {
  color: #667085;
}
.file-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  padding: 10px 14px;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}
.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}
.file-btn:focus-within {
  outline: 3px solid #d0d5dd;
  outline-offset: 2px;
}
.gallery-msg {
  min-height: 20px;
  margin: 10px 0;
  font-size: 13px;
  color: #067647;
}
.gallery-msg.is-error {
  color: #b42318;
}
.gallery-edit-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}
.gallery-edit-item {
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 8px;
}
.gallery-thumb {
  position: relative;
}
.gallery-thumb img,
.gallery-thumb video {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: #1f2937;
}
.gallery-badge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  background: #000a;
  border-radius: 4px;
  padding: 1px 5px;
}
.gallery-caption {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #667085;
}
.gallery-actions {
  display: flex;
  gap: 6px;
}
.gallery-actions button {
  padding: 8px 11px;
}
.gallery-actions button:disabled {
  opacity: 0.4;
  cursor: default;
}
.nf-dialog {
  width: min(560px, calc(100% - 24px));
}
.nf-info {
  font-size: 13px;
  color: #475467;
  margin: 0 0 10px;
}
/* Janela da NF-e (emissão direto na SEFAZ) */
.nf-env {
  margin: 0 0 12px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  background: #ecfdf3;
  color: #067647;
}
.nf-env.nf-env-teste {
  background: #fffaeb;
  color: #b54708;
}
.nf-hint {
  color: #667085;
  font-size: 12px;
}
.nf-hint:empty {
  display: none;
}
.nf-itens {
  display: table; /* no celular as tabelas viram bloco; esta precisa ocupar a largura toda */
  width: 100%;
}
.nf-itens td {
  vertical-align: middle;
}
.nf-ncm {
  width: 120px;
}
.nf-missing {
  margin-bottom: 12px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef3f2;
  color: #b42318;
  font-size: 12px;
}
.nf-missing ul {
  margin: 4px 0 0;
  padding-left: 18px;
}
.nf-dados {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  margin: 0 0 14px;
  font-size: 13px;
}
.nf-dados dt {
  color: #667085;
}
.nf-dados dd {
  margin: 0;
  font-weight: 600;
}
.nf-chave {
  font-family: ui-monospace, Consolas, monospace;
  word-break: break-word;
}
.nf-done .crud-actions,
.nf-evento .crud-actions,
#nfFormActions {
  justify-content: center;
}
/* Os 4 botões da nota emitida: mesmo tamanho e mesma cor, em grade 2 x 2 */
.nf-acoes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 420px;
  margin: 12px auto 0;
}
.nf-acoes button {
  width: 100%;
  min-height: 44px;
  margin: 0;
}
/* Subabas (centralizadas): Faturamento (Emitir nota | Nota emitida) e fornecedores da aba Produtos */
.sub-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px;
  border-bottom: 1px solid #e5e7eb;
  margin-bottom: 12px;
}
.sub-tabs button {
  background: none;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
  color: #6b7280;
  font-weight: 600;
  cursor: pointer;
}
.sub-tabs button.active {
  color: var(--bordeaux);
  border-bottom-color: var(--bordeaux);
}
.sub-count {
  display: inline-block;
  min-width: 22px;
  padding: 1px 7px;
  margin-left: 4px;
  border-radius: 999px;
  background: #f2f4f7;
  color: #475467;
  font-size: 12px;
}
.sub-tabs button.active .sub-count {
  background: var(--bordeaux);
  color: #fff;
}
.nf-canceladas {
  background: #fef3f2;
  border: 1px solid #fecdca;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 12px;
  font-size: 13px;
  color: #b42318;
}
.nf-canceladas p {
  margin: 4px 0;
}
.nf-canceladas small {
  color: #667085;
}
.nf-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #667085;
  margin-bottom: 12px;
}
.nf-field textarea {
  font: inherit;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px;
  resize: vertical;
}
.nf-ok {
  color: #067647 !important;
  font-weight: 600;
}
.order-ico {
  width: 44px;
  height: 44px;
  display: block;
}
.order-doc {
  display: block;
  color: #667085;
  font-size: 12px;
}

/* Histórico de vendas do cliente */
.client-history {
  flex-basis: 100%;
  border-top: 1px solid #e5e7eb;
  padding-top: 10px;
}
.hist-totals {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.hist-totals > div {
  background: var(--bordeaux-light);
  border-radius: 10px;
  padding: 10px 12px;
}
.hist-totals b {
  display: block;
  font-size: 18px;
  color: var(--bordeaux);
  margin: 0;
}
.hist-filter {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}
.hist-filter label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  color: #667085;
}
.order-gear {
  color: var(--bordeaux);
  animation: order-spin 3s linear infinite;
}
.order-ok {
  color: #12b76a;
}
@keyframes order-spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .order-gear {
    animation: none;
  }
}
.order-wrap {
  overflow-x: auto;
}
.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.order-table th {
  text-align: left;
  font-size: 12px;
  color: #667085;
  font-weight: 600;
  padding: 8px 10px;
  border-bottom: 1px solid #e5e7eb;
}
.order-table td {
  padding: 9px 10px;
  border-bottom: 1px solid #f2f4f7;
  vertical-align: middle;
}
.order-table tr:last-child td {
  border-bottom: 0;
}
/* Linha do pedido: dois cliques abrem os itens */
.order-row {
  cursor: pointer;
}
.order-row:hover td {
  background: var(--bordeaux-light);
}
.items-dialog {
  width: min(720px, calc(100vw - 32px));
}
#itemsList {
  max-height: 60vh;
  overflow: auto;
}
.items-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.items-table th,
.items-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #e5e7eb;
  text-align: center;
}
.items-table th {
  font-size: 12px;
  text-transform: uppercase;
  color: #667085;
}
.items-table td:first-child,
.items-table th:first-child {
  text-align: left;
}
.items-table tfoot td {
  font-weight: 700;
  border-bottom: 0;
}
/* Foto do item (janela de itens do pedido e da nota fiscal) */
.item-prod {
  display: flex;
  align-items: center;
  gap: 10px;
}
.item-thumb {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #eef2f7;
  overflow: hidden;
}
.item-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.items-table tfoot td:first-child {
  text-align: right;
}
.items-table tfoot td {
  padding: 5px 6px;
  font-weight: 600;
}
.items-table tfoot .items-total td {
  font-weight: 700;
  font-size: 15px;
}
.items-nf {
  justify-content: center;
  margin-top: 14px;
}
.order-late {
  color: #b42318;
  font-weight: 600;
}
.order-late small {
  font-weight: 400;
}
.order-status {
  font-size: 13px;
  padding: 6px 8px;
  border-radius: 999px;
  font-weight: 600;
  min-width: 170px;
}
.order-status.st-producao {
  background: #eff8ff;
  color: #175cd3;
}
.order-status.st-pronto {
  background: #ecfdf3;
  color: #067647;
}
.order-btns {
  white-space: nowrap;
  text-align: right;
}
.order-btns button {
  padding: 7px 10px;
  font-size: 13px;
  margin-left: 4px;
}
.acct-role {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 12px;
  color: #667085;
}
.acct-role select {
  padding: 6px 8px;
  font-size: 13px;
}
.crud-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
.crud-form label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  color: #667085;
}
.crud-form .crud-full {
  grid-column: 1/-1;
}
.crud-actions {
  grid-column: 1/-1;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.crud-search {
  width: 100%;
  margin-bottom: 12px;
}
.crud-list {
  display: grid;
  gap: 10px;
}
.crud-item {
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
/* Clientes e Vendedores: mesmo destaque das linhas dos Pedidos ao passar o mouse */
#clientList .crud-item:hover,
#sellerList .crud-item:hover {
  background: var(--bordeaux-light);
}
.client-item {
  cursor: pointer;
}
.crud-item b {
  display: block;
  margin-bottom: 3px;
}
.crud-item small {
  color: #667085;
  display: block;
  line-height: 1.5;
}
.crud-item .crud-btns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}
.crud-item .crud-btns button,
.crud-item .crud-btns a {
  padding: 8px 11px;
  font-size: 13px;
}
.crud-item .crud-btns a {
  display: inline-flex;
  align-items: center;
  border-radius: 8px;
  background: #ecfdf3;
  color: #067647;
  text-decoration: none;
}
.crud-empty {
  color: #667085;
  text-align: center;
  padding: 20px;
}
.danger {
  background: #fef3f2;
  color: #b42318;
}
@media (max-width: 700px) {
  nav {
    padding: 0 8px;
  }
  nav button {
    padding: 13px 12px;
  }
  .crud-form input,
  .crud-form select {
    min-height: 46px;
    font-size: 16px;
  }
  .crud-item {
    flex-direction: column;
    align-items: stretch;
  }
  .order-list,
  .order-list tbody {
    display: block;
  }
  .order-list thead {
    display: none;
  }
  .order-list tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 10px;
  }
  .order-list td {
    padding: 0;
    border: 0;
  }
  .order-list td:first-child,
  .order-list td:nth-child(4),
  .order-list .order-btns {
    grid-column: 1/-1;
  }
  .order-list td[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 11px;
    color: #667085;
    font-weight: 400;
  }
  .order-list .order-status {
    width: 100%;
    min-height: 42px;
  }
  .order-list .order-btns {
    text-align: left;
  }
  .order-list .order-btns button {
    margin: 0 6px 0 0;
  }
  .order-list .order-btns:empty {
    display: none;
  }
  .order-list .order-layout {
    grid-column: 1/-1;
  }
  .stock-form {
    grid-template-columns: 1fr;
  }
  .header-user {
    gap: 6px;
  }
  /* Celular: logo centralizada em cima, conta e Sair embaixo */
  header {
    flex-direction: column;
    gap: 8px;
  }
  header .header-user {
    position: static;
    transform: none;
  }
  header .brand {
    flex: 0 0 auto;
  }
  .user-box {
    max-width: 110px;
    padding: 5px 8px;
  }
  .user-box,
  header #backupBtn,
  header #logoutBtn {
    font-size: 12px !important;
  }
  header #backupBtn,
  header #logoutBtn {
    padding: 5px 8px !important;
  }
  .home-count {
    width: calc(50% - 7px);
    padding: 14px 8px;
  }
  .home-cfg {
    width: 100%;
    flex-direction: row;
    padding: 12px;
  }
  .home-cfg svg {
    width: 26px;
    height: 26px;
  }
  .gallery-edit-item {
    grid-template-columns: 64px 1fr;
  }
  .gallery-actions {
    grid-column: 1/-1;
    justify-content: flex-end;
  }
  .app-dialog {
    padding: 14px;
  }
  .home-count b {
    font-size: 32px;
  }
  .home-count small {
    font-size: 13px;
  }
  .home-gallery {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
  .hist-totals {
    grid-template-columns: 1fr;
  }
  .hist-filter label {
    flex: 1 1 140px;
  }
  .crud-search,
  .hist-filter input {
    min-height: 46px;
    font-size: 16px;
  }
  #inicio,
  #pedidos,
  #clientes,
  #vendedores {
    padding-bottom: 90px;
  }
}
