:root {
  --bep-blue: #1fb6e9;
  --bep-blue-strong: #0ea5d9;
  --bep-yellow: #f4c400;
  --bep-purple: #8b5cf6;
  --bep-pink: #f14cc9;
  --bep-mint: #b8efe2;
  --bg-main: #f5f7fa;
  --bg-card: #ffffff;
  --text-main: #1f2937;
  --text-soft: #6b7280;
  --border-soft: #dbe3ea;
  --shadow-soft: 0 12px 28px rgba(15, 23, 42, 0.08);
  --topbar-height: 82px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: Arial, Helvetica, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100svh;
  min-height: 100dvh;
  background: linear-gradient(180deg, #f8fbff 0%, #f3f7fb 100%);
  color: var(--text-main);
  overflow-x: hidden;
}

body.menu-open {
  overflow: hidden;
}

.hidden {
  display: none !important;
}

/* LOADING */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 251, 255, 0.88);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.loading-overlay.show {
  display: flex;
}

.loading-box {
  min-width: 280px;
  max-width: 90vw;
  background: #ffffff;
  border: 1px solid #e6edf4;
  border-radius: 24px;
  padding: 28px 24px;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
  text-align: center;
  font-weight: 700;
  color: var(--bep-blue-strong);
}

.loading-spinner {
  width: 42px;
  height: 42px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 4px solid rgba(31, 182, 233, 0.18);
  border-top-color: #1fb6e9;
  animation: girarLoading 0.9s linear infinite;
}

.loading-title {
  font-size: 18px;
  font-weight: 800;
  color: #1f2937;
  margin-bottom: 6px;
}

.loading-subtitle {
  font-size: 14px;
  color: #6b7280;
}

@keyframes girarLoading {
  to {
    transform: rotate(360deg);
  }
}

/* LOGIN */
.login-screen {
  min-height: 100svh;
  min-height: 100dvh;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(31, 182, 233, 0.14), rgba(139, 92, 246, 0.10)),
    linear-gradient(180deg, #f8fbff, #eef5fb);
}

.login-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(241, 76, 201, 0.18), transparent 26%),
    radial-gradient(circle at top right, rgba(31, 182, 233, 0.10), transparent 24%);
  pointer-events: none;
}

.login-layout {
  min-height: 100svh;
  min-height: 100dvh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 30px;
  padding: 30px;
  position: relative;
  z-index: 1;
}

.login-brand-panel,
.login-form-panel {
  display: flex;
  justify-content: center;
  align-items: center;
}

.login-brand-card {
  width: 100%;
  max-width: 900px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 34px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.login-brand-image {
  width: 100%;
  display: block;
  border-radius: 26px;
  object-fit: cover;
}

.login-card {
  width: 100%;
  max-width: 460px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 28px;
  padding: 34px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(8px);
}

.login-logo-wrap {
  margin-bottom: 18px;
  display: flex;
  justify-content: center;
}

.login-logo {
  max-width: 180px;
  width: 100%;
}

.login-card h1 {
  font-size: clamp(26px, 4vw, 32px);
  margin-bottom: 10px;
  color: var(--bep-blue-strong);
}

.login-card p {
  color: var(--text-soft);
  margin-bottom: 22px;
  line-height: 1.5;
}

.erro-login {
  margin-top: 14px;
  color: #dc2626;
  font-weight: 600;
}

/* FORMULÁRIOS */
.field {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field label {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-main);
}

.field input,
.field select {
  min-height: 50px;
  border-radius: 16px;
  border: 2px solid var(--border-soft);
  padding: 12px 14px;
  font-size: 16px;
  background: #ffffff;
  transition: 0.2s;
  width: 100%;
}

.field input:focus,
.field select:focus,
.search-input:focus {
  outline: none;
  border-color: var(--bep-blue);
  box-shadow: 0 0 0 4px rgba(31, 182, 233, 0.12);
}

/* BOTÕES */
.btn {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  min-height: 46px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.2s ease, opacity 0.2s ease;
  touch-action: manipulation;
}

.btn:hover,
.btn:active {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(135deg, var(--bep-blue), var(--bep-blue-strong));
  color: white;
  box-shadow: 0 10px 20px rgba(31, 182, 233, 0.22);
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-main);
  border: 1px solid var(--border-soft);
}

