* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Arial, sans-serif;
}

html, body {
  width: 100%;
  min-width: 0;
  height: 100%;
  overflow-x: hidden;
}

.escondido {
  display: none !important;
}

.tela {
  display: none;
  width: 100%;
  min-height: 100vh;
}

.tela.ativa {
  display: block;
}

/* ===== LOGIN ===== */
.login-container {
  width: 100%;
  min-height: 100vh;
  background-color: #1d3557;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: #ffffff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 380px;
}

.login-card h1 {
  text-align: center;
  margin-bottom: 1.5rem;
  color: #1d3557;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.3rem;
  font-weight: 600;
  color: #333;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 0.7rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  font-size: 1rem;
}

button,
input,
select {
  max-width: 100%;
}

button {
  width: 100%;
  padding: 0.8rem;
  background-color: #e63946;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  margin-top: 0.5rem;
}

.btn-secundario {
  background-color: #6c757d;
}

.erro {
  color: #e63946;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

/* ===== MENU SUPERIOR ===== */
.menu-topo {
  width: 100%;
  min-height: 64px;
  background-color: #1d3557;
  padding: 0.65rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  position: relative;
}

.menu-academia {
  color: white;
  font-weight: 700;
  font-size: clamp(1.1rem, 2.4vw, 1.8rem);
  text-align: center;
  flex: 1 1 100%;
  order: -1;
  letter-spacing: 0.5px;
}

.menu-botoes {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  width: 100%;
}

.menu-btn {
  width: auto;
  min-width: auto;
  padding: 0.5rem 0.8rem;
  background-color: rgba(255, 255, 255, 0.15);
  color: white;
  margin: 0;
  font-size: 0.9rem;
}

.menu-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.btn-sair {
  background-color: #e63946 !important;
}

/* Quando o usuário tem acesso somente ao Painel:
   nome da academia fica oculto e o menu mostra
   apenas o botão Sair alinhado à direita. */
.menu-painel-apenas {
  justify-content: flex-end;
}

.menu-painel-apenas .menu-botoes {
  width: 100%;
  justify-content: flex-end;
}

/* ===== TIMER RESPONSIVO (Painel) ===== */
.timer-display {
  width: 100%;
  min-height: calc(100vh - 64px);
  height: calc(100vh - 64px);

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  overflow: hidden;
  padding: 1vh 1vw;

  transition:
    background-color 0.3s ease,
    color 0.3s ease;
}

.fase-label {
  margin: 0 0 0.5vh;

  font-size: clamp(1.2rem, 3vw, 3.5rem);
  line-height: 1;
  letter-spacing: clamp(1px, 0.4vw, 6px);
  text-align: center;
  font-weight: 700;
}

.tempo-numero {
  font-size: clamp(8rem, 32vw, 32rem);
  line-height: 0.85;
  font-weight: 800;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: center;
}

/* ===== CONTROLE ===== */
.controle-page {
  width: 100%;
  max-width: none;
  padding: clamp(1rem, 3vw, 2rem);
}

.controle-status {
  background: #f1f1f1;
  padding: 1rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.controle-config,
.controle-acoes {
  background: white;
  border: 1px solid #ddd;
  padding: 1.5rem;
  border-radius: 8px;
  margin-bottom: 1.5rem;
}

.config-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 0.8rem;
}

.config-item label {
  flex: 1;
}

.config-item input {
  flex: 0 0 100px;
  padding: 0.4rem;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.botoes-acao,
.botoes-fase {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.botoes-acao button,
.botoes-fase button {
  width: 100%;
  min-width: 0;
  margin: 0;
}

.btn-iniciar { background-color: #2a9d8f; }
.btn-parar { background-color: #e63946; }
.btn-reiniciar, .btn-reiniciar-tudo { background-color: #457b9d; }
.botoes-fase button { background-color: #1d3557; }

/* ===== PAINEL + CONTROLE ===== */
.painel-controle-grid {
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: calc(100vh - 64px);
}

.painel-lado {
  width: 100%;
  min-height: 60vh;
  height: 60vh;
}

.painel-lado .timer-display {
  width: 100%;
  height: 100%;
  min-height: 100%;
}

.controle-lado {
  width: 100%;
  padding: 1.5rem;
  background: #f8f9fa;
}

@media (min-width: 900px) {
  .painel-controle-grid {
    flex-direction: row;
    min-height: calc(100vh - 64px);
  }

  .painel-lado {
    flex: 2;
    height: calc(100vh - 64px);
    min-height: 0;
  }

  .controle-lado {
    flex: 1;
    max-width: 360px;
    overflow-y: auto;
  }

  .painel-lado .tempo-numero {
    font-size: clamp(7rem, 16vw, 20rem);
  }
}

/* ===== ADMIN ===== */
.admin-page {
  width: 100%;
  max-width: none;
  padding: clamp(1rem, 3vw, 2rem);
}

.user-form {
  background: white;
  border: 1px solid #ddd;
  padding: 1.5rem;
  border-radius: 8px;
  max-width: 500px;
  margin-bottom: 2rem;
}

.tabela-usuarios {
  display: block;
  width: 100%;
  overflow-x: auto;
  white-space: nowrap;
  border-collapse: collapse;
}

.tabela-usuarios th,
.tabela-usuarios td {
  padding: 0.8rem;
  border: 1px solid #ddd;
  text-align: left;
}

.tabela-usuarios th {
  background-color: #1d3557;
  color: white;
}

.tabela-usuarios button {
  width: auto;
  padding: 0.4rem 0.8rem;
  margin-right: 0.4rem;
  margin-top: 0;
  background-color: #457b9d;
}

/* ===== RESPONSIVIDADE GERAL ===== */

@media (max-width: 600px) {
  .menu-topo {
    padding: 0.5rem;
  }

  .menu-academia {
    font-size: 1.2rem;
  }

  .menu-botoes {
    width: 100%;
    justify-content: center;
  }

  .menu-btn {
    flex: 1;
    padding: 0.55rem 0.35rem;
    font-size: 0.75rem;
  }

  .botoes-acao,
  .botoes-fase {
    grid-template-columns: 1fr;
  }

  .controle-config,
  .controle-acoes {
    padding: 1rem;
  }

  .config-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
  }

  .config-item input {
    width: 100%;
    flex: auto;
  }

  .painel-controle-grid {
    min-height: calc(100vh - 64px);
  }

  .painel-lado {
    min-height: 55vh;
    height: 55vh;
  }

  .painel-lado .tempo-numero {
    font-size: clamp(5rem, 26vw, 11rem);
  }

  .controle-lado {
    padding: 1rem;
  }
}

@media (max-width: 380px) {
  .tempo-numero {
    font-size: clamp(4.5rem, 25vw, 9rem);
  }

  .fase-label {
    font-size: 1rem;
  }

  .menu-academia {
    font-size: 1rem;
  }
}

@media (orientation: landscape) and (max-height: 600px) {
  .timer-display {
    min-height: calc(100vh - 64px);
    height: calc(100vh - 64px);
  }

  .tempo-numero {
    font-size: clamp(5rem, 20vh, 14rem);
  }

  .fase-label {
    font-size: clamp(1rem, 4vh, 2rem);
  }

  .painel-lado {
    height: calc(100vh - 64px);
    min-height: 0;
  }
}