:root {
  --bg: #05070a;
  --card-bg: #0f1218;
  --border: #1f232d;
  --primary: #00ff88;
  --text-main: #e2e8f0;
  --text-dim: #94a3b8;
  --hot: #ff4d4d;
  --cell-size: 4.3vh;
  --gap-size: 4px;
}

* {
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body {
  background: var(--bg);
  color: var(--text-main);
  margin: 0;
  padding: 10px;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* --- LOADING --- */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}
.loading-overlay.hidden {
  display: none !important;
}
.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--border);
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}
@keyframes spin {
  100% {
    transform: rotate(360deg);
  }
}

/* --- HEADER --- */
.top-control-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
  flex-shrink: 0;
}
.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.top-control-panel h1 {
  margin: 0;
  font-size: 1.3em;
  color: var(--primary);
  letter-spacing: 3px;
  font-weight: 900;
}
.controles-superiores {
  display: flex;
  align-items: center;
  gap: 15px;
}
.intervalo-container {
  background: #161b22;
  padding: 6px 15px;
  border-radius: 6px;
  border: 1px solid var(--border);
  display: flex;
  gap: 8px;
  align-items: center;
}
.intervalo-container input {
  background: transparent;
  border: none;
  color: white;
  width: 65px;
  text-align: center;
  font-weight: 800;
  font-size: 1.1em;
  outline: none;
}
.btn-analisar,
.btn-voltar {
  border: none;
  padding: 8px 25px;
  border-radius: 5px;
  font-weight: 800;
  cursor: pointer;
  text-transform: uppercase;
}
.btn-analisar {
  background: var(--primary);
  color: #000;
}
.btn-voltar {
  background: #333;
  color: #fff;
}

.radio-selection {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 0.9em;
  font-weight: 700;
  color: var(--text-dim);
  width: 100%;
}

