* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: #f3f4f6;
  color: #111827;
}

.login-page {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  position: relative;
  overflow: hidden;
  background: url('../img/login-bg.png') center center / cover no-repeat, #000d1f;
}

.login-page::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(0, 14, 31, 0.55) 0%, rgba(0, 14, 31, 0.35) 50%, rgba(0, 14, 31, 0.6) 100%);
}

.login-card {
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.97);
  padding: 2rem;
  border-radius: 0.75rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-link {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  color: #00407f;
  text-decoration: none;
  margin-top: -0.25rem;
}

.login-link:hover {
  text-decoration: underline;
}

.login-msg {
  font-size: 0.85rem;
  color: #16a34a;
  text-align: center;
  margin: 0;
}

.login-logos {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 1.25rem;
  margin-bottom: 0.25rem;
}

.login-logos .logo-marca {
  height: 42px;
}

.login-card h1 {
  font-size: 1.25rem;
  margin: 0 0 0.5rem;
  text-align: center;
}

.login-card label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.login-card input,
.admin-form input,
.admin-form select,
input[type='date'],
.multi-date-input {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
}

/* Multi-date picker */
.filtro-label {
  font-size: 0.875rem;
  white-space: nowrap;
}

#label-data {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

#label-data[hidden] {
  display: none;
}

/* Multi-select dropdown (semana/mês/ano) */
.ms-wrap {
  position: relative;
}

.ms-btn {
  padding: 0.5rem 0.6rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  background: white;
  color: #111827;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  min-width: 120px;
  text-align: left;
}

.ms-btn:hover {
  border-color: #9ca3af;
}

.ms-panel {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  z-index: 999;
  min-width: 100%;
  max-height: 240px;
  overflow-y: auto;
}

.ms-option {
  padding: 0.4rem 0.6rem;
  font-size: 0.82rem;
  cursor: pointer;
  color: #111827;
  white-space: nowrap;
}

.ms-option:hover {
  background: #f3f4f6;
}

.ms-option.selecionado {
  background: #e8f0f9;
  color: #00407f;
  font-weight: 600;
}

.multi-date-picker {
  position: relative;
}

.multi-date-input {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  font-family: inherit;
  cursor: pointer;
  background: white;
  min-width: 130px;
  color: #111827;
}

.cal-popup {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  background: white;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  z-index: 999;
  padding: 0.75rem;
  width: 260px;
  user-select: none;
}

.cal-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.6rem;
}

#cal-titulo {
  font-weight: 600;
  font-size: 0.9rem;
  color: #111827;
}

.cal-nav-btns {
  display: flex;
  gap: 0.25rem;
}

.cal-nav-btns button {
  background: none;
  border: none;
  padding: 0.1rem 0.4rem;
  font-size: 1rem;
  color: #374151;
  cursor: pointer;
  border-radius: 0.25rem;
  line-height: 1;
}

.cal-nav-btns button:hover {
  background: #f3f4f6;
}

.cal-semana-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: 0.72rem;
  color: #6b7280;
  margin-bottom: 0.25rem;
}

