/* =========================================================
   KOTORI 小鳥 — ESTILOS DE ABAS, TABELAS, CARDS & DASHBOARD
   ========================================================= */

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Cabeçalhos de seção e barra de ações */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.section-head h2 {
  margin: 0;
  font-size: 1.35rem;
  color: var(--espresso);
}

.section-head h3,
.section-head h4 {
  margin: 0;
  color: var(--espresso);
}

.actions-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Cards base */
.card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 2px 10px rgba(45, 36, 30, 0.03);
}

.form-box {
  max-width: 780px;
}

/* Grade de KPIs */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
}

.kpi-grid-5 {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

@media (max-width: 1100px) {
  .kpi-grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 600px) {
  .kpi-grid-5 {
    grid-template-columns: 1fr;
  }
}

.kpi-card {
  background: var(--surface, #ffffff);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  box-shadow: 0 2px 8px rgba(45, 36, 30, 0.03);
}

.kpi-card span {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--espresso-light);
}

.kpi-card strong {
  font-size: 1.28rem;
  color: var(--espresso);
  line-height: 1.2;
}

.kpi-card small {
  font-size: 0.75rem;
  color: var(--espresso-light);
  line-height: 1.3;
}

.kpi-card.highlight {
  border-color: var(--sage);
  background: #f6faf7;
}

/* Estoque CNPJ / CPF & Tooltip */
.kpi-estoque-val-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-tooltip-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  outline: none;
}

.info-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border-radius: 99px;
  background: #ece6dc;
  color: var(--espresso);
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.info-tooltip-pop {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--espresso);
  color: #fff;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: nowrap;
  z-index: 40;
  flex-direction: column;
  gap: 4px;
  font-size: 0.74rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18);
}

.info-tooltip-wrap:hover .info-tooltip-pop,
.info-tooltip-wrap:focus .info-tooltip-pop {
  display: flex;
}

.split-pill {
  font-weight: 600;
}

/* Grades de gráficos e rankings do Dashboard */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.charts-grid .full-span {
  grid-column: 1 / -1;
}

@media (max-width: 860px) {
  .charts-grid {
    grid-template-columns: 1fr;
  }
}

.dash-bar-list {
  display: flex;
  flex-direction: column;
}

.dash-inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--espresso-light);
}

/* Tabelas */
.table-wrap {
  overflow-x: auto;
  padding: 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

/* Garante que células <td> com class="actions-row" mantenham altura de célula de tabela */
td.actions-row {
  display: table-cell;
  white-space: nowrap;
}

td.actions-row > .actions-row {
  display: inline-flex;
}

th {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--espresso-light);
  background: #faf8f5;
  white-space: nowrap;
}

th[data-sort] {
  cursor: pointer;
  user-select: none;
}

th[data-sort]:hover {
  color: var(--espresso);
  background: #f3efe8;
}

tbody tr:hover {
  background: #fcfbf9;
}

tbody tr:last-child td {
  border-bottom: none;
}

/* Subtabelas expansíveis (Lotes, Vendas, Clientes, Break-even) */
.lote-master-row {
  cursor: pointer;
}

.lote-details-row td {
  background: #faf8f5;
  padding: 10px 14px;
}

.lote-subtable {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  font-size: 0.83rem;
}

.lote-subtable th {
  background: #f4f0e8;
  padding: 8px 10px;
}

.lote-subtable td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}

.lote-subtable tr:last-child td {
  border-bottom: none;
}

/* Estados de linha e badges */
tr.low-stock {
  background: #fff7f5;
}

tr.low-stock:hover {
  background: #ffefec;
}

tr.canceled {
  opacity: 0.62;
  background: #f9f7f5;
}

.stock-cell {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 99px;
  font-size: 0.72rem;
  font-weight: 600;
  background: #ece7df;
  color: var(--espresso-light);
  white-space: nowrap;
}

.badge-ok {
  background: #e3f1e8;
  color: #2a593d;
}

.badge-warn-soft {
  background: #fde8e4;
  color: var(--danger);
}

.badge-pre-venda {
  background: #fff3d6;
  color: #8a5a00;
}

.badge-brinde {
  background: #e6effa;
  color: #234c7a;
}

.badge-uso-loja {
  background: #ece8f5;
  color: #4a3775;
}

.badge-cpf {
  background: #f3ece2;
  color: #6d5843;
}

/* Miniaturas de produto */
.prod-thumb {
  width: 34px;
  height: 34px;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: #faf8f5;
}

.prod-thumb-placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px dashed var(--border);
  background: #faf8f5;
  color: #999;
  font-size: 0.62rem;
  text-align: center;
}

/* Barra de filtros da aba Gastos */
.gastos-filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding: 12px 14px;
}

.gastos-filter-bar input[type="search"] {
  min-width: 220px;
  flex: 1;
}

.date-range-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.82rem;
  color: var(--espresso-light);
}

/* Dropdown de exportação */
.export-dropdown {
  position: relative;
  display: inline-block;
}

.export-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 150px;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(45, 36, 30, 0.12);
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.export-menu button {
  background: none;
  border: none;
  padding: 9px 14px;
  text-align: left;
  font-size: 0.84rem;
  color: var(--espresso);
  cursor: pointer;
}

.export-menu button:hover {
  background: #faf8f5;
}

/* Linhas de itens nos modais de Lote e Venda */
.lote-item-row,
.venda-item-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)) auto;
  gap: 10px;
  align-items: end;
  background: #faf8f5;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
}

.sku-picker-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sku-picker-wrap select {
  flex: 1;
  min-width: 0;
}

.currency-inline-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.currency-inline-group .moeda-select {
  width: 82px;
  flex-shrink: 0;
}

.import-only {
  background: #fbf9f5;
}