/* --- NOVO PAINEL DE FILTROS --- */
.painel-filtros-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}
.filtro-categorias {
  display: flex;
  align-items: center;
  gap: 10px;
}
.filtro-categorias span {
  font-size: 0.7em;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
}
.btn-filtro-cat {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.7em;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
}
.btn-filtro-cat.active {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(0, 255, 136, 0.05);
}
.filtro-opcoes {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 25px;
}
.btn-opcao-filtro {
  background: #161b22;
  border: 1px solid var(--border);
  color: #fff;
  padding: 3px 10px;
  border-radius: 3px;
  font-size: 0.7em;
  font-weight: 700;
  cursor: pointer;
}
.btn-opcao-filtro.active {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

/* --- DASHBOARD --- */
.dashboard-container {
  display: flex;
  flex-direction: row;
  gap: 10px;
  flex: 1;
  min-height: 0;
}
.ranking-panel {
  width: 420px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.table-wrapper {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85em;
}
th {
  background: #161b22;
  padding: 12px 5px;
  position: sticky;
  top: 0;
  color: var(--text-dim);
  font-size: 0.65em;
  letter-spacing: 1px;
}
td {
  padding: 10px 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  font-weight: 700;
  text-align: center;
}

.main-content {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  position: relative;
}
.grid-master-container {
  display: grid;
  grid-template-columns: 35px repeat(10, var(--cell-size));
  grid-template-rows: 30px repeat(6, var(--cell-size));
  gap: var(--gap-size);
}
.dezena-box {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1em;
  font-weight: 900;
  border: 1px solid var(--border);
  transition: opacity 0.3s;
}
.dezena-box.dimmed {
  opacity: 0.15;
}
.regua-item {
  font-size: 0.8em;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.sigma-indicator {
  color: var(--primary);
  font-weight: 900;
  font-size: 1.2em;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- LEGENDA --- */
.legenda-container-horizontal {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin-top: 15px;
  width: 100%;
}
.leg-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75em;
  font-weight: 800;
  color: var(--text-dim);
}
.leg-box {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}
.leg-box.maior {
  background-color: var(--primary);
}
.leg-box.menor {
  background-color: rgba(0, 255, 136, 0.4);
}
.leg-box.nenhum {
  background-color: #ffffff;
}

/* --- RODAPÉ --- */
.footer-dashboard {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 20px;
  margin-top: 8px;
  flex-shrink: 0;
}
.linha-superior-footer {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 40px;
  width: 100%;
}

.footer-group-stats {
  display: flex;
  gap: 20px;
}
.metric-item b {
  font-size: 1.5em;
  color: var(--primary);
  display: block;
  line-height: 1;
}
.metric-item span {
  font-size: 0.6em;
  color: var(--text-dim);
  font-weight: 800;
}

.footer-label {
  font-size: 0.6em;
  font-weight: 800;
  color: var(--text-dim);
  margin-bottom: 5px;
  display: block;
  text-align: center;
}
.quadrantes-container {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.quadrantes-grid {
  display: grid;
  grid-template-columns: repeat(2, 40px);
  gap: 4px;
}
.quadrante-box {
  background: var(--bg);
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-weight: 900;
  font-size: 0.8em;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.paridade-flex {
  display: flex;
  flex-direction: column;
  width: 140px;
  gap: 4px;
}
.prog-container {
  display: flex;
  flex-direction: column;
}
.prog-bg {
  background: #161b22;
  height: 5px;
  border-radius: 3px;
  overflow: hidden;
}
.prog-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}
.prog-info span {
  font-size: 0.6em;
  font-weight: 900;
  color: var(--primary);
}

.sugestao-section {
  display: flex;
  align-items: center;
  gap: 15px;
  flex: 1;
}
.sugestao-controls {
  display: flex;
  align-items: center;
  gap: 12px;
}
.input-sugestao-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.input-sugestao-group label {
  font-size: 0.7em;
  font-weight: 800;
  color: var(--text-dim);
}
.btn-sugestao-main {
  background: var(--primary);
  color: #000;
  border: none;
  padding: 10px 18px;
  border-radius: 4px;
  font-weight: 900;
  cursor: pointer;
  font-size: 0.8em;
}
#qtd-sugestao {
  background: #161b22;
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 4px;
  width: 45px;
  text-align: center;
  font-weight: 800;
  height: 35px;
}
#output-sugestao {
  flex: 1;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--primary);
  border-radius: 4px;
  height: 35px;
  padding: 6px;
  font-size: 1.1em;
  font-weight: 900;
  resize: none;
  overflow: hidden;
  text-align: center;
}

/* --- MOBILE --- */
@media (max-width: 768px) {
  body {
    overflow-y: auto;
    height: auto;
    padding: 5px;
  }
  .top-control-panel h1 {
    text-align: center;
    width: 100%;
  }
  .header-content {
    align-items: center;
  }
  .controles-superiores {
    flex-direction: column;
    width: 100%;
    gap: 10px;
    align-items: center;
  }
  .intervalo-container {
    width: 100%;
    justify-content: center;
  }
  .btn-group-header {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: 100%;
    gap: 8px;
  }
  .radio-selection {
    justify-content: center;
    width: 100%;
    margin-top: 5px;
  }
  .painel-filtros-container {
    padding: 10px 5px;
  }
  .filtro-categorias {
    flex-wrap: wrap;
    justify-content: center;
  }
  .dashboard-container {
    flex-direction: column;
  }
  .ranking-panel {
    width: 100%;
    height: 300px;
  }
  .main-content {
    padding: 20px 5px;
  }
  .grid-master-container {
    --cell-size: 8vw;
  }
  .linha-superior-footer {
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 15px;
  }
  .footer-group-stats {
    flex-direction: column;
    min-width: 80px;
  }
  .paridade-flex {
    width: 110px;
  }
  .sugestao-section {
    flex-direction: row;
    border-top: 1px solid var(--border);
    padding-top: 15px;
    width: 100%;
    margin-top: 10px;
  }
  .sugestao-controls {
    flex-direction: column;
    width: 100px;
  }
  #output-sugestao {
    height: 60px;
  }
}