/* APP */
.app-shell {
  min-height: 100svh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  min-height: var(--topbar-height);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 24px;
  border-bottom: 1px solid #e7edf3;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left,
.topbar-right,
.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-right {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.topbar-badges,
.topbar-user-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-user-actions {
  justify-content: flex-end;
}

.user-info {
  text-align: right;
}

.topbar-logout {
  min-width: 112px;
}

.header-logo {
  width: 86px;
  max-height: 52px;
  object-fit: contain;
}

.menu-button {
  width: 46px;
  height: 40px;
  background: white;
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 0 10px;
}

.menu-button span {
  display: block;
  height: 3px;
  border-radius: 4px;
  background: var(--bep-blue-strong);
}

.topbar-title {
  font-size: clamp(18px, 4vw, 22px);
  font-weight: 800;
  color: var(--bep-blue-strong);
}

.topbar-subtitle {
  font-size: 13px;
  color: var(--text-soft);
  margin-top: 3px;
}

.base-badge,
.connection-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.base-badge {
  background: rgba(244, 196, 0, 0.14);
  color: #9a6a00;
}

.connection-badge {
  background: rgba(34, 197, 94, 0.12);
  color: #15803d;
}

.connection-badge.offline {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.layout {
  display: flex;
  flex: 1;
  min-width: 0;
}

.sidebar-backdrop {
  display: none;
}

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: linear-gradient(180deg, #ffffff 0%, #f7faff 100%);
  border-right: 1px solid #e7edf3;
  padding: 24px 14px;
  transition: transform 0.25s ease, visibility 0.25s ease;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 18px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
  transition: 0.2s;
  color: var(--text-main);
}

.nav-item:hover,
.nav-item.active {
  background: linear-gradient(135deg, rgba(31, 182, 233, 0.12), rgba(139, 92, 246, 0.10));
}

.nav-icon-img {
  width: 30px;
  height: 30px;
  object-fit: contain;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 32px 28px;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

/* HERO */
.hero-banner {
  margin-bottom: 28px;
  background:
    linear-gradient(135deg, rgba(31, 182, 233, 0.12), rgba(184, 239, 226, 0.42)),
    #ffffff;
  border: 1px solid #e5eef5;
  border-radius: 28px;
  padding: 30px 26px;
  box-shadow: var(--shadow-soft);
}

.hero-tag {
  display: inline-block;
  margin-bottom: 14px;
  background: rgba(139, 92, 246, 0.12);
  color: var(--bep-purple);
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 13px;
}

.hero-banner h2 {
  font-size: clamp(22px, 4vw, 28px);
  color: var(--bep-blue-strong);
  margin-bottom: 10px;
}

.hero-banner p,
.student-meta,
.empty-state {
  color: var(--text-soft);
}

.texto-secundario {
  color: var(--text-soft);
  margin-bottom: 16px;
  display: block;
  line-height: 1.5;
}

/* CARDS */
.card {
  background: var(--bg-card);
  border: 1px solid #e7edf3;
  border-radius: 28px;
  padding: 26px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.card-accent {
  background: linear-gradient(180deg, #ffffff, #fcfdff);
}

.section-title {
  font-size: clamp(20px, 4vw, 24px);
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--bep-blue-strong);
}

/* LAYOUT DASHBOARD */
.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
  gap: 32px;
}

.home-left,
.stats-grid,
.student-list {
  display: grid;
  gap: 18px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 32px;
  margin-top: 18px;
}

/* GRÁFICOS */
.chart-area {
  height: 370px;
  margin-top: 12px;
  padding-top: 8px;
}

.chart-area.small {
  height: 280px;
}

/* RESUMO */
.stat-box {
  background: linear-gradient(135deg, #ffffff, #f8fbff);
  border: 1px solid #e6edf4;
  border-radius: 22px;
  padding: 18px;
}

.stat-box small {
  display: block;
  margin-bottom: 8px;
  color: var(--text-soft);
}

.stat-box strong {
  color: var(--bep-yellow);
  font-size: clamp(24px, 6vw, 30px);
}

/* RANKING */
.ranking-card {
  display: flex;
  flex-direction: column;
  min-height: 560px;
  max-height: 560px;
}

.ranking-card .texto-secundario {
  margin-bottom: 8px;
}

.ranking-list {
  list-style: none;
  display: block;
  flex: 1 1 auto;
  height: 420px;
  min-height: 420px;
  max-height: 420px;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 8px;
  margin-top: 12px;
  scrollbar-gutter: stable;
}

.ranking-list .empty-state {
  padding: 20px;
  text-align: center;
}

.ranking-list::-webkit-scrollbar {
  width: 8px;
}

.ranking-list::-webkit-scrollbar-thumb {
  background: rgba(31, 182, 233, 0.35);
  border-radius: 999px;
}

.ranking-item {
  margin-bottom: 12px;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

/* ALUNOS */
.ranking-item,
.student-row {
  background: linear-gradient(135deg, #ffffff, #f7fbff);
  border: 1px solid #e6edf4;
  border-radius: 22px;
  box-shadow: var(--shadow-soft);
}

.toolbar,
.search-wrap,
.student-row,
.student-left,
.student-actions,
.modal-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.toolbar {
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.search-wrap {
  align-items: center;
  flex: 1;
}

.search-input {
  min-height: 48px;
  min-width: min(320px, 100%);
  width: min(100%, 420px);
  background: #ffffff;
  border: 2px solid var(--border-soft);
  border-radius: 999px;
  padding: 0 16px;
  font-size: 16px;
}

.icone-busca {
  font-size: 24px;
}

.student-row {
  align-items: center;
  justify-content: space-between;
  padding: 18px;
}

.student-left {
  align-items: center;
}

.avatar {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--bep-blue), var(--bep-purple));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 24px;
  flex-shrink: 0;
}

.student-name {
  font-size: 19px;
  font-weight: 800;
}

.student-meta {
  font-size: 14px;
  margin-top: 4px;
  line-height: 1.5;
}

.student-actions {
  justify-content: flex-end;
}

/* TABELAS */
.table-wrapper {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 18px;
  background: #ffffff;
}

th,
td {
  padding: 14px;
  text-align: left;
  border-bottom: 1px solid #edf2f7;
  font-size: 15px;
  vertical-align: top;
}

th {
  background: #f7fbff;
  font-size: 16px;
  color: var(--bep-blue-strong);
}

.empty-state {
  text-align: center;
  padding: 24px;
}

/* MODAL */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-backdrop.show {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 460px;
  max-height: min(88svh, 88dvh);
  overflow: auto;
  background: #ffffff;
  border: 1px solid #e6edf4;
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 18px 34px rgba(15, 23, 42, 0.16);
}

.modal h3 {
  font-size: 24px;
  margin-bottom: 14px;
  color: var(--bep-blue-strong);
}

.modal-actions {
  justify-content: flex-end;
  margin-top: 14px;
}

/* TABLET */
@media (max-width: 1200px) {
  .login-layout,
  .home-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
  }

  .login-brand-panel {
    order: 2;
  }

  .login-form-panel {
    order: 1;
  }
}

/* MOBILE */
@media (max-width: 780px) {
  .login-layout {
    padding: 18px;
    gap: 18px;
  }

  .login-brand-card {
    padding: 10px;
    border-radius: 22px;
  }

  .login-brand-image {
    border-radius: 16px;
  }

  .login-card,
  .card,
  .hero-banner,
  .modal {
    padding: 20px;
    border-radius: 20px;
  }

  .topbar {
    padding: 12px 14px;
    align-items: stretch;
    gap: 12px;
  }

  .topbar-left,
  .topbar-right {
    width: 100%;
    align-items: center;
  }

  .topbar-left {
    justify-content: flex-start;
    gap: 10px;
  }

  .brand-header {
    gap: 10px;
    flex: 1;
    min-width: 0;
  }

  .header-logo {
    width: 48px;
    max-height: 38px;
  }

  .topbar-right {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .topbar-badges {
    justify-content: space-between;
    gap: 8px;
  }

  .topbar-user-actions {
    justify-content: space-between;
    gap: 10px;
    align-items: center;
  }

  .topbar-badges .base-badge,
  .topbar-badges .connection-badge {
    padding: 8px 12px;
    font-size: 12px;
  }

  .user-info {
    text-align: left;
    flex: 1;
    min-width: 0;
  }

  .topbar-logout {
    width: auto;
    min-width: 96px;
    padding-inline: 18px;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 59;
  }

  .sidebar-backdrop.show {
    display: block;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100svh;
    height: 100dvh;
    width: min(82vw, 280px);
    z-index: 60;
    transform: translateX(-100%);
    box-shadow: 10px 0 30px rgba(15, 23, 42, 0.16);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .content {
    padding: 20px 16px;
  }

  .home-grid,
  .bottom-grid {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .toolbar,
  .search-wrap,
  .student-row,
  .student-left,
  .student-actions,
  .modal-actions {
    width: 100%;
  }

  .search-input,
  .btn,
  .student-actions .btn,
  .modal-actions .btn {
    width: 100%;
  }

  .topbar .btn,
  .topbar-logout {
    width: auto;
  }

  .student-row,
  .student-left {
    align-items: flex-start;
  }

  .chart-area {
    height: 260px;
    margin-top: 10px;
    padding-top: 4px;
  }

  .chart-area.small {
    height: 220px;
  }

  .ranking-card {
    min-height: 430px;
    max-height: 430px;
  }

  .ranking-list {
    height: 300px;
    min-height: 300px;
    max-height: 300px;
  }

  .topbar-title,
  .topbar-subtitle {
    display: none !important;
  }

  #connectionBadge {
    display: none !important;
  }

  table,
  thead,
  tbody,
  th,
  td,
  tr {
    display: block;
  }

  thead {
    display: none;
  }

  tbody {
    display: grid;
    gap: 12px;
  }

  tr {
    border: 1px solid #e6edf4;
    border-radius: 18px;
    background: #fff;
    box-shadow: var(--shadow-soft);
    overflow: hidden;
    padding: 8px 0;
  }

  td {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 10px;
    border: none;
    padding: 10px 14px;
  }

  td::before {
    content: attr(data-label);
    font-weight: 800;
    color: var(--bep-blue-strong);
  }
}

@media (max-width: 420px) {
  .topbar-badges {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-user-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-logout {
    width: 100%;
  }
}
