/* ===== VARIÁVEIS ===== */
:root {
  --primary-color: #1a237e;
  --success-color: #00A859;
  --warning-color: #FFF212;
  --danger-color: #ED3237;
  --orange-color: #F58634;
  --dark-color: #0d1b2a;
  --light-color: #f8f9fa;
  --gray-color: #6c757d;
  --border-radius: 6px;
  --box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --transition: all 0.2s ease;
}

/* ===== RESET ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #f0f2f5;
  color: #333;
  min-height: 100vh;
  font-size: 13px;
  padding: 0;
}

/* ===== CABEÇALHO COM STATUS ===== */
.dashboard-header {
  background: var(--primary-color);
  color: white;
  padding: 8px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 50px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
}

.logo i {
  font-size: 20px;
  color: #bbdefb;
}

.logo h1 {
  font-size: 18px;
  font-weight: 600;
}

/* Status no cabeçalho - à direita */
.system-status-header {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 12px;
}

.status-item-header {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.1);
  padding: 4px 8px;
  border-radius: 4px;
  transition: var(--transition);
}

.status-item-header:hover {
  background: rgba(255, 255, 255, 0.15);
}

.status-item-header i {
  font-size: 11px;
  color: #bbdefb;
}

/* ===== PAINEL SUPERIOR ===== */
.top-panel {
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 10px;
  padding: 10px 15px;
  background: transparent;
  min-height: 70px;
}

/* Leitura */
.scan-section {
  background: white;
  border-radius: var(--border-radius);
  padding: 8px;
  box-shadow: var(--box-shadow);
  border: 1px solid #e0e0e0;
}

.compact-controls {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 6px;
  align-items: center;
}

.compact-select, .compact-input {
  padding: 5px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  transition: var(--transition);
  background: white;
  height: 28px;
}

.compact-select:focus, .compact-input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 2px rgba(26, 35, 126, 0.08);
}

.btn-icon {
  background: linear-gradient(to right, var(--primary-color), #3949ab);
  color: white;
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: var(--transition);
  font-size: 12px;
}

.btn-icon:hover {
  background: linear-gradient(to right, #3949ab, #303f9f);
  transform: translateY(-1px);
}

.scan-feedback {
  margin-top: 5px;
  padding: 4px;
  border-radius: 4px;
  font-size: 11px;
  text-align: center;
  min-height: 16px;
  background: #f8f9fa;
  color: #666;
}

/* Estatísticas do Dia */
.daily-stats {
  background: white;
  border-radius: var(--border-radius);
  padding: 8px;
  box-shadow: var(--box-shadow);
  border: 1px solid #e0e0e0;
}

.stats-grid-ultra {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  height: 100%;
}

.stat-ultra {
  background: #f8f9fa;
  border-radius: var(--border-radius);
  padding: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  border: 1px solid #e9ecef;
  min-height: 45px;
}

.stat-ultra:hover {
  transform: translateY(-1px);
  box-shadow: var(--box-shadow);
}

.stat-value-ultra {
  font-size: 16px;
  font-weight: 700;
  color: var(--primary-color);
  line-height: 1;
}

.stat-label-ultra {
  font-size: 9px;
  color: var(--gray-color);
  margin-top: 2px;
  text-align: center;
  white-space: nowrap;
}

/* ===== BARRA DE DISTRIBUIÇÃO ===== */
.distribution-header {
  background: white;
  margin: 0 15px 10px 15px;
  padding: 8px 12px;
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  border: 1px solid #e0e0e0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 45px;
}

.flow-title-section {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
}

.flow-title-section i {
  color: var(--primary-color);
  font-size: 16px;
}

.flow-title-section h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--primary-color);
}

.total-ops {
  font-size: 14px;
  margin-left: 12px;
  color: #555;
  font-weight: 500;
}

.total-ops strong {
  color: var(--primary-color);
  font-weight: 700;
}

/* Distribuição por Cor - lado a lado */
.distribution-display {
  display: flex;
  align-items: center;
  gap: 20px;
  flex: 2;
  justify-content: center;
}

.dist-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #f8f9fa;
  padding: 4px 8px;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  transition: var(--transition);
}

.dist-item-header:hover {
  background: #f0f0f0;
  transform: translateY(-1px);
}

.dist-dot-header {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid white;
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.dist-label-header {
  font-size: 11px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

.dist-value-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--primary-color);
  min-width: 20px;
  text-align: right;
}