.cal-dias {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.cal-dia {
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1;
  font-size: 0.82rem;
  border-radius: 50%;
  cursor: pointer;
  color: #111827;
  border: none;
  background: none;
  padding: 0;
  width: 100%;
}

.cal-dia:hover {
  background: #f3f4f6;
}

.cal-dia.selecionado {
  background: #00407f;
  color: white;
  font-weight: 600;
}

.cal-dia.hoje:not(.selecionado) {
  border: 2px solid #00407f;
  color: #00407f;
  font-weight: 600;
}

.cal-dia.outro-mes {
  color: #d1d5db;
}

.cal-footer {
  margin-top: 0.5rem;
  text-align: right;
}

.cal-footer button {
  background: none;
  border: none;
  color: #00407f;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  padding: 0.2rem 0.4rem;
  letter-spacing: 0.05em;
}

.cal-footer button:hover {
  text-decoration: underline;
}

button {
  cursor: pointer;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  background: #00407f;
  color: white;
  font-size: 0.875rem;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-like[hidden] {
  display: none;
}

.btn-like {
  display: inline-block;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 0.375rem;
  background: #00407f;
  color: white;
  font-size: 0.875rem;
  text-decoration: none;
  line-height: 1.25;
}

.btn-like:hover {
  background: #002e5c;
}

.header-conta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
}

.header-conta-botoes {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.error {
  color: #dc2626;
  font-size: 0.875rem;
}

.dashboard {
  padding: 0.3rem 1rem 0;
  display: flex;
  flex-direction: column;
}

@media (min-width: 701px) {
  .dashboard {
    height: 100vh;
    overflow: hidden;
    box-sizing: border-box;
  }

  .dashboard .cards-grid {
    flex: 1;
    overflow: hidden;
    align-content: start;
  }
}

.admin-page,
.maquina-page {
  padding: 1.5rem;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-bottom: 0;
}

.header-esquerda {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.dashboard-header h1 {
  font-size: 1.2rem;
  margin: 0;
}

.header-direita {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.6rem;
}

.header-logos {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-marca {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.header-actions select,
.header-actions .ms-btn,
.header-actions .multi-date-input {
  font-size: 0.875rem;
  font-family: inherit;
  padding: 0.25rem 0.4rem;
  height: 1.9rem;
  box-sizing: border-box;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
}


.header-actions a:not(.btn-like) {
  color: #00407f;
  text-decoration: none;
  font-size: 0.875rem;
}

.user-badge {
  font-size: 0.8rem;
  color: #4b5563;
}

.machine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.5rem;
}

.machine-chart {
  background: white;
  border-radius: 0.75rem;
  padding: 1rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.machine-chart h3 {
  margin-top: 0;
}

.admin-form {
  background: white;
  border-radius: 0.75rem;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 420px;
  margin-bottom: 2rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay[hidden] {
  display: none;
}

.modal-caixa {
  background: white;
  border-radius: 0.9rem;
  padding: 1.75rem;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.modal-caixa p {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: #111827;
}

.modal-botoes {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
}

.modal-btn-cancelar {
  background: #e5e7eb;
  color: #111827;
}

.modal-btn-confirmar {
  background: #dc2626;
}

.admin-form-botoes {
  display: flex;
  gap: 0.75rem;
}

.admin-form-botoes button:last-child {
  background: #6b7280;
}

.profiles-table button {
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  margin-right: 0.25rem;
}

.profiles-table .btn-excluir-produto {
  background: #dc2626;
}

.profiles-table .btn-secundario {
  background: #6b7280;
}

.dev-credit {
  position: fixed;
  bottom: 6px;
  right: 10px;
  font-size: 0.68rem;
  color: #9ca3af;
  z-index: 40;
  pointer-events: none;
  user-select: none;
}

.admin-form .label-checkbox {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  cursor: pointer;
}

.admin-form .label-checkbox input[type='checkbox'] {
  width: auto;
  margin: 0;
}

.admin-form label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.profiles-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 0.5rem;
  overflow: hidden;
}

.profiles-table th,
.profiles-table td {
  padding: 0.6rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

/* Dashboard estilo Power BI */

.periodo-label {
  grid-column: 1 / -1;
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
  color: #374151;
  font-weight: 500;
}

.atualizado-em {
  font-size: 0.75rem;
  color: #4b5563;
}

.cards-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.75rem;
}

.maquina-card {
  background: white;
  border-radius: 0.8rem;
  padding: 0.9rem 1rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  transition: transform 0.1s ease;
}

.maquina-card:hover {
  transform: translateY(-2px);
}

.card-topo {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
  min-height: 2rem;
}

.card-topo h3 {
  margin: 0;
  font-size: 0.9rem;
}

.status-icone {
  font-size: 1.2rem;
  flex-shrink: 0;
}

.status-icone-grande {
  font-size: 2rem;
  position: absolute;
  top: 0;
  right: 0;
}

.card-metrica {
  margin: 0.15rem 0;
  font-size: 0.82rem;
  color: #374151;
  min-height: 1.1rem;
}

.gauge-wrap {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
  justify-content: center;
}

.gauge-svg {
  width: 100%;
  max-width: 220px;
}

.gauge-valor {
  margin-top: -1.6rem;
  font-size: 1.6rem;
  font-weight: 600;
  color: #374151;
}

.gauge-valor-grande {
  font-size: 2.5rem;
  margin-top: -2.5rem;
}

.gauge-grande {
  max-width: 380px;
  margin: 0 auto;
}

.gauge-limites {
  display: flex;
  justify-content: space-between;
  font-size: 0.72rem;
  color: #6b7280;
  padding: 0 0.5rem;
}

.maquina-detalhe {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 2rem;
  align-items: start;
}

.produto-imagem {
  position: fixed;
  bottom: 1rem;
  left: 1.5rem;
  height: 180px;
  width: auto;
  pointer-events: none;
  z-index: 1;
}

.produto-imagem[hidden] {
  display: none;
}

@media (max-width: 700px) {
  .produto-imagem {
    height: 100px;
    left: 0.5rem;
  }
}

.maquina-resumo {
  background: white;
  border-radius: 0.9rem;
  padding: 1.5rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.resumo-linha {
  font-size: 0.9rem;
  color: #374151;
}

.hora-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 0.5rem;
  overflow: hidden;
  font-size: 0.85rem;
}

.hora-table th,
.hora-table td {
  padding: 0.45rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.pct-bom {
  color: #16a34a;
  font-weight: 600;
}

.pct-ruim {
  color: #dc2626;
  font-weight: 600;
}

@media (max-width: 700px) {
  .hora-table thead {
    display: none;
  }

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

  .hora-table tr {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0.75rem;
  }

  .hora-table td {
    padding: 0.25rem 0;
    border: none;
    font-size: 0.82rem;
    display: flex;
    gap: 0.4rem;
  }

  .hora-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6b7280;
    width: 110px;
    flex-shrink: 0;
  }

  .hora-table td:empty {
    display: none;
  }
}

.prog-filtros {
  display: flex;
  align-items: end;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.prog-filtros label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.875rem;
}

.prog-filtros input {
  padding: 0.5rem;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
}

.prog-total-geral {
  background: #111827;
  color: white;
  border-radius: 0.75rem;
  padding: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
}

.prog-resumo-geral {
  background: #111827;
  color: white;
  border-radius: 0.75rem;
  padding: 1rem 1.5rem;
  margin-bottom: 1.25rem;
  font-size: 1.05rem;
  display: flex;
  gap: 2rem;
  flex-wrap: wrap;
}

.atend-ok    { color: #16a34a; }
.atend-alerta { color: #d97706; }
.atend-baixo  { color: #dc2626; }

.prog-bloco {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  overflow: hidden;
  margin-bottom: 1rem;
}

.prog-bloco-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  background: #00407f;
  color: white;
  padding: 0.65rem 1.25rem;
}

.prog-bloco-nome {
  font-weight: 700;
  font-size: 1rem;
}

.prog-tabela .prog-linha-maquina td {
  background: #00407f !important;
  color: white !important;
  font-weight: 700;
  padding: 0.5rem 1rem;
}

.prog-tabela .prog-linha-total-maq td {
  background: #f1f5f9 !important;
  font-weight: 700;
  border-top: 2px solid #e5e7eb;
  border-bottom: 3px solid #cbd5e1;
  color: #1e3a5f !important;
}

.prog-tabela .prog-linha-total-geral td {
  background: #111827 !important;
  color: white !important;
  font-weight: 700;
  border-top: 3px solid #374151;
}

.prog-tabela td.atend-ok    { color: #16a34a !important; }
.prog-tabela td.atend-alerta { color: #d97706 !important; }
.prog-tabela td.atend-baixo  { color: #dc2626 !important; }

.prog-tabela .prog-linha-total-geral td.atend-ok    { color: #4ade80 !important; }
.prog-tabela .prog-linha-total-geral td.atend-alerta { color: #fbbf24 !important; }
.prog-tabela .prog-linha-total-geral td.atend-baixo  { color: #f87171 !important; }

.prog-tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.prog-tabela th {
  background: #f1f5f9;
  color: #374151;
  font-weight: 600;
  padding: 0.5rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.prog-tabela td {
  padding: 0.45rem 1rem;
  border-bottom: 1px solid #f3f4f6;
  color: #111827;
}

.prog-tabela tr:last-child td { border-bottom: none; }
.prog-tabela tr:hover td { background: #f9fafb; }

.prog-tabela th.num,
.prog-tabela td.num { text-align: right; }

.prog-total-geral {
  display: flex;
  align-items: center;
  gap: 2rem;
  flex-wrap: wrap;
  background: #111827;
  color: white;
  border-radius: 0.75rem;
  padding: 0.9rem 1.25rem;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.prog-total-geral span:first-child {
  font-weight: 700;
  font-size: 1rem;
  margin-right: 0.5rem;
}

.prog-bloco-header .atend-ok    { color: #4ade80; }
.prog-bloco-header .atend-alerta { color: #fbbf24; }
.prog-bloco-header .atend-baixo  { color: #f87171; }

.prog-total-geral .atend-ok    { color: #4ade80; }
.prog-total-geral .atend-alerta { color: #fbbf24; }
.prog-total-geral .atend-baixo  { color: #f87171; }

.prog-sem-sku { color: #9ca3af; font-style: italic; }

.prog-acordeao-cabecalho .atend-ok    { color: #4ade80; }
.prog-acordeao-cabecalho .atend-alerta { color: #fbbf24; }
.prog-acordeao-cabecalho .atend-baixo  { color: #f87171; }

.prog-acordeao {
  background: white;
  border-radius: 0.75rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
  margin-bottom: 1rem;
  overflow: hidden;
}

.prog-acordeao-cabecalho {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1rem 1.5rem;
  cursor: pointer;
  list-style: none;
  font-size: 1rem;
}

.prog-acordeao-cabecalho::-webkit-details-marker {
  display: none;
}

.prog-acordeao-cabecalho::before {
  content: '▸';
  margin-right: 0.5rem;
  color: #6b7280;
  transition: transform 0.15s ease;
}

.prog-acordeao[open] .prog-acordeao-cabecalho::before {
  transform: rotate(90deg);
}

.prog-acordeao-maquina {
  font-weight: 600;
  font-size: 1.05rem;
}

.prog-acordeao-meta {
  color: #374151;
  font-size: 0.95rem;
}

.prog-acordeao-corpo {
  padding: 0 1.5rem 1.25rem;
}

@media (max-width: 800px) {
  .maquina-detalhe {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px) {
  .dashboard-header {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  /* "Desfaz" as colunas esquerda/direita no mobile, pra dar pra reordenar
     livremente os itens (logos, título, ações) direto no header. */
  .header-esquerda,
  .header-direita {
    display: contents;
  }

  .header-logos {
    order: -1;
    justify-content: center;
  }

  .header-esquerda h1 {
    order: 0;
    font-size: 1.3rem;
  }

  .atualizado-em {
    order: 1;
  }

  .header-actions {
    order: 2;
  }

  .header-conta {
    order: 3;
  }

  .logo-marca {
    height: 28px;
  }

  .header-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 0.6rem;
  }

  .header-actions label {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }

  .header-actions select,
  .header-actions input[type='date'] {
    width: 60%;
  }

  .header-actions button,
  .header-actions .btn-like {
    width: 100%;
    text-align: center;
  }

  .header-conta {
    width: 100%;
    align-items: stretch;
  }

  .header-conta-botoes {
    flex-direction: column;
    width: 100%;
  }

  .header-conta-botoes .btn-like,
  .header-conta-botoes button {
    width: 100%;
    text-align: center;
  }

  .user-badge {
    text-align: center;
  }

  .cards-grid {
    grid-template-columns: 1fr;
  }
}