/* Botão de Atualização */
.btn-refresh-header {
  background: linear-gradient(to right, var(--primary-color), #3949ab);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.btn-refresh-header:hover {
  background: linear-gradient(to right, #3949ab, #303f9f);
  transform: translateY(-1px);
  box-shadow: 0 3px 6px rgba(0,0,0,0.1);
}

/* ===== CONTEÚDO PRINCIPAL ===== */
.dashboard-main {
  padding: 0 15px 10px;
  height: calc(100vh - 195px);
}

.board-container {
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Linhas do Board - 40% MAIS LARGAS */
.board-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  flex: 1;
  min-height: 300px;
}

#board-row-2 {
  grid-template-columns: repeat(6, 1fr);
}

/* Colunas - 40% MAIS LARGAS */
.column {
  background: #f8f9fa;
  border-radius: var(--border-radius);
  overflow: hidden;
  border: 1px solid #dee2e6;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
}

.column.empty-column {
  background: #f0f0f0;
  border: 1px dashed #ccc;
  opacity: 0.6;
}

.column.empty-column .column-header {
  background: #95a5a6;
}

.column.empty-column .col {
  background: repeating-linear-gradient(
    45deg,
    #f8f8f8,
    #f8f8f8 10px,
    #e8e8e8 10px,
    #e8e8e8 20px
  );
}

.column-header {
  background: #2c3e50;
  color: white;
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.column-header h3 {
  font-size: 11px;
  margin: 0;
  line-height: 1.1;
  text-align: center;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.column-count {
  background: rgba(255, 255, 255, 0.2);
  padding: 1px 4px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 10px;
  min-width: 18px;
  text-align: center;
}

/* Colunas das OPs - 4 COLUNAS POR SETOR */
.col {
  padding: 6px;
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  align-content: start;
  background: #fcfcfc;
}

/* Cards das OPs - MOLDURA 10% MAIOR QUE O NÚMERO */
.card {
  background: white;
  border-radius: 4px;
  padding: 4px;
  border: 1px solid #e0e0e0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: var(--transition);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  height: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-width: 0;
}

.card:hover {
  transform: scale(1.02);
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card-code {
  font-size: 9px;
  font-weight: 700;
  color: var(--dark-color);
  letter-spacing: 0.3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  padding: 0 2px;
}

/* CORES DE AGING - FUNDO COMPLETO COM CORES EXATAS */
.card.age-green { 
  background-color: #00A859 !important;
  border-color: #007a3f !important;
  color: #ffffff !important;
}
.card.age-yellow { 
  background-color: #FFF212 !important;
  border-color: #d4b900 !important;
  color: #000000 !important;
}
.card.age-orange { 
  background-color: #F58634 !important;
  border-color: #c4691e !important;
  color: #000000 !important;
}
.card.age-red { 
  background-color: #ED3237 !important;
  border-color: #b0262a !important;
  color: #ffffff !important;
}

/* Inversão de cores */
.card.invert {
  background: linear-gradient(135deg, #1a1a1a 0%, #2d2d2d 100%) !important;
  color: #fff !important;
  border-color: #fff !important;
}
.card.invert .card-code { color: #fff; }

/* ===== RODAPÉ ===== */
.dashboard-footer {
  background: var(--dark-color);
  color: white;
  height: 25px;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 11px;
}

/* ===== SCROLLBAR PERSONALIZADO ===== */
::-webkit-scrollbar {
  width: 4px;
  height: 4px;
}

::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3949ab;
}

/* ===== RESPONSIVIDADE ===== */
@media (max-width: 1400px) {
  .distribution-display {
    gap: 12px;
  }
  
  .dist-item-header {
    padding: 4px 6px;
  }
  
  .dist-label-header {
    font-size: 10px;
  }
  
  .dist-value-header {
    font-size: 12px;
  }
}

@media (max-width: 1200px) {
  .board-row {
    grid-template-columns: repeat(3, 1fr);
  }
  
  #board-row-2 {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .distribution-header {
    flex-wrap: wrap;
    height: auto;
    padding: 10px;
    gap: 10px;
  }
  
  .flow-title-section {
    order: 1;
    width: 100%;
    justify-content: center;
    margin-bottom: 8px;
  }
  
  .distribution-display {
    order: 2;
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
  }
  
  .btn-refresh-header {
    order: 3;
    margin: 0 auto;
  }
}

@media (max-width: 900px) {
  .board-row {
    grid-template-columns: repeat(2, 1fr);
  }
  
  #board-row-2 {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .col {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .top-panel {
    grid-template-columns: 1fr;
  }
  
  .system-status-header {
    gap: 10px;
    font-size: 11px;
  }
}

@media (max-width: 600px) {
  .board-row {
    grid-template-columns: 1fr;
  }
  
  #board-row-2 {
    grid-template-columns: 1fr;
  }
  
  .col {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .stats-grid-ultra {
    grid-template-columns: repeat(2, 1fr);
  }
  
  .distribution-display {
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
  }
  
  .dist-item-header {
    width: 100%;
    justify-content: space-between;
  }
}

/* ===== SELEÇÃO DE BLOCO POR CLIQUE NO TÍTULO ===== */
.compact-select {
  display: none;
}

.column-header[data-sector-key] {
  cursor: pointer;
  user-select: none;
}

.column-header.active-sector {
  box-shadow: 0 0 0 3px rgba(26, 35, 126, 0.25);
  border-radius: 6px;
}

.btn-undo {
  opacity: 0.9;
}

.btn-undo:hover {
  opacity: 1;
}



/* ===== MODAIS (Expedição / NF-e) ===== */
.modal-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.modal-overlay.hidden{ display:none; }

.modal-box{
  background: #ffffff;
  width: 360px;
  max-width: calc(100vw - 32px);
  border-radius: 10px;
  padding: 14px 14px 12px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}
.modal-title{
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 2px;
}
.modal-subtitle{
  font-size: 12px;
  opacity: 0.75;
  margin-bottom: 10px;
}
.modal-row{
  display:flex;
  gap:10px;
  align-items: center;
  margin: 8px 0;
}
.modal-row label{
  width: 58px;
  font-size: 12px;
  font-weight: 600;
}
.modal-row input, .modal-row textarea{
  flex:1;
  border: 1px solid rgba(0,0,0,0.18);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  outline: none;
}
.modal-row textarea{
  min-height: 64px;
  resize: none;
}
.modal-actions{
  display:flex;
  justify-content: flex-end;
  gap:10px;
  margin-top: 10px;
}
.btn-modal{
  border: 0;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
}
.btn-modal.primary{ background: #111827; color:#fff; }
.btn-modal.secondary{ background: #e5e7eb; color:#111827; }

.modal-hint{
  margin-top: 8px;
  font-size: 11px;
  opacity: 0.7;
}


.legenda-img {
  height: 34px;
  margin-left: 10px;
  object-fit: contain;
}
